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
| Name | Type |
|---|---|
options | Partial<EntitiesOptions> |
Returns
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
| Name | Type |
|---|---|
id | string |
Returns
number
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
Parameters
| Name | Type |
|---|---|
type | string |
entity | (id: string) => Entity<any> | (id: string) => Entity<any> |
Returns
void
snapAllToTarget
▸ snapAllToTarget(): void
Returns
void
update
▸ update(cameraPos?, renderDistance?): void
Parameters
| Name | Type |
|---|---|
cameraPos? | Vector3 |
renderDistance? | number |
Returns
void