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

## Code Example

`// 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 ); }`

## Examples

[example:webgl_loader_mmd]
[example:webgl_loader_mmd_pose]
[example:webgl_loader_mmd_audio]

## Constructor

### [name]( [param:Object params] )

[page:Object params] — (optional)

- [page:Boolean sync] - Whether animation durations of added objects are synched. Default is true.
- [page:Number afterglow] - Default is 0.0.
- [page:Boolean resetPhysicsOnLoop] - Default is true.
- [page:Boolean pmxAnimation] - If it is set to true, the helper follows the complex and costly PMX animation system. Try this option only if your PMX model animation doesn't work well. Default is false.

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)

- [page:AnimationClip animation] - an [page:AnimationClip] or an array of [page:AnimationClip] set to object. Only for [page:SkinnedMesh] and [page:Camera]. Default is undefined.
- [page:Boolean physics] - Only for [page:SkinnedMesh]. A flag whether turn on physics. Default is true.
- [page:Integer warmup] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 60.
- [page:Number unitStep] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 1 / 65.
- [page:Integer maxStepNum] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 3.
- [page:Vector3 gravity] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is ( 0, - 9.8 * 10, 0 ).
- [page:Number delayTime] - Only for [page:Audio]. Default is 0.0.

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)

- [page:Boolean resetPose] - Default is true.
- [page:Boolean ik] - Default is true.
- [page:Boolean grant] - Default is true.

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:Number 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]