コライダー
説明
このコンポーネントは、エンティティに物理コライダーを確立します。
コライダーシェイプ
タイプ | 説明 |
---|---|
ボックス | ボックス |
スフィア | スフィア |
飛行機 | 飛行機 |
カプセル | カプセル |
コーン | コーン |
シリンダ ー | シリンダー |
コライダー型
タイプ | 概要 |
---|---|
スタティック | シミュレーションでは動かず、あたかも質量が無限であるかのように振る舞う物体に適用される。 |
ダイナミック | 力、重力、衝突の影響を受ける、完全にシミュレートされた現実の物体に適用される。 |
キネマティック | 力の影響を受けず、ユーザーによって完全にプログラム制御されるオブジェクトに適用される。 静的ボディとは異なり、運動ボディは動くことができ、衝突によって他の動的ボディに影響を与えることができる。 |
プロパティ
プロパティ | タイプ | デフォルト | 説明 |
---|---|---|---|
type | ecs.ColliderType | ecs.ColliderType.Static | Supported types include static, dynamic, and kinematic |
shape | ecs.ColliderShape | ecs.ColliderShape.Box | Supported shape types include geometries and auto generated shapes from meshes |
width | number | 0 | Width of Box or Plane shapes |
height | number | 0 | Height of Box, Plane, Capsule, Cone, or Cylinder shapes |
depth | number | 0 | Depth of Box shape |
radius | number | 0 | Radius of Sphere, Capsule, Cone, or Cylinder shapes |
mass | number | 0 | Mass of the entity |
eventOnly | boolean | false | Determines if the object should only dispatch collision events, and not physically respond |
gravityFactor | number | 1 | Factor of which to scale the world’s gravity |
lockXAxis | boolean | false | Disables rotation on the X Axis |
lockYAxis | boolean | false | Disables rotation on the Y Axis |
lockZAxis | boolean | false | Disables rotation on the Z Axis |
friction | number | 0.5 | The amount of contact friction on the entity |
restitution | number | 0 | The bounciness of the entity, negative values absorb impact |
linearDamping | number | 0 | The amount of air resistance while moving |
angularDamping | number | 0 | The amount of air resistance while rotating |
lockXPosition | boolean | false | Prevents movement of the collider along the X-axis |
lockYPosition | boolean | false | Prevents movement of the collider along the Y-axis |
lockZPosition | boolean | false | Prevents movement of the collider along the Z-axis |
highPrecision | boolean | false | Enables continuous collision detection to increase precision of collision events |
offsetX | number | 0 | Local X offset of the collider shape from the object origin |
offsetY | number | 0 | Local Y offset of the collider shape from the object origin |
offsetZ | number | 0 | Local Z offset of the collider shape from the object origin |
機能
Get
Returns a read-only reference.
Example
ecs.Collider.get(world, component.eid)
Set
Ensures the component exists on the entity, then assigns the (optional) data to the component.
Example
ecs.Collider.set(world, component.eid, {
shape: ecs.ColliderShape.Sphere,
type: ecs.ColliderType.Static,
radius: 1,
mass: 0,
eventOnly: false,
gravityFactory: 1,
lockXAxis: false,
lockYAxis: false,
lockZAxis: false,
friction: 0.5,
restitution: 0,
linearDamping: 0,
angularDamping: 0
})
Mutate
Perform an update to the component within a callback function. Return true
to indicate no changes made.
Example
ecs.Collider.mutate(world, component.eid, (cursor) => {
cursor.mass = 5;
cursor.friction = 0.8;
return false;
})
Remove
Removes the component from the entity.
Example
ecs.Collider.remove(world, component.eid)