根据这个主题:Rotating .obj file OBJMTLLoader three.js
我可以根据以下代码更改obj的轴:
loader.load('models/motor12.obj', 'models/motor12.mtl', function (object) {
object.traverse(function (child) {
console.log(child);
child.centroid = new THREE.Vector3();
for (var i = 0, l = child.geometry.vertices.length; i < l; i++) {
child.centroid.add(child.geometry.vertices[i].clone());
}
child.centroid.divideScalar(child.geometry.vertices.length);
var offset = child.centroid.clone();
child.geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-offset.x, -offset.y, -offset.z));
child.position.copy(child.centroid);
child.geometry.computeBoundingBox();
});
scene.add( object );
}, onProgress, onError);
不幸的是,我有错误:
TypeError:child.geometry未定义
我放了一个console.log(孩子),实际上,孩子没有几何:
我错过了什么?
由于