From 110fbbe4b5277a39b2db77c219431bfad24cd4ec Mon Sep 17 00:00:00 2001 From: Mike Fernandez <79382274+MikeFernandez-Pro@users.noreply.github.com> Date: Mon, 28 Sep 2026 10:24:09 +0200 Subject: [PATCH 1/3] BatchedMesh: Clarify geometry compatibility requirements. (#34675) Co-authored-by: Michael Herzog --- src/objects/BatchedMesh.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/objects/BatchedMesh.js b/src/objects/BatchedMesh.js index 1f540865d22a3b..3fb8bdb99ba77f 100644 --- a/src/objects/BatchedMesh.js +++ b/src/objects/BatchedMesh.js @@ -177,6 +177,10 @@ function copyArrayContents( src, target ) { * scene.add( batchedMesh ); * ``` * + * The first geometry added defines the layout of the batch. All subsequent geometries must + * match its index usage and provide its attributes with the same itemSize and normalized + * values. Additional attributes are ignored. + * * @augments Mesh */ class BatchedMesh extends Mesh { @@ -437,7 +441,7 @@ class BatchedMesh extends Mesh { const dstAttribute = batchGeometry.getAttribute( attributeName ); if ( srcAttribute.itemSize !== dstAttribute.itemSize || srcAttribute.normalized !== dstAttribute.normalized ) { - throw new Error( 'THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.' ); + throw new Error( `THREE.BatchedMesh: Added geometry attribute "${ attributeName }" has an inconsistent itemSize or normalized value.` ); } From 386c8f2a75fc7309d611a18ebe15600da3c13e0c Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Mon, 28 Sep 2026 11:39:08 +0200 Subject: [PATCH 2/3] Update BatchedMesh.js Clean up. --- src/objects/BatchedMesh.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objects/BatchedMesh.js b/src/objects/BatchedMesh.js index 3fb8bdb99ba77f..e0b6ada1db4ecc 100644 --- a/src/objects/BatchedMesh.js +++ b/src/objects/BatchedMesh.js @@ -177,8 +177,8 @@ function copyArrayContents( src, target ) { * scene.add( batchedMesh ); * ``` * - * The first geometry added defines the layout of the batch. All subsequent geometries must - * match its index usage and provide its attributes with the same itemSize and normalized + * The first geometry added defines the layout of the batch. All subsequent geometries must + * match its index usage and provide its attributes with the same itemSize and normalized * values. Additional attributes are ignored. * * @augments Mesh From 9be9ac908f72405f5f36d5a029e1905ea3428b95 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Mon, 28 Sep 2026 11:53:30 +0200 Subject: [PATCH 3/3] WebGLRenderer: Correctly init default depth textures. (#34687) --- src/renderers/webgl/WebGLTextures.js | 6 ---- src/renderers/webgl/WebGLUniforms.js | 50 ++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 11835723ca7e5d..879ccdf7b8be18 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -2571,12 +2571,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, this.useMultisampledRTT = useMultisampledRTT; this.dispose = dispose; - this.isReversedDepthBuffer = function () { - - return state.buffers.depth.getReversed(); - - }; - } export { WebGLTextures }; diff --git a/src/renderers/webgl/WebGLUniforms.js b/src/renderers/webgl/WebGLUniforms.js index ee3191d009d186..a4f0a7ee554daa 100644 --- a/src/renderers/webgl/WebGLUniforms.js +++ b/src/renderers/webgl/WebGLUniforms.js @@ -46,11 +46,13 @@ import { Texture } from '../../textures/Texture.js'; import { DataArrayTexture } from '../../textures/DataArrayTexture.js'; import { Data3DTexture } from '../../textures/Data3DTexture.js'; import { DepthTexture } from '../../textures/DepthTexture.js'; -import { LessEqualCompare, GreaterEqualCompare } from '../../constants.js'; +import { CubeDepthTexture } from '../../textures/CubeDepthTexture.js'; +import { AlwaysCompare } from '../../constants.js'; const emptyTexture = /*@__PURE__*/ new Texture(); const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 ); +const emptyCubeShadowTexture = /*@__PURE__*/ new CubeDepthTexture( 1 ); const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture(); const empty3dTexture = /*@__PURE__*/ new Data3DTexture(); @@ -554,6 +556,19 @@ function setValueV4ui( gl, v ) { } +function initShadowTexture( texture ) { + + if ( texture.version === 0 ) { + + texture.compareFunction = AlwaysCompare; + texture.needsUpdate = true; + + } + + return texture; + +} + // Single texture (2D / Cube) function setValueT1( gl, v, textures ) { @@ -572,8 +587,7 @@ function setValueT1( gl, v, textures ) { if ( this.type === gl.SAMPLER_2D_SHADOW ) { - emptyShadowTexture.compareFunction = textures.isReversedDepthBuffer() ? GreaterEqualCompare : LessEqualCompare; - emptyTexture2D = emptyShadowTexture; + emptyTexture2D = initShadowTexture( emptyShadowTexture ); } else { @@ -613,7 +627,19 @@ function setValueT6( gl, v, textures ) { } - textures.setTextureCube( v || emptyCubeTexture, unit ); + let emptyTextureCube; + + if ( this.type === gl.SAMPLER_CUBE_SHADOW ) { + + emptyTextureCube = initShadowTexture( emptyCubeShadowTexture ); + + } else { + + emptyTextureCube = emptyCubeTexture; + + } + + textures.setTextureCube( v || emptyTextureCube, unit ); } @@ -826,7 +852,7 @@ function setValueT1Array( gl, v, textures ) { if ( this.type === gl.SAMPLER_2D_SHADOW ) { - emptyTexture2D = emptyShadowTexture; + emptyTexture2D = initShadowTexture( emptyShadowTexture ); } else { @@ -882,9 +908,21 @@ function setValueT6Array( gl, v, textures ) { } + let emptyTextureCube; + + if ( this.type === gl.SAMPLER_CUBE_SHADOW ) { + + emptyTextureCube = initShadowTexture( emptyCubeShadowTexture ); + + } else { + + emptyTextureCube = emptyCubeTexture; + + } + for ( let i = 0; i !== n; ++ i ) { - textures.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] ); + textures.setTextureCube( v[ i ] || emptyTextureCube, units[ i ] ); }