Cope with slight avatar position and orientation jitter when stationary

This commit is contained in:
David Rowe 2020-01-06 11:14:12 +13:00
parent 81e1dd4d6a
commit a1056f34ed

View file

@ -25,6 +25,9 @@ var ALTITUDE_RATE = 200.0;
var RADIUS_RATE = 1.0 / 100.0; var RADIUS_RATE = 1.0 / 100.0;
var PAN_RATE = 250.0; var PAN_RATE = 250.0;
var AVATAR_POSITION_SLOP = 0.1;
var AVATAR_ROTATION_SLOP = 0.09; // 5 degrees
var Y_AXIS = { var Y_AXIS = {
x: 0, x: 0,
y: 1, y: 1,
@ -179,14 +182,10 @@ function handleModes() {
avatarOrientation = MyAvatar.orientation; avatarOrientation = MyAvatar.orientation;
} }
// if leaving detachMode // if leaving detachMode
if (mode === detachedMode && newMode === detachedMode && if (mode === detachedMode && newMode === detachedMode && (
(avatarPosition.x !== MyAvatar.position.x || Vec3.length(Vec3.subtract(avatarPosition, MyAvatar.position)) > AVATAR_POSITION_SLOP
avatarPosition.y !== MyAvatar.position.y || || Vec3.length(Vec3.subtract(Quat.getFront(avatarOrientation), Quat.getFront(MyAvatar.orientation)))
avatarPosition.z !== MyAvatar.position.z || > AVATAR_ROTATION_SLOP)) {
avatarOrientation.x !== MyAvatar.orientation.x ||
avatarOrientation.y !== MyAvatar.orientation.y ||
avatarOrientation.z !== MyAvatar.orientation.z ||
avatarOrientation.w !== MyAvatar.orientation.w)) {
newMode = noMode; newMode = noMode;
} }