From 18db5f1724b180d7a518007f6144a7931fbdeab0 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 15 Feb 2017 14:19:03 -0800 Subject: [PATCH 01/17] add a tablet button for photobooth --- .../utilities/render/photobooth/photobooth.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photobooth.js b/scripts/developer/utilities/render/photobooth/photobooth.js index 3e86d83a98..19528f7173 100644 --- a/scripts/developer/utilities/render/photobooth/photobooth.js +++ b/scripts/developer/utilities/render/photobooth/photobooth.js @@ -1,9 +1,28 @@ +// +// photobooth.js +// scripts/developer/utilities/render/photobooth +// +// Created by Howard Stearns on 2 Nov 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +/* globals Tablet, Toolbars, Script, HMD, Controller, Menu */ (function () { var SNAPSHOT_DELAY = 500; // 500ms var PHOTOBOOTH_WINDOW_HTML_URL = Script.resolvePath("./html/photobooth.html"); var PHOTOBOOTH_SETUP_JSON_URL = Script.resolvePath("./photoboothSetup.json"); - var toolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); var MODEL_BOUNDING_BOX_DIMENSIONS = {x: 1.0174,y: 1.1925,z: 1.0165}; + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var button = tablet.addButton({ + icon: "icons/tablet-icons/snap-i.svg", + text: "PHOTOBOOTH" + }); + function onClicked() { + PhotoBooth.init(); + } + button.clicked.connect(onClicked); var PhotoBooth = {}; PhotoBooth.init = function () { @@ -96,7 +115,6 @@ }; var main = function () { - PhotoBooth.init(); var photoboothWindowListener = {}; photoboothWindowListener.onLoad = function (event) { @@ -172,6 +190,7 @@ function cleanup() { Camera.mode = "first person"; PhotoBooth.destroy(); + tablet.removeButton(button); } Script.scriptEnding.connect(cleanup); }()); \ No newline at end of file From 3149f02de6f30f32b0b654c12c2194c52f9e7fb3 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 15 Feb 2017 14:25:57 -0800 Subject: [PATCH 02/17] display HTML in tablet instead of overlay web window --- .../developer/utilities/render/photobooth/photobooth.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photobooth.js b/scripts/developer/utilities/render/photobooth/photobooth.js index 19528f7173..ab881ede4d 100644 --- a/scripts/developer/utilities/render/photobooth/photobooth.js +++ b/scripts/developer/utilities/render/photobooth/photobooth.js @@ -20,6 +20,7 @@ text: "PHOTOBOOTH" }); function onClicked() { + tablet.gotoWebScreen(PHOTOBOOTH_WINDOW_HTML_URL); PhotoBooth.init(); } button.clicked.connect(onClicked); @@ -169,14 +170,6 @@ print("clicked reload model button " + event.value); PhotoBooth.changeModel(event.value); }; - - var photoboothWindow = new OverlayWebWindow({ - title: 'Photo Booth', - source: PHOTOBOOTH_WINDOW_HTML_URL, - width: 450, - height: 450, - visible: true - }); photoboothWindow.webEventReceived.connect(function (data) { var event = JSON.parse(data); From f3fdb7c315e6451a6398657e046e4c3e01bfce84 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 15 Feb 2017 15:02:10 -0800 Subject: [PATCH 03/17] added top bar title --- .../render/photobooth/html/photobooth.html | 81 ++++++++++++------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/html/photobooth.html b/scripts/developer/utilities/render/photobooth/html/photobooth.html index 8964a51f05..a7740330fb 100644 --- a/scripts/developer/utilities/render/photobooth/html/photobooth.html +++ b/scripts/developer/utilities/render/photobooth/html/photobooth.html @@ -2,7 +2,37 @@ Photo Booth + + - + + + +
+
Photobooth
+
+
+
+
+ + + +
+ +
+ +
+
+
+ - - - - -
-
Photobooth
-
-
-
-
- - - -
- -
- -
-
-
diff --git a/scripts/developer/utilities/render/photobooth/photobooth.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js similarity index 95% rename from scripts/developer/utilities/render/photobooth/photobooth.js rename to scripts/developer/utilities/render/photobooth/photoboothApp.js index ab881ede4d..ca298d00de 100644 --- a/scripts/developer/utilities/render/photobooth/photobooth.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -19,11 +19,24 @@ icon: "icons/tablet-icons/snap-i.svg", text: "PHOTOBOOTH" }); + function onClicked() { tablet.gotoWebScreen(PHOTOBOOTH_WINDOW_HTML_URL); PhotoBooth.init(); } button.clicked.connect(onClicked); + tablet.webEventReceived.connect(onWebEventReceived); + + function onWebEventReceived(event) { + print("photobooth.js received a web event:" + event); + // Converts the event to a JavasScript Object + if (typeof event === "string") { + event = JSON.parse(event); + } + if (event.app === "photobooth") { + + } + } var PhotoBooth = {}; PhotoBooth.init = function () { @@ -170,20 +183,13 @@ print("clicked reload model button " + event.value); PhotoBooth.changeModel(event.value); }; - - photoboothWindow.webEventReceived.connect(function (data) { - var event = JSON.parse(data); - if (photoboothWindowListener[event.type]) { - photoboothWindowListener[event.type](event); - } - }); }; main(); function cleanup() { + tablet.removeButton(button); Camera.mode = "first person"; PhotoBooth.destroy(); - tablet.removeButton(button); } Script.scriptEnding.connect(cleanup); }()); \ No newline at end of file From 19bff20ebffdd457c8ed97814b2c29374cc0be67 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 15 Feb 2017 16:19:56 -0800 Subject: [PATCH 05/17] event handling - can now load models --- .../render/photobooth/html/photobooth.html | 12 +++- .../render/photobooth/photoboothApp.js | 62 +++++++------------ 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/html/photobooth.html b/scripts/developer/utilities/render/photobooth/html/photobooth.html index 0250084a54..6165896bf0 100644 --- a/scripts/developer/utilities/render/photobooth/html/photobooth.html +++ b/scripts/developer/utilities/render/photobooth/html/photobooth.html @@ -93,13 +93,19 @@ elPictureButton.addEventListener('click', function() { emit("onClickPictureButton", {value: "faye"}); }); - - }); + } $(document).ready(function() { // Send a ready event to hifi emit("ready", null); - + // Send an event to hifi to trigger snapshot + $("#picture-button").click(function() { + emit("onClickPictureButton", null); + }); + // Send an event to hifi for loading the given model URL + $("#reload-model-button").click(function() { + emit("onClickReloadModelButton", {value: $("#model-url").val()}); + }); }); diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index ca298d00de..c32744fe63 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -34,7 +34,29 @@ event = JSON.parse(event); } if (event.app === "photobooth") { - + if (event.type === "onClickPictureButton") { + print("clicked picture button"); + // // hide HUD tool bar + // toolbar.writeProperty("visible", false); + // // hide Overlays (such as Running Scripts or other Dialog UI) + // Menu.setIsOptionChecked("Overlays", false); + // // hide mouse cursor + // Reticle.visible = false; + // // giving a delay here before snapshotting so that there is time to hide toolbar and other UIs + // // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) + // Script.setTimeout(function () { + // Window.takeSnapshot(false, false, 1.91); + // // show hidden items after snapshot is taken + // toolbar.writeProperty("visible", true); + // Menu.setIsOptionChecked("Overlays", true); + // // unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot + // // Reticle.visible = true; + // }, SNAPSHOT_DELAY); + + } else if (event.type === "onClickReloadModelButton"){ + print("clicked reload model button " + event.data.value); + PhotoBooth.changeModel(event.data.value); + } } } @@ -131,12 +153,6 @@ var main = function () { var photoboothWindowListener = {}; - photoboothWindowListener.onLoad = function (event) { - print("loaded" + event.value); - if (!event.hasOwnProperty("value")){ - return; - } - }; photoboothWindowListener.onSelectCamera = function (event) { print("selected camera " + event.value); @@ -151,38 +167,6 @@ Camera.setCameraEntity(cameraID); } }; - - photoboothWindowListener.onSelectLightingPreset = function (event) { - print("selected lighting preset" + event.value); - if (!event.hasOwnProperty("value")){ - return; - } - }; - - photoboothWindowListener.onClickPictureButton = function (event) { - print("clicked picture button"); - // hide HUD tool bar - toolbar.writeProperty("visible", false); - // hide Overlays (such as Running Scripts or other Dialog UI) - Menu.setIsOptionChecked("Overlays", false); - // hide mouse cursor - Reticle.visible = false; - // giving a delay here before snapshotting so that there is time to hide toolbar and other UIs - // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) - Script.setTimeout(function () { - Window.takeSnapshot(false, false, 1.91); - // show hidden items after snapshot is taken - toolbar.writeProperty("visible", true); - Menu.setIsOptionChecked("Overlays", true); - // unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot - // Reticle.visible = true; - }, SNAPSHOT_DELAY); - }; - - photoboothWindowListener.onClickReloadModelButton = function (event) { - print("clicked reload model button " + event.value); - PhotoBooth.changeModel(event.value); - }; }; main(); From 1e5090ad27f762663e93a2011441944a2c6a46e8 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 15 Feb 2017 16:47:06 -0800 Subject: [PATCH 06/17] end of day commit --- .../render/photobooth/html/photobooth.html | 4 ++++ .../utilities/render/photobooth/photoboothApp.js | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/developer/utilities/render/photobooth/html/photobooth.html b/scripts/developer/utilities/render/photobooth/html/photobooth.html index 6165896bf0..b23b65cfdd 100644 --- a/scripts/developer/utilities/render/photobooth/html/photobooth.html +++ b/scripts/developer/utilities/render/photobooth/html/photobooth.html @@ -98,6 +98,10 @@ $(document).ready(function() { // Send a ready event to hifi emit("ready", null); + $("#property-camera").on('change', function() { + console.log("ok"); + emit("onSelectCamera", {value: this.val()}); + }); // Send an event to hifi to trigger snapshot $("#picture-button").click(function() { emit("onClickPictureButton", null); diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index c32744fe63..0b58e51224 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -53,9 +53,21 @@ // // Reticle.visible = true; // }, SNAPSHOT_DELAY); - } else if (event.type === "onClickReloadModelButton"){ + } else if (event.type === "onClickReloadModelButton") { print("clicked reload model button " + event.data.value); PhotoBooth.changeModel(event.data.value); + } else if (event.type === "onSelectCamera") { + print("selected camera " + event.data.value); + if (!event.data.hasOwnProperty("value")){ + return; + } + if (event.data.value === "First Person Camera") { + Camera.mode = "first person"; + } else { + Camera.mode = "entity"; + var cameraID = PhotoBooth.cameraEntities[event.data.value]; + Camera.setCameraEntity(cameraID); + } } } } From 217ec46222babb371830b0365b0211a175ee0a5e Mon Sep 17 00:00:00 2001 From: Faye Li Date: Fri, 17 Feb 2017 10:54:40 -0800 Subject: [PATCH 07/17] able to switch camera and clean up code --- .../render/photobooth/html/photobooth.html | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/html/photobooth.html b/scripts/developer/utilities/render/photobooth/html/photobooth.html index b23b65cfdd..e60cb2764d 100644 --- a/scripts/developer/utilities/render/photobooth/html/photobooth.html +++ b/scripts/developer/utilities/render/photobooth/html/photobooth.html @@ -69,38 +69,15 @@ "data": eventData }; EventBridge.emitWebEvent(JSON.stringify(eventObject)); - }; - - function loaded () { - openEventBridge(function () { - emit("onLoad", {value: "faye"}); - - var elModelURL = document.getElementById("model-url"); - var elReloadModelButton = document.getElementById("reload-model-button"); - var elCamera = document.getElementById("property-camera"); - //var elLightingPreset = document.getElementById("property-lighting-preset"); - var elPictureButton = document.getElementById("picture-button"); - - elReloadModelButton.addEventListener('click', function() { - emit("onClickReloadModelButton", {value: elModelURL.value}); - }); - elCamera.addEventListener('change', function() { - emit("onSelectCamera", {value: this.value}); - }); - // elLightingPreset.addEventListener('change', function() { - // emit("onSelectLightingPreset", {value: "faye"}); - // }); - elPictureButton.addEventListener('click', function() { - emit("onClickPictureButton", {value: "faye"}); - }); - }); } + $(document).ready(function() { // Send a ready event to hifi emit("ready", null); + // Send an event when camera selection changes $("#property-camera").on('change', function() { - console.log("ok"); - emit("onSelectCamera", {value: this.val()}); + console.log($("#property-camera").val()); + emit("onSelectCamera", {value: $("#property-camera").val()}); }); // Send an event to hifi to trigger snapshot $("#picture-button").click(function() { From 27b619030d304a00558ff733b55a844e435a3cbf Mon Sep 17 00:00:00 2001 From: Faye Li Date: Fri, 17 Feb 2017 11:32:53 -0800 Subject: [PATCH 08/17] ability to hide tablet and take picture --- .../render/photobooth/photoboothApp.js | 51 +++++++------------ 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index 0b58e51224..8389516c7d 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -38,20 +38,23 @@ print("clicked picture button"); // // hide HUD tool bar // toolbar.writeProperty("visible", false); - // // hide Overlays (such as Running Scripts or other Dialog UI) - // Menu.setIsOptionChecked("Overlays", false); - // // hide mouse cursor - // Reticle.visible = false; - // // giving a delay here before snapshotting so that there is time to hide toolbar and other UIs - // // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) - // Script.setTimeout(function () { - // Window.takeSnapshot(false, false, 1.91); - // // show hidden items after snapshot is taken - // toolbar.writeProperty("visible", true); - // Menu.setIsOptionChecked("Overlays", true); - // // unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot - // // Reticle.visible = true; - // }, SNAPSHOT_DELAY); + // hide tablet + HMD.closeTablet(); + // hide Overlays (such as Running Scripts or other Dialog UI) + Menu.setIsOptionChecked("Overlays", false); + // hide mouse cursor + Reticle.visible = false; + // // giving a delay here before snapshotting so that there is time to hide other UIs + // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) + Script.setTimeout(function () { + Window.takeSnapshot(false, false, 1.91); + // show hidden items after snapshot is taken + // issue: currently there's no way to show tablet via a script command. user will have to manually open tablet again + // toolbar.writeProperty("visible", true); + Menu.setIsOptionChecked("Overlays", true); + // issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot + // Reticle.visible = true; + }, SNAPSHOT_DELAY); } else if (event.type === "onClickReloadModelButton") { print("clicked reload model button " + event.data.value); @@ -161,26 +164,6 @@ }); Entities.deleteEntity(this.modelEntityID); }; - - var main = function () { - - var photoboothWindowListener = {}; - - photoboothWindowListener.onSelectCamera = function (event) { - print("selected camera " + event.value); - if (!event.hasOwnProperty("value")){ - return; - } - if (event.value === "First Person Camera") { - Camera.mode = "first person"; - } else { - Camera.mode = "entity"; - var cameraID = PhotoBooth.cameraEntities[event.value]; - Camera.setCameraEntity(cameraID); - } - }; - }; - main(); function cleanup() { tablet.removeButton(button); From 0e8d008b8c295ff6ccbd09f0bedaad9dff9883dc Mon Sep 17 00:00:00 2001 From: Faye Li Date: Fri, 17 Feb 2017 13:38:23 -0800 Subject: [PATCH 09/17] only have one instance of photobooth at a time --- .../render/photobooth/photoboothApp.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index 8389516c7d..f6a968a97b 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -14,15 +14,21 @@ var PHOTOBOOTH_WINDOW_HTML_URL = Script.resolvePath("./html/photobooth.html"); var PHOTOBOOTH_SETUP_JSON_URL = Script.resolvePath("./photoboothSetup.json"); var MODEL_BOUNDING_BOX_DIMENSIONS = {x: 1.0174,y: 1.1925,z: 1.0165}; + var PhotoBooth = {}; + var photoboothCreated = false; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ icon: "icons/tablet-icons/snap-i.svg", - text: "PHOTOBOOTH" + text: "TOP MODEL" }); function onClicked() { tablet.gotoWebScreen(PHOTOBOOTH_WINDOW_HTML_URL); - PhotoBooth.init(); + // Initialise the photobooth if it wasn't created already + if (!photoboothCreated) { + PhotoBooth.init(); + photoboothCreated = true; + } } button.clicked.connect(onClicked); tablet.webEventReceived.connect(onWebEventReceived); @@ -38,24 +44,23 @@ print("clicked picture button"); // // hide HUD tool bar // toolbar.writeProperty("visible", false); - // hide tablet - HMD.closeTablet(); // hide Overlays (such as Running Scripts or other Dialog UI) Menu.setIsOptionChecked("Overlays", false); // hide mouse cursor Reticle.visible = false; + // hide tablet + HMD.closeTablet(); // // giving a delay here before snapshotting so that there is time to hide other UIs // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) Script.setTimeout(function () { Window.takeSnapshot(false, false, 1.91); // show hidden items after snapshot is taken // issue: currently there's no way to show tablet via a script command. user will have to manually open tablet again - // toolbar.writeProperty("visible", true); - Menu.setIsOptionChecked("Overlays", true); // issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot // Reticle.visible = true; + // toolbar.writeProperty("visible", true); + Menu.setIsOptionChecked("Overlays", true); }, SNAPSHOT_DELAY); - } else if (event.type === "onClickReloadModelButton") { print("clicked reload model button " + event.data.value); PhotoBooth.changeModel(event.data.value); @@ -75,7 +80,6 @@ } } - var PhotoBooth = {}; PhotoBooth.init = function () { var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL); var frontFactor = 10; @@ -163,6 +167,7 @@ Entities.deleteEntity(id); }); Entities.deleteEntity(this.modelEntityID); + photoboothCreated = false; }; function cleanup() { From bd10b5d48fadaabaccfd4509db549345c6bbc54e Mon Sep 17 00:00:00 2001 From: Faye Li Date: Tue, 28 Feb 2017 11:34:07 -0800 Subject: [PATCH 10/17] fix camera drop down issue --- .../render/photobooth/html/photobooth.html | 53 +++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/html/photobooth.html b/scripts/developer/utilities/render/photobooth/html/photobooth.html index e60cb2764d..57d33f850a 100644 --- a/scripts/developer/utilities/render/photobooth/html/photobooth.html +++ b/scripts/developer/utilities/render/photobooth/html/photobooth.html @@ -3,6 +3,7 @@ Photo Booth + @@ -44,14 +68,20 @@ - + + diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index f6a968a97b..09c141b277 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -29,10 +29,12 @@ PhotoBooth.init(); photoboothCreated = true; } + } button.clicked.connect(onClicked); tablet.webEventReceived.connect(onWebEventReceived); + function onWebEventReceived(event) { print("photobooth.js received a web event:" + event); // Converts the event to a JavasScript Object @@ -76,6 +78,10 @@ var cameraID = PhotoBooth.cameraEntities[event.data.value]; Camera.setCameraEntity(cameraID); } + } else if (event.type === "onRotateSlider") { + var props = {}; + props.rotation = Quat.fromPitchYawRollDegrees(0, event.data.value, 0); + Entities.editEntity(PhotoBooth.modelEntityID, props); } } } From 067faad9cde341576543ea1be7e1daf597f94d11 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Fri, 24 Mar 2017 10:22:08 -0700 Subject: [PATCH 13/17] Fix careless math mistake --- .../developer/utilities/render/photobooth/photoboothApp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index 09c141b277..4e1ed6a1ae 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -2,7 +2,7 @@ // photobooth.js // scripts/developer/utilities/render/photobooth // -// Created by Howard Stearns on 2 Nov 2016 +// Created by Faye Li on 2 Nov 2016 // Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -93,7 +93,8 @@ var frontOffset = Vec3.multiply(frontUnitVec,frontFactor); var rightFactor = 3; var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation)); - var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,frontOffset),rightFactor); + var rightOffset = Vec3.multiply(rightUnitVec,rightFactor); + var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,frontOffset),rightOffset); if (success) { this.pastedEntityIDs = Clipboard.pasteEntities(spawnLocation); this.processPastedEntities(); From ccd4fdb5407e90c3b3e764e6547d3dd86a2cb23d Mon Sep 17 00:00:00 2001 From: Faye Li Date: Fri, 24 Mar 2017 10:46:52 -0700 Subject: [PATCH 14/17] naming --- .../developer/utilities/render/photobooth/photoboothApp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index 4e1ed6a1ae..c193513b35 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -19,7 +19,7 @@ var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ icon: "icons/tablet-icons/snap-i.svg", - text: "TOP MODEL" + text: "PHOTOBOOTH" }); function onClicked() { @@ -89,7 +89,8 @@ PhotoBooth.init = function () { var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL); var frontFactor = 10; - var frontUnitVec = Vec3.normalize(Quat.getFront(MyAvatar.orientation)); + // getForward is preffered as getFront function is deprecated + var frontUnitVec = (typeof Quat.getForward === "undefined") ? Vec3.normalize(Quat.getFront(MyAvatar.orientation)) : Vec3.normalize(Quat.getForward(MyAvatar.orientation)); var frontOffset = Vec3.multiply(frontUnitVec,frontFactor); var rightFactor = 3; var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation)); From 405be471c32e8dbd8448329af0fcb5b070514c5a Mon Sep 17 00:00:00 2001 From: Faye Li Date: Fri, 24 Mar 2017 13:47:19 -0700 Subject: [PATCH 15/17] button state change --- .../render/photobooth/photoboothApp.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index c193513b35..675db14be3 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -23,14 +23,25 @@ }); function onClicked() { - tablet.gotoWebScreen(PHOTOBOOTH_WINDOW_HTML_URL); - // Initialise the photobooth if it wasn't created already - if (!photoboothCreated) { + if (photoboothCreated) { + tablet.gotoHomeScreen(); + PhotoBooth.destroy(); + } else { + tablet.gotoWebScreen(PHOTOBOOTH_WINDOW_HTML_URL); PhotoBooth.init(); - photoboothCreated = true; } - } + + function onScreenChanged() { + if (photoboothCreated) { + tablet.gotoHomeScreen(); + PhotoBooth.destroy(); + button.editProperties({isActive: false}); + } else { + button.editProperties({isActive: true}); + } + } + tablet.screenChanged.connect(onScreenChanged); button.clicked.connect(onClicked); tablet.webEventReceived.connect(onWebEventReceived); @@ -87,6 +98,7 @@ } PhotoBooth.init = function () { + photoboothCreated = true; var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL); var frontFactor = 10; // getForward is preffered as getFront function is deprecated From d726bd352dc9ab67d73efa804d5ed4198f308944 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Mon, 3 Apr 2017 12:14:29 -0700 Subject: [PATCH 16/17] fix for locked camera state issue --- scripts/developer/utilities/render/photobooth/photoboothApp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index 675db14be3..dcbf363c3d 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -188,11 +188,11 @@ }); Entities.deleteEntity(this.modelEntityID); photoboothCreated = false; + Camera.mode = "first person"; }; function cleanup() { tablet.removeButton(button); - Camera.mode = "first person"; PhotoBooth.destroy(); } Script.scriptEnding.connect(cleanup); From 2ca4203d85c9eece148743b7bc83ea2a9b0aa607 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Mon, 3 Apr 2017 12:57:51 -0700 Subject: [PATCH 17/17] fix for submerge in floor issue --- .../utilities/render/photobooth/photoboothApp.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index dcbf363c3d..154028f091 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -102,16 +102,16 @@ var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL); var frontFactor = 10; // getForward is preffered as getFront function is deprecated - var frontUnitVec = (typeof Quat.getForward === "undefined") ? Vec3.normalize(Quat.getFront(MyAvatar.orientation)) : Vec3.normalize(Quat.getForward(MyAvatar.orientation)); + var frontUnitVec = Vec3.normalize(Quat.getFront(MyAvatar.orientation)); var frontOffset = Vec3.multiply(frontUnitVec,frontFactor); - var rightFactor = 3; - var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation)); - var rightOffset = Vec3.multiply(rightUnitVec,rightFactor); - var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,frontOffset),rightOffset); + var upFactor = 3; + var upUnitVec = Vec3.normalize(Quat.getUp(MyAvatar.orientation)); + var upOffset = Vec3.multiply(upUnitVec, upFactor); + var spawnLocation = Vec3.sum(MyAvatar.position,frontOffset); + spawnLocation = Vec3.sum(spawnLocation, upOffset); if (success) { this.pastedEntityIDs = Clipboard.pasteEntities(spawnLocation); this.processPastedEntities(); - } };