[name]

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]

Constructor

[name]( [param:Object params] )

[page:Object params] — (optional)

Creates a new [name].

Properties

[property:Audio audio]

An [page:Audio] added to helper.

[property:Camera camera]

An [page:Camera] added to helper.

[property:Array meshes]

An array of [page:SkinnedMesh] added to helper.

[property:WeakMap objects]

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"

[property:Function onBeforePhysics]

An optional callback that is executed immediately before the physicis calculation for an [page:SkinnedMesh]. This function is called with the [page:SkinnedMesh].

Methods

[method:MMDAnimationHelper add]( [param:Object3D object], [param:Object params] )

[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.

[method:MMDAnimationHelper enable]( [param:String key], [param:Boolean enabled] )

[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

[method:MMDAnimationHelper pose]( [param:SkinnedMesh mesh], [param:Object vpd], [param:Object params] )

[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.

[method:MMDAnimationHelper remove]( [param:Object3D object] )

[page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]

Remove an [page:SkinnedMesh], [page:Camera], or [page:Audio] from helper.

[method:MMDAnimationHelper update]( [param:Nummber delta] )

[page:Number delta] — number in second

Advance mixer time and update the animations of objects added to helper

Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDAnimationHelper.js examples/jsm/animation/MMDAnimationHelper.js]