Browse Source

Editor: Call dispose() when using DRACOLoader. (#25283)

Michael Herzog 2 years ago
parent
commit
835f533081
1 changed files with 10 additions and 2 deletions
  1. 10 2
      editor/js/Loader.js

+ 10 - 2
editor/js/Loader.js

@@ -279,6 +279,8 @@ function Loader( editor ) {
 						scene.animations.push( ...result.animations );
 						editor.execute( new AddObjectCommand( editor, scene ) );
 
+						dracoLoader.dispose();
+
 					} );
 
 				}, false );
@@ -296,7 +298,7 @@ function Loader( editor ) {
 
 					const contents = event.target.result;
 
-					let loader;
+					let loader, dracoLoader;
 
 					if ( isGLTF1( contents ) ) {
 
@@ -307,7 +309,7 @@ function Loader( editor ) {
 						const { DRACOLoader } = await import( 'three/addons/loaders/DRACOLoader.js' );
 						const { GLTFLoader } = await import( 'three/addons/loaders/GLTFLoader.js' );
 
-						const dracoLoader = new DRACOLoader();
+						dracoLoader = new DRACOLoader();
 						dracoLoader.setDecoderPath( '../examples/jsm/libs/draco/gltf/' );
 
 						loader = new GLTFLoader( manager );
@@ -323,6 +325,8 @@ function Loader( editor ) {
 						scene.animations.push( ...result.animations );
 						editor.execute( new AddObjectCommand( editor, scene ) );
 
+						dracoLoader.dispose();
+
 					} );
 
 				}, false );
@@ -968,6 +972,8 @@ function Loader( editor ) {
 						scene.animations.push( ...result.animations );
 						editor.execute( new AddObjectCommand( editor, scene ) );
 
+						dracoLoader.dispose();
+
 					} );
 
 					break;
@@ -993,6 +999,8 @@ function Loader( editor ) {
 						scene.animations.push( ...result.animations );
 						editor.execute( new AddObjectCommand( editor, scene ) );
 
+						dracoLoader.dispose();
+
 					} );
 
 					break;