diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 1d7f4fc05e..449d1d8222 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -1,7 +1,7 @@ // edit.js // -// Created by Brad Hefta-Gaub on 10/2/14. -// Persist toolbar by HRS 6/11/15. +// Created by Brad Hefta-Gaub on October 2nd, 2014. +// Persist toolbar by HRS on June 2nd, 2015. // Copyright 2014 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. // Copyright 2022-2024 Overte e.V. @@ -121,6 +121,8 @@ var copiedPosition; var copiedRotation; + var copiedDimensions; + var importUiPersistedData = { "elJsonUrl": "", "elImportAtAvatar": true, @@ -2718,6 +2720,13 @@ copiedRotation = properties.rotation; Window.copyToClipboard(JSON.stringify(copiedRotation)); } + } else if (data.action === "copyDimensions") { + if (selectionManager.selections.length === 1) { + selectionManager.saveProperties(); + properties = selectionManager.savedProperties[selectionManager.selections[0]]; + copiedDimensions = properties.dimensions; + Window.copyToClipboard(JSON.stringify(copiedDimensions)); + } } else if (data.action === "pastePosition") { if (copiedPosition !== undefined && selectionManager.selections.length > 0 && SelectionManager.hasUnlockedSelection()) { selectionManager.saveProperties(); @@ -2731,6 +2740,19 @@ } else { audioFeedback.rejection(); } + } else if (data.action === "pasteDimensions") { + if (copiedDimensions !== undefined && selectionManager.selections.length > 0 && SelectionManager.hasUnlockedSelection()) { + selectionManager.saveProperties(); + for (i = 0; i < selectionManager.selections.length; i++) { + Entities.editEntity(selectionManager.selections[i], { + dimensions: copiedDimensions + }); + } + createApp.pushCommandForSelections(); + selectionManager._update(false, this); + } else { + audioFeedback.rejection(); + } } else if (data.action === "pasteRotation") { if (copiedRotation !== undefined && selectionManager.selections.length > 0 && SelectionManager.hasUnlockedSelection()) { selectionManager.saveProperties(); diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index e16b6ca653..8b594d85b5 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1,9 +1,9 @@ // entityProperties.js // -// Created by Ryan Huffman on 13 Nov 2014 +// Created by Ryan Huffman on November 13th, 2014 // Copyright 2014 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. -// Copyright 2022 Overte e.V. +// Copyright 2022-2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -136,7 +136,7 @@ const GROUPS = [ }, { id: "shape", - label: "SHAPE", + label: "SHAPE", properties: [ { label: "Shape", @@ -161,7 +161,7 @@ const GROUPS = [ decimals: 2, propertyID: "shapeAlpha", propertyName: "alpha", - }, + }, ] }, { @@ -393,7 +393,7 @@ const GROUPS = [ decimals: 2, propertyID: "keyLight.shadowMaxDistance", showPropertyRule: { "keyLightMode": "enabled" }, - } + } ] }, { @@ -1458,6 +1458,12 @@ const GROUPS = [ propertyID: "localDimensions", spaceMode: PROPERTY_SPACE_MODE.LOCAL, }, + { + type: "buttons", + buttons: [ { id: "copyDimensions", label: "Copy Dimensions", className: "secondary", onClick: copyDimensionsProperty }, + { id: "pasteDimensions", label: "Paste Dimensions", className: "secondary", onClick: pasteDimensionsProperty } ], + propertyID: "copyPasteDimensions" + }, { label: "Scale", type: "number-draggable", @@ -1915,14 +1921,17 @@ function setCopyPastePositionAndRotationAvailability (selectionLength, islocked) if (selectionLength === 1) { $('#property-copyPastePosition-button-copyPosition').attr('disabled', false); $('#property-copyPasteRotation-button-copyRotation').attr('disabled', false); + $('#property-copyPasteDimensions-button-copyDimensions').attr('disabled', false); } else { $('#property-copyPastePosition-button-copyPosition').attr('disabled', true); - $('#property-copyPasteRotation-button-copyRotation').attr('disabled', true); + $('#property-copyPasteRotation-button-copyRotation').attr('disabled', true); + $('#property-copyPasteDimensions-button-copyDimensions').attr('disabled', true); } if (selectionLength > 0 && !islocked) { $('#property-copyPastePosition-button-pastePosition').attr('disabled', false); $('#property-copyPasteRotation-button-pasteRotation').attr('disabled', false); + $('#property-copyPasteDimensions-button-pasteDimensions').attr('disabled', false); if (selectionLength === 1) { $('#property-copyPasteRotation-button-setRotationToZero').attr('disabled', false); } else { @@ -1932,6 +1941,7 @@ function setCopyPastePositionAndRotationAvailability (selectionLength, islocked) $('#property-copyPastePosition-button-pastePosition').attr('disabled', true); $('#property-copyPasteRotation-button-pasteRotation').attr('disabled', true); $('#property-copyPasteRotation-button-setRotationToZero').attr('disabled', true); + $('#property-copyPasteDimensions-button-pasteDimensions').attr('disabled', true); } } @@ -3360,27 +3370,41 @@ function pastePositionProperty() { EventBridge.emitWebEvent(JSON.stringify({ type: "action", action: "pastePosition" - })); + })); } function copyRotationProperty() { EventBridge.emitWebEvent(JSON.stringify({ type: "action", action: "copyRotation" - })); + })); } function pasteRotationProperty() { EventBridge.emitWebEvent(JSON.stringify({ type: "action", action: "pasteRotation" - })); + })); } function setRotationToZeroProperty() { EventBridge.emitWebEvent(JSON.stringify({ type: "action", action: "setRotationToZero" - })); + })); +} + +function copyDimensionsProperty() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "copyDimensions" + })); +} + +function pasteDimensionsProperty() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "pasteDimensions" + })); } /** * USER DATA FUNCTIONS