Can an Object3D object be rotated around its end?
Absolutely. By default, an Object3D rotates around its center, but it is possible to change the rotation point by enclosing the object in a parent (Object3D) and setting the position for the parent which will then become the new rotation point:
function redefineRotationPoint(obj, scene, position) {
// create a parent object and add it to the scene
const parent = new THREE.Object3D();
parent.add(obj);
if (obj.parent) {
obj.parent.add(parent);
} else {
// add to the THREE scene if obj has no parent
scene.add(parent);
}
// set the position for rotation, for example: { x: 0.1, y: 0.1, z: 0 }
parent.position.set(position.x, position.y, position.z);
// adjust the object's position so only the rotation point changes
const x = obj.position.x - position.x;
const y = obj.position.y - position.y;
const z = obj.position.z - position.z;
obj.position.set(x, y, z);
}
// invoke the function
redefineRotationPoint(this.object, scene, { x: 0.1, y: 0.1, z: 0 });
// rotate the object
this.object.parent.rotation.set(0.1, 0.2, 0.3);