From 884fa2f125289bff5aa7b141b7dbdda1d2fdec6f Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Wed, 12 May 2021 00:11:52 -0400 Subject: [PATCH] Add Location and Rotation Copy-Paste Add Location and Rotation Copy-Paste --- scripts/system/create/edit.js | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index ed9763875d..c29eb32903 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -113,6 +113,9 @@ var hmdMultiSelectMode = false; var expectingRotateAsClickedSurface = false; var keepSelectedOnNextClick = false; +var copiedPosition; +var copiedRotation; + var cameraManager = new CameraManager(); var grid = new Grid(); @@ -2613,6 +2616,46 @@ var PropertiesTool = function (opts) { Entities.reloadServerScripts(selectionManager.selections[i]); } } + } else if (data.action === "copyPosition") { + selectionManager.saveProperties(); + properties = selectionManager.savedProperties[selectionManager.selections[0]]; + copiedPosition = properties.position; + Window.copyToClipboard(JSON.stringify(copiedPosition)); + print("COPIED: " + JSON.stringify(copiedPosition)); + } else if (data.action === "copyRotation") { + selectionManager.saveProperties(); + properties = selectionManager.savedProperties[selectionManager.selections[0]]; + copiedRotation = properties.rotation; + Window.copyToClipboard(JSON.stringify(copiedRotation)); + print("COPIED: " + JSON.stringify(copiedRotation)); + } else if (data.action === "pastePosition") { + if (copiedPosition !== undefined) { + selectionManager.saveProperties(); + for (i = 0; i < selectionManager.selections.length; i++) { + Entities.editEntity(selectionManager.selections[i], { + position: copiedPosition + }); + } + pushCommandForSelections(); + selectionManager._update(false, this); + print("PASTE POSITION"); + } else { + audioFeedback.rejection(); + } + } else if (data.action === "pasteRotation") { + if (copiedRotation !== undefined) { + selectionManager.saveProperties(); + for (i = 0; i < selectionManager.selections.length; i++) { + Entities.editEntity(selectionManager.selections[i], { + rotation: copiedRotation + }); + } + pushCommandForSelections(); + selectionManager._update(false, this); + print("PASTE ROTATION"); + } else { + audioFeedback.rejection(); + } } } else if (data.type === "propertiesPageReady") { updateSelections(true);