CannonRigidbodyComponent

CannonRigidbodyComponent

Adds Cannon physics to an entity. Should be combined with one of the CannonCollider components, such as the CannonSphereColliderComponent. Also see CannonSystem.

Constructor

new CannonRigidbodyComponent(settingsopt)

Parameters:
Name Type Attributes Description
settings Object <optional>
Properties
Name Type Attributes Default Description
mass number <optional>
1
Example
world.setSystem(new CannonSystem());
var entity = world.createEntity();
var rigidBodyComponent = new CannonRigidBodyComponent({
  mass: 1
});
entity.setComponent(rigidBodyComponent);
var boxColliderComponent = new CannonBoxColliderComponent({
  halfExtents: new Vector3(1, 1, 1)
});
entity.setComponent(boxColliderComponent);

Methods

(static) getCollider() → {mixed}

Get the collider component from an entity, if one exist.

setAngularVelocity(angularVelocity)

Set the body angular velocity position.

Parameters:
Name Type Description
angularVelocity Vector3

setForce(force)

Set the force on the body

Parameters:
Name Type Description
force Vector3

setPosition(position)

Set the body position.

Parameters:
Name Type Description
position Vector3

setVelocity(velocity)

Set the velocity on the body

Parameters:
Name Type Description
velocity Vector3