Let's take a closer look at what you are trying to calculate. Begin with
gyro = start^(-1)*end
and then adjust the scene rotation to
scene = end*gyro = end*start^(-1)*end
It is evident that this product does not result in the desired start
quaternion. Considering the assumption that
start == scene = end*gyro
you will need to evaluate
gyro = end^(-1)*start
This means swapping end
and start
in your current calculation of gyro
.
Furthermore, investigate which quaternion methods modify themselves (all except for .clone()
if the outcome is a quaternion).
The .inverse()
method, equivalent to .conjugate().normalize()
, falls under this category. Therefore,
var gyroTrackingDelta=endOrientation.inverse();
initially reverses endOrientation
and subsequently shares reference with gyroTrackingDelta
, leading to unexpected side effects during future calculations. A more reliable alternative to avoid unintentional self-modification would be
var gyroTrackingDelta=endOrientation.clone().inverse();
gyroTrackingDelta.multiply(startOrientation);
scene.quaternion.copy(endOrientation).multiply(gyroTrackingDelta);