From cffba7b32709c117ab731fb9321d2cca53321f66 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 5 Mar 2025 09:56:54 -0600 Subject: [PATCH] =?UTF-8?q?Agregar=20men=C3=BA=20de=20selecci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.tsx | 5 +-- src/pages/Home.tsx | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/pages/Home.tsx diff --git a/src/main.tsx b/src/main.tsx index 74c133a..a559407 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,17 +1,18 @@ // import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' -import App from './pages/App.tsx' import { BrowserRouter, Route, Routes } from "react-router"; import Login from './pages/Login.tsx'; import Previewer from './pages/Previewer.tsx'; import NotFound from './pages/NotFound.tsx'; +import Home from './pages/Home.tsx'; createRoot(document.getElementById('root')!).render( - } /> + } /> } /> } /> + } /> } /> , diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx new file mode 100644 index 0000000..0595eb8 --- /dev/null +++ b/src/pages/Home.tsx @@ -0,0 +1,79 @@ +import { useNavigate } from "react-router"; +import { Canvas } from "@react-three/fiber"; +import { Environment, useGLTF } from "@react-three/drei"; +import { Button } from "@/components/ui/button"; + +const models = [ + { + name: "Motor de Combustión", + url: "/3d/motor_de_combustion/scene.gltf", + route: "/previewer", + }, + { + name: "Raspberry Pi Cam V2.1", + url: "/3d/raspberry_pi_cam_v2.1/scene.gltf", + route: "/previewer2", + }, +]; + +function ModelPreview({ url }: { url: string }) { + const { scene } = useGLTF(url); + + // Define heuristic parameters for best perspective + const parameters: Record = { + "/3d/motor_de_combustion/scene.gltf": { + position: [0, -1.5, 0], + rotation: [0.2, Math.PI / 4, 0], + scale: 0.01, + }, + "/3d/raspberry_pi_cam_v2.1/scene.gltf": { + position: [0, -0.5, 0], + rotation: [0.1, Math.PI / 6, 0], + scale: 0.5, + }, + }; + + const { position, rotation, scale } = parameters[url] || { position: [0, 0, 0], rotation: [0, 0, 0], scale: 0.02 }; + + return ; +} + +export default function Home() { + const navigate = useNavigate(); + + return ( +
+

Selecciona un Modelo 3D

+
+ {models.map((model, index) => ( +
+ {/* 3D Preview */} +
+ + + + +
+ + {/* Model Name */} +

{model.name}

+ + {/* Navigation Button */} + +
+ ))} +
+
+ ); +} + +// Preload models for performance +models.forEach(model => useGLTF.preload(model.url));