0
votes

I have a series of Object3Ds in a scene that I have created myself from vertices and faces. It should be said that the vertices of these objects can be very far away from the world origin (X and Y values up to 600'000ish). Upon trying to rotate or scale them, they appear to be rotating around the another axis instead of their local center.

Weirdly object3D.translateX (or Y Z) work fine and as expected, as does simply moving the position (i.e:

object.position.x = 10

increments the x position by 10 (away from 0,0,0 local origin).

I am not even entirely sure which axis this object is rotating around. When I moved the geometry to 0,0,0 with object.position that didn't appear to make the object rotate around itself either.

If it is of any use, I have code to get the center of the object ( using:

THREE.Box3().setFromObject(object).center

(although there might be more appropriate ways?))

Indeed I have found this post which has allowed me to rotate (XYZ) around the center point, however I can't find a way to rotate around X Y Z axes individually, only all together.

Are there any solutions? This must be a common thing to attempt to achieve (scaling and rotating objects around their central axes?)

edit: Interestinly I am finding various sources of information implying that rotation is around a local axis, however this doesn't appear to be the case with my geometries! Saying that rotation is around object axis

Similarly saying the same sort of thing, however implying this can change depending on how it is 'built' (not sure what that means)

1

1 Answers

1
votes

The objects are rotating around the 0,0,0 point of the mesh/object coordinates. And not around the 0,0,0 coordinates of the world. And the object maybe not in the center of their own origin.

Set your object to 0,0,0 and create a cube at 0,0,0 and look if they are in the same place.

I needed to edit the mesh vertices so they realy centered around 0,0,0. After that i could rotate them without a problem.

Or put your object to 0,0,0 and run your code to get the center of your object. And i think it will not be 0,0,0.