Physics3DManager 类型
物理系统管理器。
索引
属性(properties)
enabledboolean是否启用物理系统,默认不启用。allowSleepboolean物理系统是否允许自动休眠,默认为 true。maxSubStepnumber物理每帧模拟的最大子步数,默认为 2。deltaTimenumber物理每步模拟消耗的固定时间,默认为 1/60 秒。useFixedTimeboolean是否使用固定的时间步长。gravityVec3物理世界的重力数值,默认为 (0, -10, 0)。defaultMaterialPhysicsMaterial | null获取全局的默认物理材质,注意:builtin 时为 null。
方法
update执行一次物理系统的模拟,目前将在每帧自动执行一次。raycast检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。raycastClosest检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。
Details
属性(properties)
enabled
是否启用物理系统,默认不启用。
| meta | description |
|---|---|
| 类型 | boolean |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:46 |
allowSleep
物理系统是否允许自动休眠,默认为 true。
| meta | description |
|---|---|
| 类型 | boolean |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:60 |
maxSubStep
物理每帧模拟的最大子步数,默认为 2。
| meta | description |
|---|---|
| 类型 | number |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:77 |
deltaTime
物理每步模拟消耗的固定时间,默认为 1/60 秒。
| meta | description |
|---|---|
| 类型 | number |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:91 |
useFixedTime
是否使用固定的时间步长。
| meta | description |
|---|---|
| 类型 | boolean |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:105 |
gravity
物理世界的重力数值,默认为 (0, -10, 0)。
| meta | description |
|---|---|
| 类型 | Vec3 |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:119 |
defaultMaterial
获取全局的默认物理材质,注意:builtin 时为 null。
| meta | description |
|---|---|
| 类型 | PhysicsMaterial | Null |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:136 |
方法
update
执行一次物理系统的模拟,目前将在每帧自动执行一次。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:210 |
参数列表
deltaTimenumber The time difference from the last execution is currently elapsed per frame
raycast
检测所有的碰撞盒,并返回所有被检测到的结果,若没有检测到,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。
| meta | description |
|---|---|
| 返回 | PhysicsRayResult[] | Null |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:259 |
参数列表
worldRayRay A ray in world spacegroupIndexOrNamenumber | string Collision group index or group namemaxDistancenumber Maximum detection distancequeryTriggerboolean Detect trigger or not
raycastClosest
检测所有的碰撞盒,并返回射线距离最短的检测结果,若没有,则返回空值。注意返回值是从对象池中取的,所以请不要保存结果引用或者修改结果。
| meta | description |
|---|---|
| 返回 | PhysicsRayResult | Null |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:286 |