diff --git a/src/components/three/XRHudInWorld.tsx b/src/components/three/XRHudInWorld.tsx index 5c6bf98..51a7890 100644 --- a/src/components/three/XRHudInWorld.tsx +++ b/src/components/three/XRHudInWorld.tsx @@ -51,10 +51,13 @@ const WristToggle = forwardRef voi export function XRHudInWorld(props: XRHudInWorldProps) { const { camera } = useThree(); const leftCtrl = useXRInputSourceState('controller', 'left'); + const rightCtrl = useXRInputSourceState('controller', 'right'); const [open, setOpen] = useState(true); const [tab, setTab] = useState('scene'); /** When pinned, the panel stays fixed in world space and does NOT follow the head. */ const [pinned, setPinned] = useState(true); + /** While true, the panel is glued to the right controller (drag mode). */ + const [dragging, setDragging] = useState(false); /** Forces re-anchor on next frame (used by "trazer" / unpin→pin). */ const reanchorRequested = useRef(true); @@ -63,6 +66,10 @@ export function XRHudInWorld(props: XRHudInWorldProps) { const targetPos = useRef(new THREE.Vector3()); const targetQuat = useRef(new THREE.Quaternion()); const lastABtn = useRef(false); + /** Cached offset from controller to panel at drag start. */ + const dragOffsetPos = useRef(new THREE.Vector3()); + const dragOffsetQuat = useRef(new THREE.Quaternion()); + const dragInitialized = useRef(false); useFrame(() => { // Toggle via left A button (Quest Touch buttons[4])