AnimationModule

modules/mesh/ AnimationModule

.new AnimationModule(app, isDeferredopt, paramsopt)

Convenience module that wraps the three.js animation system

Source:
Parameters:
Name Type Attributes Default Description
app App

the app

isDeferred Boolean <optional>
false

set to true if animation should not start automatically

params Object <optional>
{speed: 1}

the params

Example

Create animation module and play a given clip of an imported model

const animationModule = new AnimationModule(app, false, {
  speed: 1.2 // speed up animation by 20%
});

new Importer({
  parser(geometry, materials) {
    // Override parse to generate a skinnedMesh, needed for skinned models
    return new THREE.SkinnedMesh(geometry, materials);
  },

  url: `path/to/model.json`,
  useCustomMaterial: true,

  material: new THREE.MeshStandardMaterial({
    skinning: true
  }),

  modules: [animationModule]
}).addTo(app).then(() => {
  // adding model to app returns a promise, so pipe the function to kick off the animation clip
  animationModule.play('clipName');
});

Methods

.play(clipName)

Plays the given clip name

Source:
Parameters:
Name Type Description
clipName String

the clip to play

.update()

Update the mixer (being called on frame animation loop)

Source: