[name]

A Physics handler for MMD resources.

[name] calculates Physics for model loaded by [page:MMDLoader] with ammo.js (Bullet-based JavaScript Physics engine).

代码示例

const physics; // Load MMD resources and instantiate MMDPhysics new MMDLoader().load( 'models/mmd/miku.pmd', function ( mesh ) { physics = new MMDPhysics( mesh ) scene.add( mesh ); } ); function render() { const delta = clock.getDelta(); animate( delta ); // update bones if ( physics !== undefined ) physics.update( delta ); renderer.render( scene, camera ); }

例子

[example:webgl_loader_mmd]
[example:webgl_loader_mmd_audio]

Constructor

[name]( [param:SkinnedMesh mesh], [param:Array rigidBodyParams], [param:Array constraintParams], [param:Object params] )

[page:SkinnedMesh mesh] — [page:SkinnedMesh] for which [name] calculates Physics.
[page:Array rigidBodyParams] — An array of [page:Object] specifying Rigid Body parameters.
[page:Array constraintParams] — (optional) An array of [page:Object] specifying Constraint parameters.
[page:Object params] — (optional)

Creates a new [name].

Properties

[property:Array mesh]

[page:SkinnedMesh] passed to the constructor.

Methods

[method:MMDPhysicsHelper createHelper]()

Return [page:MMDPhysicsHelper]. You can visualize Rigid bodies by adding the helper to scene.

[method:this reset]()

Resets Rigid bodies transform to current bone's.

[method:this setGravity]( [param:Vector3 gravity] )

[page:Vector3 gravity] — Direction and volume of gravity.

Set gravity.

[method:this update]( [param:Number delta] )

[page:Number delta] — Time in second.

Advance Physics calculation and updates bones.

[method:this warmup]( [param:Integer cycles] )

[page:Number delta] — Time in second.

Warm up Rigid bodies. Calculates cycles steps.

Source

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