Constructor
new EntityTemplate()
Methods
(async, static) instantiateEntities(parent, entityTemplates) → {Array.<Entity>}
Instantiate entities with different entity templates.
Name | Type | Description |
---|---|---|
parent | Entity | | The parent entity, set to null for the root |
entityTemplates | Array.<EntityTemplate> | The entity templates |
The instantiated entities.
- Type:
- Array.<Entity>
attachComponent(componentType, componentValueopt) → {EntityTemplate}
Attach component to the entity template. If component is already attached, overwrite the component's specified attributes.
This will attach the component and all the component's dependencies if the dependencies aren't already attached. You can see the dependencies of each component in this page.
Name | Type | Attributes | Description |
---|---|---|---|
componentType | string | Component type | |
componentValue | object | <optional> | Component value. The component attributes that are not specified will be given default values |
- Returns this
EntityTemplate
object. Allows chaining ofattachComponent
.
- Type:
- EntityTemplate
const entityTemplate = new SDK3DVerse.EntityTemplate();
// Attach component and its dependencies (local_transform is a dependency of mesh_ref)
entityTemplate.attachComponent('mesh_ref', { value : meshUUID });
// Overwrite already attached components by attaching them again
entityTemplate.attachComponent('local_transform', { position : [1, 0, 0]});
// Chain attachComponent
entityTemplate.attachComponent('box_geometry').attachComponent('physics_material').attachComponent('rigid_body');
attachEntityComponents(entity) → {EntityTemplate}
Attach all components of an entity to the entity template with their values. If component is already attached, overwrite the component's specified attributes.
Name | Type | Description |
---|---|---|
entity | Entity | Entity to attach components from |
- Returns this
EntityTemplate
object. Allows chaining ofattachComponent
.
- Type:
- EntityTemplate
(async) instantiateEntity(nameopt, parentopt) → {Entity}
Instantiate an Entity in the scene.
The entity will have the entity template's components attached. Some system components, such as debug_name, euid, local_aabb, and lineage, will be automatically attached as well.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name | string | <optional> | 'unnamed entity' | The entity's name that will be set in its debug_name component |
parent | Entity | <optional> | null | The parent of the entity. If null, the entity will be instantiated at the root |
- Entity that was instantiated.
- Type:
- Entity
(async) instantiateTransientEntity(nameopt, parentopt, deleteOnClientDisconnectionopt) → {Entity}
Instantiate a transient Entity in the scene. Transient entities only exist for the duration of the session.
The entity will have the entity template's components attached. Some system components, such as debug_name, euid, local_aabb, and lineage, will be automatically attached as well.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name | string | <optional> | 'unnamed entity' | The entity's name that will be set in its debug_name component |
parent | Entity | <optional> | null | The parent of the entity. If null, the entity will be instantiated at the root |
deleteOnClientDisconnection | boolean | <optional> | false | If true, entity will be deleted when the client that instantiated it disconnects from the session. If false, entity will be deleted when the session terminates, i.e. once all clients disconnect |
- Transient entity that was instantiated.
- Type:
- Entity
isAttached(componentType) → {boolean}
Return true if the specified component is attached to the entity template.
Name | Type | Description |
---|---|---|
componentType | string | Component type |
Attached component state.
- Type:
- boolean