A animation helper for MMD resources.
[name] handles animation of MMD assets loaded by [page:MMDLoader] with MMD special features as IK, Grant, and Physics.
It uses [page:CCDIKSolver] and [page:MMDPhysics] inside.
// Instantiate a helper
const helper = new MMDAnimationHelper();
// Load MMD resources and add to helper
new MMDLoader().loadWithAnimation(
'models/mmd/miku.pmd',
'models/mmd/dance.vmd',
function ( mmd ) {
helper.add( mmd.mesh, {
animation: mmd.animation,
physics: true
} );
scene.add( mmd.mesh );
new THREE.AudioLoader().load(
'audios/mmd/song.mp3',
function ( buffer ) {
const listener = new THREE.AudioListener();
const audio = new THREE.Audio( listener ).setBuffer( buffer );
listener.position.z = 1;
scene.add( audio );
scene.add( listener );
}
);
}
);
function render() {
helper.update( clock.getDelta() );
renderer.render( scene, camera );
}
[example:webgl_loader_mmd]
[example:webgl_loader_mmd_pose]
[example:webgl_loader_mmd_audio]
[page:Object params] — (optional)
Creates a new [name].
An [page:Audio] added to helper.
An [page:Camera] added to helper.
An array of [page:SkinnedMesh] added to helper.
A [page:WeakMap] which holds animation stuffs used in helper for objects added to helper. For example, you can access [page:AnimationMixer] for an added [page:SkinnedMesh] with "helper.objects.get( mesh ).mixer"
An optional callback that is executed immediately before the physicis calculation for an [page:SkinnedMesh]. This function is called with the [page:SkinnedMesh].
[page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]
[page:Object params] — (optional)
Add an [page:SkinnedMesh], [page:Camera], or [page:Audio] to helper and setup animation. The anmation durations of added objects are synched. If camera/audio has already been added, it'll be replaced with a new one.
[page:String key] — Allowed strings are 'animation', 'ik', 'grant', 'physics', and 'cameraAnimation'.
[page:Boolean enabled] — true is enable, false is disable
Enable/Disable an animation feature
[page:SkinnedMesh mesh] — [page:SkinnedMesh] which changes the posing. It doesn't need to be added to helper.
[page:Object vpd] — VPD content obtained by [page:MMDLoader].loadVPD
[page:Object params] — (optional)
Changes the posing of [page:SkinnedMesh] as VPD content specifies.
[page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]
Remove an [page:SkinnedMesh], [page:Camera], or [page:Audio] from helper.
[page:Number delta] — number in second
Advance mixer time and update the animations of objects added to helper
[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDAnimationHelper.js examples/jsm/animation/MMDAnimationHelper.js]