Capítulo 188 de 859

Chapter 188: MDDLoader

Core Idea

A loader for the MDD format.

MDD stores a position for every vertex in a model for every frame in an animation. Similar to BVH, it can be used to transfer animation data between different 3D applications or engines.

MDD stores its data in binary format (big endian) in the following way:

  • number of frames (a single uint32)
  • number of vertices (a single uint32)
  • time values for each frame (sequence of float32)
  • vertex data for each frame (sequence of float32)

Code Examples

const loader = new MDDLoader();
const result = await loader.loadAsync( 'models/mdd/cube.mdd' );
const morphTargets = result.morphTargets;
const clip = result.clip;
// clip.optimize(); // optional
const geometry = new THREE.BoxGeometry();
geometry.morphAttributes.position = morphTargets; // apply morph targets (vertex data must match)
const material = new THREE.MeshBasicMaterial();
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
const mixer = new THREE.AnimationMixer( mesh );
mixer.clipAction( clip ).play();
  • What it demonstrates: Typical usage of MDDLoader.

Reference Tables

Constructor

Signature
new MDDLoader( manager : LoadingManager )

Methods

MethodDescription
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and passes the loaded MDD asset to the onLoad() callback.
.parse( data : ArrayBuffer ) : ObjectParses the given MDD data and returns an object holding the animation clip and the respective morph targets.

Key Takeaways

  1. MDDLoader extends: Loader
  2. Key methods: load, parse.

Connects To