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

Geometries: Delete the disposed geometry's own attributes. (#33939)

Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Sashank Aryal 5 дней назад
Родитель
Сommit
4e369cb1ba
1 измененных файлов с 24 добавлено и 3 удалено
  1. 24 3
      src/renderers/common/Geometries.js

+ 24 - 3
src/renderers/common/Geometries.js

@@ -186,8 +186,9 @@ class Geometries extends DataMap {
 
 			this.info.memory.geometries --;
 
+			// index
+
 			const index = geometry.index;
-			const geometryAttributes = renderObject.getAttributes();
 
 			if ( index !== null ) {
 
@@ -195,12 +196,16 @@ class Geometries extends DataMap {
 
 			}
 
-			for ( const geometryAttribute of geometryAttributes ) {
+			// geometry attributes
+
+			for ( const attribute of Object.values( geometry.attributes ) ) {
 
-				this.attributes.delete( geometryAttribute );
+				this.attributes.delete( attribute );
 
 			}
 
+			// wireframe attributes
+
 			const wireframeAttribute = this.wireframes.get( geometry );
 
 			if ( wireframeAttribute !== undefined ) {
@@ -209,6 +214,22 @@ class Geometries extends DataMap {
 
 			}
 
+			// node attributes (TODO: Remove this bit once we support BufferAttribute.dispose())
+
+			const currentAttributes = new Set( Object.values( renderObject.geometry.attributes ) );
+
+			for ( const attribute of renderObject.getAttributes() ) {
+
+				if ( currentAttributes.has( attribute ) === false ) {
+
+					this.attributes.delete( attribute );
+
+				}
+
+			}
+
+			//
+
 			geometry.removeEventListener( 'dispose', onDispose );
 
 			this._geometryDisposeListeners.delete( geometry );

粤ICP备19079148号