|
@@ -120,10 +120,22 @@
|
|
|
var material = new THREE.MeshPhongMaterial( { color: 0x545454, specular: 0x0c0c0c, shininess: 100 } );
|
|
|
var mesh = new THREE.Mesh( geometry, material );
|
|
|
const center = new THREE.Vector3();
|
|
|
- mesh.position.set( 0, 0, 0 );
|
|
|
- mesh.rotation.set( 0, 0, 0);
|
|
|
+
|
|
|
+ //Scsale it down to original's 10%
|
|
|
mesh.scale.set( 0.1, 0.1, 0.1 );
|
|
|
+ render();
|
|
|
+ var bbox = new THREE.Box3().setFromObject(mesh);
|
|
|
+ //Move the mesh to scene center
|
|
|
+ console.log(bbox);
|
|
|
+ mesh.updateMatrixWorld();
|
|
|
+ console.log(-1 * (bbox.max.x + bbox.min.x));
|
|
|
+ mesh.position.set(-1 * (bbox.max.x + bbox.min.x) / 2, -1 * (bbox.max.y + bbox.min.y) / 2, -1 * (bbox.max.z + bbox.min.z) / 2);
|
|
|
+ mesh.updateMatrixWorld();
|
|
|
+ console.log("Setting mesh world position: ", mesh.getWorldPosition())
|
|
|
+ mesh.rotation.set( 0, 0, 0);
|
|
|
|
|
|
+ render();
|
|
|
+
|
|
|
var box = new THREE.Box3().setFromObject(mesh);
|
|
|
console.log( box.min, box.max, box.getSize(center) );
|
|
|
objectSize = box.getSize(center);
|