Skip to content

Commit 6857b6d

Browse files
committed
removed deprecated THREE.ImageUtils.loadTexture
1 parent 3f5ac21 commit 6857b6d

File tree

76 files changed

+277
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+277
-209
lines changed

docs/api/objects/Sprite.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h1>[name]</h1>
1717
<h2>Example</h2>
1818

1919
<code>
20-
var map = THREE.ImageUtils.loadTexture( "sprite.png" );
20+
var map = new THREE.TextureLoader().load( "sprite.png" );
2121
var material = new THREE.SpriteMaterial( { map: map, color: 0xffffff, fog: true } );
2222
var sprite = new THREE.Sprite( material );
2323
scene.add( sprite );
@@ -48,7 +48,7 @@ <h3>[method:Sprite clone]()</h3>
4848
<div>
4949
This creates a new clone of the sprite.
5050
</div>
51-
51+
5252
<h3>[method:Object3D clone]([page:Object3D object])</h3>
5353
<div>
5454
object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned Sprite Object.

docs/api/textures/Texture.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h2>Example</h2>
2121

2222
<code>
2323
// load a texture, set wrap mode to repeat
24-
var texture = THREE.ImageUtils.loadTexture( "textures/water.jpg" );
24+
var texture = new THREE.TextureLoader().load( "textures/water.jpg" );
2525
texture.wrapS = THREE.RepeatWrapping;
2626
texture.wrapT = THREE.RepeatWrapping;
2727
texture.repeat.set( 4, 4 );
@@ -53,7 +53,7 @@ <h3>[property:number wrapT]</h3>
5353
<div>
5454
The default is THREE.ClampToEdgeWrapping, where the edge is clamped to the outer edge texels. The other two choices are THREE.RepeatWrapping and THREE.MirroredRepeatWrapping.
5555
</div>
56-
56+
5757
<div>
5858
NOTE: tiling of images in textures only functions if image dimensions are powers of two (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...) in terms of pixels. Individual dimensions need not be equal, but each must be a power of two. This is a limitation of WebGL, not Three.js.
5959
</div>

docs/scenes/js/material.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ var textureMaps = (function () {
125125

126126
return {
127127
none : null,
128-
grass : THREE.ImageUtils.loadTexture( "../../examples/textures/terrain/grasslight-thin.jpg" )
128+
grass : new THREE.TextureLoader().load( "../../examples/textures/terrain/grasslight-thin.jpg" )
129129
};
130130

131131
})();

examples/canvas_materials.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,22 @@
6767

6868
var geometry = new THREE.SphereGeometry( 100, 14, 7 );
6969

70+
var textureLoader = new THREE.TextureLoader();
71+
72+
var earthTexture = textureLoader.load( 'textures/land_ocean_ice_cloud_2048.jpg' );
73+
74+
var envMap = textureLoader.load( 'textures/envmap.png' );
75+
envMap.mapping = THREE.SphericalReflectionMapping;
76+
7077
var materials = [
7178

7279
new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true, side: THREE.DoubleSide } ),
7380
new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ),
74-
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: 0.5 } ),
75-
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading, overdraw: 0.5 } ),
81+
new THREE.MeshLambertMaterial( { color: 0xffffff, overdraw: 0.5 } ),
82+
new THREE.MeshLambertMaterial( { color: 0xffffff, overdraw: 0.5 } ),
7683
new THREE.MeshNormalMaterial( { overdraw: 0.5 } ),
77-
new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
78-
new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', THREE.SphericalReflectionMapping ), overdraw: 0.5 } )
84+
new THREE.MeshBasicMaterial( { map: earthTexture } ),
85+
new THREE.MeshBasicMaterial( { envMap: envMap, overdraw: 0.5 } )
7986

8087
];
8188

examples/canvas_materials_reflection.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@
6767

6868
geometry.computeVertexNormals();
6969

70-
mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', THREE.SphericalReflectionMapping ), overdraw: 0.5 } ) );
70+
var envMap = new THREE.TextureLoader().load( 'textures/metal.jpg' );
71+
envMap.mapping = THREE.SphericalReflectionMapping;
72+
73+
mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: envMap, overdraw: 0.5 } ) );
7174
scene.add( mesh );
7275

7376
} );

examples/canvas_sandbox.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@
9494

9595
geometry = new THREE.IcosahedronGeometry( 100, 1 );
9696

97-
material = new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', THREE.SphericalReflectionMapping ), overdraw: 0.5 } );
97+
var envMap = new THREE.TextureLoader().load( 'textures/metal.jpg' );
98+
envMap.mapping = THREE.SphericalReflectionMapping;
99+
100+
material = new THREE.MeshBasicMaterial( { envMap: envMap, overdraw: 0.5 } );
98101

99102
for ( var i = 0; i < 10; i ++ ) {
100103

examples/js/GPUParticleSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,12 @@ THREE.GPUParticleSystem = function(options) {
198198
return ++i >= self.rand.length ? self.rand[i = 1] : self.rand[i];
199199
}
200200

201-
self.particleNoiseTex = THREE.ImageUtils.loadTexture("textures/perlin-512.png");
201+
var textureLoader = new THREE.TextureLoader();
202+
203+
self.particleNoiseTex = textureLoader.load("textures/perlin-512.png");
202204
self.particleNoiseTex.wrapS = self.particleNoiseTex.wrapT = THREE.RepeatWrapping;
203205

204-
self.particleSpriteTex = THREE.ImageUtils.loadTexture("textures/particle2.png");
206+
self.particleSpriteTex = textureLoader.load("textures/particle2.png");
205207
self.particleSpriteTex.wrapS = self.particleSpriteTex.wrapT = THREE.RepeatWrapping;
206208

207209
self.particleShaderMat = new THREE.ShaderMaterial({

examples/js/MD2Character.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ THREE.MD2Character = function () {
212212
}
213213

214214
}
215-
215+
216216
}
217217

218218
this.update = function ( delta ) {
@@ -228,7 +228,8 @@ THREE.MD2Character = function () {
228228

229229
for ( var i = 0; i < textureUrls.length; i ++ ) {
230230

231-
textures[ i ] = THREE.ImageUtils.loadTexture( baseUrl + textureUrls[ i ], mapping, checkLoadingComplete );
231+
textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], checkLoadingComplete );
232+
textures[ i ].mapping = mapping;
232233
textures[ i ].name = textureUrls[ i ];
233234

234235
}
@@ -254,7 +255,7 @@ THREE.MD2Character = function () {
254255

255256
mesh.materialTexture = materialTexture;
256257
mesh.materialWireframe = materialWireframe;
257-
258+
258259
return mesh;
259260

260261
}

examples/js/MD2CharacterComplex.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,9 @@ THREE.MD2CharacterComplex = function () {
510510
var textures = [];
511511

512512
for ( var i = 0; i < textureUrls.length; i ++ ) {
513-
514-
textures[ i ] = THREE.ImageUtils.loadTexture( baseUrl + textureUrls[ i ], mapping, checkLoadingComplete );
513+
514+
textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], checkLoadingComplete );
515+
textures[ i ].mapping = mapping;
515516
textures[ i ].name = textureUrls[ i ];
516517

517518
}

examples/js/UCSCharacter.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
THREE.UCSCharacter = function() {
22

33
var scope = this;
4-
4+
55
var mesh;
66

77
this.scale = 1;
88

99
this.root = new THREE.Object3D();
10-
10+
1111
this.numSkins;
1212
this.numMorphs;
13-
13+
1414
this.skins = [];
1515
this.materials = [];
1616
this.morphs = [];
1717

1818
this.mixer = new THREE.AnimationMixer( this.root );
1919

2020
this.onLoadComplete = function () {};
21-
21+
2222
this.loadCounter = 0;
2323

2424
this.loadParts = function ( config ) {
25-
25+
2626
this.numSkins = config.skins.length;
2727
this.numMorphs = config.morphs.length;
28-
28+
2929
// Character geometry + number of skins
3030
this.loadCounter = 1 + config.skins.length;
31-
31+
3232
// SKINS
3333
this.skins = loadTextures( config.baseUrl + "skins/", config.skins );
3434
this.materials = createMaterials( this.skins );
35-
35+
3636
// MORPHS
3737
this.morphs = config.morphs;
38-
38+
3939
// CHARACTER
4040
var loader = new THREE.JSONLoader();
4141
console.log( config.baseUrl + config.character );
4242
loader.load( config.baseUrl + config.character, function( geometry ) {
4343

4444
geometry.computeBoundingBox();
4545
geometry.computeVertexNormals();
46-
46+
4747
mesh = new THREE.SkinnedMesh( geometry, new THREE.MeshFaceMaterial() );
4848
mesh.name = config.character;
4949
scope.root.add( mesh );
50-
50+
5151
var bb = geometry.boundingBox;
5252
scope.root.scale.set( config.s, config.s, config.s );
5353
scope.root.position.set( config.x, config.y - bb.min.y * config.s, config.z );
@@ -56,15 +56,15 @@ THREE.UCSCharacter = function() {
5656
mesh.receiveShadow = true;
5757

5858
scope.mixer.clipAction( geometry.animations[0], mesh ).play();
59-
59+
6060
scope.setSkin( 0 );
61-
61+
6262
scope.checkLoadComplete();
6363

6464
} );
6565

6666
};
67-
67+
6868
this.setSkin = function( index ) {
6969

7070
if ( mesh && scope.materials ) {
@@ -74,7 +74,7 @@ THREE.UCSCharacter = function() {
7474
}
7575

7676
};
77-
77+
7878
this.updateMorphs = function( influences ) {
7979

8080
if ( mesh ) {
@@ -88,15 +88,16 @@ THREE.UCSCharacter = function() {
8888
}
8989

9090
};
91-
91+
9292
function loadTextures( baseUrl, textureUrls ) {
9393

9494
var mapping = THREE.UVMapping;
9595
var textures = [];
9696

9797
for ( var i = 0; i < textureUrls.length; i ++ ) {
9898

99-
textures[ i ] = THREE.ImageUtils.loadTexture( baseUrl + textureUrls[ i ], mapping, scope.checkLoadComplete );
99+
textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], scope.checkLoadingComplete );
100+
textures[ i ].mapping = mapping;
100101
textures[ i ].name = textureUrls[ i ];
101102

102103
}
@@ -108,7 +109,7 @@ THREE.UCSCharacter = function() {
108109
function createMaterials( skins ) {
109110

110111
var materials = [];
111-
112+
112113
for ( var i = 0; i < skins.length; i ++ ) {
113114

114115
materials[ i ] = new THREE.MeshLambertMaterial( {
@@ -120,7 +121,7 @@ THREE.UCSCharacter = function() {
120121
} );
121122

122123
}
123-
124+
124125
return materials;
125126

126127
}

0 commit comments

Comments
 (0)