diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index ed9763875d..614bd5fd59 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") { + if (selectionManager.selections.length === 1) { + selectionManager.saveProperties(); + properties = selectionManager.savedProperties[selectionManager.selections[0]]; + copiedPosition = properties.position; + Window.copyToClipboard(JSON.stringify(copiedPosition)); + } + } else if (data.action === "copyRotation") { + if (selectionManager.selections.length === 1) { + selectionManager.saveProperties(); + properties = selectionManager.savedProperties[selectionManager.selections[0]]; + copiedRotation = properties.rotation; + Window.copyToClipboard(JSON.stringify(copiedRotation)); + } + } else if (data.action === "pastePosition") { + if (copiedPosition !== undefined && selectionManager.selections.length > 0 && SelectionManager.hasUnlockedSelection()) { + selectionManager.saveProperties(); + for (i = 0; i < selectionManager.selections.length; i++) { + Entities.editEntity(selectionManager.selections[i], { + position: copiedPosition + }); + } + pushCommandForSelections(); + selectionManager._update(false, this); + } else { + audioFeedback.rejection(); + } + } else if (data.action === "pasteRotation") { + if (copiedRotation !== undefined && selectionManager.selections.length > 0 && SelectionManager.hasUnlockedSelection()) { + selectionManager.saveProperties(); + for (i = 0; i < selectionManager.selections.length; i++) { + Entities.editEntity(selectionManager.selections[i], { + rotation: copiedRotation + }); + } + pushCommandForSelections(); + selectionManager._update(false, this); + } else { + audioFeedback.rejection(); + } } } else if (data.type === "propertiesPageReady") { updateSelections(true); diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 06ffbc2f99..5c6806653d 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1353,6 +1353,12 @@ const GROUPS = [ propertyID: "localPosition", spaceMode: PROPERTY_SPACE_MODE.LOCAL, }, + { + type: "buttons", + buttons: [ { id: "copyPosition", label: "Copy Position", className: "secondary", onClick: copyPositionProperty }, + { id: "pastePosition", label: "Paste Position", className: "secondary", onClick: pastePositionProperty } ], + propertyID: "copyPastePosition" + }, { label: "Rotation", type: "vec3", @@ -1375,6 +1381,12 @@ const GROUPS = [ propertyID: "localRotation", spaceMode: PROPERTY_SPACE_MODE.LOCAL, }, + { + type: "buttons", + buttons: [ { id: "copyRotation", label: "Copy Rotation", className: "secondary", onClick: copyRotationProperty }, + { id: "pasteRotation", label: "Paste Rotation", className: "secondary", onClick: pasteRotationProperty } ], + propertyID: "copyPasteRotation" + }, { label: "Dimensions", type: "vec3", @@ -1852,6 +1864,24 @@ function setPropertyVisibility(property, visible) { property.elContainer.style.display = visible ? null : "none"; } +function setCopyPastePositionAndRotationAvailability (selectionLength, islocked) { + if (selectionLength === 1) { + $('#property-copyPastePosition-button-copyPosition').attr('disabled', false); + $('#property-copyPasteRotation-button-copyRotation').attr('disabled', false); + } else { + $('#property-copyPastePosition-button-copyPosition').attr('disabled', true); + $('#property-copyPasteRotation-button-copyRotation').attr('disabled', true); + } + + if (selectionLength > 0 && !islocked) { + $('#property-copyPastePosition-button-pastePosition').attr('disabled', false); + $('#property-copyPasteRotation-button-pasteRotation').attr('disabled', false); + } else { + $('#property-copyPastePosition-button-pastePosition').attr('disabled', true); + $('#property-copyPasteRotation-button-pasteRotation').attr('disabled', true); + } +} + function resetProperties() { for (let propertyID in properties) { let property = properties[propertyID]; @@ -3217,6 +3247,33 @@ function copySkyboxURLToAmbientURL() { updateProperty("ambientLight.ambientURL", skyboxURL, false); } +function copyPositionProperty() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "copyPosition" + })); +} + +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" + })); +} /** * USER DATA FUNCTIONS @@ -3952,7 +4009,7 @@ function handleEntitySelectionUpdate(selections, isPropertiesToolUpdate) { selectedEntityIDs = new Set(selections.map(selection => selection.id)); const multipleSelections = currentSelections.length > 1; const hasSelectedEntityChanged = !areSetsEqual(selectedEntityIDs, previouslySelectedEntityIDs); - + requestZoneList(); if (selections.length === 0) { @@ -3976,6 +4033,8 @@ function handleEntitySelectionUpdate(selections, isPropertiesToolUpdate) { showSaveMaterialDataButton(); showNewJSONMaterialEditorButton(); + setCopyPastePositionAndRotationAvailability (selections.length, true); + disableProperties(); } else { if (!isPropertiesToolUpdate && !hasSelectedEntityChanged && document.hasFocus()) { @@ -4006,10 +4065,12 @@ function handleEntitySelectionUpdate(selections, isPropertiesToolUpdate) { if (lockedMultiValue.isMultiDiffValue || lockedMultiValue.value) { disableProperties(); getPropertyInputElement('locked').removeAttribute('disabled'); + setCopyPastePositionAndRotationAvailability (selections.length, true); } else { enableProperties(); disableSaveUserDataButton(); disableSaveMaterialDataButton(); + setCopyPastePositionAndRotationAvailability (selections.length, false); } const certificateIDMultiValue = getMultiplePropertyValue('certificateID'); diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 9b3e862210..9f7f329040 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -463,6 +463,22 @@ input[type=button].white, button.hifi-edit-button.white { background-color: #afafaf; background: linear-gradient(#fff 20%, #afafaf 100%); } +input[type=button].secondary, button.hifi-edit-button.secondary { + font-family: Raleway-Bold; + font-size: 10px; + text-transform: uppercase; + vertical-align: top; + height: 18px; + min-width: 60px; + padding: 0 14px; + margin-right: 6px; + border-radius: 4px; + border: none; + color: #fff; + background-color: #000; + background: linear-gradient(#343434 20%, #000 100%); + cursor: pointer; +} input[type=button]:enabled:hover, button.hifi-edit-button:enabled:hover { background: linear-gradient(#000, #000);