网格没有几何三.js

时间:2015-02-19 18:27:02

标签: rotation three.js

根据这个主题: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(孩子),实际上,孩子没有几何:

enter image description here

我错过了什么?

由于

0 个答案:

没有答案