Skip to content

ModelComp

Defined in: packages/threeplay/src/plugins/assets/types.ts:55

Fields added by model(). Also satisfies the shape contract (shape.kind === "model", mesh is the instanced scene root, a child of object3d). Each instance owns an AnimationMixer, ticked with k.dt(). The object emits an "animEnd" event (with the animation name) when a non-looping animation finishes.

optional add(this): void

Defined in: packages/threeplay/src/core/types.ts:63

Called when the object enters the scene (or when used on a live object).

GameObj

void

ShapeComp.add


curAnim(): string | null

Defined in: packages/threeplay/src/plugins/assets/types.ts:68

Name of the playing animation, if any.

string | null


optional destroy(this): void

Defined in: packages/threeplay/src/core/types.ts:69

Called when the object is destroyed or the component removed.

GameObj

void

ShapeComp.destroy


optional fixedUpdate(this): void

Defined in: packages/threeplay/src/core/types.ts:67

Called at the fixed physics rate (50 Hz by default).

GameObj

void

ShapeComp.fixedUpdate


optional inspect(this): string | null | undefined

Defined in: packages/threeplay/src/core/types.ts:71

Short status line shown by the debug inspector.

GameObj

string | null | undefined

ShapeComp.inspect


optional isolateMaterials(): void

Defined in: packages/threeplay/src/plugins/shapes/types.ts:34

Optional. Makes the shape’s materials private to this object (clones them, once), for shapes whose materials may be shared with other objects, like model(). color() and opacity() call it before writing to the materials.

void

ShapeComp.isolateMaterials


onAnimEnd(fn): EventController

Defined in: packages/threeplay/src/plugins/assets/types.ts:70

Runs when a non-looping animation finishes.

(name) => void

EventController


playAnim(name, opts?): void

Defined in: packages/threeplay/src/plugins/assets/types.ts:64

Plays an animation by name, cross-fading from the current one. Calling it again for the animation that is already playing only updates its speed. Throws (listing the available names) if the model has no such animation.

string

PlayAnimOpts

void


stopAnim(): void

Defined in: packages/threeplay/src/plugins/assets/types.ts:66

Stops every animation (the model goes back to its bind pose).

void


optional update(this): void

Defined in: packages/threeplay/src/core/types.ts:65

Called once per frame.

GameObj

void

ShapeComp.update

anims: string[]

Defined in: packages/threeplay/src/plugins/assets/types.ts:58

Names of the model’s animations.


optional conflicts?: string[]

Defined in: packages/threeplay/src/core/types.ts:61

Ids of components that can’t be on the same object (checked both ways).

ShapeComp.conflicts


id: "shape"

Defined in: packages/threeplay/src/plugins/assets/types.ts:56

Unique name. Two components with the same id replace each other.

ShapeComp.id


mesh: Object3D

Defined in: packages/threeplay/src/plugins/shapes/types.ts:28

ShapeComp.mesh


mixer: AnimationMixer<AnimationMixerEventMap> | null

Defined in: packages/threeplay/src/plugins/assets/types.ts:72

Escape hatch: the instance’s mixer (null if the model has no animations).


optional require?: string[]

Defined in: packages/threeplay/src/core/types.ts:59

Ids of components that must be present on the object.

ShapeComp.require


shape: ShapeDesc

Defined in: packages/threeplay/src/plugins/shapes/types.ts:27

ShapeComp.shape