Constructor
new ScriptComponentSystem(app)
Create a new ScriptComponentSystem
Parameters:
Name | Type | Description |
---|---|---|
app |
pc.Application | The application |
Extends
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 |
- 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:
(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