diff --git a/examples/headMove.js b/examples/headMove.js index df5c858b46..4d2e4ded07 100644 --- a/examples/headMove.js +++ b/examples/headMove.js @@ -19,6 +19,7 @@ var warpPosition = { x: 0, y: 0, z: 0 }; var hipsToEyes; var restoreCountdownTimer; +var headTurningTimer = 0.0; // Overlays to show target location @@ -168,6 +169,20 @@ function update(deltaTime) { restoreCountDownTimer = 0.0; } } + var HEAD_TURN_TIME = 0.10; + var HEAD_TURN_DEGREES = 4.0; + var HEAD_TURN_START_ANGLE = 45.0; + var currentYaw = MyAvatar.getHeadFinalYaw(); + if (Math.abs(currentYaw) > HEAD_TURN_START_ANGLE) { + headTurningTimer += deltaTime; + if (headTurningTimer > HEAD_TURN_TIME) { + headTurningTimer = 0.0; + MyAvatar.orientation = Quat.multiply(Quat.fromPitchYawRollDegrees(0, (currentYaw > 0) ? HEAD_TURN_DEGREES: -HEAD_TURN_DEGREES, 0), + MyAvatar.orientation); + } + } else { + headTurningTimer = 0.0; + } } Controller.keyPressEvent.connect(function(event) {