From 500b8a49d1969d4ab412af7164e008b903f02b57 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 4 Dec 2014 14:17:24 -0800 Subject: [PATCH] Add button to gamepad.js to toggle mirror mode --- examples/gamepad.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/gamepad.js b/examples/gamepad.js index 0012103c4e..d8a7e33fe3 100644 --- a/examples/gamepad.js +++ b/examples/gamepad.js @@ -18,6 +18,8 @@ var AXIS_ROTATE = Joysticks.AXIS_RIGHT_X; var BUTTON_SPRINT = Joysticks.BUTTON_LEFT_STICK; +var BUTTON_TOGGLE_MIRROR = Joysticks.BUTTON_FACE_LEFT; + var BUTTON_TURN_AROUND = Joysticks.BUTTON_RIGHT_STICK; var BUTTON_FLY_UP = Joysticks.BUTTON_RIGHT_SHOULDER; @@ -49,6 +51,10 @@ var WARP_PICK_MAX_DISTANCE = 100; var flyDownButtonState = false; var flyUpButtonState = false; +// When toggling to mirror mode, this stores the mode the user was previously in +// so it can be toggled back to. +var toggledFromCameraMode = 'first person'; + // Current move direction, axis aligned - that is, looking down and moving forward // will not move you into the ground, but instead will keep you on the horizontal plane. var moveDirection = { x: 0, y: 0, z: 0 }; @@ -179,6 +185,16 @@ function reportButtonValue(button, newValue, oldValue) { } } else if (button == BUTTON_SPRINT) { sprintButtonState = newValue; + } else if (button == BUTTON_TOGGLE_MIRROR) { + if (newValue) { + var currentMode = Camera.mode; + if (currentMode == "mirror") { + Camera.mode = toggledFromCameraMode; + } else { + toggledFromCameraMode = currentMode; + Camera.mode = "mirror"; + } + } } else if (newValue) { var direction = null;