API Reference

Class List

pc.RigidBodyComponentSystem

Extends: pc.ComponentSystem

The RigidBodyComponentSystem maintains the dynamics world for simulating rigid bodies, it also controls global values for the world such as gravity. Note: The RigidBodyComponentSystem is only valid if 3D Physics is enabled in your application. You can enable this in the application settings for your Depot.

Summary

Methods

raycastFirstRaycast the world and return the first entity the ray hits.
setGravitySet the gravity vector for the 3D physics world.

Events

contactFired when a contact occurs between two rigid bodies

Inherited

Details

Constructor

RigidBodyComponentSystem(app)

Create a new RigidBodyComponentSystem

Parameters

apppc.ApplicationThe Application

Methods

raycastFirst(start, end)

Raycast the world and return the first entity the ray hits. Fire a ray into the world from start to end, if the ray hits an entity with a collision component, it returns a pc.RaycastResult, otherwise returns null.

Parameters

startpc.Vec3The world space point where the ray starts
endpc.Vec3The world space point where the ray ends

Returns

pc.RaycastResult The result of the raycasting or null if there was no hit.

setGravity(x, [y], [z])

Set the gravity vector for the 3D physics world. This function has two valid signatures. You can either specify the gravity with a 3D-vector or 3 numbers.

// Set via vector
var gravity = new pc.Vec3(0, -9.81, 0);
this.app.systems.rigidbody.setGravity(gravity);
// Set via numbers
this.app.systems.rigidbody.setGravity(0, -9.81, 0);

Parameters

xpc.Vec3, NumberThe x-component of the gravity vector
yNumberThe y-component of the gravity vector
zNumberThe z-component of the gravity vector

Events

contact

Fired when a contact occurs between two rigid bodies

Parameters

resultpc.SingleContactResultDetails of the contact between the two bodies

Inherited