A network interceptor that can be used to handle ENTITY messages. This is useful
for creating custom entities that can be sent over the network.
TODO-DOCS
Example
const entities = new VOXELIZE.Entities();
// Define an entity type.
class MyEntity extends VOXELIZE.Entity<{ position: VOXELIZE.Coords3 }> {
onUpdate = (data) => {
// Do something with `data.position`.
};
}
// Register the entity type.
entities.setClass("my-entity", MyEntity);
// Register the interceptor with the network.
network.register(entities);
Hierarchy
-
Group↳
Entities
Implements
Constructors
constructor
• new Entities(): Entities
Creates a new Group.
Returns
Inherited from
Group.constructor
Properties
map
• map: Map<string, Entity<any>>
types
• types: Map<string, (id: string) => Entity<any> | (id: string) => Entity<any>>
Methods
getEntityById
▸ getEntityById(id): Entity<any>
Get an entity instance by its ID.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The ID of the entity to get. |
Returns
Entity<any>
The entity object with the given ID.
setClass
▸ setClass(type, entity): void
Set a new entity type to the entities manager.
Parameters
| Name | Type | Description |
|---|---|---|
type | string | The type of entity to register. |
entity | (id: string) => Entity<any> | (id: string) => Entity<any> | The entity class to register. |
Returns
void
update
▸ update(): void
Returns
void