From 03490c81da5a6a76f06f13e1341d44d4fcea9f5e Mon Sep 17 00:00:00 2001 From: Mike Moody Date: Sat, 6 May 2017 15:36:18 -0700 Subject: [PATCH 1/3] v1 with bug, looking into. --- .../system/libraries/entitySelectionTool.js | 101 ++++++++++++++++-- 1 file changed, 94 insertions(+), 7 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 79d45d5cd2..70ded31ca4 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -340,6 +340,11 @@ SelectionDisplay = (function() { green: 120, blue: 120 }; + var grabberColorCloner = { + red: 0, + green: 155, + blue: 0 + }; var grabberLineWidth = 0.5; var grabberSolid = true; var grabberMoveUpPosition = { @@ -405,6 +410,23 @@ SelectionDisplay = (function() { borderSize: 1.4, }; + var grabberPropertiesCloner = { + position: { + x: 0, + y: 0, + z: 0 + }, + size: grabberSizeCorner + 0.025, + color: grabberColorCloner, + alpha: 1, + solid: grabberSolid, + visible: false, + dashed: false, + lineWidth: grabberLineWidth, + drawInFront: true, + borderSize: 1.4, + }; + var spotLightLineProperties = { color: lightOverlayColor, lineWidth: 1.5, @@ -582,6 +604,8 @@ SelectionDisplay = (function() { var grabberPointLightF = Overlays.addOverlay("cube", grabberPropertiesEdge); var grabberPointLightN = Overlays.addOverlay("cube", grabberPropertiesEdge); + var grabberCloner = Overlays.addOverlay("cube", grabberPropertiesCloner); + var stretchHandles = [ grabberLBN, grabberRBN, @@ -969,6 +993,9 @@ SelectionDisplay = (function() { grabberPointLightCircleX, grabberPointLightCircleY, grabberPointLightCircleZ, + + grabberCloner + ].concat(stretchHandles); overlayNames[highlightBox] = "highlightBox"; @@ -1015,7 +1042,7 @@ SelectionDisplay = (function() { overlayNames[rotateZeroOverlay] = "rotateZeroOverlay"; overlayNames[rotateCurrentOverlay] = "rotateCurrentOverlay"; - + overlayNames[grabberCloner] = "grabberCloner"; var activeTool = null; var grabberTools = {}; @@ -1107,7 +1134,7 @@ SelectionDisplay = (function() { if (event !== false) { pickRay = generalComputePickRay(event.x, event.y); - var wantDebug = false; + var wantDebug = true; if (wantDebug) { print("select() with EVENT...... "); print(" event.y:" + event.y); @@ -2291,7 +2318,11 @@ SelectionDisplay = (function() { }, rotation: Quat.fromPitchYawRollDegrees(90, 0, 0), }); - + Overlays.editOverlay(grabberCloner, { + visible: stretchHandlesVisible, + rotation: rotation, + position: RIGHT + }); }; @@ -2371,7 +2402,7 @@ SelectionDisplay = (function() { return (origin.y - intersection.y) / Vec3.distance(origin, intersection); }, onMove: function(event) { - var wantDebug = false; + var wantDebug = true; pickRay = generalComputePickRay(event.x, event.y); var pick = rayPlaneIntersection2(pickRay, translateXZTool.pickPlanePosition, { @@ -2556,7 +2587,7 @@ SelectionDisplay = (function() { vector.x = 0; vector.z = 0; - var wantDebug = false; + var wantDebug = true; if (wantDebug) { print("translateUpDown... "); print(" event.y:" + event.y); @@ -2580,6 +2611,52 @@ SelectionDisplay = (function() { }, }); + addGrabberTool(grabberCloner, { + mode: "CLONE", + pickPlanePosition: { x: 0, y: 0, z: 0 }, + greatestDimension: 0.0, + startingDistance: 0.0, + startingElevation: 0.0, + onBegin: function(event) { + SelectionManager.saveProperties(); + startPosition = SelectionManager.worldPosition; + var dimensions = SelectionManager.worldDimensions; + + var pickRay = generalComputePickRay(event.x, event.y); + initialXZPick = rayPlaneIntersection(pickRay, translateXZTool.pickPlanePosition, { + x: 0, + y: 1, + z: 0 + }); + + // Duplicate entities if alt is pressed. This will make a + // copy of the selected entities and move the _original_ entities, not + // the new ones. + + duplicatedEntityIDs = []; + for (var otherEntityID in SelectionManager.savedProperties) { + var properties = SelectionManager.savedProperties[otherEntityID]; + if (!properties.locked) { + var entityID = Entities.addEntity(properties); + duplicatedEntityIDs.push({ + entityID: entityID, + properties: properties, + }); + } + } + + isConstrained = false; + }, + elevation: translateXZTool.elevation, + + onEnd: translateXZTool.onEnd, + + onMove: translateXZTool.onMove + }); + + + + var vec3Mult = function(v1, v2) { return { x: v1.x * v2.x, @@ -2844,7 +2921,7 @@ SelectionDisplay = (function() { }); } - var wantDebug = false; + var wantDebug = true; if (wantDebug) { print(stretchMode); //Vec3.print(" newIntersection:", newIntersection); @@ -3861,7 +3938,7 @@ SelectionDisplay = (function() { }; that.mousePressEvent = function(event) { - var wantDebug = false; + var wantDebug = true; if (!event.isLeftButton && !that.triggered) { // if another mouse button than left is pressed ignore it return false; @@ -3958,6 +4035,10 @@ SelectionDisplay = (function() { mode = "STRETCH_LEFT"; somethingClicked = mode; break; + // case grabberCloner: + // mode = "CLONE"; + // somethingClicked = mode; + // break; default: mode = "UNKNOWN"; @@ -4344,6 +4425,12 @@ SelectionDisplay = (function() { highlightNeeded = true; break; + case grabberCloner: + pickedColor = grabberColorCloner; + pickedAlpha = grabberAlpha; + highlightNeeded = true; + break; + default: if (previousHandle) { Overlays.editOverlay(previousHandle, { From dae652d3db31309f90bbbb63df61c9c1b692187f Mon Sep 17 00:00:00 2001 From: Mike Moody Date: Mon, 8 May 2017 11:25:24 -0700 Subject: [PATCH 2/3] v1 HMD duplication overlay. --- .../system/libraries/entitySelectionTool.js | 70 +++++++------------ 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 70ded31ca4..3e4b8d8518 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -416,7 +416,7 @@ SelectionDisplay = (function() { y: 0, z: 0 }, - size: grabberSizeCorner + 0.025, + size: grabberSizeCorner, color: grabberColorCloner, alpha: 1, solid: grabberSolid, @@ -652,6 +652,8 @@ SelectionDisplay = (function() { grabberPointLightR, grabberPointLightF, grabberPointLightN, + + grabberCloner ]; @@ -994,8 +996,6 @@ SelectionDisplay = (function() { grabberPointLightCircleY, grabberPointLightCircleZ, - grabberCloner - ].concat(stretchHandles); overlayNames[highlightBox] = "highlightBox"; @@ -1134,7 +1134,7 @@ SelectionDisplay = (function() { if (event !== false) { pickRay = generalComputePickRay(event.x, event.y); - var wantDebug = true; + var wantDebug = false; if (wantDebug) { print("select() with EVENT...... "); print(" event.y:" + event.y); @@ -2355,7 +2355,7 @@ SelectionDisplay = (function() { greatestDimension: 0.0, startingDistance: 0.0, startingElevation: 0.0, - onBegin: function(event) { + onBegin: function(event,isAltFromGrab) { SelectionManager.saveProperties(); startPosition = SelectionManager.worldPosition; var dimensions = SelectionManager.worldDimensions; @@ -2370,7 +2370,7 @@ SelectionDisplay = (function() { // Duplicate entities if alt is pressed. This will make a // copy of the selected entities and move the _original_ entities, not // the new ones. - if (event.isAlt) { + if (event.isAlt || isAltFromGrab) { duplicatedEntityIDs = []; for (var otherEntityID in SelectionManager.savedProperties) { var properties = SelectionManager.savedProperties[otherEntityID]; @@ -2402,7 +2402,7 @@ SelectionDisplay = (function() { return (origin.y - intersection.y) / Vec3.distance(origin, intersection); }, onMove: function(event) { - var wantDebug = true; + var wantDebug = false; pickRay = generalComputePickRay(event.x, event.y); var pick = rayPlaneIntersection2(pickRay, translateXZTool.pickPlanePosition, { @@ -2587,7 +2587,7 @@ SelectionDisplay = (function() { vector.x = 0; vector.z = 0; - var wantDebug = true; + var wantDebug = false; if (wantDebug) { print("translateUpDown... "); print(" event.y:" + event.y); @@ -2613,45 +2613,27 @@ SelectionDisplay = (function() { addGrabberTool(grabberCloner, { mode: "CLONE", - pickPlanePosition: { x: 0, y: 0, z: 0 }, - greatestDimension: 0.0, - startingDistance: 0.0, - startingElevation: 0.0, onBegin: function(event) { - SelectionManager.saveProperties(); - startPosition = SelectionManager.worldPosition; - var dimensions = SelectionManager.worldDimensions; var pickRay = generalComputePickRay(event.x, event.y); - initialXZPick = rayPlaneIntersection(pickRay, translateXZTool.pickPlanePosition, { - x: 0, - y: 1, - z: 0 - }); + var result = Overlays.findRayIntersection(pickRay); + translateXZTool.pickPlanePosition = result.intersection; + translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y), + SelectionManager.worldDimensions.z); - // Duplicate entities if alt is pressed. This will make a - // copy of the selected entities and move the _original_ entities, not - // the new ones. - - duplicatedEntityIDs = []; - for (var otherEntityID in SelectionManager.savedProperties) { - var properties = SelectionManager.savedProperties[otherEntityID]; - if (!properties.locked) { - var entityID = Entities.addEntity(properties); - duplicatedEntityIDs.push({ - entityID: entityID, - properties: properties, - }); - } - } - - isConstrained = false; + translateXZTool.onBegin(event,true); + }, + elevation: function (event) { + translateXZTool.elevation(event); }, - elevation: translateXZTool.elevation, - onEnd: translateXZTool.onEnd, + onEnd: function (event) { + translateXZTool.onEnd(event); + }, - onMove: translateXZTool.onMove + onMove: function (event) { + translateXZTool.onMove(event); + } }); @@ -2921,7 +2903,7 @@ SelectionDisplay = (function() { }); } - var wantDebug = true; + var wantDebug = false; if (wantDebug) { print(stretchMode); //Vec3.print(" newIntersection:", newIntersection); @@ -3938,7 +3920,7 @@ SelectionDisplay = (function() { }; that.mousePressEvent = function(event) { - var wantDebug = true; + var wantDebug = false; if (!event.isLeftButton && !that.triggered) { // if another mouse button than left is pressed ignore it return false; @@ -4035,10 +4017,6 @@ SelectionDisplay = (function() { mode = "STRETCH_LEFT"; somethingClicked = mode; break; - // case grabberCloner: - // mode = "CLONE"; - // somethingClicked = mode; - // break; default: mode = "UNKNOWN"; From 89d93ee56db5022b6caa860ab0715f3b9c5ec915 Mon Sep 17 00:00:00 2001 From: Mike Moody Date: Thu, 11 May 2017 04:16:22 -0700 Subject: [PATCH 3/3] Updated HMD grab Clone to work with all entity types. --- scripts/system/libraries/entitySelectionTool.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 3e4b8d8518..3389ab0836 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2162,6 +2162,12 @@ SelectionDisplay = (function() { position: FAR }); + Overlays.editOverlay(grabberCloner, { + visible: true, + rotation: rotation, + position: EdgeTR + }); + var boxPosition = Vec3.multiplyQbyV(rotation, center); boxPosition = Vec3.sum(position, boxPosition); Overlays.editOverlay(selectionBox, { @@ -2318,11 +2324,6 @@ SelectionDisplay = (function() { }, rotation: Quat.fromPitchYawRollDegrees(90, 0, 0), }); - Overlays.editOverlay(grabberCloner, { - visible: stretchHandlesVisible, - rotation: rotation, - position: RIGHT - }); };