My goal is to rotate the geometry around a pivot point and set that as the new definition of the geometry. I want the current rotationZ to become the new rotationZ 0 without having to keep editing the rotationZ.
This way, when I create a new rotation task, it will start from the updated pivot point and radian value.
I attempted the following solution, but the rotation point ends up moving:
// Add cube for calculations
var box = new THREE.Box3().setFromObject( o );
var size = box.getSize();
var offsetZ = size.z / 2;
o.geometry.translate(0, -offsetZ, 0)
// Perform rotation
o.rotateZ(CalcUtils.degreeToRad(degree));
o.geometry.translate(0, offsetZ, 0)
I also experimented with adding a Group, rotating the group, and then removing it. However, I need to retain the rotation without additional objects. This is the code snippet I came up with:
var box = new THREE.Box3().setFromObject( o );
var size = box.size();
var geometry = new THREE.BoxGeometry( 20, 20, 20 );
var material = new THREE.MeshBasicMaterial( { color: 0xcc0000 } );
var cube = new THREE.Mesh( geometry, material );
cube.position.x = o.position.x;
cube.position.y = 0; // Height / 2
cube.position.z = -size.z / 2;
o.position.x = 0;
o.position.y = 0;
o.position.z = size.z / 2;
cube.add(o);
scene.add(cube);
// Perform rotation
cube.rotateY(CalcUtils.degreeToRad(degree));
// Remove cube and revert to single object
var position = o.getWorldPosition();
scene.add(o)
scene.remove(cube);
console.log(o);
o.position.x = position.x;
o.position.y = position.y;
o.position.z = position.z;
Therefore, my question is how can I preserve the current rotation as the new 0 rotation point and finalize the rotation?
EDIT I have provided an image depicting my objective. The green object represents the geometry. There is a world origin point (black), an object origin point (red), and a rotation point (blue).
How can I effectively rotate the object around the blue point depicted in the image?