fixed lookWithTouch.js to not reset

This commit is contained in:
ZappoMan 2014-03-25 12:55:50 -07:00
parent db05523bc3
commit a256473ac5

View file

@ -9,6 +9,7 @@
//
//
var startedTouching = false;
var lastX = 0;
var lastY = 0;
var yawFromMouse = 0;
@ -21,12 +22,14 @@ function touchBeginEvent(event) {
}
lastX = event.x;
lastY = event.y;
startedTouching = true;
}
function touchEndEvent(event) {
if (wantDebugging) {
print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
}
startedTouching = false;
}
function touchUpdateEvent(event) {
@ -44,6 +47,7 @@ function touchUpdateEvent(event) {
}
function update(deltaTime) {
if (startedTouching) {
// rotate body yaw for yaw received from mouse
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromMouse, 0));
if (wantDebugging) {
@ -63,6 +67,7 @@ function update(deltaTime) {
MyAvatar.headPitch = newPitch;
pitchFromMouse = 0;
}
}
// Map the mouse events to our functions
Controller.touchBeginEvent.connect(touchBeginEvent);
@ -77,10 +82,6 @@ function scriptEnding() {
Controller.releaseTouchEvents();
}
MyAvatar.bodyYaw = 0;
MyAvatar.bodyPitch = 0;
MyAvatar.bodyRoll = 0;
// would be nice to change to update
Script.update.connect(update);
Script.scriptEnding.connect(scriptEnding);