LittleJS 1.28.0

GLTF

GLTFModel

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

Constructor

new GLTFModel(parts)gltf.js:129

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:139

The animations, play one through createObject's GLTFObject

bounds : Object|undefinedgltf.js:156

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:142
parts : Array<GLTFPart>gltf.js:136

One per primitive of every node that has a mesh

textureInfo : TextureInfo|undefinedgltf.js:154

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:246

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:232

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:178

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:201

Find an animation by name or number

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

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

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

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:187

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

matrix Matrix4|Vector3

Transform, or just an offset to move by