From 3fc3ea25f1b36c0aa1b0e6ab3b79431a44728aea Mon Sep 17 00:00:00 2001 From: David espinosa <104380606+davespser@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:39:11 +0100 Subject: [PATCH] Create main.js --- js/main.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 js/main.js diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..a1370a4 --- /dev/null +++ b/js/main.js @@ -0,0 +1,23 @@ +import { initLobby } from './lobby.js'; +import { initCuestionario } from './cuestionario.js'; +import { initEscenario1 } from './escenario1.js'; + +// ConfiguraciĆ³n inicial +const renderer = new THREE.WebGLRenderer({ antialias: true }); +renderer.setSize(window.innerWidth, window.innerHeight); +document.body.appendChild(renderer.domElement); +const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); + +// Controlador de escenas +let currentScene, currentAnimationLoop; + +// FunciĆ³n para cambiar escenas +function switchScene(newScene, newAnimationLoop) { + if (currentAnimationLoop) cancelAnimationFrame(currentAnimationLoop); + currentScene = newScene; + currentAnimationLoop = newAnimationLoop; + newAnimationLoop(); +} + +// Inicializar el Lobby como escena inicial +initLobby(renderer, camera, switchScene);