Skip to content

Commit 787ba7e

Browse files
authored
InstanceNode: Honor updateRanges. (#31816)
1 parent 27255fe commit 787ba7e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/nodes/accessors/InstanceNode.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,33 @@ class InstanceNode extends Node {
195195
*/
196196
update( /*frame*/ ) {
197197

198-
if ( this.instanceMatrix.usage !== DynamicDrawUsage && this.buffer !== null && this.instanceMatrix.version !== this.buffer.version ) {
198+
if ( this.buffer !== null ) {
199199

200-
this.buffer.version = this.instanceMatrix.version;
200+
// keep update ranges in sync
201+
202+
this.buffer.clearUpdateRanges();
203+
this.buffer.updateRanges.push( ... this.instanceMatrix.updateRanges );
204+
205+
// update version if necessary
206+
207+
if ( this.instanceMatrix.usage !== DynamicDrawUsage && this.instanceMatrix.version !== this.buffer.version ) {
208+
209+
this.buffer.version = this.instanceMatrix.version;
210+
211+
}
201212

202213
}
203214

204-
if ( this.instanceColor && this.instanceColor.usage !== DynamicDrawUsage && this.bufferColor !== null && this.instanceColor.version !== this.bufferColor.version ) {
215+
if ( this.instanceColor && this.bufferColor !== null ) {
216+
217+
this.bufferColor.clearUpdateRanges();
218+
this.bufferColor.updateRanges.push( ... this.instanceColor.updateRanges );
219+
220+
if ( this.instanceColor.usage !== DynamicDrawUsage && this.instanceColor.version !== this.bufferColor.version ) {
205221

206-
this.bufferColor.version = this.instanceColor.version;
222+
this.bufferColor.version = this.instanceColor.version;
223+
224+
}
207225

208226
}
209227

0 commit comments

Comments
 (0)