Browse Source

WebGPURenderer: Add "updateRanges" support for WebGLAttributeUtils (#27149)

* Add "updateRanges" support for WebGLAttributeUtils

* Fix failed test
Garrett Johnson 1 year ago
parent
commit
763c53eb55
1 changed files with 22 additions and 1 deletions
  1. 22 1
      examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js

+ 22 - 1
examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js

@@ -105,9 +105,30 @@ class WebGLAttributeUtils {
 		const bufferAttribute = attribute.isInterleavedBufferAttribute ? attribute.data : attribute;
 		const bufferData = backend.get( bufferAttribute );
 		const bufferType = bufferData.bufferType;
+		const updateRanges = attribute.isInterleavedBufferAttribute ? attribute.data.updateRanges : attribute.updateRanges;
 
 		gl.bindBuffer( bufferType, bufferData.bufferGPU );
-		gl.bufferSubData( bufferType, 0, array );
+
+		if ( updateRanges.length === 0 ) {
+
+			// Not using update ranges
+
+			gl.bufferSubData( bufferType, 0, array );
+
+		} else {
+
+			for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
+
+				const range = updateRanges[ i ];
+				gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
+					array, range.start, range.count );
+
+			}
+
+			bufferAttribute.clearUpdateRanges();
+
+		}
+
 		gl.bindBuffer( bufferType, null );
 
 		bufferData.version = bufferAttribute.version;