我目前正在尝试使用Three.js FBXLoader通过以下代码加载.fbx文件:
var fbxLoader = new THREE.FBXLoader();
fbxLoader.load('assets/item2.fbx', function (object){
object.position.y = - 100;
scene.add(object);
console.log("Object inserted.");
fitCameraToObject(camera,object,2,controls);
controls.update();
animate();
},
function ( xhr ) {
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
},
function (err)
{
console.error(err);
}
);
(第122-138行)
但这在加载页面webGLLoader.js时给了我这个错误:
8.514530412006819% loaded
webGLLoader.js:132 100% loaded
FBXLoader.js:3252 THREE.FBXLoader: FBX binary version: 7400
webGLLoader.js:136 TypeError: node.applyMatrix4 is not a function
at FBXLoader.js:827
at Mesh.traverse (three.js:5686)
at Group.traverse (three.js:5692)
at FBXTreeParser.parseScene (FBXLoader.js:819)
at FBXTreeParser.parse (FBXLoader.js:130)
at FBXLoader.parse (FBXLoader.js:102)
at Object.onLoad (FBXLoader.js:54)
at XMLHttpRequest.<anonymous> (three.js:35758)
(anonymous) @ webGLLoader.js:136
(anonymous) @ FBXLoader.js:60
setTimeout (async)
(anonymous) @ FBXLoader.js:58
(anonymous) @ three.js:35758
load (async)
load @ three.js:35736
load @ FBXLoader.js:50
(anonymous) @ webGLLoader.js:123
github上已经讨论了类似的问题:https : //github.com/mrdoob/three.js/issues/18523
问题是您使用的版本FBXLoader
与three.js
核心库不同步。示例文件,如FBXLoader
和three.js
必须来自同一版本。因此,我建议您将两个文件都升级到最新版本,然后应避免运行时错误。
three.js R113