Просмотр исходного кода

NodeMaterialObserver: Avoid usage of `Object.keys()`. (#33113)

Michael Herzog 1 месяц назад
Родитель
Сommit
051fbfd1a9
1 измененных файлов с 13 добавлено и 9 удалено
  1. 13 9
      src/materials/nodes/manager/NodeMaterialObserver.js

+ 13 - 9
src/materials/nodes/manager/NodeMaterialObserver.js

@@ -393,9 +393,6 @@ class NodeMaterialObserver {
 		const attributes = geometry.attributes;
 		const storedAttributes = storedGeometryData.attributes;
 
-		const storedAttributeNames = Object.keys( storedAttributes );
-		const currentAttributeNames = Object.keys( attributes );
-
 		if ( storedGeometryData.id !== geometry.id ) {
 
 			storedGeometryData.id = geometry.id;
@@ -403,16 +400,16 @@ class NodeMaterialObserver {
 
 		}
 
-		if ( storedAttributeNames.length !== currentAttributeNames.length ) {
+		// attributes
 
-			renderObjectData.geometry.attributes = this.getAttributesData( attributes );
-			return false;
+		let currentAttributeCount = 0;
+		let storedAttributeCount = 0;
 
-		}
+		for ( const _ in attributes ) currentAttributeCount ++; // eslint-disable-line no-unused-vars
 
-		// compare each attribute
+		for ( const name in storedAttributes ) {
 
-		for ( const name of storedAttributeNames ) {
+			storedAttributeCount ++;
 
 			const storedAttributeData = storedAttributes[ name ];
 			const attribute = attributes[ name ];
@@ -435,6 +432,13 @@ class NodeMaterialObserver {
 
 		}
 
+		if ( storedAttributeCount !== currentAttributeCount ) {
+
+			renderObjectData.geometry.attributes = this.getAttributesData( attributes );
+			return false;
+
+		}
+
 		// check index
 
 		const index = geometry.index;

粤ICP备19079148号