paireks / dotbim

Minimalist file format for BIM
MIT License
161 stars 20 forks source link

Exporting BIM to GLB format with DRACO compression #36

Closed GitHubDragonFly closed 9 months ago

GitHubDragonFly commented 9 months ago

@paireks here is something that you might eventually find interesting since it seems to have a high potential when it comes to the sizes of the models.

This all relates to exporting BIM files to GLB format with DRACO compression and has been implemented in my STEP Viewer. I did make some additional updates to BIM Loader on my end and the exported GLB file should have meshes names but not material names.

EDIT: Material names have been fixed and should show as either Default or Default Material or the name provided by the model.

The exported file is rather small when compared to the original BIM file and you could test run some of your examples and then compare it to the Online 3D Viewer.

Since this is not an issue it can be closed at any time.

GitHubDragonFly commented 9 months ago

Just to mention that this all is related to what I call alternative GLB exporter, which in my STEP Viewer is under the - ALT - section of the exporter and marked as either of GLBx 1k or GLBx 2k or GLBx 4k.

paireks commented 9 months ago

Hello @GitHubDragonFly

It looks interesting, I've tried it, and will try it with more files. Main con is metadata is missing. Glb/Gltf itself can handle metadata, but maybe DRACO can compress only geometries(?). Also because of missing metadata we cannot truly compare file sizes, because it cuts down metadata, so it would be a data-loss during the compression.

Also if you're into data compression, try out simple zipping of .bim files, cause after some tests in the past it turned to be extremely efficient.

Just for the record: I also tried BSON and MessagePack, but nothing could beat simple .zip :)

GitHubDragonFly commented 9 months ago

I thought that you should know about its availability and it can be used by anyone if needed in the future.

On my end, I did include meshes and material names but nothing else is being exported by the current BIM Loader. The Online 3D Viewer shows these names when the exported GLB is loaded.

DRACO does compress geometry only and I did a test with one of your example models to compare sizes:

Users can probably get by with whatever choice they make so let them choose.

I will close this topic.

paireks commented 9 months ago

Thank you very much for information and tests! In the past Daniel told me that it should be interesting to have a look at Draco regarding .bim, so @DanielSBoba maybe you will find it useful :)

GitHubDragonFly commented 9 months ago

@paireks just as an FYI, the library on my end was updated to also include additional metadata, like the whole info section and guid, type and schema_version.

This is all being passed within the userData of the objects.

paireks commented 9 months ago

@GitHubDragonFly have you tried it with your example file? Teapots1000.zip

Probably something with instancing is missing, cause after conversion when I open .glb in Online3dViewer there is some data duplication :)

By the way: Happy New Year :)

GitHubDragonFly commented 9 months ago

Happy New Year to you too.

It's hard to debate what you stated since it relates to the developer's approach.

The online 3D Viewer appears to be designed to handle names differently, which in case of the Teapots1000 GLB export causes duplication in the Details section. With the original BIM file, since there are no names assigned to meshes, it resorts to handling the type only and shows all the meshes as Furnishing Element (and if there was no type specified then it would probably show all the meshes as No Name).

Regardless, I will leave the things as they are on my end.

GitHubDragonFly commented 9 months ago

@paireks my code has been adjusted but the Online 3D Viewer is still showing multiple (not duplicate) information in the Details section. It appears that this is based on the geometry node, which is the only thing these meshes have in common.

Since the original GUIDs are exported then maybe the Online 3D Viewer code should be adjusted to actually observe GUID instead of the geometry node. Also, all the meshes have unique names.

Here is a GLB file that you can open in that viewer to see how it shows now. Probably the simplest thing to examine would be the following meshes, which are blue in color and there is only 3 of them:

Teapots1000_GLB.zip

Exporting BIM to three.js is a little bit complex since instanced meshes are used but all the pertinent information is still there.

I will not be looking to modify this any further.