From e997fc05d27fdf26497dda261f5ed7243de3da16 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 5 Mar 2025 09:57:05 -0600 Subject: [PATCH] Pantalla completa --- src/pages/Previewer.tsx | 45 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/pages/Previewer.tsx b/src/pages/Previewer.tsx index dfbc5b9..761819a 100644 --- a/src/pages/Previewer.tsx +++ b/src/pages/Previewer.tsx @@ -4,7 +4,7 @@ import type { OrbitControls as OrbitControlsImpl } from 'three-stdlib'; import { Canvas } from "@react-three/fiber"; import { useGLTF, useAnimations, Environment, Loader, OrbitControls, Html } from "@react-three/drei"; import { Suspense, useEffect, useRef, useState } from "react"; -import { RotateCw, Play, Pause, Film, ListTree } from "lucide-react"; +import { RotateCw, Play, Pause, Film, ListTree, Shrink, Expand } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Popover, @@ -14,6 +14,7 @@ import { import { ScrollArea } from "@/components/ui/scroll-area"; + // Model component function Model({ url, position, rotation, scale, onAnimationsLoaded, onNodesLoaded }: { url: string; @@ -56,7 +57,7 @@ function Model({ url, position, rotation, scale, onAnimationsLoaded, onNodesLoad ); } // Preload the model -useGLTF.preload("/3d/motor_de_combustion/scene.gltf"); +// useGLTF.preload("/3d/motor_de_combustion/scene.gltf"); const InitialParams = { position: [0, -2, 0] as [number, number, number], @@ -67,12 +68,14 @@ const InitialParams = { // Main 3D Viewer export default function Previewer({ modelUrl }: { modelUrl: string }) { const controlsRef = useRef(null); + const containerRef = useRef(null); const [animations, setAnimations] = useState([]); const [actions, setActions] = useState>({}); const [currentAnimation, setCurrentAnimation] = useState(null); const [nodes, setNodes] = useState([]); const [nodePositions, setNodePositions] = useState>({}); + const [isFullscreen, setIsFullscreen] = useState(false); const resetView = () => { @@ -96,8 +99,26 @@ export default function Previewer({ modelUrl }: { modelUrl: string }) { } }; + // Handle Fullscreen Mode + const toggleFullscreen = () => { + if (!document.fullscreenElement) { + containerRef.current?.requestFullscreen().then(() => { + setIsFullscreen(true); + }).catch(err => { + console.error("Error entering fullscreen:", err); + }); + } else { + document.exitFullscreen().then(() => { + setIsFullscreen(false); + }).catch(err => { + console.error("Error exiting fullscreen:", err); + }); + } + }; + + return ( -
+
@@ -105,7 +126,7 @@ export default function Previewer({ modelUrl }: { modelUrl: string }) { Animaciones - +
{animations.length > 0 ? ( @@ -138,7 +159,7 @@ export default function Previewer({ modelUrl }: { modelUrl: string }) { Partes del modelo - +
{nodes.length > 0 ? ( @@ -155,17 +176,23 @@ export default function Previewer({ modelUrl }: { modelUrl: string }) {
- {/* Reset Camera Button */} -
+
+ + {/* Botón de pantalla completa */} +
-
}>