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

Constructor

new GLTFObject(model, pos3Dopt)

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

Parameters:
NameTypeAttributesDescription
modelGLTFModel
pos3DVector3<optional>
Example
const door = model.createObject(vec3(0, 0, 5));
door.play('open', false); // once, holding the last pose

Extends

  • EngineObject3D

Members

animation :GLTFAnimation|undefined

Type:
  • GLTFAnimation | undefined
Properties
TypeDescription
GLTFAnimation | undefined

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

animationLoop

Properties
TypeDescription
boolean

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

animationPlaying

Properties
TypeDescription
boolean

Whether it is moving through the animation now

animationSpeed

Properties
TypeDescription
number

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

animationTime

Properties
TypeDescription
number

Seconds into the animation

model

Properties
TypeDescription
GLTFModel

The model it shows

parts :Array.<EngineObject3D>

Type:
  • Array.<EngineObject3D>
Properties
TypeDescription
Array.<EngineObject3D>

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

Methods

play(animationopt, loopopt, speedopt)

Play an animation from its start

Parameters:
NameTypeAttributesDefaultDescription
animationstring | number | GLTFAnimation<optional>
0

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

loopboolean<optional>
true

Start again at the end, or stop there

speednumber<optional>
1

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

setAnimationTime(time)

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

Parameters:
NameTypeDescription
timenumber

Seconds into the animation

stop()

Stop the animation where it is, the parts hold that pose

update()

Move through the animation, called automatically each frame