Skip to content

Commit 141a4d6

Browse files
make batchMesh._matricesTexture optional
1 parent 8384278 commit 141a4d6

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/nodes/accessors/BatchNode.js

+17-11
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,23 @@ class BatchNode extends Node {
9191

9292
const matricesTexture = this.batchMesh._matricesTexture;
9393

94-
const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x );
95-
const j = float( indirectId ).mul( 4 ).toInt().toVar();
96-
97-
const x = j.mod( size );
98-
const y = j.div( size );
99-
const batchingMatrix = mat4(
100-
textureLoad( matricesTexture, ivec2( x, y ) ),
101-
textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ),
102-
textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ),
103-
textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) )
104-
);
94+
let batchingMatrix = mat4();
95+
96+
if ( matricesTexture !== null ) {
97+
98+
const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x );
99+
const j = float( indirectId ).mul( 4 ).toInt().toVar();
100+
101+
const x = j.mod( size );
102+
const y = j.div( size );
103+
batchingMatrix = mat4(
104+
textureLoad( matricesTexture, ivec2( x, y ) ),
105+
textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ),
106+
textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ),
107+
textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) )
108+
);
109+
110+
}
105111

106112

107113
const colorsTexture = this.batchMesh._colorsTexture;

src/renderers/common/RenderObject.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,12 @@ class RenderObject {
703703
}
704704

705705
if ( object.isBatchedMesh ) {
706+
707+
if ( object._matricesTexture !== null ) {
706708

707-
cacheKey += object._matricesTexture.uuid + ',';
709+
cacheKey += object._matricesTexture.uuid + ',';
710+
711+
}
708712

709713
if ( object._colorsTexture !== null ) {
710714

0 commit comments

Comments
 (0)