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

Add support for glTF EXT_mesh_features extension #526

Closed gkjohnson closed 2 months ago

gkjohnson commented 2 months ago

Specification

https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features

Test files

https://github.com/CesiumGS/3d-tiles-samples/tree/main/glTF/EXT_mesh_features

TODO

gkjohnson commented 2 months ago

Notes

Feature by Texture

Feature by Attribute

Feature by Index

gkjohnson commented 2 months ago

Reading data from a canvas takes around 1-2ms to read but we don't have to deal with disposing texture data from the canvas and it's sync. WebGL texture read would probably also be similarly slow unless async reads are used.

https://jsfiddle.net/ycn46tfq/2/

Multiple textures can be sampled at once by writing them next to each other to cut down on read time

gkjohnson commented 2 months ago

We can't use canvas readback due to the inability to disable alpha multiplication (link) which results in losing all data on read. A better solution may be to render and readback from a local webgl instance and immediately discard the texture. Then all image bitmaps can be disposed on tiles renderer disposal.

See gltf variants approach for a similar type of case.

Depending on potential performace impliciations it would be possible to just upload the single pixel that needs to be written. See latest WebGL2 update from here.

gkjohnson commented 2 months ago

Updating the WebGLRenderer.copyTextureToTexture to behave more similarly to the copyTextureToTexture3D function such that it takes a bounding box to copy in. Must perform benchmarks to demonstrate performance improvements.