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​

appliedTick​

▸ appliedTick(id): number

The server tick stamp of the newest state applied for entity id, or undefined before any stamped message reached it. A client can name it in a request that acts on what it sees, so an authoritative server can tell how old that view was, however long the message queue held it, and resolve the request against the entity as the client saw it.

Parameters​

NameType
idstring

Returns​

number


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