@@ -91,17 +91,23 @@ class BatchNode extends Node {
91
91
92
92
const matricesTexture = this . batchMesh . _matricesTexture ;
93
93
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
+ }
105
111
106
112
107
113
const colorsTexture = this . batchMesh . _colorsTexture ;
0 commit comments