From b9e73a6ef73b790476f5c48b60322b72bba0accd Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 May 2014 12:23:01 -0700 Subject: [PATCH 1/2] added delete support to edit models --- examples/editModels.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/examples/editModels.js b/examples/editModels.js index a73cf72987..ceaec136c5 100644 --- a/examples/editModels.js +++ b/examples/editModels.js @@ -632,10 +632,23 @@ function mouseMoveEvent(event) { Models.editModel(selectedModelID, selectedModelProperties); } +function setupModelMenus() { + // add our menuitems + Menu.addMenuItem({ menuName: "Edit", menuItemName: "Models", isSeparator: true, beforeItem: "Physics" }); + Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete Model", shortcutKeyEvent: { text: "backspace" }, afterItem: "Models" }); +} + +function cleanupModelMenus() { + // delete our menuitems + Menu.removeSeparator("Edit", "Models"); + Menu.removeMenuItem("Edit", "Delete Model"); +} + function scriptEnding() { leftController.cleanup(); rightController.cleanup(); toolBar.cleanup(); + cleanupModelMenus(); } Script.scriptEnding.connect(scriptEnding); @@ -644,5 +657,22 @@ Script.update.connect(checkController); Controller.mousePressEvent.connect(mousePressEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent); +setupModelMenus(); +Menu.menuItemEvent.connect(function(menuItem){ + print("menuItemEvent() in JS... menuItem=" + menuItem); + if (menuItem == "Delete Model") { + if (leftController.grabbing) { + print(" Delete Model.... controller.modelID="+ leftController.modelID); + Models.deleteModel(leftController.modelID); + leftController.grabbing = false; + } else if (rightController.grabbing) { + print(" Delete Model.... controller.modelID="+ rightController.modelID); + Models.deleteModel(rightController.modelID); + rightController.grabbing = false; + } else { + print(" Delete Model.... not holding..."); + } + } +}); From 66b9d582a80e9a4ad69dbb835f78b173c945c4dd Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 May 2014 12:43:23 -0700 Subject: [PATCH 2/2] fix broken mouse edit --- examples/editModels.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/examples/editModels.js b/examples/editModels.js index ceaec136c5..717b7824bb 100644 --- a/examples/editModels.js +++ b/examples/editModels.js @@ -40,6 +40,16 @@ var modelURLs = [ var toolBar; +function isLocked(properties) { + // special case to lock the ground plane model in hq. + if (location.hostname == "hq.highfidelity.io" && + properties.modelURL == "https://s3-us-west-1.amazonaws.com/highfidelity-public/ozan/Terrain_Reduce_forAlpha.fbx") { + return true; + } + return false; +} + + function controller(wichSide) { this.side = wichSide; this.palm = 2 * wichSide; @@ -117,7 +127,7 @@ function controller(wichSide) { this.grab = function (modelID, properties) { - if (this.isLocked(properties)) { + if (isLocked(properties)) { print("Model locked " + modelID.id); } else { print("Grabbing " + modelID.id); @@ -150,15 +160,6 @@ function controller(wichSide) { } } - this.isLocked = function (properties) { - // special case to lock the ground plane model in hq. - if (location.hostname == "hq.highfidelity.io" && - properties.modelURL == "https://s3-us-west-1.amazonaws.com/highfidelity-public/ozan/Terrain_Reduce_forAlpha.fbx") { - return true; - } - return false; - } - this.checkModel = function (properties) { // special case to lock the ground plane model in hq. if (this.isLocked(properties)) { @@ -293,6 +294,7 @@ function controller(wichSide) { if (this.pressing) { Vec3.print("Looking at: ", this.palmPosition); var foundModels = Models.findModels(this.palmPosition, LASER_LENGTH_FACTOR); + for (var i = 0; i < foundModels.length; i++) { if (!foundModels[i].isKnownID) { @@ -305,7 +307,9 @@ function controller(wichSide) { } var properties = Models.getModelProperties(foundModels[i]); - if (this.isLocked(properties)) { + print("foundModels["+i+"].modelURL=" + properties.modelURL); + + if (isLocked(properties)) { print("Model locked " + properties.id); } else { print("Checking properties: " + properties.id + " " + properties.isKnownID); @@ -486,7 +490,7 @@ function mousePressEvent(event) { } var properties = Models.getModelProperties(foundModels[i]); - if (this.isLocked(properties)) { + if (isLocked(properties)) { print("Model locked " + properties.id); } else { print("Checking properties: " + properties.id + " " + properties.isKnownID);