diff --git a/app/pages/PageEnigma/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx b/app/pages/PageEnigma/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx index 4d5e8cdf2c..945c63345c 100644 --- a/app/pages/PageEnigma/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx +++ b/app/pages/PageEnigma/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx @@ -1,9 +1,11 @@ -import { useContext, useEffect, useState } from "react"; +import { useContext, useEffect, useId, useState } from "react"; import { Transition } from "@headlessui/react"; import { faChevronDown, faChevronUp, faCube, + faLock, + faLockOpen, faTrash, } from "@fortawesome/pro-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -66,6 +68,12 @@ export const ControlPanelSceneObject = () => { const [inputsUpdated, inputsUpdatedSet] = useState(false); const [inputsFocused, inputsFocusedSet] = useState(false); + const [locked, lockedSet] = useState(false); + + const [color, colorSet] = useState("#ffffff"); + + const colorInputId = useId(); + // clears leading and trailing zeros const sanitizeNumericInput = (input: string): number => { const regex = /(\-?\d+)(\.\d+)?/; @@ -132,7 +140,7 @@ export const ControlPanelSceneObject = () => { useEffect(() => { const isCurrentObj = - appUiState.controlPanel.currentSceneObject.object_uuid === initializedObj; + (editorEngine?.selected?.uuid || "") === initializedObj; // TODO this causes a subtle bug because it renders way too many times. if (!appUiState.controlPanel.currentSceneObject) { return; @@ -175,11 +183,19 @@ export const ControlPanelSceneObject = () => { localPositionSet(numsToStrings(vectors.position)); localRotationSet(numsToStrings(vectors.rotation)); localScaleSet(numsToStrings(vectors.scale)); + + lockedSet( + editorEngine.isObjectLocked(editorEngine?.selected?.uuid || ""), + ); + colorSet(editorEngine?.selected?.userData.color); } else if (!appUiState.controlPanel.isShowing && isCurrentObj) { initializedObjSet(""); localPositionSet(defaultAxises); localRotationSet(defaultAxises); localScaleSet(defaultAxises); + + lockedSet(false); + colorSet("#ffffff"); } // updating engine if values originate from the inputs and are valid @@ -213,6 +229,11 @@ export const ControlPanelSceneObject = () => { return null; } + const toggleLock = () => { + lockedSet((lockState: boolean) => !lockState); + editorEngine.lockUnlockObject(editorEngine?.selected?.uuid || ""); + }; + const handlePositionChange = (xyz: XYZ) => { localPositionSet(xyz); inputsUpdatedSet(true); @@ -398,6 +419,35 @@ export const ControlPanelSceneObject = () => { leaveFrom="opacity-100 max-h-96" leaveTo="opacity-0 max-h-0" className={"flex flex-col gap-2 overflow-y-auto"}> + + +