Sfoglia il codice sorgente

Applying @Mugen87's suggestion

Brandon Jones 5 anni fa
parent
commit
bf3f60e129
2 ha cambiato i file con 18 aggiunte e 6 eliminazioni
  1. 4 5
      examples/jsm/loaders/GLTFLoader.js
  2. 14 1
      src/loaders/TextureLoader.js

+ 4 - 5
examples/jsm/loaders/GLTFLoader.js

@@ -1477,16 +1477,15 @@ var GLTFLoader = ( function () {
 		// BufferGeometry caching
 		this.primitiveCache = {};
 
+		this.textureLoader = new TextureLoader( this.options.manager );
+		this.textureLoader.setCrossOrigin( this.options.crossOrigin );
+
 		// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
 		// expensive work of uploading a texture to the GPU off the main thread.
-		var imageLoader = null;
 		if (typeof createImageBitmap !== 'undefined') {
-			imageLoader = new ImageBitmapLoader( this.options.manager );
+			this.textureLoader.setImageLoader( new ImageBitmapLoader( this.options.manager ) );
 		}
 
-		this.textureLoader = new TextureLoader( this.options.manager, imageLoader );
-		this.textureLoader.setCrossOrigin( this.options.crossOrigin );
-
 		this.fileLoader = new FileLoader( this.options.manager );
 		this.fileLoader.setResponseType( 'arraybuffer' );
 

+ 14 - 1
src/loaders/TextureLoader.js

@@ -11,7 +11,7 @@ function TextureLoader( manager, imageLoader ) {
 
 	Loader.call( this, manager );
 
-	this.imageLoader = imageLoader || new ImageLoader( manager );
+	this.imageLoader = null;
 
 }
 
@@ -23,6 +23,12 @@ TextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		const texture = new Texture();
 
+		if ( !this.imageLoader ) {
+
+			this.imageLoader = new ImageLoader( this.manager );
+
+		}
+
 		const loader = this.imageLoader;
 		loader.setCrossOrigin( this.crossOrigin );
 		loader.setPath( this.path );
@@ -47,6 +53,13 @@ TextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return texture;
 
+	},
+
+	setImageLoader: function ( imageLoader ) {
+
+		this.imageLoader = imageLoader;
+		return this;
+
 	}
 
 } );