I am looking to implement object3D rotation using hammerjs gestures.
The rotation is mostly working, but I am facing two persistent issues that I cannot resolve:
The rotation direction changes unexpectedly. For example, if I start rotating left and then stop, when I try to rotate in the same direction again, it suddenly starts rotating right. This seems to occur randomly and not consistently.
Once the rotation begins, it only continues in the initial direction despite me attempting to change finger movement directions.
This snippet demonstrates my approach to handling the rotation:
public rotateObject3D (e: HammerInput): void {
if (rotationEnabled) {
const translation = new THREE.Vector3();
const rotation = new THREE.Quaternion();
const scale = new THREE.Vector3();
const rotateMatrix = new THREE.Matrix4();
const deltaRotationQuaternion = new THREE.Quaternion();
this._myObject.matrix.decompose(translation, rotation, scale);
this._deltaRot = (e.rotation * 0.01);
deltaRotationQuaternion.setFromEuler(new THREE.Euler(
0,
this._deltaRot * (Math.PI / 180),
0,
'XYZ'
));
deltaRotationQuaternion.multiplyQuaternions(deltaRotationQuaternion, rotation);
this._myObject.matrix = rotateMatrix.compose(translation, deltaRotationQuaternion, scale);
}
}
Here is how I call this function:
this._hammerManager.on('rotate', (e) => {
this._arTools.rotateObject3D(e);
});
Do you have any suggestions on what might be causing these issues?