Skip to main content

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(options?): Entities

Parameters​

NameType
optionsPartial<EntitiesOptions>

Returns​

Entities

Overrides​

Group.constructor

Properties​

map​

• map: Map<string, Entity<any>>


options​

• options: EntitiesOptions


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​

NameTypeDescription
idstringThe ID of the entity to get.

Returns​

Entity<any>

The entity object with the given ID.


setClass​

▸ setClass(type, entity): void

Parameters​

NameType
typestring
entity(id: string) => Entity<any> | (id: string) => Entity<any>

Returns​

void


snapAllToTarget​

▸ snapAllToTarget(): void

Returns​

void


update​

▸ update(cameraPos?, renderDistance?): void

Parameters​

NameType
cameraPos?Vector3
renderDistance?number

Returns​

void