Save plan in Lovable

This commit is contained in:
gpt-engineer-app[bot]
2026-02-28 18:47:45 +00:00
parent ec12b70c4c
commit d6064be80b
+41 -30
View File
@@ -1,43 +1,54 @@
## Plano: Corrigir entrada XR no Meta Quest 3 ## Plan: Help Button + Full Rotation Controls (X, Y, Z)
### Problema raiz ### 1. Add rotX and rotZ to the store
O codigo atual cria **duas sessoes XR em sequencia**: primeiro manualmente via `navigator.xr.requestSession('immersive-ar', ...)` (linha 242), depois via `xrStore.enterAR()` (linha 271). O Quest 3 rejeita a segunda porque ja existe uma sessao ativa. Alem disso, a primeira sessao nao esta conectada ao renderer do Three.js, entao mesmo se funcionasse, nao renderizaria nada.
### Correcoes Update `src/stores/useModelStore.ts`:
- Add `rotX: number` and `rotZ: number` to the `FineTuning` interface
- Set defaults to 0 in `defaultFineTuning`
**1. Remover a chamada manual a `navigator.xr.requestSession`** ### 2. Apply rotX/rotZ to the XR model
- Eliminar todo o bloco `try` das linhas 239-268 que tenta criar uma sessao manualmente
- A lib `@react-three/xr` gerencia a sessao internamente via `xrStore.enterAR()`
**2. Usar `customSessionInit` no `createXRStore` para image tracking** Update `src/pages/XRSession.tsx` (`XRModel` component):
- A lib suporta `customSessionInit` em `XRSessionInitOptions` que permite injetar opcoes extras na sessao - Read `rotX`, `rotZ` from fineTuning
- Passar `optionalFeatures: ['image-tracking']` e `trackedImages` via `customSessionInit` - Change `rotation={[0, rotYRad, 0]}` to `rotation={[rotXRad, rotYRad, rotZRad]}`
- O `createXRStore` ja adiciona `local-floor`, `hand-tracking`, `anchors`, `plane-detection` automaticamente
**3. Condicionar o emulador** Update `ControllerFineTuning`:
- `emulate: 'metaQuest3'` ativa o emulador IWER em localhost, o que pode interferir no Quest real - Map additional controller inputs (e.g., A/B buttons or grip+joystick combos) to rotX/rotZ, or leave rotation to the HUD controls
- Condicionar: so emular se nao estiver em dispositivo XR real (checar `navigator.xr?.isSessionSupported`)
- Ou mais simples: so emular em `location.hostname === 'localhost'` E quando `!navigator.xr`
**4. Arquivo: `src/pages/XRSession.tsx`** ### 3. Add rotX/rotZ controls to XRHud
Mudancas: Update `src/components/XRHud.tsx`:
- Mover criacao do store para dentro do componente (ou lazy init) para poder passar o bitmap como `customSessionInit` - In the fine-tuning expanded panel, add rotation rows for X° and Z° alongside the existing Y° control (same `+/` button pattern)
- `handleEnterAR`: simplificar para apenas `await xrStore.enterAR()` com listener de `end`
- Manter `ImageTrackingAnchor`, `ControllerFineTuning`, `XRModel` sem alteracoes
```text ### 4. Create Help panel with (?) button
ANTES (bugado):
1. navigator.xr.requestSession('immersive-ar') ← cria sessao A
2. xrStore.enterAR() ← tenta sessao B → REJEITADA
DEPOIS (correto): Update `src/components/XRHud.tsx`:
1. createXRStore({ customSessionInit: { optionalFeatures: ['image-tracking'], trackedImages: [...] } }) - Add a `HelpCircle` (?) icon button to the main toolbar
2. xrStore.enterAR() ← unica sessao, com image tracking - When pressed, open a full-height slide-out panel (same pattern as the checklist panel) containing a scrollable list of all tools and controls with descriptions:
```
### Sem alteracoes em Content sections:
- ModelViewer, ViewerControls, SmartMeasure, checklist, medicoes, screenshots, PDF, IFC import - **Posicionar (Hit-Test)**: Tap to place model on real surfaces
- **Snap**: Auto-align to detected planes (floor, wall, table)
- **Mover (Free Move)**: Use left joystick for X/Y, right joystick for Z movement
- **Grid**: Toggle reference grid
- **Sólido / Wire / Bordas**: Render mode switching
- **Medir**: Tap two points to measure distance in mm
- **Screenshot**: Capture current AR view
- **Inspeção**: Open checklist to approve/reject items
- **Opacidade**: Adjust model transparency
- **Posição (mm)**: Fine-tune X/Y/Z in 1mm steps
- **Rotação X° / Y° / Z°**: Rotate model around each axis
- **Controladores Quest 3**: Joystick left = move X/Y, joystick right = move Z + rotate Y, grip = hold to move (when Free Move is off)
### 5. Also apply rotX/rotZ in desktop ModelViewer (if used)
Check `src/components/three/ModelViewer.tsx` and update rotation there too for consistency.
### Files to modify
- `src/stores/useModelStore.ts` — add rotX, rotZ fields
- `src/pages/XRSession.tsx` — apply 3-axis rotation, update controller mapping
- `src/components/XRHud.tsx` — add rotation controls for X/Z, add help (?) panel
- `src/components/three/ModelViewer.tsx` — apply rotX/rotZ if fineTuning is used there