I have a JSON model that is a box and I use the Three.JSONLoader
in my project. I can see in the ThreeJS Editor that the pivot Point or origin is near the centre of the model in both the X and Z directions. In the ThreeJS Editor after loading the JSON model, rotating around the Y spins from near the centre as expected.
I need to find the position of the pivot. I have used a bounding box which gives me the min/max values so I can get the actual size (I think scale gives the same) and I was expecting that the mesh position would be the position of the pivot or origin but it isn't. In Unity, I Believe you use the transform.
How can I find (or calculate) the pivot?
I added some code
var cube = new THREE.Mesh(new THREE.BoxGeometry(0.1, 0.1, 0.1),
new THREE.MeshBasicMaterial({ color: 0xff0000 }));
mesh.add(cube);
And I can see the box attached to the model at the pivot point. Obviously different places for different models but whether I use matrix
or matrixWorld
on either the model or the cube I have just added, the numbers are the same for position. So maybe the position is correct. In which case, turning this on its head, how do I calculate the distance from the position to the edge of the model? I thought the bounding box min/max could be used, but this doesn't seem to work either.