Pārlūkot izejas kodu

ArcballControls: Use dispose() in makeGizmos(). (#24241)

Michael Herzog 3 gadi atpakaļ
vecāks
revīzija
533cf80f0f
1 mainītis faili ar 16 papildinājumiem un 1 dzēšanām
  1. 16 1
      examples/jsm/controls/ArcballControls.js

+ 16 - 1
examples/jsm/controls/ArcballControls.js

@@ -2279,7 +2279,7 @@ class ArcballControls extends EventDispatcher {
 		this._gizmoMatrixState0.identity().setPosition( tbCenter );
 		this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
 
-		if ( this.camera.zoom != 1 ) {
+		if ( this.camera.zoom !== 1 ) {
 
 			//adapt gizmos size to camera zoom
 			const size = 1 / this.camera.zoom;
@@ -2294,8 +2294,23 @@ class ArcballControls extends EventDispatcher {
 
 		this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
 
+		//
+
+		this._gizmos.traverse( function( object ) {
+
+			if ( object.isLine ) {
+		
+				object.geometry.dispose();
+				object.material.dispose();
+		
+			}
+		
+		} );
+
 		this._gizmos.clear();
 
+		//
+
 		this._gizmos.add( gizmoX );
 		this._gizmos.add( gizmoY );
 		this._gizmos.add( gizmoZ );