Physics3DManager 类型
物理系统管理器。
索引
属性(properties)
enabledboolean获取或设置是否启用物理系统,默认不启用。allowSleepboolean获取或设置物理系统是否允许自动休眠,默认为 truemaxSubStepnumber获取或设置每帧模拟的最大子步数。deltaTimenumber获取或设置每步模拟消耗的固定时间。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
获取或设置每帧模拟的最大子步数。
| meta | description |
|---|---|
| 类型 | number |
| 定义于 | cocos2d/core/3d/physics/framework/physics-manager.ts:77 |
deltaTime
获取或设置每步模拟消耗的固定时间。
| 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:196 |
参数列表
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:223 |
参数列表
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:250 |