Skip to content

Commit

Permalink
Update three-scene.js
Browse files Browse the repository at this point in the history
  • Loading branch information
davespser authored Dec 10, 2024
1 parent cd3943f commit f1f8da6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions js/three-scene.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from "three";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
import { createMenu, createJoypad, createStats} from "./ui.js"; // Importar funciones de interfaz
import { createMenu, createJoypad, createStats } from "./ui.js"; // Importar funciones de interfaz
import { createFloor } from "./ground.js"; // Importar la función para crear el suelo

let scene, camera, renderer, cube, floor, robot, light, mixer;
Expand All @@ -17,7 +17,7 @@ export function loadThreeScene({ x = 0, y = 0, z = 0, color = 0xff4500, stats =
// Configurar cámara
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(x + 10, y + 5, z + 10);
camera.lookAt(x + 10, y + 5, z + 10);
camera.lookAt(x, y, z);

// Configurar renderizador
renderer = new THREE.WebGLRenderer({ antialias: true });
Expand Down Expand Up @@ -91,10 +91,11 @@ export function loadThreeScene({ x = 0, y = 0, z = 0, color = 0xff4500, stats =
window.addEventListener("keydown", handleKeyDown);

// Crear menú y joypad desde ui.js
// Crear joypad
createJoypad((stickX, stickY) => {
cube.position.x += stickX * 0.01;
cube.position.z += stickY * 0.01;
if (cube) {
cube.position.x += stickX * 0.1; // Ajusta la sensibilidad del movimiento
cube.position.z += stickY * 0.1;
}
});

// Crear estadísticas
Expand All @@ -106,8 +107,6 @@ export function loadThreeScene({ x = 0, y = 0, z = 0, color = 0xff4500, stats =
animate();
}



// Manejar teclas
function handleKeyDown(event) {
if (!cube) return;
Expand Down

0 comments on commit f1f8da6

Please sign in to comment.