我在网上查了很久没有详细代码。整理了一下
object.children[0].geometry.computeBoundingBox(); var centroid = new THREE.Vector3(); centroid.addVectors( object.children[0].geometry.boundingBox.min, object.children[0].geometry.boundingBox.max ); centroid.multiplyScalar( 0.5 ); centroid.applyMatrix4( object.children[0].matrixWorld );
object.children[0].geometry.center(centroid.x*0.05, centroid.y*0.05, centroid.z*0.05) object.position.set(centroid.x*0.05, centroid.y*0.05, centroid.z*0.05)//
导入OBJ时
var mtlLoader1 = new THREE.MTLLoader(); mtlLoader1.setPath('精简风扇/'); mtlLoader1.load('shanye_020.mtl', function(materials) { mtlLoader1.receiveShadow = true; materials.preload(); var objLoader1 = new THREE.OBJLoader(); objLoader1.setMaterials(materials); objLoader1.setPath('精简风扇/'); objLoader1.load('shanye_020.o