3DBAG / 3dbag-viewer

https://3dbag.nl
GNU General Public License v3.0
35 stars 10 forks source link

3D tileset in Cesium #74

Open lanminik opened 3 years ago

lanminik commented 3 years ago

Hello there, I am trying to use a 3d tileset (https://3dbag.nl/download/3dtiles/v21031_7425c21b/lod22/tileset.json) and have an issue showing it in Cesium.js. Cesium doesn't report any warning, error, or information and everything seems like it should work but the tiles are not showing at all ( there are no requests for tiles when I am moving around). I tried with another resources that I've found on the internet and tileset.json looks pretty the same as yours, but those worked.

If this requires exporting of your PostgreSQL db in another way to support Cesium, please help (guide) me on how to do that.

BTW, great job!

Ylannl commented 3 years ago

Hi, we are not really offering the 3D tiles as a service for external use at this moment. Our tileset files are optimised for our specific 3D viewer needs, and may not be completely compliant with the 3D tiles standard. That's probably why it doesn't work in Cesium.

If you want to get this working now you can modify the tileset.json yourself (make a flat hierarchy of the child nodes and play with the geometric error). In any case please copy the b3dm files to your own server.

In the future we may be able to make this easier to do.

liberostelios commented 3 years ago

The problem is that Cesium uses WGS84 horizontal coordinates, while we use EPSG 28992. You'll have to convert the coordinates of the batched files to make them work with Cesium, as far as I am concerned.

You could try to create your own tileset using pg2b3dm after you load the 3D BAG database in PostGIS and transform it.

lanminik commented 3 years ago

Thank you guys for the answers.

I've downloaded all b3dm files and will try somehow to change the projection to fits the Cesium requirements (Plan B). In general, it would be much better for me to create a new tileset with pg2b3dm as @liberostelios said but I am not sure what are all steps that I have to do to achieve that.

I've followed the getting started guide and this is what I did since now:

  1. Downloaded your PostgreSQL db.
  2. Created Postgres server, installed gis extension, and imported the db so now I see pand and other columns.
  3. Downloaded bag3d_2020-05-13.gpkg and imported it to the db;
  4. Tried to use the tesselate_building library but I got 'height' column is missing (this is the step where I am now)
  5. I have found this page where is the link for downloading a file with Building footprints (+ height) but I am always redirected to the bag3d viewer (I guess because it is a single-page app and the router redirects me);

If I don't need some of the steps above please let me know;

Any suggestion or help is much appreciated.

DmitriLapushkin commented 3 years ago

I have the same problem. I want to create my own tiles using tool "pg2b3dm" from postgis dump and table "bag3d.lod22_3d" and column "geometrie", where the pure 3d model of the buildings are located in MultiPolygonZ type.

But there is like a dead end. When I`m starting with prepartions.

My flow:

  1. restored postgis 3dbag dump
  2. followed the pg2b3dm
  3. starting to prepare data for pg2d3dm which requires column of "lod22_3d.geometrie" to be in "POLYHEDRALSURFACE Z"
  4. getting started guide tells that we need to use this tool https://github.com/bertt/tesselate_building, but it requires HEIGHT attribute, we can`t get height because "lod22_3d.geometrie" is already a 3d model

But every doc that Im reading on http://3dbag.bk.tudelft.nl tells me that for creation of b3dm models pg2b3dm tool was used from the postgis dum. But when you start to follow what is required for pg2b3dm, you are stuck. You can`t use bertt/tesselate_building, because it requires hight and you cant get height from lod22_3d.geometrie, because it is alredy a building 3d model. And if you generate buildings from bag3d.lod22_2d variant, then you wont get slanted roofs like we see on 3dbag viewer.

@Ylannl Please help us. I think @lanminik is stuck on same thing.

@liberostelios commented, that "You could try to create your own tileset using pg2b3dm after you load the 3D BAG database in PostGIS and transform it." The tricky totally undocumented part is "...and transform it.", since we cant use lod22_3d.geometrie type directly with pg2b3dm to create tiles used in http://3dbag.bk.tudelft.nl. Can you please give some hints how todo that?

Ylannl commented 3 years ago

You shouldn't need to triangulate/tesselate the geometries since they are already triangulated in the DB dump.

Also if you want building footprints with height you can find this in the 2d layers, however that won't give you LoD 2 roofs.

DmitriLapushkin commented 3 years ago

@Ylannl thanks for clarification! But still there is one piece in puzzle is missing. How we can produce tiles used in http://3dbag.bk.tudelft.nl by using pg2b3dm tool?

Maybe you can give a hint or share a tools/code you have used to produce your tiles. I suppose you used directly LOD22 models from PostGis database dump (which is available here https://3dbag.nl/en/download) to produce your tilesets. But I dont find anywhere this information.

P.S I suppose you have used pg2b3dm code with modificaitons. Otherwise it is not possible, because in pg2b3dm code heavily relies on ... ST_GeometryType({geometry_column}) = 'ST_PolyhedralSurface... '

But LOD22 models (in column geometrie and table bag3d.lod22_3d) are not "ST_PolyhedralSurface", BUT "ST_MultiPolygon", meaning out of the box this wont work with 3dbag postgis dump

Ylannl commented 3 years ago

We use a modified version of pg2b3dm which has some hacks specific to our viewer that won't work with Cesium. However, the regular pg2b3dm should also work. Just pass it the db parameters.

DmitriLapushkin commented 3 years ago

@Ylannl so my assumption was correct about pg2b3dm. I need it to be used with mapbox. And as I have described above, out of the box using pg2b3dm is not possible :)

P.S And before coming here and asking for help, I sure was trying all the variants with out of the box code from pg2b3dm, but failed. I even can display your tilesets with mapbox, but i want to produce my own with coordinate system suited directly for mapbox out of PostGis dump (i have St_Translated lod22 models to 3857 srid, but stuck on generating tilesets)

Ylannl commented 3 years ago

You are right we changed it to work with MultiPolygons, see https://github.com/tudelft3d/pg2b3dm/commit/96489b63442f1fdfd28843ce7831d2e8f1d79705.

DmitriLapushkin commented 3 years ago

@Ylannl thanks for your help! That seems is the piece of the puzzle I was looking for! Have not spotted that you have forked this repo. Will try to do the same

DmitriLapushkin commented 3 years ago

@Ylannl does it really take several weeks to produce 3d tiles for whole netherlands with pg2b3dm? :) I see you use some sort of precalculated tables tiles.xyz_tiles and tiles.bag_tiles_3k in time consuming sections. Can you please help, how and what you precompute, cause from source code it is not clear.

Ylannl commented 3 years ago

I think you need to create a spatial index in the database on the geometry column. Also we use multithreading in our modified pg2b3dm.

DmitriLapushkin commented 3 years ago

@Ylannl yes, thats already creaeted. And you use multithreading only when you output the tiles that can be multithreaded. But not when you do are creating quadtree, since there is recursion.

lanminik commented 3 years ago

Yes @DmitriLapushkin we have the same issue with generating the tileset :) Maybe you explained it better.

Did you manage it to work? I didn't, so if you are then please give me some steps and hints on how did you achieve it? And did you use the forked pg2b3dm or the original one? Thanks in advance!

DmitriLapushkin commented 2 years ago

@lanminik I have archived it but, only they appear in Gulf of Gunea :) image

And i dont know how to move them to Netherlands, there is some puzzled math involved. One way is to generate them with right SRID for mapbox, which should avoid complex math. But that just takes ages to complete

mnHybrid commented 2 years ago

@DmitriLapushkin I am still struggling with this as well. Had the same issue with the positioning in the Gulf of Gunea, and have managed the transformation with query directly in the Postgres DB. Will drop it here when I find it.

Did you manage to generate the geojson data in LOD2.2? (I cannot see from the screenshot); If yes, can you describe the steps that you went through, please? I managed somehow to export LOD1 (an extremely slow process) but it is not what I need to have. So have to figure out how to generate lod22.

rbraggaar commented 1 year ago

Any news on support for Cesium or Mapbox/Deck tile formats?

alexhuygen commented 10 months ago

So BAG and Cesium and Unreal can work together?