@@ -150,7 +150,7 @@ class InstanceNode extends Node {
150150
151151 if ( instanceMatrixNode === null ) {
152152
153- instanceMatrixNode = this . _createInstanceMatrixNode ( true ) ;
153+ instanceMatrixNode = this . _createInstanceMatrixNode ( true , builder ) ;
154154
155155 this . instanceMatrixNode = instanceMatrixNode ;
156156
@@ -229,7 +229,7 @@ class InstanceNode extends Node {
229229
230230 // update version if necessary
231231
232- if ( this . instanceMatrix . usage !== DynamicDrawUsage && this . instanceMatrix . version !== this . buffer . version ) {
232+ if ( this . instanceMatrix . version !== this . buffer . version ) {
233233
234234 this . buffer . version = this . instanceMatrix . version ;
235235
@@ -242,7 +242,7 @@ class InstanceNode extends Node {
242242 this . bufferColor . clearUpdateRanges ( ) ;
243243 this . bufferColor . updateRanges . push ( ... this . instanceColor . updateRanges ) ;
244244
245- if ( this . instanceColor . usage !== DynamicDrawUsage && this . instanceColor . version !== this . bufferColor . version ) {
245+ if ( this . instanceColor . version !== this . bufferColor . version ) {
246246
247247 this . bufferColor . version = this . instanceColor . version ;
248248
@@ -272,7 +272,7 @@ class InstanceNode extends Node {
272272
273273 instancedMesh . previousInstanceMatrix = this . instanceMatrix . clone ( ) ;
274274
275- this . previousInstanceMatrixNode = this . _createInstanceMatrixNode ( false ) ;
275+ this . previousInstanceMatrixNode = this . _createInstanceMatrixNode ( false , builder ) ;
276276
277277 }
278278
@@ -285,9 +285,10 @@ class InstanceNode extends Node {
285285 *
286286 * @private
287287 * @param {boolean } assignBuffer - Whether the created interleaved buffer should be assigned to the `buffer` member or not.
288+ * @param {NodeBuilder } builder - A reference to the current node builder.
288289 * @return {Node } The instance matrix node.
289290 */
290- _createInstanceMatrixNode ( assignBuffer ) {
291+ _createInstanceMatrixNode ( assignBuffer , builder ) {
291292
292293 let instanceMatrixNode ;
293294
@@ -300,9 +301,11 @@ class InstanceNode extends Node {
300301
301302 } else {
302303
303- // Both backends have ~ 64kb UBO limit; fallback to attributes above 1000 matrices.
304+ // WebGPU has a 64kb UBO limit, WebGL 2 ensures only 16KB ; fallback to attributes if a certain count is exceeded
304305
305- if ( count <= 1000 ) {
306+ const limit = ( builder . renderer . backend . isWebGPUBackend === true ) ? 1000 : 250 ;
307+
308+ if ( count <= limit ) {
306309
307310 instanceMatrixNode = buffer ( instanceMatrix . array , 'mat4' , Math . max ( count , 1 ) ) . element ( instanceIndex ) ;
308311
0 commit comments