From 795d866da9555f8151b07705e85c5874de07860c Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:29:54 -0700 Subject: [PATCH 1/4] re add locking/visibility tools to edit.js --- scripts/system/edit.js | 22 +++++++++------------- scripts/system/html/entityList.html | 2 +- scripts/system/libraries/entityList.js | 8 +++++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 2796297e40..163ac867b4 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -50,10 +50,9 @@ selectionManager.addEventListener(function() { lightOverlayManager.updatePositions(); }); -var toolIconUrl = Script.resolvePath("assets/images/tools/"); +var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; var toolHeight = 50; var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 25; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; @@ -106,7 +105,7 @@ IMPORTING_SVO_OVERLAY_HEIGHT = 30; IMPORTING_SVO_OVERLAY_MARGIN = 5; IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34; var importingSVOImageOverlay = Overlays.addOverlay("image", { - imageURL: Script.resolvePath("assets") + "/images/hourglass.svg", + imageURL: HIFI_PUBLIC_BUCKET + "images/hourglass.svg", width: 20, height: 20, alpha: 1.0, @@ -180,18 +179,15 @@ var toolBar = (function() { newParticleButton function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x / 2, - y: windowDimensions.y + x: windowDimensions.x - 8 - toolbar.width, + y: (windowDimensions.y - toolbar.height) / 2 }; - }, { - x: toolWidth, - y: -TOOLBAR_MARGIN_Y - toolHeight }); activeButton = toolBar.addTool({ - imageURL: toolIconUrl + "edit-01.svg", + imageURL: toolIconUrl + "edit-01.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, @@ -205,7 +201,7 @@ var toolBar = (function() { }, true, false); newModelButton = toolBar.addTool({ - imageURL:toolIconUrl + "model-01.svg", + imageURL: toolIconUrl + "model-01.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, @@ -220,7 +216,7 @@ var toolBar = (function() { }); newCubeButton = toolBar.addTool({ - imageURL:toolIconUrl + "cube-01.svg", + imageURL: toolIconUrl + "cube-01.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, @@ -1864,4 +1860,4 @@ entityListTool.webView.webEventReceived.connect(function(data) { } } } -}); +}); \ No newline at end of file diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index e5fa2ce839..dbc224e9fb 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -378,4 +378,4 @@ - + \ No newline at end of file diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 00120ab4c2..e9baeac86c 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -59,6 +59,8 @@ EntityListTool = function(opts) { name: properties.name, type: properties.type, url: properties.type == "Model" ? properties.modelURL : "", + locked: properties.locked, + visible: properties.visible }); } @@ -99,6 +101,10 @@ EntityListTool = function(opts) { } } else if (data.type == "delete") { deleteSelectedEntities(); + } else if (data.type == "toggleLocked") { + toggleSelectedEntitiesLocked(); + } else if (data.type == "toggleVisible") { + toggleSelectedEntitiesVisible(); } else if (data.type === "radius") { searchRadius = data.radius; that.sendUpdate(); @@ -112,4 +118,4 @@ EntityListTool = function(opts) { }); return that; -}; +}; \ No newline at end of file From b52406e127504c3264d9986143733a5bf630d715 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:40:58 -0700 Subject: [PATCH 2/4] horizontal --- scripts/system/edit.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 163ac867b4..30e1996bae 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -53,6 +53,7 @@ selectionManager.addEventListener(function() { var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 25; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; @@ -179,11 +180,14 @@ var toolBar = (function() { newParticleButton function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: (windowDimensions.y - toolbar.height) / 2 + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: toolWidth, + y: -TOOLBAR_MARGIN_Y - toolHeight }); activeButton = toolBar.addTool({ From aafed4e1b8470889ac9284bb52547aef83bfeb20 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:42:10 -0700 Subject: [PATCH 3/4] fix horizontal typo in examples --- scripts/system/examples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/examples.js b/scripts/system/examples.js index 9caedec70f..eeadfc21a0 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -58,7 +58,7 @@ var toolBar = (function() { browseExamplesButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.HORIXONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { return { x: windowDimensions.x / 2, y: windowDimensions.y From e68909ce3e65288c27790403693d23a1a6180e5a Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:48:09 -0700 Subject: [PATCH 4/4] re add local paths --- scripts/system/edit.js | 47 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 30e1996bae..568ee28bc6 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -48,9 +48,9 @@ var entityListTool = EntityListTool(); selectionManager.addEventListener(function() { selectionDisplay.updateHandles(); lightOverlayManager.updatePositions(); -}); +}); -var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; +var toolIconUrl = Script.resolvePath("assets/images/tools/"); var toolHeight = 50; var toolWidth = 50; var TOOLBAR_MARGIN_Y = 25; @@ -106,7 +106,7 @@ IMPORTING_SVO_OVERLAY_HEIGHT = 30; IMPORTING_SVO_OVERLAY_MARGIN = 5; IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34; var importingSVOImageOverlay = Overlays.addOverlay("image", { - imageURL: HIFI_PUBLIC_BUCKET + "images/hourglass.svg", + imageURL: Script.resolvePath("assets") + "/images/hourglass.svg", width: 20, height: 20, alpha: 1.0, @@ -336,7 +336,9 @@ var toolBar = (function() { if (active && !Entities.canAdjustLocks()) { Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG); } else { - Messages.sendLocalMessage("edit-events", JSON.stringify({enabled: active})); + Messages.sendLocalMessage("edit-events", JSON.stringify({ + enabled: active + })); isActive = active; if (!isActive) { entityListTool.setVisible(false); @@ -549,8 +551,16 @@ var toolBar = (function() { type: "ParticleEffect", isEmitting: true, particleRadius: 0.1, - emitAcceleration: {x: 0, y: -1, z: 0}, - accelerationSpread: {x: 5, y: 0, z: 5}, + emitAcceleration: { + x: 0, + y: -1, + z: 0 + }, + accelerationSpread: { + x: 5, + y: 0, + z: 5 + }, emitSpeed: 1, lifespan: 1, particleRadius: 0.025, @@ -563,7 +573,7 @@ var toolBar = (function() { return false; }; - that.mouseReleaseEvent = function (event) { + that.mouseReleaseEvent = function(event) { return false; } @@ -604,7 +614,7 @@ var intersection; var SCALE_FACTOR = 200.0; -function rayPlaneIntersection(pickRay, point, normal) { // +function rayPlaneIntersection(pickRay, point, normal) { // // // This version of the test returns the intersection of a line with a plane // @@ -1207,7 +1217,9 @@ function toggleSelectedEntitiesLocked() { var locked = !Entities.getEntityProperties(SelectionManager.selections[0], ["locked"]).locked; for (var i = 0; i < selectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - Entities.editEntity(entityID, { locked: locked }); + Entities.editEntity(entityID, { + locked: locked + }); } entityListTool.sendUpdate(); selectionManager._update(); @@ -1219,7 +1231,9 @@ function toggleSelectedEntitiesVisible() { var visible = !Entities.getEntityProperties(SelectionManager.selections[0], ["visible"]).visible; for (var i = 0; i < selectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - Entities.editEntity(entityID, { visible: visible }); + Entities.editEntity(entityID, { + visible: visible + }); } entityListTool.sendUpdate(); selectionManager._update(); @@ -1554,8 +1568,7 @@ PropertiesTool = function(opts) { data.properties.keyLight.direction.x * DEGREES_TO_RADIANS, data.properties.keyLight.direction.y * DEGREES_TO_RADIANS); } Entities.editEntity(selectionManager.selections[0], data.properties); - if (data.properties.name !== undefined || data.properties.modelURL !== undefined - || data.properties.visible !== undefined || data.properties.locked !== undefined) { + if (data.properties.name !== undefined || data.properties.modelURL !== undefined || data.properties.visible !== undefined || data.properties.locked !== undefined) { entityListTool.sendUpdate(); } } @@ -1835,15 +1848,15 @@ entityListTool.webView.webEventReceived.connect(function(data) { var data = JSON.parse(data); if (data.type == "selectionUpdate") { var ids = data.entityIds; - if(ids.length === 1) { - if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect" ) { + if (ids.length === 1) { + if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) { // This particle entity is already selected, so return return; } // Destroy the old particles web view first - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); + particleExplorerTool.destroyWebView(); + particleExplorerTool.createWebView(); var properties = Entities.getEntityProperties(ids[0]); var particleData = { messageType: "particle_settings", @@ -1855,7 +1868,7 @@ entityListTool.webView.webEventReceived.connect(function(data) { particleExplorerTool.webView.webEventReceived.connect(function(data) { var data = JSON.parse(data); if (data.messageType === "page_loaded") { - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); } }); } else {