jscastro76 / threebox

A Three.js plugin for Mapbox GL JS, with support for animations and advanced 3D rendering.
Other
549 stars 145 forks source link

How to convert coordinate in threebox.scene to threebox.world or longitude /latitude? #422

Open huangzhe2015 opened 5 months ago

huangzhe2015 commented 5 months ago

Hello

I am using Raycaster to locate the intersect point when I click a 3D model on map with threebox. var intersects = raycaster.intersectObjects(tb.scene.children, true); Then I get the intersects[0].point which seems the coordinate in threebox.scene space. I am wondering how can I convert intersects[0].point to some coordinate in threebox.world space or longitude /latitude?

Thanks.

harriputterr commented 2 months ago

Hello @huangzhe2015

Were you able to find a solution to your problem?

I am kind of trying to achieve the same thing.

If you were able to find a solution, it would be wonderful if you can reply to this comment

Thank you so much

huangzhe2015 commented 2 months ago

Hello @harriputterr I am still working on this issue. I have tried to calculate below way but it failed.

  1. Get the center of map by map.getCenter() which is lng and lat format.
  2. Convert center to world position by projectToWorld(), that is a Vector3
  3. Use Vector3.add() method to add the position in scene system. Also I consider how many meters are equal to a pixel, according to https://docs.mapbox.com/help/glossary/zoom-level/#zoom-levels-and-geographical-distance. But I can't get correct result.