toggle sync & normal position control
This commit is contained in:
96
index.html
96
index.html
@@ -235,6 +235,8 @@
|
|||||||
var dollyCam;
|
var dollyCam;
|
||||||
// EnterVRButton for rendering enter/exit UI.
|
// EnterVRButton for rendering enter/exit UI.
|
||||||
var vrButton;
|
var vrButton;
|
||||||
|
var keyPanSpeed = 1;
|
||||||
|
var broadcastCamMovement = true;
|
||||||
|
|
||||||
var moved = false;
|
var moved = false;
|
||||||
var pressing = false;
|
var pressing = false;
|
||||||
@@ -371,8 +373,10 @@
|
|||||||
|
|
||||||
var oldUpdate = controls.update;
|
var oldUpdate = controls.update;
|
||||||
controls.update = function() {
|
controls.update = function() {
|
||||||
|
if (broadcastCamMovement) {
|
||||||
oldUpdate();
|
oldUpdate();
|
||||||
publishCameraLocationMessage();
|
publishCameraLocationMessage();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// The dolly has to be a PerspectiveCamera, as opposed
|
// The dolly has to be a PerspectiveCamera, as opposed
|
||||||
@@ -1087,38 +1091,93 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveForward() {
|
||||||
|
var direction = camera.getWorldDirection();
|
||||||
|
if (!pressing) {
|
||||||
|
dollyCam.position.add(direction.multiplyScalar(keyPanSpeed));
|
||||||
|
controls.update();
|
||||||
|
moved = true;
|
||||||
|
pressing = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
pressing = false;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveBackward() {
|
||||||
|
var direction = camera.getWorldDirection();
|
||||||
|
if (!pressing) {
|
||||||
|
dollyCam.position.add(direction.multiplyScalar(-keyPanSpeed));
|
||||||
|
controls.update();
|
||||||
|
moved = true;
|
||||||
|
pressing = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
pressing = false;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function strafeLeft() {
|
||||||
|
var vectorUp = new THREE.Vector3(0, 1, 0);
|
||||||
|
var direction = camera.getWorldDirection();
|
||||||
|
var strafeVector = new THREE.Vector3().crossVectors(vectorUp, direction).normalize();
|
||||||
|
if (!pressing) {
|
||||||
|
dollyCam.position.add(strafeVector.multiplyScalar(-keyPanSpeed))
|
||||||
|
controls.update();
|
||||||
|
moved = true;
|
||||||
|
pressing = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
pressing = false;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function strafeRight() {
|
||||||
|
var vectorUp = new THREE.Vector3(0, 1, 0);
|
||||||
|
var direction = camera.getWorldDirection();
|
||||||
|
var strafeVector = new THREE.Vector3().crossVectors(vectorUp, direction).normalize();
|
||||||
|
if (!pressing) {
|
||||||
|
dollyCam.position.add(strafeVector.multiplyScalar(keyPanSpeed))
|
||||||
|
controls.update();
|
||||||
|
moved = true;
|
||||||
|
pressing = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
pressing = false;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCamMovementBroadcast() {
|
||||||
|
if (!pressing) {
|
||||||
|
broadcastCamMovement = !broadcastCamMovement;
|
||||||
|
pressing = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
pressing = false;
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function buttonPressed(buttonNumber) {
|
function buttonPressed(buttonNumber) {
|
||||||
var keyPanSpeed = 1;
|
|
||||||
var direction = camera.getWorldDirection();
|
|
||||||
var vectorUp = new THREE.Vector3(0, 1, 0);
|
|
||||||
var strafeVector = new THREE.Vector3().crossVectors(vectorUp, direction).normalize();
|
|
||||||
|
|
||||||
switch (buttonNumber) {
|
switch (buttonNumber) {
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
|
moveForward();
|
||||||
dollyCam.position.add(direction.multiplyScalar(keyPanSpeed));
|
|
||||||
controls.update();
|
|
||||||
moved = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
dollyCam.position.add(direction.multiplyScalar(-keyPanSpeed));
|
moveBackward();
|
||||||
controls.update();
|
|
||||||
moved = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
dollyCam.position.add(strafeVector.multiplyScalar(keyPanSpeed))
|
strafeRight();
|
||||||
controls.update();
|
|
||||||
moved = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
dollyCam.position.add(strafeVector.multiplyScalar(-keyPanSpeed))
|
strafeLeft();
|
||||||
controls.update();
|
|
||||||
moved = true;
|
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
moveToPreviousPlace();
|
moveToPreviousPlace();
|
||||||
@@ -1126,6 +1185,9 @@
|
|||||||
case 1:
|
case 1:
|
||||||
moveToNextPlace();
|
moveToNextPlace();
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
toggleCamMovementBroadcast();
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user