Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

316
Views
Animación lenta del objeto Three.js en el evento, mientras se mantiene la posición actual

Estoy tratando de ralentizar la animación de un cubo giratorio en mouseOver y hacer que continúe en mouseLeave.

Actualmente, cuando el mouse ingresa al cubo, se ralentiza, pero también cambia a otra rotación bastante repentinamente, antes de regresar cuando el mouse se va.

¿Alguien puede aconsejarme sobre cómo lograr una transición de desaceleración suave sin chasquidos? Un degradado también sería muy bueno, similar a las animaciones css. Mi código está abajo.

 let rotationSpeed = 0.9; const interaction = new Interaction(renderer, scene, camera); cube.cursor = "pointer"; cube.on("mouseover", () => { rotationSpeed -= 0.5; }); cube.on("mouseout", () => { rotationSpeed += 0.5; }); // CLOCK const clock = new THREE.Clock(); const tick = () => { // targetX = mouseX * 0.001; // targetY = mouseY * 0.001; const elapsedTime = clock.getElapsedTime(); // Update objects cube.rotation.y = rotationSpeed * elapsedTime; cube.rotation.x = rotationSpeed * elapsedTime;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El evento "mouseover" se resta muchas veces -0.5 a 0.9, luego el valor "rotationSpeed" cambia a negativo. Entonces, prueba:

 cube.on("mouseover", () => { if(rotationSpeed > 0){ rotationSpeed -= 0.1; } }); cube.on("mouseout", () => { rotationSpeed = 0.9; });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!