diff --git a/src/objects/BatchedMesh.js b/src/objects/BatchedMesh.js index 1f540865d22a3b..e0b6ada1db4ecc 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.` ); } 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 ] ); }