Skip to content

Commit

Permalink
BatchedMesh: Add fallback when the function extension is not supported (
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson authored and AdaRoseCannon committed Jan 15, 2024
1 parent 136a3ea commit 1943901
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
23 changes: 14 additions & 9 deletions src/renderers/webgl/WebGLBufferRenderer.js
Expand Up @@ -56,21 +56,26 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
const extension = extensions.get( 'WEBGL_multi_draw' );
if ( extension === null ) {

console.error( 'THREE.WebGLBufferRenderer: using THREE.BatchedMesh but hardware does not support extension WEBGL_multi_draw.' );
return;
for ( let i = 0; i < drawCount; i ++ ) {

}
this.render( starts[ i ], counts[ i ] );

extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
}

let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {
} else {

elementCount += counts[ i ];
extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );

}
let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {

elementCount += counts[ i ];

info.update( elementCount, mode, 1 );
}

info.update( elementCount, mode, 1 );

}

}

Expand Down
23 changes: 14 additions & 9 deletions src/renderers/webgl/WebGLIndexedBufferRenderer.js
Expand Up @@ -65,21 +65,26 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
const extension = extensions.get( 'WEBGL_multi_draw' );
if ( extension === null ) {

console.error( 'THREE.WebGLBufferRenderer: using THREE.BatchedMesh but hardware does not support extension WEBGL_multi_draw.' );
return;
for ( let i = 0; i < drawCount; i ++ ) {

}
this.render( starts[ i ] / bytesPerElement, counts[ i ] );

extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
}

let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {
} else {

elementCount += counts[ i ];
extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );

}
let elementCount = 0;
for ( let i = 0; i < drawCount; i ++ ) {

elementCount += counts[ i ];

info.update( elementCount, mode, 1 );
}

info.update( elementCount, mode, 1 );

}

}

Expand Down

0 comments on commit 1943901

Please sign in to comment.