Skip to content

Commit

Permalink
Update menu.js
Browse files Browse the repository at this point in the history
  • Loading branch information
davespser authored Dec 6, 2024
1 parent 4740aa9 commit d6fa05f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions js/menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Importar Three.js y GSAP
// Importar Three.js
import * as THREE from "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js";
import { gsap } from "https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js";

// Crear la escena, cámara y renderizador
const scene = new THREE.Scene();
Expand All @@ -11,7 +10,7 @@ document.body.appendChild(renderer.domElement);

// Crear un plano para el menú
const planeGeometry = new THREE.PlaneGeometry(2, 1);
const planeMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff }); // Color de fondo del menú
const planeMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff });
const plane = new THREE.Mesh(planeGeometry, planeMaterial);
plane.position.set(0, -1, -5);
scene.add(plane);
Expand Down Expand Up @@ -53,25 +52,23 @@ function onMouseClick(event) {

window.addEventListener("click", onMouseClick);

// Función para animar el menú
function animateMenu() {
gsap.to(plane.scale, {
x: 2,
duration: 0.5,
ease: "power2.out"
});
}

// Crear un botón para activar la animación del menú
// Agregar un botón de animación al DOM
const menuButton = document.createElement("button");
menuButton.id = "menu-button";
menuButton.innerText = "Mostrar Menú";
menuButton.style.position = "absolute";
menuButton.style.top = "10px";
menuButton.style.left = "10px";
menuButton.style.padding = "10px 20px";
menuButton.style.cursor = "pointer";
menuButton.style.fontSize = "16px";
document.body.appendChild(menuButton);

menuButton.addEventListener("click", animateMenu);
// Animación sencilla con CSS
menuButton.addEventListener("click", () => {
plane.scale.x = plane.scale.x === 1 ? 2 : 1;
plane.scale.y = plane.scale.y === 1 ? 2 : 1;
});

// Función de renderizado
function animate() {
Expand Down

0 comments on commit d6fa05f

Please sign in to comment.