Geodan / mapbox-3dtiles

3D Tiles implementation using Mapbox GL JS custom layers
BSD 3-Clause "New" or "Revised" License
296 stars 63 forks source link

Question about intersectsBox and crs transform. #15

Open skywalkershen opened 4 years ago

skywalkershen commented 4 years ago

Hi, I'm new to 3d tiles and trying to use this lib to display my cesium asset tiles, and found during the checkLoad, there is no boundingvolume intersets with the camera frustum. Below are my understanding toward this issue and how this lib works, and I wish you can help me to clarify some of the doubts and point a direction. Thank you so much.

To my understanding, this is how 3d tile works: The vertex info in b3dm/pnts are merely forming meshes in a non-georeferenced Cartesian coordinate system. It is the boundingvolume that defines its geo location and bounding. And the bounding volume can be in any crs or even non georeferenced(in 3d scene Cartesian coordinate system). The transform is applied to project children's crs to the parent's crs, or from root crs to base map crs(in this case, web mercator EPSG:3857 for mapbox).

So I assume the problem with my case lies in the crs. The cesium ion assets are not in EPSG3857(There is no crs info in the tileset.json, I assume it is in EPSG: 4979 since it is recommended in the 3d tile standard), and the transform provided is not from 4979 to 3857.

So there can be two approaches:

  1. Transform the boundingvolume into 3857 to make it consistent with mapbox crs, and remove the transform info(or use default identity matrix).
  2. Leave the boundingvolume as it is, and change the transform info to the transform needed from the boundingvolume's crs to 3857.

I've tried gdal and epsg.io to transform 4979 to 3857, but failed. And I don't really have a clue about how to form the transform matrix needed from 4979 to 3857.

Could you please help to clarify the doubt and shed some light upon this issue? Thank you.

bertt commented 4 years ago

Hi, Cesium uses EPSG:4978 not 4979.

You can follow tutorial on https://github.com/Geodan/pg2b3dm/blob/master/getting_started.md to see how it all works.