Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed deprecated THREE.ImageUtils.loadTexture in all examples and docs #7988

Merged
merged 2 commits into from
Jan 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api/objects/Sprite.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>[name]</h1>
<h2>Example</h2>

<code>
var map = THREE.ImageUtils.loadTexture( "sprite.png" );
var map = new THREE.TextureLoader().load( "sprite.png" );
var material = new THREE.SpriteMaterial( { map: map, color: 0xffffff, fog: true } );
var sprite = new THREE.Sprite( material );
scene.add( sprite );
Expand Down Expand Up @@ -48,7 +48,7 @@ <h3>[method:Sprite clone]()</h3>
<div>
This creates a new clone of the sprite.
</div>

<h3>[method:Object3D clone]([page:Object3D object])</h3>
<div>
object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned Sprite Object.
Expand Down
4 changes: 2 additions & 2 deletions docs/api/textures/Texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>Example</h2>

<code>
// load a texture, set wrap mode to repeat
var texture = THREE.ImageUtils.loadTexture( "textures/water.jpg" );
var texture = new THREE.TextureLoader().load( "textures/water.jpg" );
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 4, 4 );
Expand Down Expand Up @@ -53,7 +53,7 @@ <h3>[property:number wrapT]</h3>
<div>
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.
</div>

<div>
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.
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/scenes/js/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var textureMaps = (function () {

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

})();
Expand Down
15 changes: 11 additions & 4 deletions examples/canvas_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,22 @@

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

var textureLoader = new THREE.TextureLoader();

var earthTexture = textureLoader.load( 'textures/land_ocean_ice_cloud_2048.jpg' );

var envMap = textureLoader.load( 'textures/envmap.png' );
envMap.mapping = THREE.SphericalReflectionMapping;

var materials = [

new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true, side: THREE.DoubleSide } ),
new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ),
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: 0.5 } ),
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading, overdraw: 0.5 } ),
new THREE.MeshLambertMaterial( { color: 0xffffff, overdraw: 0.5 } ),
new THREE.MeshLambertMaterial( { color: 0xffffff, overdraw: 0.5 } ),
new THREE.MeshNormalMaterial( { overdraw: 0.5 } ),
new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', THREE.SphericalReflectionMapping ), overdraw: 0.5 } )
new THREE.MeshBasicMaterial( { map: earthTexture } ),
new THREE.MeshBasicMaterial( { envMap: envMap, overdraw: 0.5 } )

];

Expand Down
5 changes: 4 additions & 1 deletion examples/canvas_materials_reflection.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@

geometry.computeVertexNormals();

mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', THREE.SphericalReflectionMapping ), overdraw: 0.5 } ) );
var envMap = new THREE.TextureLoader().load( 'textures/metal.jpg' );
envMap.mapping = THREE.SphericalReflectionMapping;

mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: envMap, overdraw: 0.5 } ) );
scene.add( mesh );

} );
Expand Down
5 changes: 4 additions & 1 deletion examples/canvas_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@

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

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

material = new THREE.MeshBasicMaterial( { envMap: envMap, overdraw: 0.5 } );

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

Expand Down
6 changes: 4 additions & 2 deletions examples/js/GPUParticleSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ THREE.GPUParticleSystem = function(options) {
return ++i >= self.rand.length ? self.rand[i = 1] : self.rand[i];
}

self.particleNoiseTex = THREE.ImageUtils.loadTexture("textures/perlin-512.png");
var textureLoader = new THREE.TextureLoader();

self.particleNoiseTex = textureLoader.load("textures/perlin-512.png");
self.particleNoiseTex.wrapS = self.particleNoiseTex.wrapT = THREE.RepeatWrapping;

self.particleSpriteTex = THREE.ImageUtils.loadTexture("textures/particle2.png");
self.particleSpriteTex = textureLoader.load("textures/particle2.png");
self.particleSpriteTex.wrapS = self.particleSpriteTex.wrapT = THREE.RepeatWrapping;

self.particleShaderMat = new THREE.ShaderMaterial({
Expand Down
7 changes: 4 additions & 3 deletions examples/js/MD2Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ THREE.MD2Character = function () {
}

}

}

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

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

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

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

mesh.materialTexture = materialTexture;
mesh.materialWireframe = materialWireframe;

return mesh;

}
Expand Down
5 changes: 3 additions & 2 deletions examples/js/MD2CharacterComplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,9 @@ THREE.MD2CharacterComplex = function () {
var textures = [];

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

textures[ i ] = THREE.ImageUtils.loadTexture( baseUrl + textureUrls[ i ], mapping, checkLoadingComplete );

textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], checkLoadingComplete );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are multiple instances of the loader required for some reason?

textures[ i ].mapping = mapping;
textures[ i ].name = textureUrls[ i ];

}
Expand Down
39 changes: 20 additions & 19 deletions examples/js/UCSCharacter.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
THREE.UCSCharacter = function() {

var scope = this;

var mesh;

this.scale = 1;

this.root = new THREE.Object3D();

this.numSkins;
this.numMorphs;

this.skins = [];
this.materials = [];
this.morphs = [];

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

this.onLoadComplete = function () {};

this.loadCounter = 0;

this.loadParts = function ( config ) {

this.numSkins = config.skins.length;
this.numMorphs = config.morphs.length;

// Character geometry + number of skins
this.loadCounter = 1 + config.skins.length;

// SKINS
this.skins = loadTextures( config.baseUrl + "skins/", config.skins );
this.materials = createMaterials( this.skins );

// MORPHS
this.morphs = config.morphs;

// CHARACTER
var loader = new THREE.JSONLoader();
console.log( config.baseUrl + config.character );
loader.load( config.baseUrl + config.character, function( geometry ) {

geometry.computeBoundingBox();
geometry.computeVertexNormals();

mesh = new THREE.SkinnedMesh( geometry, new THREE.MeshFaceMaterial() );
mesh.name = config.character;
scope.root.add( mesh );

var bb = geometry.boundingBox;
scope.root.scale.set( config.s, config.s, config.s );
scope.root.position.set( config.x, config.y - bb.min.y * config.s, config.z );
Expand All @@ -56,15 +56,15 @@ THREE.UCSCharacter = function() {
mesh.receiveShadow = true;

scope.mixer.clipAction( geometry.animations[0], mesh ).play();

scope.setSkin( 0 );

scope.checkLoadComplete();

} );

};

this.setSkin = function( index ) {

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

};

this.updateMorphs = function( influences ) {

if ( mesh ) {
Expand All @@ -88,15 +88,16 @@ THREE.UCSCharacter = function() {
}

};

function loadTextures( baseUrl, textureUrls ) {

var mapping = THREE.UVMapping;
var textures = [];

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

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

}
Expand All @@ -108,7 +109,7 @@ THREE.UCSCharacter = function() {
function createMaterials( skins ) {

var materials = [];

for ( var i = 0; i < skins.length; i ++ ) {

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

}

return materials;

}
Expand Down
4 changes: 2 additions & 2 deletions examples/js/loaders/sea3d/SEA3DLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ THREE.SEA3D.prototype.readImage = function( sea ) {

var image = new Image(), texture = new THREE.Texture();
image.src = this.bufferToTexture( sea.data.buffer );

texture.name = sea.name;
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.flipY = false;
Expand Down Expand Up @@ -1583,7 +1583,7 @@ THREE.SEA3D.prototype.readSound = function( sea ) {

THREE.SEA3D.prototype.readTextureURL = function( sea ) {

var texture = THREE.ImageUtils.loadTexture( sea.url );
var texture = new THREE.TextureLoader().load( sea.url );

texture.name = sea.name;
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
Expand Down
3 changes: 2 additions & 1 deletion examples/misc_animation_authoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
scene.add( light );


var texture = THREE.ImageUtils.loadTexture( 'textures/crate.gif', THREE.UVMapping, render );
var texture = new THREE.TextureLoader().load( 'textures/crate.gif', render );
texture.mapping = THREE.UVMapping;
texture.anisotropy = renderer.getMaxAnisotropy();

var geometry = new THREE.BoxGeometry( 200, 200, 200 );
Expand Down
2 changes: 1 addition & 1 deletion examples/misc_controls_deviceorientation.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
geometry.scale( - 1, 1, 1 );

var material = new THREE.MeshBasicMaterial( {
map: THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' )
map: new THREE.TextureLoader().load( 'textures/2294472375_24a3b8ef46_o.jpg' )
} );

var mesh = new THREE.Mesh( geometry, material );
Expand Down
4 changes: 2 additions & 2 deletions examples/misc_controls_transform.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
light.position.set( 1, 1, 1 );
scene.add( light );


var texture = THREE.ImageUtils.loadTexture( 'textures/crate.gif', THREE.UVMapping, render );
var texture = new THREE.TextureLoader().load( 'textures/crate.gif', render );
texture.mapping = THREE.UVMapping;
texture.anisotropy = renderer.getMaxAnisotropy();

var geometry = new THREE.BoxGeometry( 200, 200, 200 );
Expand Down
2 changes: 1 addition & 1 deletion examples/misc_fps.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
function makePlatform( jsonUrl, textureUrl, textureQuality ) {
var placeholder = new THREE.Object3D();

var texture = THREE.ImageUtils.loadTexture( textureUrl );
var texture = new THREE.TextureLoader().load( textureUrl );
texture.minFilter = THREE.LinearFilter;
texture.anisotropy = textureQuality;

Expand Down
6 changes: 4 additions & 2 deletions examples/misc_ubiquity_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@

// SPRITES

THREE.ImageUtils.loadTexture( 'textures/sprite.png', null, function ( texture ) {
var textureLoader = new THREE.TextureLoader();

textureLoader.load( 'textures/sprite.png', function ( texture ) {

var material = new THREE.SpriteMaterial( { map: texture, transparent: true } );

Expand All @@ -159,7 +161,7 @@
scene.add( sprite );

}

} );

for ( var i = 0; i < 50; i ++ ) {
Expand Down
9 changes: 5 additions & 4 deletions examples/misc_ubiquity_test2.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@

scene = new THREE.Scene();

var textureLoader = new THREE.TextureLoader();

// MESH - Repeat Pattern

texture = THREE.ImageUtils.loadTexture( 'textures/UV_Grid_Sm.jpg' );
texture = textureLoader.load( 'textures/UV_Grid_Sm.jpg' );
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;

Expand All @@ -63,7 +64,7 @@

// SPRITES - from Sprite Sheet

texture1 = THREE.ImageUtils.loadTexture( 'textures/UV_Grid_Sm.jpg', undefined, function() {
texture1 = textureLoader.load( 'textures/UV_Grid_Sm.jpg', function() {

texture1.wrapS = THREE.ClampToEdgeWrapping;
texture1.wrapT = THREE.ClampToEdgeWrapping;
Expand Down Expand Up @@ -99,7 +100,7 @@

// SPRITES - Repeat Pattern

texture2 = THREE.ImageUtils.loadTexture( 'textures/sprite0.jpg' );
texture2 = textureLoader.load( 'textures/sprite0.jpg' );
texture2.wrapS = THREE.RepeatWrapping;
texture2.wrapT = THREE.RepeatWrapping;

Expand All @@ -123,7 +124,7 @@

// SPRITES - PNG

texture3 = THREE.ImageUtils.loadTexture( 'textures/sprite1.png' );
texture3 = textureLoader.load( 'textures/sprite1.png' );
texture3.wrapS = THREE.ClampToEdgeWrapping;
texture3.wrapT = THREE.ClampToEdgeWrapping;

Expand Down
Loading