diff --git a/src/pages/MeetingRoom.tsx b/src/pages/MeetingRoom.tsx index 61cd712..547e07b 100644 --- a/src/pages/MeetingRoom.tsx +++ b/src/pages/MeetingRoom.tsx @@ -623,6 +623,21 @@ export default function MeetingRoom() { sectionInvert: false }); + // Carrega modificações da peça vindas do Viewer se houver + useEffect(() => { + const savedState = localStorage.getItem('tsxr_initial_meeting_state'); + if (savedState) { + try { + const parsed = JSON.parse(savedState) as PresentationState; + setPresentationState(parsed); + console.log('🔄 [MeetingRoom] Estado inicial carregado do Viewer:', parsed); + } catch (err) { + console.error('Falha ao carregar estado inicial do Viewer', err); + } + localStorage.removeItem('tsxr_initial_meeting_state'); + } + }, []); + const channelRef = useRef | null>(null); const chatScrollRef = useRef(null); @@ -799,6 +814,16 @@ export default function MeetingRoom() { empresa: empresa.trim() || 'SteelXR Corp', joinedAt: new Date().toISOString(), }); + + // Se for o apresentador, propaga o estado inicial de apresentação (vinda do Viewer) para todos + if (isPresenter) { + channel.send({ + type: 'broadcast', + event: 'presentation_update', + payload: presentationState + }); + } + setInRoom(true); toast.success(`Entrou na sala de reunião: ${finalRoomId}`); navigate(`/meeting/${finalRoomId}`, { replace: true }); diff --git a/src/pages/Viewer.tsx b/src/pages/Viewer.tsx index 75e033e..3c4cd17 100644 --- a/src/pages/Viewer.tsx +++ b/src/pages/Viewer.tsx @@ -1,5 +1,5 @@ import { useNavigate } from "react-router-dom"; -import { ArrowLeft, Glasses, Box, Ruler, FileText, Upload, Loader2 } from "lucide-react"; +import { ArrowLeft, Glasses, Box, Ruler, FileText, Upload, Loader2, Users } from "lucide-react"; import { Button } from "@/components/ui/button"; import { useModelStore } from "@/stores/useModelStore"; import { ModelViewerCanvas } from "@/components/three/ModelViewer"; @@ -23,7 +23,18 @@ import { convertIFCtoGLB } from "@/lib/convertIFC"; const Viewer = () => { const navigate = useNavigate(); - const { model, xrSupported, addModel, models, maxModels, scaleRatio } = useModelStore(); + const { + model, + xrSupported, + addModel, + models, + maxModels, + scaleRatio, + fineTuning, + sectionEnabled, + sectionInvert, + sectionLevel + } = useModelStore(); const fileInputRef = useRef(null); const [converting, setConverting] = useState(false); @@ -101,6 +112,29 @@ const Viewer = () => { navigate("/xr"); }; + const handleEnterMeeting = () => { + // Coleta o eixo habilitado de seção no Viewer + const enabledAxis = (['x', 'y', 'z'] as const).find(ax => sectionEnabled[ax]); + const isSectionActive = !!enabledAxis; + const sectionAxis = enabledAxis || 'y'; + const sectionLevelVal = isSectionActive ? sectionLevel[sectionAxis] : 0.0; + const sectionInvertVal = isSectionActive ? sectionInvert[sectionAxis] : false; + + // Salva o estado atual da peça + const initialMeetingState = { + rotation: [fineTuning.rotX, fineTuning.rotY, fineTuning.rotZ], + scale: fineTuning.scale, + sectionEnabled: isSectionActive, + sectionAxis, + sectionLevel: sectionLevelVal, + sectionInvert: sectionInvertVal + }; + + localStorage.setItem('tsxr_initial_meeting_state', JSON.stringify(initialMeetingState)); + toast.success('Configurações da maquete salvas. Direcionando para a reunião...'); + navigate('/meeting'); + }; + const canAddMore = models.length < maxModels; return ( @@ -128,8 +162,16 @@ const Viewer = () => {
+ -