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

176
Views
Raycast not hitting a scene child using Three.js with GMaps

Im trying to hit a pin scene child with a click in GMaps, using Three.js and threejs-overlay-view but I can't get the object clicked. Raycaster.intersectObjects only returns [].

Image of pin

Here's a snippet of the code, everything works fine except the intersection part.

(async () => {        
  const map = await initMap();
  const mapDiv = map.getDiv();

  const mousePosition = new Vector2();
  const raycaster = new THREE.Raycaster();
  const overlay = new ThreeJSOverlayView(mapOptions.center);

  const scene = overlay.getScene();
  overlay.setMap(map);
  ...

  map.addListener('click', ev => {
    const {domEvent} = ev;
    const {left, top, width, height} = mapDiv.getBoundingClientRect();
    const x = domEvent.clientX - left;
    const y = domEvent.clientY - top;
    mousePosition.x = 2 * (x / width) - 1;
    mousePosition.y = 1 - 2 * (y / height);

    // dont get nothing here...
    raycaster.setFromCamera(mousePosition, overlay.camera);
    const intersects = raycaster.intersectObjects(scene.children, true);
    overlay.requestRedraw();
  });

  overlay.update = () => {
    // ... and here
    raycaster.setFromCamera(mousePosition, overlay.camera);
    const intersects = raycaster.intersectObjects(scene.children, true);
    ...
    overlay.requestRedraw();
  };
})();

Glad if any help, Thanks!

about 4 years ago · Juan Pablo Isaza
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!