Skip to content

Commit

Permalink
BatchedMesh: Add support for Instanced rendering with sorting, frustu…
Browse files Browse the repository at this point in the history
…m culling (#28404)

* Get the instanced batching working

* re add color support

* fix extension use

* update function name

* small fixes

* fix array initialization

* fix raycast

* missed variable usage

* Add logic for the batched instancing fallbacks

* Alternative fallback

* Update fallback
  • Loading branch information
gkjohnson committed May 22, 2024
1 parent 687a4ca commit 02ed248
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 218 deletions.
16 changes: 13 additions & 3 deletions examples/webgl_mesh_batch.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@
function initBatchedMesh() {

const geometryCount = api.count;
const vertexCount = api.count * 512;
const indexCount = api.count * 1024;
const vertexCount = geometries.length * 512;
const indexCount = geometries.length * 1024;

const euler = new THREE.Euler();
const matrix = new THREE.Matrix4();
Expand All @@ -194,7 +194,17 @@

for ( let i = 0; i < api.count; i ++ ) {

const id = mesh.addGeometry( geometries[ i % geometries.length ] );
let id;
if ( i < geometries.length ) {

id = mesh.addGeometry( geometries[ i % geometries.length ] );

} else {

id = mesh.addInstance( i % geometries.length );

}

mesh.setMatrixAt( id, randomizeMatrix( matrix ) );

const rotationMatrix = new THREE.Matrix4();
Expand Down
Loading

0 comments on commit 02ed248

Please sign in to comment.