Skip to content

ecsia-monorepo / three/src / ThreeBindings

Interface: ThreeBindings

Defined in: three/src/bindings.ts:22

Properties

size

ts
readonly size: number;

Defined in: three/src/bindings.ts:34

Number of live bindings.

Methods

bind()

ts
bind(handle, object3d): void;

Defined in: three/src/bindings.ts:25

Associate object3d with handle. If scene was provided, the object is added to it. Re-binding a handle replaces (and detaches from the scene) the previous object.

Parameters

ParameterType
handleEntityHandle
object3dObject3D

Returns

void


unbind()

ts
unbind(handle): Object3D<Object3DEventMap> | undefined;

Defined in: three/src/bindings.ts:28

Drop the binding for handle (and remove its object from the scene if one was provided). No-op if unbound. Returns the object that was bound, or undefined.

Parameters

ParameterType
handleEntityHandle

Returns

Object3D<Object3DEventMap> | undefined


objectOf()

ts
objectOf(handle): Object3D<Object3DEventMap> | undefined;

Defined in: three/src/bindings.ts:30

The Object3D bound to handle, or undefined.

Parameters

ParameterType
handleEntityHandle

Returns

Object3D<Object3DEventMap> | undefined


has()

ts
has(handle): boolean;

Defined in: three/src/bindings.ts:32

True if handle currently has a bound object.

Parameters

ParameterType
handleEntityHandle

Returns

boolean


entries()

ts
entries(): IterableIterator<[EntityHandle, Object3D<Object3DEventMap>]>;

Defined in: three/src/bindings.ts:36

Iterate the live (handle, object) pairs.

Returns

IterableIterator<[EntityHandle, Object3D<Object3DEventMap>]>


autoUnbindOn()

ts
autoUnbindOn(anchor): ObserverHandle;

Defined in: three/src/bindings.ts:43

Auto-unbind when anchor is removed from an entity OR the entity despawns (onRemove fires on both, ). Returns the observer handle so the caller can dispose it; registering twice for the same anchor is idempotent (the second call returns the existing handle). The handler reads only e.handle — a scalar safe to read under the lenient pooled-ref rules even for a dying entity.

Parameters

ParameterType
anchorComponentDef<Readonly<Record<string, FieldToken>>>

Returns

ObserverHandle


sweep()

ts
sweep(): number;

Defined in: three/src/bindings.ts:49

Drop every binding whose entity is no longer alive (world.isAlive(handle) === false). The belt-and-suspenders path for entities despawned without an autoUnbindOn anchor. O(size). The frame driver / scheduler can call this once per frame; most apps prefer autoUnbindOn (O(despawns)).

Returns

number


clear()

ts
clear(): void;

Defined in: three/src/bindings.ts:51

Drop all bindings (detaching every object from the scene).

Returns

void

MIT licensed · 0.x, unpublished, experimental.