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

149
Views
Problema en la declaración if else cuando se trabaja con raycasting

Estoy tratando de usar raycasting para detectar si mi mouse apuntó al objeto, cuando no tocó la función funciona bien, pero cuando tocó, dejó de imprimir "no tocó", mientras que no imprimió "tocar" en el Mismo tiempo. Para la declaración if que incluyo aquí, solo hay 2 casos, ya sea === o no, ¿verdad? Entonces, ¿por qué mi código no funciona? ¿alguien puede ayudarme?

 function animate(){ renderer.render(scene,camera); sLightHelper.update(); rayCaster.setFromCamera(mousePosition,camera); var intersects = rayCaster.intersectObjects(scene.children); if ( house != undefined ){ for(let i = 0; i < intersects.length; i++){ if(intersects[0].object.id === house.ID){ console.log("touch"); } else{ console.log("didnt touch"); } } console.log("finished"); } else{ console.log('not ready') } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intenta escribir tu código así:

 if ( intersects.length > 0 ) { for(let i = 0; i < intersects.length; i++){ if(intersects[0].object.id === house.ID){ console.log("touch"); } else{ console.log("didnt touch"); } } } else { console.log("didnt touch"); } console.log("finished");
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!