I’m actually working with Transform Gizmo and I tried to display each time we drag (translate, rotation or scale) a control, it displays the mode, the axis and the value positive or negative after dragging…
My problem is that it takes world coordinates to make these comparisons, my control may be in local mode. I can’t get its local variation.
I have tried to calculate it using the Matrix 4 transformation but I get stuck
It was a custom TransformControl component, and I succeed to manage it by changing the position of its parent when I move my objet, like it it’s always in the position/rotation zero.
let globalPosition = new THREE.Vector3();
let globalQuaternion = new THREE.Quaternion();
let globalScale = new THREE.Vector3();
this.controls.object.matrixWorld.decompose(globalPosition, globalQuaternion, globalScale);
this.controls.object.position.set(0, 0, 0);
this.controls.object.quaternion.set(0, 0, 0, 1); // Reset to identity quaternion
this.controls.object.scale.set(1, 1, 1);
this.controls.object.updateMatrixWorld(true);
let inverseParentWorldMatrix = new THREE.Matrix4();
inverseParentWorldMatrix.copy(this.controls.object.parent.matrixWorld).invert();
let relativePosition = new THREE.Vector3();
let relativeQuaternion = new THREE.Quaternion();
let relativeScale = new THREE.Vector3();
let relativeMatrix = new THREE.Matrix4();
relativeMatrix.copy(inverseParentWorldMatrix).multiply(this.controls.object.matrixWorld);
relativeMatrix.decompose(relativePosition, relativeQuaternion, relativeScale);
this.controls.object.parent.position.copy(globalPosition);
this.controls.object.parent.quaternion.copy(globalQuaternion);
this.controls.object.parent.scale.copy(globalScale);
this.controls.object.parent.updateMatrixWorld(true);
this.controls.object.position.copy(relativePosition);
this.controls.object.quaternion.copy(relativeQuaternion);
this.controls.object.scale.copy(relativeScale);
this.controls.object.updateMatrixWorld(true);
}