LittleJS 1.29.0

GLTF

GLTFModel

GLTFModel - A loaded model: its parts, and everything as one mesh

Constructor

new GLTFModel(parts)gltf.js:140

Make a model from its parts, as the loader does

parts Array<GLTFPart>

@param {Array} [animations] @param {Object} [nodeTree]

Members

Methods

Members

animations : Array<GLTFAnimation>gltf.js:150

The animations, play one through createObject's GLTFObject

bounds : Object|undefinedgltf.js:167

Every part combined, each tinted with its material color; the texture is textureInfo, and blending and unlit stay with the parts, which createObject draws

nodeTree : Object|undefinedgltf.js:153
parts : Array<GLTFPart>gltf.js:147

One per primitive of every node that has a mesh

textureInfo : TextureInfo|undefinedgltf.js:165

The texture to draw mesh with, when every part uses the same one

Methods

Move every part so the center of the model's bounds is on the origin, like Mesh.center

createObject(pos3D) → GLTFObjectgltf.js:257

Make an object at a position with a child per part, so each keeps its own texture, color and blending, and the model's animations can play on it; the way to show a model with windows or other see through parts, which the combined mesh draws solid, or one that moves

pos3D Vector3 optional
Returns
  • The root, move and turn it and the parts follow
dispose()gltf.js:243

Free the GPU buffers of every part's mesh and of the combined mesh, and the textures, for a model that is done with, like a level's models when the next level loads

  • Destroy the objects createObject made from it first; a mesh drawn again only uploads again, but a freed texture is gone
fit(size) → GLTFModelgltf.js:189

Scale every part evenly so the model's largest extent is a size, like Mesh.fit, for models of unknown units

size number optional, default 1
getAnimation(animation) → GLTFAnimation|undefinedgltf.js:212

Find an animation by name or number

animation string|number|GLTFAnimation
getBounds() → Objectgltf.js:172

The box around every part, measured once and again after transform, so change the model through that

getPose(animation, time) → Array<Matrix4>gltf.js:223

How far each part has moved from its resting place at a time in an animation, one matrix per part

  • createObject's GLTFObject calls this as it plays, a game only needs it to pose something by hand
animation GLTFAnimation
time number

Seconds into it

transform(matrix) → GLTFModelgltf.js:198

Move, turn or scale every part and the combined mesh together

matrix Matrix4|Vector3

Transform, or just an offset to move by