This commit is contained in:
David Rowe 2020-01-06 10:58:49 +13:00
parent d872e9f07d
commit fcc1f928a1

View file

@ -160,7 +160,7 @@ function restoreCameraState() {
} }
function handleModes() { function handleModes() {
var newMode = (mode == noMode) ? noMode : detachedMode; var newMode = (mode === noMode) ? noMode : detachedMode;
if (alt) { if (alt) {
if (control) { if (control) {
if (shift) { if (shift) {
@ -174,32 +174,32 @@ function handleModes() {
} }
// if entering detachMode // if entering detachMode
if (newMode == detachedMode && mode != detachedMode) { if (newMode === detachedMode && mode !== detachedMode) {
avatarPosition = MyAvatar.position; avatarPosition = MyAvatar.position;
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 || (avatarPosition.x !== MyAvatar.position.x ||
avatarPosition.y != MyAvatar.position.y || avatarPosition.y !== MyAvatar.position.y ||
avatarPosition.z != MyAvatar.position.z || avatarPosition.z !== MyAvatar.position.z ||
avatarOrientation.x != MyAvatar.orientation.x || avatarOrientation.x !== MyAvatar.orientation.x ||
avatarOrientation.y != MyAvatar.orientation.y || avatarOrientation.y !== MyAvatar.orientation.y ||
avatarOrientation.z != MyAvatar.orientation.z || avatarOrientation.z !== MyAvatar.orientation.z ||
avatarOrientation.w != MyAvatar.orientation.w)) { avatarOrientation.w !== MyAvatar.orientation.w)) {
newMode = noMode; newMode = noMode;
} }
if (mode == noMode && newMode != noMode && Camera.mode == "independent") { if (mode === noMode && newMode !== noMode && Camera.mode === "independent") {
newMode = noMode; newMode = noMode;
} }
// if leaving noMode // if leaving noMode
if (mode == noMode && newMode != noMode) { if (mode === noMode && newMode !== noMode) {
saveCameraState(); saveCameraState();
} }
// if entering noMode // if entering noMode
if (newMode == noMode && mode != noMode) { if (newMode === noMode && mode !== noMode) {
restoreCameraState(); restoreCameraState();
} }
@ -209,15 +209,15 @@ function handleModes() {
function keyPressEvent(event) { function keyPressEvent(event) {
var changed = false; var changed = false;
if (event.text == "ALT") { if (event.text === "ALT") {
alt = true; alt = true;
changed = true; changed = true;
} }
if (event.text == "CONTROL") { if (event.text === "CONTROL") {
control = true; control = true;
changed = true; changed = true;
} }
if (event.text == "SHIFT") { if (event.text === "SHIFT") {
shift = true; shift = true;
changed = true; changed = true;
} }
@ -230,17 +230,17 @@ function keyPressEvent(event) {
function keyReleaseEvent(event) { function keyReleaseEvent(event) {
var changed = false; var changed = false;
if (event.text == "ALT") { if (event.text === "ALT") {
alt = false; alt = false;
changed = true; changed = true;
mode = noMode; mode = noMode;
restoreCameraState(); restoreCameraState();
} }
if (event.text == "CONTROL") { if (event.text === "CONTROL") {
control = false; control = false;
changed = true; changed = true;
} }
if (event.text == "SHIFT") { if (event.text === "SHIFT") {
shift = false; shift = false;
changed = true; changed = true;
} }
@ -293,14 +293,14 @@ function mouseReleaseEvent(event) {
} }
function mouseMoveEvent(event) { function mouseMoveEvent(event) {
if (isActive && mode != noMode && !rotatingTowardsTarget) { if (isActive && mode !== noMode && !rotatingTowardsTarget) {
if (mode == radialMode) { if (mode === radialMode) {
handleRadialMode(event.x - mouseLastX, event.y - mouseLastY); handleRadialMode(event.x - mouseLastX, event.y - mouseLastY);
} }
if (mode == orbitMode) { if (mode === orbitMode) {
handleOrbitMode(event.x - mouseLastX, event.y - mouseLastY); handleOrbitMode(event.x - mouseLastX, event.y - mouseLastY);
} }
if (mode == panningMode) { if (mode === panningMode) {
handlePanMode(event.x - mouseLastX, event.y - mouseLastY); handlePanMode(event.x - mouseLastX, event.y - mouseLastY);
} }
} }
@ -316,12 +316,13 @@ function update() {
} }
function rotateTowardsTarget() { function rotateTowardsTarget() {
var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, 0.1); var MIX_FACTOR = 0.1;
var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, MIX_FACTOR);
Camera.setOrientation(newOrientation); Camera.setOrientation(newOrientation);
} }
function scriptEnding() { function scriptEnding() {
if (mode != noMode) { if (mode !== noMode) {
restoreCameraState(); restoreCameraState();
} }
} }