Plugins: Consider plugin that uses / enables use of BatchedMesh
Provide a variant of 3d tiles renderer that uses three.js' BatchedMesh to reduce draw calls. Related to gkjohnson/batched-3d-tiles-demo.
Useful for things like google earth and mars tiles.
For an initial set of requirements:
- Requires all geometry to be of a similar size or maximum-size.
- Requires that all geometry use a similar size of texture and at most one texture.
- Requires that all tiles must use a common tile material / shader.
Process:
- On geometry load copy the texture into a texture array and geometry into the BatchedMesh in a pre-determined buffer size along with the transform.
- Discard the original geometry on load and store the BatchedMesh and texture index.
- If we find a mesh that is too large to fit in the pre-allocated buffer length then create a new BatchedMesh.
- Implement a custom traversal algorithm for batched mesh.
Open Questions:
- Interoperability with other plugins (with shader, etc)
From #628
Related to #604
Add a plugin that fills in a BatchedMesh with the loaded tiles geometry, uses a custom material with support for reading from a texture array, and uploading textures to an array.
Approach
- Create a preallocated BatchedMesh with enough space and large enough slots for the number of tiles to be rendered.
- Preallocate a texture array with enough space for each texture needed.
- Auto expand allocations if needed.
- Custom materials for rendering with albedo from texture array.
- We can lose original references to loaded geometry.
Changes Needed
- Ray casting must change
- Approach for storing internally references to geometry must change
- Lots of internal callbacks and functions that rely on "scene" would have to change
Limitations
- Will not work with Fading tiles.
- Will only work with tile albedo.
To start this could be developed to only work in simple cases (eg earth globe tiles)
BatchedMesh optimizing and resizing will help here when we want to resize the gometry to support more / larger tiles than originally anticipated:
- https://github.com/mrdoob/three.js/pull/29577
- https://github.com/mrdoob/three.js/pull/29527
Options
{
instanceCount,
vertexCount,
indexCount,
expansionPercent,
maxExpansionCount,
// possibly just inherit?
textureSize, generateMipmaps, wrapping, etc,
material,
}