Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/objects/BatchedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.` );

}

Expand Down
6 changes: 0 additions & 6 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
50 changes: 44 additions & 6 deletions src/renderers/webgl/WebGLUniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 ) {
Expand All @@ -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 {

Expand Down Expand Up @@ -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 );

}

Expand Down Expand Up @@ -826,7 +852,7 @@ function setValueT1Array( gl, v, textures ) {

if ( this.type === gl.SAMPLER_2D_SHADOW ) {

emptyTexture2D = emptyShadowTexture;
emptyTexture2D = initShadowTexture( emptyShadowTexture );

} else {

Expand Down Expand Up @@ -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 ] );

}

Expand Down
Loading