Is there a straightforward method to change the rotation pivot of THREE.Object3D
? By default, the pivot point is the position point of the object.
I have a group (implemented as THREE.Object3D
) of objects and I want to rotate all objects together around a specific THREE.Vector3
point that can be adjusted during runtime.
It's important to note that the position of the group cannot be altered.
I attempted the following solution (with assistance from Derte Trdelnik), however, it did not yield the desired outcome:
someButton.onClick(function () {
var object = editor.selected;
if (!object instanceof THREE.Object3D) return;
var pivot = new THREE.Vector3(100, 0, 0);
var vectorToPivot = object.position.sub(pivot);
var moveToPivot = new THREE.Matrix4().makeTranslation(vectorToPivot.x,
vectorToPivot.y, vectorToPivot.z);
var rotation = new THREE.Matrix4().makeRotationZ(Math.PI);
var inverseMove = new THREE.Matrix4().makeTranslation(-vectorToPivot.x,-vectorToPivot.y, -vectorToPivot.z);
var matrix = inverseMove.clone().multiply(rotation).multiply(moveToPivot);
object.applyMatrix(matrix);
editor.signals.objectChanged.dispatch(object);
});
Thank you in advance for any guidance!