NASA-AMMOS / 3DTilesRendererJS

Renderer for 3D Tiles in Javascript using three.js
https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/mars.html
Apache License 2.0
1.47k stars 266 forks source link

Considering supporting legacy b3dm headers? #508

Closed Insopitus closed 3 months ago

Insopitus commented 3 months ago

Describe the bug

My project uses some legacy old b3dm format (still version 1 though) which 3DTilesRendererJS failed to parse. It throws: Uncaught RangeError: Invalid typed array length: -1179912019. I did some research and found out it is because of the legacy header the b3dm models use. The cesium repository has some code to handle it, which I didn't find here in 3DTilesRendererJS.

To Reproduce

Steps to reproduce the behavior:

  1. download and unzip the file attached
  2. parse it with B3DMLoaderBase
gkjohnson commented 3 months ago

As far as I know these legacy formats are from pre release (version 0) variants of the 3d tiles specification which are not supported. Even if the legacy header did parse the gltf contents contained within the file are also a legacy 1.0 version which the three.js library cannot parse, anyway:

"asset":{
  "generator":"infoearth",
  "premultipliedAlpha":true,
  "profile":{"api":"webgl","version":"1.0.2"},
  "version":1
}

You'll have to upgrade your files if you'd like to use them with this project.

Insopitus commented 3 months ago

Would there be options to use custom loaders for parsing and decoding rather than the default ones? I have written a gltf 1.0 parser and b3dm parser that supports legacy headers. For now, I want to migrate to 3DTilesRendererJS but still need to support the legacy model files. I could modify the source code of 3DTilesRendererJS to meet the requirements. It would be better to directly use the library so it's easier to keep up with future updates though.

gkjohnson commented 3 months ago

I'll have to think about this - maybe supporting the ability to get a loader constructor from LoadingManager.getHandler? But generally I don't love the idea of adding a feature just to enable support long-deprecated, pre-release file formats. Even the newer B3DM version and the other original 3d tiles geometry formats (PNTS, I3DM, CMPT) are deprecated in favor of glTF. Is there no Cesium tool or something that will migrate a format to a newer version of the format?

Insopitus commented 3 months ago

Yes, there actually is one by the Cesium team.

But the upgrade failed for our models. Still looking for the reason why it doesn't work though.

Also, we have lots of legacy format models stored here and there. Migrating them all would be painful, not to mention the possible side-effects in the migration.

The LoadingManager.getHandler approach looks neat.

gkjohnson commented 3 months ago

The LoadingManager.getHandler approach looks neat.

If you'd like to make a PR that implements this solution we can see how it looks and possibly get it added.

Insopitus commented 3 months ago

Okay, I will give this a try next Monday.