Browse Source

Merge pull request #10829 from yomotsu/feature/textureload

To detect texture loaded for Loaders
Mr.doob 8 years ago
parent
commit
613b6e86e2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/loaders/TextureLoader.js

+ 2 - 2
src/loaders/TextureLoader.js

@@ -23,13 +23,12 @@ Object.assign( TextureLoader.prototype, {
 		var loader = new ImageLoader( this.manager );
 		loader.setCrossOrigin( this.crossOrigin );
 		loader.setPath( this.path );
-		loader.load( url, function ( image ) {
+		var image = loader.load( url, function ( image ) {
 
 			// JPEGs can't have an alpha channel, so memory can be saved by storing them as RGB.
 			var isJPEG = url.search( /\.(jpg|jpeg)$/ ) > 0 || url.search( /^data\:image\/jpeg/ ) === 0;
 
 			texture.format = isJPEG ? RGBFormat : RGBAFormat;
-			texture.image = image;
 			texture.needsUpdate = true;
 
 			if ( onLoad !== undefined ) {
@@ -40,6 +39,7 @@ Object.assign( TextureLoader.prototype, {
 
 		}, onProgress, onError );
 
+		texture.image = image;
 		return texture;
 
 	},