Merge pull request #11694 from ElderOrb/FB8315

8315 Stylus appears in wrong place on hand
This commit is contained in:
Brad Hefta-Gaub 2017-10-30 18:00:56 -07:00 committed by GitHub
commit fbcd813d7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,6 +154,25 @@ Script.include("/~/system/libraries/controllers.js");
this.showStylus = function() {
if (this.stylus) {
var X_ROT_NEG_90 = { x: -0.70710678, y: 0, z: 0, w: 0.70710678 };
var modelOrientation = Quat.multiply(this.stylusTip.orientation, X_ROT_NEG_90);
var modelOrientationAngles = Quat.safeEulerAngles(modelOrientation);
var rotation = Overlays.getProperty(this.stylus, "rotation");
var rotationAngles = Quat.safeEulerAngles(rotation);
if(!Vec3.withinEpsilon(modelOrientationAngles, rotationAngles, 1)) {
var modelPositionOffset = Vec3.multiplyQbyV(modelOrientation, { x: 0, y: 0, z: MyAvatar.sensorToWorldScale * -WEB_STYLUS_LENGTH / 2 });
var updatedStylusProperties = {
position: Vec3.sum(this.stylusTip.position, modelPositionOffset),
rotation: modelOrientation,
dimensions: Vec3.multiply(MyAvatar.sensorToWorldScale, { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }),
};
Overlays.editOverlay(this.stylus, updatedStylusProperties);
}
return;
}