From 6fa1d7a7bd8c3247d432bdf9780d92d8e518ecd8 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 10 Dec 2014 14:08:59 -0800 Subject: [PATCH 1/4] Update lobby to start on the second row --- examples/lobby.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index dd011d08a4..51b8feea7a 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -71,6 +71,23 @@ function textOverlayPosition() { Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN)); } +var panelLocationOrder = [ + 7, 8, 9, 10, 11, 12, 13, + 0, 1, 2, 3, 4, 5, 6, + 14, 15, 16, 17, 18, 19, 20 +]; + +// Location index is 0-based +function locationIndexToPanelIndex(locationIndex) { + return panelLocationOrder.indexOf(locationIndex) + 1; +} + +// Panel index is 1-based +function panelIndexToLocationIndex(panelIndex) { + return panelLocationOrder[panelIndex - 1]; +} + + var MAX_NUM_PANELS = 21; var DRONE_VOLUME = 0.3; @@ -168,7 +185,8 @@ function changeLobbyTextures() { }; for (var j = 0; j < NUM_PANELS; j++) { - textureProp["textures"]["file" + (j + 1)] = "http:" + locations[j].thumbnail_url + panelIndex = locationIndexToPanelIndex(j); + textureProp["textures"]["file" + panelIndex] = "http:" + locations[j].thumbnail_url; }; Overlays.editOverlay(panelWall, textureProp); @@ -259,12 +277,13 @@ function actionStartEvent(event) { var panelStringIndex = panelName.indexOf("Panel"); if (panelStringIndex != -1) { - var panelIndex = parseInt(panelName.slice(5)) - 1; - if (panelIndex < locations.length) { - var actionLocation = locations[panelIndex]; + var panelIndex = parseInt(panelName.slice(5)); + var locationIndex = panelIndexToLocationIndex(panelIndex); + if (locationIndex < locations.length) { + var actionLocation = locations[locationIndex]; print("Jumping to " + actionLocation.name + " at " + actionLocation.path - + " in " + actionLocation.domain.name + " after click on panel " + panelIndex); + + " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex); Window.location = actionLocation; maybeCleanupLobby(); @@ -308,9 +327,10 @@ function handleLookAt(pickRay) { var panelName = result.extraInfo; var panelStringIndex = panelName.indexOf("Panel"); if (panelStringIndex != -1) { - var panelIndex = parseInt(panelName.slice(5)) - 1; - if (panelIndex < locations.length) { - var actionLocation = locations[panelIndex]; + var panelIndex = parseInt(panelName.slice(5)); + var locationIndex = panelIndexToLocationIndex(panelIndex); + if (locationIndex< locations.length) { + var actionLocation = locations[locationIndex]; if (actionLocation.description == "") { Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: true }); From a24acb485807a0fe757bf07c196a1a6c42ae25fa Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 10 Dec 2014 14:15:43 -0800 Subject: [PATCH 2/4] Fix style --- examples/lobby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lobby.js b/examples/lobby.js index 51b8feea7a..702fb732a1 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -329,7 +329,7 @@ function handleLookAt(pickRay) { if (panelStringIndex != -1) { var panelIndex = parseInt(panelName.slice(5)); var locationIndex = panelIndexToLocationIndex(panelIndex); - if (locationIndex< locations.length) { + if (locationIndex < locations.length) { var actionLocation = locations[locationIndex]; if (actionLocation.description == "") { From 961f6290741d2aee25ea7be659b1b00aaa48aef1 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 10 Dec 2014 14:26:42 -0800 Subject: [PATCH 3/4] Fix indentation, 4 -> 2 --- examples/lobby.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index a72e61a629..5c856f1862 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -70,16 +70,14 @@ var panelLocationOrder = [ // Location index is 0-based function locationIndexToPanelIndex(locationIndex) { - return panelLocationOrder.indexOf(locationIndex) + 1; + return panelLocationOrder.indexOf(locationIndex) + 1; } // Panel index is 1-based function panelIndexToLocationIndex(panelIndex) { - return panelLocationOrder[panelIndex - 1]; + return panelLocationOrder[panelIndex - 1]; } - - var MAX_NUM_PANELS = 21; var DRONE_VOLUME = 0.3; From 9c9bfeed333d75b18f6e8b182fffc9da67e43dc1 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 10 Dec 2014 14:27:37 -0800 Subject: [PATCH 4/4] Add missing 'var' to local variable --- examples/lobby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lobby.js b/examples/lobby.js index 5c856f1862..647202bebc 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -158,7 +158,7 @@ function changeLobbyTextures() { }; for (var j = 0; j < NUM_PANELS; j++) { - panelIndex = locationIndexToPanelIndex(j); + var panelIndex = locationIndexToPanelIndex(j); textureProp["textures"]["file" + panelIndex] = "http:" + locations[j].thumbnail_url; };