Constructor
new RigidBodyComponentSystem(app)
Create a new RigidBodyComponentSystem
Parameters:
Name | Type | Description |
---|---|---|
app |
pc.Application | The Application |
Properties:
Name | Type | Description |
---|---|---|
gravity |
pc.Vec3 | The world space vector representing global gravity in the physics simulation. Defaults to [0, -9.81, 0] which is an approximation of the gravitational force on Earth. |
Extends
Methods
(private) _cleanOldCollisions()
Removes collisions that no longer exist from the collisions list and fires collisionend events to the
related entities.
(private) _storeCollision(entity, other) → {Boolean}
Stores a collision between the entity and other in the contacts map and returns true if it is a new collision
Parameters:
Name | Type | Description |
---|---|---|
entity |
pc.Entity | The entity |
other |
pc.Entity | The entity that collides with the first entity |
Returns:
true if this is a new collision, false otherwise.
- Type
- Boolean
(private) addComponent(entity, data) → {pc.Component}
Create new pc.Component and pc.ComponentData instances and attach them to the entity
Parameters:
Name | Type | Description |
---|---|---|
entity |
pc.Entity | The Entity to attach this component to |
data |
Object | The source data with which to create the component |
- Inherited From:
- Source:
Returns:
Returns a Component of type defined by the component system
- Type
- pc.Component
Example
var entity = new pc.Entity(app);
app.systems.model.addComponent(entity, { type: 'box' });
// entity.model is now set to a pc.ModelComponent
(private) cloneComponent(entity, clone) → {pc.Component}
Create a clone of component. This creates a copy all ComponentData variables.
Parameters:
Name | Type | Description |
---|---|---|
entity |
pc.Entity | The entity to clone the component from |
clone |
pc.Entity | The entity to clone the component into |
- Inherited From:
- Source:
Returns:
The newly cloned component.
- Type
- pc.Component
(private) getPropertiesOfType(type) → {Array}
Searches the component schema for properties that match the specified type.
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The type to search for |
- Inherited From:
- Source:
Returns:
An array of property descriptors matching the specified type.
- Type
- Array
(private) initializeComponentData(component, data, properties)
Called during pc.ComponentSystem#addComponent to initialize the pc.ComponentData in the store
This can be overridden by derived Component Systems and either called by the derived System or replaced entirely
Parameters:
Name | Type | Description |
---|---|---|
component |
pc.Component | The component being initialized. |
data |
Object | The data block used to initialize the component. |
properties |
Array | The array of property descriptors for the component. A descriptor can be either a plain property name, or an object specifying the name and type. |
- Inherited From:
- Source:
raycastFirst(start, end) → {pc.RaycastResult}
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:
Name | Type | Description |
---|---|---|
start |
pc.Vec3 | The world space point where the ray starts |
end |
pc.Vec3 | The world space point where the ray ends |
Returns:
The result of the raycasting or null if there was no hit.
- Type
- pc.RaycastResult
(private) removeComponent(entity)
Remove the pc.Component from the entity and delete the associated pc.ComponentData
Parameters:
Name | Type | Description |
---|---|---|
entity |
pc.Entity | The entity to remove the component from |
- Inherited From:
- Source:
Example
app.systems.model.removeComponent(entity);
// entity.model === undefined
Events
contact
Fired when a contact occurs between two rigid bodies
Parameters:
Name | Type | Description |
---|---|---|
result |
pc.SingleContactResult | Details of the contact between the two bodies |