Geodan / mapbox-3dtiles

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

i3dm: add support for uri of the glTF #35

Open bertt opened 4 years ago

bertt commented 4 years ago

add support for uri of the glTF in i3dm

Currently only a embedded glTF is supported.

Specs: https://github.com/CesiumGS/3d-tiles/tree/master/specification/TileFormats/Instanced3DModel#gltf

when header.gltfFormat == 0: glTF field contains a uri of the glTF when header.gltfFormat == 1: glTF field contains bytes of the glTF

bertt commented 4 years ago

testcase: https://bertt.github.io/mapbox_3dtiles_samples/samples/instanced/trees_external_gltf/index.html

error thrown: "Mapbox3DTiles.js:54037 Unexpected end of JSON input" when loading i3dm

i3dm tile have header.gltfFormat == 0 and a reference to external glb https://bertt.github.io/mapbox_3dtiles_samples/samples/instanced/trees_external_gltf/tree.glb

anneb commented 4 years ago

loader was not awaiting external response. Pushed new version. Example set at https://bertt.github.io/mapbox_3dtiles_samples/samples/instanced/trees_external_gltf/tileset.json now works.

bertt commented 4 years ago

tested, it works now. One possible improvement: the same glb is retrieved for each tile, is it possible to retrieve the glb once (and use a cached version for other tiles with same external glb)?

anneb commented 4 years ago

Internal gltf cache added. Risk: requires memory for every new object. Benefit: save many extra requests. For discussion: without internal caching, caching is handled by the browser cache?

tebben commented 4 years ago

@anneb Is it possible to store a reference to the instanced model/mesh instead of the downloaded bytes? This way you won't have the 'risk' of requiring more memory and save time and resources on creating the model from bytes for every tile with the same model.