LittleJS 1.28.0

GLTF

GLTFObject

GLTFObject - A model as an object with a child per part, which plays the model's animations

  • model.createObject makes one; move, turn and scale it like any EngineObject3D and the parts follow
  • play starts an animation by name or number, and the object moves its parts each frame as it runs
  • The parts' meshes stay where they rest, an animation moves the child objects that draw them

Extends EngineObject3D

Constructor

new GLTFObject(model, pos3D)gltf.js:261

Make the object and its parts, model.createObject is the usual way

model GLTFModel
pos3D Vector3 optional
const door = model.createObject(vec3(0, 0, 5));
door.play('open', false); // once, holding the last pose

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

animation : GLTFAnimation|undefinedgltf.js:277

The animation playing, or the last one, undefined for none

animationLoop : booleangltf.js:283

Start again at the end, or stop there and hold the last pose

animationPlaying : booleangltf.js:285

Whether it is moving through the animation now

animationSpeed : numbergltf.js:281

How fast it plays, 1 is as made, negative plays it backward

animationTime : numbergltf.js:279

Seconds into the animation

blendFrom : {animation?: GLTFAnimation, time?: number, speed?: number, loop?: boolean, nodes?: Map<number, Object>}|undefinedgltf.js:288

The model it shows

The child that draws each of the model's parts, in the order of model.parts, which an animation poses; one destroyed or taken off the object is left alone

poseNodes : Map<number, Object>|undefinedgltf.js:294
poseWorldOf : (function(number): Matrix4)|undefinedgltf.js:297

Methods

destroy(immediate)gltf.js:330

Destroy the object and its parts, and free the meshes its skinned parts bend, which are its own

immediate boolean optional
getJointMatrix(name) → Matrix4|undefinedgltf.js:442

A node's matrix in the world as the model is posed now, by its name in the file, to hang something on a joint, a sword on a hand or a hat on a head; undefined when the model has no node of that name

name string
play(animation, loop, speed, blend)gltf.js:345

Play an animation from its start, at once or cross-faded from the pose it is in

  • A play with a blend of the animation already playing goes on with it, so state code may call it each frame; without a blend it starts the animation again
animation string|number|GLTFAnimation optional, default 0

Its name, its number in model.animations, or itself

loop boolean optional, default true

Start again at the end, or stop there

speed number optional, default 1

1 is as made, negative plays it backward from its end

blend number optional, default 0

Seconds to cross-fade from the pose it is in, 0 to switch at once; the animation it comes from goes on through the fade, and a fade started during another fades from the mix there

setAnimationTime(time)gltf.js:378

Put the parts where the animation has them at a time, playing or not

time number

Seconds into the animation

Stop the animation where it is, the parts hold that pose; a cross-fade going on stops too, holding the mix

update()gltf.js:415

Move through the animation, and a cross-fade into it, called automatically each frame