Three.js居中显示OBJ

我用的是Three.js里的OBJLoader2

将源文件里的代码加以修改即可

objLoader.load( objDef.fileObj, function (object) {
	//console.log(object);
	object.children[0].geometry.computeBoundingBox();
	object.rotation.x = THREE.Math.degToRad( 90 );
	//console.log(- ( object.children[0].geometry.boundingBox.max.x + object.children[0].geometry.boundingBox.min.x ) / 2);
	//console.log(- ( object.children[0].geometry.boundingBox.max.y + object.children[0].geometry.boundingBox.min.y ) / 2);
	//console.log(- ( object.children[0].geometry.boundingBox.max.z + object.children[0].geometry.boundingBox.min.z ) / 2);
	//console.log( object.children[0].geometry.center() );
	object.children[0].geometry.center()//居中显示
	//helper = new THREE.BoundingBoxHelper(object, 0xff0000);
	//helper.update();
	//scene.add(helper);
	scene.add(object);
}, onSuccess, onProgress, onError );//加载OBJ文件