Skip to content

Commit e96712e

Browse files
committed
ImageUtils: Use CubeTextureLoader in loadTextureCube.
1 parent 839efa1 commit e96712e

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

src/extras/ImageUtils.js

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,23 @@ THREE.ImageUtils = {
2020
}, undefined, onError );
2121

2222
texture.mapping = mapping;
23-
texture.sourceFile = url;
2423

2524
return texture;
2625

2726
},
2827

29-
loadTextureCube: function ( array, mapping, onLoad, onError ) {
28+
loadTextureCube: function ( urls, mapping, onLoad, onError ) {
3029

31-
var images = [];
32-
33-
var loader = new THREE.ImageLoader();
34-
loader.crossOrigin = this.crossOrigin;
35-
36-
var texture = new THREE.CubeTexture( images, mapping );
37-
38-
var loaded = 0;
39-
40-
function loadTexture( i ) {
41-
42-
loader.load( array[ i ], function ( image ) {
43-
44-
texture.images[ i ] = image;
45-
46-
loaded += 1;
47-
48-
if ( loaded === 6 ) {
49-
50-
texture.needsUpdate = true;
51-
52-
if ( onLoad ) onLoad( texture );
53-
54-
}
55-
56-
}, undefined, onError );
30+
var loader = new THREE.CubeTextureLoader();
31+
loader.setCrossOrigin( this.crossOrigin );
5732

58-
}
33+
var texture = loader.load( urls, function ( texture ) {
5934

60-
for ( var i = 0, il = array.length; i < il; ++ i ) {
35+
if ( onLoad ) onLoad( texture );
6136

62-
loadTexture( i );
37+
}, undefined, onError );
6338

64-
}
39+
texture.mapping = mapping;
6540

6641
return texture;
6742

src/loaders/TextureLoader.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ THREE.TextureLoader.prototype = {
1414

1515
load: function ( url, onLoad, onProgress, onError ) {
1616

17-
var scope = this;
18-
1917
var texture = new THREE.Texture();
2018

21-
var loader = new THREE.ImageLoader( scope.manager );
19+
var loader = new THREE.ImageLoader( this.manager );
2220
loader.setCrossOrigin( this.crossOrigin );
2321
loader.load( url, function ( image ) {
2422

0 commit comments

Comments
 (0)