首页 > 解决方案 > 将两个动画 Maya 文件加载到 Javascript 中

问题描述

我正在尝试加载两个不同的动画文件,但只有一个动画,第二个没有动画。

我尝试使用 fbx 加载器加载 fbx 文件

var loader = new THREE.FBXLoader();

loader.load('models/jumpi.fbx', function(object) {
      mixer = new THREE.AnimationMixer(object);
      var action = mixer.clipAction(object.animations[0]);
      action.play();
      window.addEventListener("keydown", function(event) {
          if (event.defaultPrevented) {
            return; // Do nothing if the event was already processed
            keyPressed = event.key;
            // If the button pressed is "e" or "E" (using caps lock or shift), then the player jumps.
            if (keyPressed == "e" || keyPressed == "E") {
              // call your jump function.
              // console.log('working');
              //action.play();
            }
            // Cancel the default action to avoid it being handled twice
            event.preventDefault();
          }, true); object.traverse(function(child) {}); scene.add(object);
      });

    var loader = new THREE.FBXLoader(); loader.load('models/move.fbx', function(object) {
      mixer = new THREE.AnimationMixer(object);
      object.traverse(function(child) {});
      object.position.y = 2;
      object.position.x = 50;
      object.scale.x = 20;
      object.scale.y = 20;
      object.scale.z = 20;
      scene.add(object);
    });

标签: javascriptmaya

解决方案


推荐阅读