2
0
Эх сурвалжийг харах

Merge pull request #20045 from shawn0326/fix-vao

WebGLBindingStates: Add index to cache.
Mr.doob 5 жил өмнө
parent
commit
5298bdc15a

+ 10 - 5
src/renderers/webgl/WebGLBindingStates.js

@@ -25,9 +25,9 @@
 
 			}
 
-			updateBuffers = needsUpdate( geometry );
+			updateBuffers = needsUpdate( geometry, index );
 
-			if ( updateBuffers ) saveCache( geometry );
+			if ( updateBuffers ) saveCache( geometry, index );
 
 		} else {
 
@@ -157,13 +157,14 @@
 			enabledAttributes: enabledAttributes,
 			attributeDivisors: attributeDivisors,
 			object: vao,
-			attributes: {}
+			attributes: {},
+			index: null
 
 		};
 
 	}
 
-	function needsUpdate( geometry ) {
+	function needsUpdate( geometry, index ) {
 
 		const cachedAttributes = currentState.attributes;
 		const geometryAttributes = geometry.attributes;
@@ -183,11 +184,13 @@
 
 		}
 
+		if ( currentState.index !== index ) return true;
+
 		return false;
 
 	}
 
-	function saveCache( geometry ) {
+	function saveCache( geometry, index ) {
 
 		const cache = {};
 		const attributes = geometry.attributes;
@@ -211,6 +214,8 @@
 
 		currentState.attributes = cache;
 
+		currentState.index = index;
+
 	}
 
 	function initAttributes() {