MMDPhysics
A Physics handler for MMD resources.
MMDPhysics calculates Physics for model loaded by 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 ); }
例子
webgl_loader_mmd
webgl_loader_mmd_audio
Constructor
MMDPhysics( mesh : SkinnedMesh, rigidBodyParams : Array, constraintParams : Array, params : Object )
mesh — SkinnedMesh for which MMDPhysics calculates Physics.
rigidBodyParams — An array of Object specifying Rigid Body parameters.
constraintParams — (optional) An array of Object specifying Constraint parameters.
params — (optional)
- unitStep - Default is 1 / 65.
- maxStepNum - Default is 3.
- gravity - Default is ( 0, - 9.8 * 10, 0 )
Creates a new MMDPhysics.
Properties
.mesh : Array
SkinnedMesh passed to the constructor.
Methods
.createHelper () : MMDPhysicsHelper
Return MMDPhysicsHelper. You can visualize Rigid bodies by adding the helper to scene.
.reset () : CCDIKSolver
Resets Rigid bodies transorm to current bone's.
.setGravity ( gravity : Vector3 ) : CCDIKSolver
gravity — Direction and volume of gravity.
Set gravity.
.update ( delta : Number ) : CCDIKSolver
delta — Time in second.
Advance Physics calculation and updates bones.
.warmup ( cycles : Integer ) : CCDIKSolver
delta — Time in second.
Warm up Rigid bodies. Calculates cycles steps.