Class: ComponentSystem

pc.ComponentSystem

Component Systems contain the logic and functionality to update all Components of a particular type.

Constructor

new ComponentSystem(app)

Parameters:
Name Type Description
app pc.Application The application managing this system.
Source:

Methods

(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
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
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
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.
Source:

(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
Source:
Example
app.systems.model.removeComponent(entity);
// entity.model === undefined