sharing geometry and transforms between BatchedMesh

Add a “BatchedBufferGeometry” object that BatchedMesh references and stores all the geometry, draw ranges, etc. The BatchedMesh would still bookkeep the multidraw buffers, etc:

const mesh1 = new BatchedMesh( maxGeometryCount, maxVertexCount, maxIndexCount, material1 );
const index = mesh1.geometry.addGeometry( ... );
mesh1.setMatrixAt( ... );

const mesh2 = new BatchedMesh( mesh1.geometry, material2 );

mesh1.setVisibilityAt( 0, false );
mesh1.setVisibilityAt( 1, true );
scene.add( mesh1, mesh2 );

Alternatives

Instead the end user could just use something like a proxy or wrapper class that forwards all common information between the BatchedMeshes while reimplementing all needed:

const mesh1 = new BatchedMesh( ... );
const mesh2 = new BatchedMeshWrapper( mesh1 );

Or – possibly the better approach – BatchedMesh could support different and arbitrary material properties and textures but this can get complicated. It’s possible this would be best done with node materials in the future.

Leave a comment

Your email address will not be published. Required fields are marked *