Hi,
Sorry for repeating this question and I checked out many posts regarding this issue but I still can’t get it to work. I have a checkerboard on the X Y plane with many objects and labels in a group object.
I have an on-click event that will rotate the camera on the Z axis 90 degrees.
I figured out how to rotate the camera but I can’t figure out how to keep the label where it should be and just rotate the label object 90 degrees with the camera.
I started by trying the .rotateZ(Math.PI / 2). Which I believe rotates on the world axis.
I saw this function on a different post
// Rotate an object around an arbitrary axis in object space
var rotObjectMatrix;
function rotateAroundObjectAxis(object, axis, radians) {
rotObjectMatrix = new THREE.Matrix4();
rotObjectMatrix.makeRotationAxis(axis.normalize(), radians);
// old code for Three.JS pre r54:
// object.matrix.multiplySelf(rotObjectMatrix); // post-multiply
// new code for Three.JS r55+:
object.matrix.multiply(rotObjectMatrix);
// old code for Three.js pre r49:
// object.rotation.getRotationFromMatrix(object.matrix, object.scale);
// old code for Three.js r50-r58:
// object.rotation.setEulerFromRotationMatrix(object.matrix);
// new code for Three.js r59+:
object.rotation.setFromRotationMatrix(object.matrix);
}
so I tried something like
var zAxis = new THREE.Vector3( 0, 0, 1);
rotateAroundObjectAxis( groupedLabelObject, zAxis, Math.PI / 2 );
but results to this:
it looks like the position in terms with X and Y appears to be correct but it’s rotating the wrong direction.
I also tried .rorateOnAxis and .rotateAroundWorldAxis with different variation but I still can’t get it to work.
Any help will be appreciated