Sfoglia il codice sorgente

Clean up Blob resources.

Don McCurdy 8 anni fa
parent
commit
bce22389bb
1 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 9 1
      examples/js/loaders/GLTF2Loader.js

+ 9 - 1
examples/js/loaders/GLTF2Loader.js

@@ -1074,11 +1074,13 @@ THREE.GLTF2Loader = ( function () {
 						var source = json.images[ texture.source ];
 						var sourceUri = source.uri;
 
+						var urlCreator;
+
 						if ( source.bufferView !== undefined ) {
 
 							var bufferView = dependencies.bufferViews[ source.bufferView ];
 							var blob = new Blob( [ bufferView ], { type: source.mimeType } );
-							var urlCreator = window.URL || window.webkitURL;
+							urlCreator = window.URL || window.webkitURL;
 							sourceUri = urlCreator.createObjectURL( blob );
 
 						}
@@ -1095,6 +1097,12 @@ THREE.GLTF2Loader = ( function () {
 
 						textureLoader.load( resolveURL( sourceUri, options.path ), function ( _texture ) {
 
+							if ( urlCreator !== undefined ) {
+
+								urlCreator.revokeObjectURL( sourceUri );
+
+							}
+
 							_texture.flipY = false;
 
 							if ( texture.name !== undefined ) _texture.name = texture.name;