diff --git a/interface/resources/fonts/vircadia_glyphs.ttf b/interface/resources/fonts/vircadia_glyphs.ttf index 7d3fe9d913..ed89c2719a 100644 Binary files a/interface/resources/fonts/vircadia_glyphs.ttf and b/interface/resources/fonts/vircadia_glyphs.ttf differ diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index 5709b19efe..8453a7d8d3 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -2,6 +2,9 @@ // inEditMode.js // +// Copyright 2014 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. +// // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -80,7 +83,9 @@ Script.include("/~/system/libraries/utils.js"); Messages.sendLocalMessage(this.ENTITY_TOOL_UPDATES_CHANNEL, JSON.stringify({ method: "selectEntity", entityID: this.selectedTarget.objectID, - hand: hand + hand: hand, + surfaceNormal: this.selectedTarget.surfaceNormal, + intersection: this.selectedTarget.intersection })); } else if (this.selectedTarget.type === Picks.INTERSECTED_OVERLAY) { Messages.sendLocalMessage(this.ENTITY_TOOL_UPDATES_CHANNEL, JSON.stringify({ diff --git a/scripts/system/create/audioFeedback/audioFeedback.js b/scripts/system/create/audioFeedback/audioFeedback.js index f1900d5716..881afddfaf 100644 --- a/scripts/system/create/audioFeedback/audioFeedback.js +++ b/scripts/system/create/audioFeedback/audioFeedback.js @@ -12,9 +12,10 @@ audioFeedback = (function() { var that = {}; - + var confirmationSound = SoundCache.getSound(Script.resolvePath("./sounds/confirmation.mp3")); var rejectionSound = SoundCache.getSound(Script.resolvePath("./sounds/rejection.mp3")); + var actionSound = SoundCache.getSound(Script.resolvePath("./sounds/action.mp3")); that.confirmation = function() { //Play a confirmation sound var injector = Audio.playSound(confirmationSound, { @@ -25,8 +26,15 @@ audioFeedback = (function() { that.rejection = function() { //Play a rejection sound var injector = Audio.playSound(rejectionSound, { - "volume": 0.3, - "localOnly": true + "volume": 0.3, + "localOnly": true + }); + } + + that.action = function() { //Play an action sound + var injector = Audio.playSound(actionSound, { + "volume": 0.3, + "localOnly": true }); } diff --git a/scripts/system/create/audioFeedback/sounds/action.mp3 b/scripts/system/create/audioFeedback/sounds/action.mp3 new file mode 100644 index 0000000000..fd004847b0 Binary files /dev/null and b/scripts/system/create/audioFeedback/sounds/action.mp3 differ diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 9e94b68ba1..05bc7d2381 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -109,6 +109,8 @@ var entityIconOverlayManager = new EntityIconOverlayManager(["Light", "ParticleE }); var hmdMultiSelectMode = false; +var expectingRotateAsClickedSurface = false; +var keepSelectedOnNextClick = false; var cameraManager = new CameraManager(); @@ -1106,25 +1108,50 @@ function findClickedEntity(event) { } var result; - - if (iconResult.intersects) { - result = iconResult; - } else if (entityResult.intersects) { - result = entityResult; + if (expectingRotateAsClickedSurface) { + if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) { + audioFeedback.rejection(); + Window.notifyEditError("You have nothing selected, or the selection is locked."); + expectingRotateAsClickedSurface = false; + } else { + //Rotate Selection according the Surface Normal + var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(entityResult.surfaceNormal, -1)); + selectionDisplay.rotateSelection(normalRotation); + //Translate Selection according the clicked Surface + var distanceFromSurface; + if (selectionDisplay.getSpaceMode() === "world"){ + distanceFromSurface = SelectionManager.worldDimensions.z / 2; + } else { + distanceFromSurface = SelectionManager.localDimensions.z / 2; + } + selectionDisplay.moveSelection(Vec3.sum(entityResult.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface}))); + selectionManager._update(false, this); + pushCommandForSelections(); + expectingRotateAsClickedSurface = false; + audioFeedback.action(); + } + keepSelectedOnNextClick = true; + return null; } else { - return null; - } + if (iconResult.intersects) { + result = iconResult; + } else if (entityResult.intersects) { + result = entityResult; + } else { + return null; + } - if (!result.accurate) { - return null; - } + if (!result.accurate) { + return null; + } - var foundEntity = result.entityID; - return { - pickRay: pickRay, - entityID: foundEntity, - intersection: result.intersection - }; + var foundEntity = result.entityID; + return { + pickRay: pickRay, + entityID: foundEntity, + intersection: result.intersection + }; + } } // Handles selections on overlays while in edit mode by querying entities from @@ -1295,7 +1322,10 @@ function mouseClickEvent(event) { if (result === null || result === undefined) { if (!event.isShifted) { - selectionManager.clearSelections(this); + if (!keepSelectedOnNextClick) { + selectionManager.clearSelections(this); + } + keepSelectedOnNextClick = false; } return; } @@ -2052,6 +2082,26 @@ function gridToAvatarKey(value) { alignGridToAvatar(); } } +function rotateAsNextClickedSurfaceKey(value) { + if (value === 0) { // on release + rotateAsNextClickedSurface(); + } +} +function quickRotate90xKey(value) { + if (value === 0) { // on release + selectionDisplay.rotate90degreeSelection("X"); + } +} +function quickRotate90yKey(value) { + if (value === 0) { // on release + selectionDisplay.rotate90degreeSelection("Y"); + } +} +function quickRotate90zKey(value) { + if (value === 0) { // on release + selectionDisplay.rotate90degreeSelection("Z"); + } +} function recursiveAdd(newParentID, parentData) { if (parentData.children !== undefined) { var children = parentData.children; @@ -2819,6 +2869,10 @@ mapping.from([Controller.Hardware.Keyboard.J]).to(gridKey); mapping.from([Controller.Hardware.Keyboard.G]).to(viewGridKey); mapping.from([Controller.Hardware.Keyboard.H]).to(snapKey); mapping.from([Controller.Hardware.Keyboard.K]).to(gridToAvatarKey); +mapping.from([Controller.Hardware.Keyboard["0"]]).to(rotateAsNextClickedSurfaceKey); +mapping.from([Controller.Hardware.Keyboard["7"]]).to(quickRotate90xKey); +mapping.from([Controller.Hardware.Keyboard["8"]]).to(quickRotate90yKey); +mapping.from([Controller.Hardware.Keyboard["9"]]).to(quickRotate90zKey); mapping.from([Controller.Hardware.Keyboard.X]) .when([Controller.Hardware.Keyboard.Control]) .to(whenReleased(function() { selectionManager.cutSelectedEntities() })); @@ -2867,6 +2921,14 @@ keyUpEventFromUIWindow = function(keyUpEvent) { snapKey(pressedValue); } else if (keyUpEvent.keyCodeString === "K") { gridToAvatarKey(pressedValue); + } else if (keyUpEvent.keyCodeString === "0") { + rotateAsNextClickedSurfaceKey(pressedValue); + } else if (keyUpEvent.keyCodeString === "7") { + quickRotate90xKey(pressedValue); + } else if (keyUpEvent.keyCodeString === "8") { + quickRotate90yKey(pressedValue); + } else if (keyUpEvent.keyCodeString === "9") { + quickRotate90zKey(pressedValue); } else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "X") { selectionManager.cutSelectedEntities(); } else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "C") { @@ -3015,4 +3077,14 @@ function toggleGridVisibility() { } } +function rotateAsNextClickedSurface() { + if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) { + audioFeedback.rejection(); + Window.notifyEditError("You have nothing selected, or the selection is locked."); + expectingRotateAsClickedSurface = false; + } else { + expectingRotateAsClickedSurface = true; + } +} + }()); // END LOCAL_SCOPE diff --git a/scripts/system/create/entityList/entityList.js b/scripts/system/create/entityList/entityList.js index a4d4decedb..5119d7d3da 100644 --- a/scripts/system/create/entityList/entityList.js +++ b/scripts/system/create/entityList/entityList.js @@ -383,6 +383,14 @@ EntityListTool = function(shouldUseEditTabletApp) { SelectionManager.selectTopFamily(); } else if (data.type === 'teleportToEntity') { SelectionManager.teleportToEntity(); + } else if (data.type === 'rotateAsTheNextClickedSurface') { + rotateAsNextClickedSurface(); + } else if (data.type === 'quickRotate90x') { + selectionDisplay.rotate90degreeSelection("X"); + } else if (data.type === 'quickRotate90y') { + selectionDisplay.rotate90degreeSelection("Y"); + } else if (data.type === 'quickRotate90z') { + selectionDisplay.rotate90degreeSelection("Z"); } else if (data.type === 'moveEntitySelectionToAvatar') { SelectionManager.moveEntitiesSelectionToAvatar(); } else if (data.type === 'loadConfigSetting') { diff --git a/scripts/system/create/entityList/html/entityList.html b/scripts/system/create/entityList/html/entityList.html index 9817f9ddf9..93585c7338 100644 --- a/scripts/system/create/entityList/html/entityList.html +++ b/scripts/system/create/entityList/html/entityList.html @@ -24,6 +24,11 @@ +
+ + + +
@@ -32,9 +37,7 @@
- - - +
@@ -58,8 +61,7 @@
- - + D
@@ -130,12 +132,6 @@
- + + + + +