diff --git a/src/nodes/accessors/BatchNode.js b/src/nodes/accessors/BatchNode.js index 221682606faaf9..9a50cc6f34ef6d 100644 --- a/src/nodes/accessors/BatchNode.js +++ b/src/nodes/accessors/BatchNode.js @@ -91,17 +91,23 @@ class BatchNode extends Node { const matricesTexture = this.batchMesh._matricesTexture; - const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x ); - const j = float( indirectId ).mul( 4 ).toInt().toVar(); - - const x = j.mod( size ); - const y = j.div( size ); - const batchingMatrix = mat4( - textureLoad( matricesTexture, ivec2( x, y ) ), - textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ), - textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ), - textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) ) - ); + let batchingMatrix = mat4(); + + if ( matricesTexture !== null ) { + + const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x ); + const j = float( indirectId ).mul( 4 ).toInt().toVar(); + + const x = j.mod( size ); + const y = j.div( size ); + batchingMatrix = mat4( + textureLoad( matricesTexture, ivec2( x, y ) ), + textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ), + textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ), + textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) ) + ); + + } const colorsTexture = this.batchMesh._colorsTexture; diff --git a/src/renderers/common/RenderObject.js b/src/renderers/common/RenderObject.js index eb112879f68708..bd206139bb05a9 100644 --- a/src/renderers/common/RenderObject.js +++ b/src/renderers/common/RenderObject.js @@ -704,7 +704,11 @@ class RenderObject { if ( object.isBatchedMesh ) { - cacheKey += object._matricesTexture.uuid + ','; + if ( object._matricesTexture !== null ) { + + cacheKey += object._matricesTexture.uuid + ','; + + } if ( object._colorsTexture !== null ) {