Fix frame of reference for rotations.

This commit is contained in:
r3tk0n 2019-02-26 12:46:46 -08:00
parent 2a04d2b9c5
commit f3b65d06ad

View file

@ -242,15 +242,13 @@ Script.include("/~/system/libraries/controllers.js");
var pose = Controller.getPoseValue((this.getDominantHand() ? Controller.Standard.RightHand : Controller.Standard.LeftHand));
if (pose.valid) {
if (!this.manipulating) {
//this.initialEntityRotation = Quat.multiply(this.getTargetRotation(), Quat.inverse(MyAvatar.orientation)); // Avatar frame.
this.initialEntityRotation = this.getTargetRotation(); // Worldframe.
this.initialControllerRotation = Quat.multiply(MyAvatar.orientation, pose.rotation); // Worldframe.
//this.initialEntityRotation = Quat.multiply(this.getTargetRotation(), Quat.inverse(MyAvatar.orientation));
this.initialControllerRotation = Quat.multiply(pose.rotation, MyAvatar.orientation); // Worldframe.
this.manipulating = true;
}
}
var rot = Quat.multiply(MyAvatar.orientation, pose.rotation);
var rot = Quat.multiply(pose.rotation, MyAvatar.orientation);
var rotBetween = this.calculateEntityRotationManipulation(rot);
this.setJointRotation(Quat.multiply(rotBetween, this.initialEntityRotation));
} else {