three.js,Uncaught TypeError:无法读取未定义的属性'type'

时间:2015-12-21 17:20:23

标签: javascript json html5 three.js blender

我正在尝试使用three.js在html中加载json文件但是我遇到了以下错误:

> Uncaught TypeError: Cannot read property 'type' of undefined
THREE.ObjectLoader.parseObject @ three.js:13066
THREE.ObjectLoader.parse @ three.js:12706
(anonymous function) @ three.js:12677
(anonymous function) @ three.js:11761

我使用Blender(2.75a)的three.js(71)插件从FBX导出到json。

我尝试从ObjectLoader切换到JSONLoader,但是我得到了类似的错误,除了它不能读取属性'length'。有什么想法吗?

我正在使用https://github.com/master-atul/blender3js/dis/index.html

中的示例

这是我遇到问题的json文件的链接: http://we.tl/8a3rxgpqr5

以下是json加载代码的片段:

var characterGenerator = function () {
  var init = function () {
    var defer = q.defer();
    var mesh = null;
    var loader = new THREE.ObjectLoader();

    loader.load("assets/test_igor.json", function (geometry, materials) {
      for (var i = 0; i < materials.length; i++) {
        var m = materials[i];
        m.skinning = true;
      }
      mesh = new THREE.SkinnedMesh(geometry, new THREE.MeshFaceMaterial(materials));
      //mesh.rotation.y = 90;
      mesh.animator = function (animeName) {
        var selected = _.find(geometry.animations, {'name': animeName});
        var animation = new THREE.Animation(mesh, selected);
        animation.play();
      };
      defer.resolve(mesh);
    });
    return defer.promise;
  };

  return {
    init: init
  }
}();

0 个答案:

没有答案