返回介绍

手册

参考

示例

开发者参考

MMDAnimationHelper

发布于 2021-07-10 14:14:19 字数 6778 浏览 1540 评论 0 收藏 0

A animation helper for MMD resources.

MMDAnimationHelper handles animation of MMD assets loaded by MMDLoader with MMD special features as IK, Grant, and Physics. It uses CCDIKSolver and 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 );
}

例子

webgl_loader_mmd
webgl_loader_mmd_pose
webgl_loader_mmd_audio

Constructor

MMDAnimationHelper( params : Object )

params — (optional)

  • sync - Whether animation durations of added objects are synched. Default is true.
  • afterglow - Default is 0.0.
  • resetPhysicsOnLoop - Default is true.
  • 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 MMDAnimationHelper.

Properties

.audio : Audio

An Audio added to helper.

.camera : Camera

An Camera added to helper.

.meshes : Array

An array of SkinnedMesh added to helper.

.objects : WeakMap

A WeakMap which holds animation stuffs used in helper for objects added to helper. For example, you can access AnimationMixer for an added SkinnedMesh with "helper.objects.get( mesh ).mixer"

.onBeforePhysics : Function

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

Methods

.add ( object : Object3D, params : Object ) : MMDAnimationHelper

objectSkinnedMesh, Camera, or Audio
params — (optional)

Add an SkinnedMesh, Camera, or 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.

.enable ( key : String, enabled : Boolean ) : MMDAnimationHelper

key — Allowed strings are 'animation', 'ik', 'grant', 'physics', and 'cameraAnimation'.
enabled — true is enable, false is disable

Enable/Disable an animation feature

.pose ( mesh : SkinnedMesh, vpd : Object, params : Object ) : MMDAnimationHelper

meshSkinnedMesh which changes the posing. It doesn't need to be added to helper.
vpd — VPD content obtained by MMDLoader.loadVPD
params — (optional)

Changes the posing of SkinnedMesh as VPD content specifies.

.remove ( object : Object3D ) : MMDAnimationHelper

objectSkinnedMesh, Camera, or Audio

Remove an SkinnedMesh, Camera, or Audio from helper.

.update ( delta : Nummber ) : MMDAnimationHelper

delta — number in second

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

Source

examples/jsm/animation/MMDAnimationHelper.js

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文