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

185
Views
Recibo un error cuando escribo condiciones en JavaScript

Soy novato con JavaScript e intenté almacenar la posición del Vector y con dos botones (adelante y atrás) para mover la cámara a esa posición específica. También traté de usar 'gsap' para tener movimientos suaves pero el código no funciona.

 //Coordinates let positionIndex = 0; const positions = [ { x: -0.05, y: 0.6, z: -0.17 }, { x: -2, y: 1, z: 1 }, { x: 0.3, y: 0.6, z: -0.6 } ] //on buttonforward clicked var element = document.querySelector(".button-1"); element.onclick = function MoveUp(){ if(positionIndex) == 3 { positionIndex = 0; } else { positionIndex += 1; }} camera.position.x = positions[positionIndex].x camera.position.y = positions[positionIndex].y camera.position.z = positions[positionIndex].z //on buttonbackwards clicked var element = document.querySelector(".button-2"); element.onclick = function MoveDown(){ if(positionIndex) == 0 { positionIndex = 3; } else { positionIndex -= 1; }} camera.position.x = positions[positionIndex].x camera.position.y = positions[positionIndex].y camera.position.z = positions[positionIndex].z

Alguien me puede dar un consejo?

Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

cuando estableces positionIndex en 3 obtendrás indefinido. Quizás sería mejor usar positions.length - 1

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!