@@ -14339,16 +14339,16 @@ THREE.Loader.prototype = {
14339
14339
14340
14340
if ( repeat !== undefined ) {
14341
14341
14342
- texture.repeat.set ( repeat[ 0 ], repeat[ 1 ] );
14342
+ texture.repeat.fromArray ( repeat );
14343
14343
14344
- if ( repeat[ 0 ] > 1 ) texture.wrapS = THREE.RepeatWrapping;
14345
- if ( repeat[ 1 ] > 1 ) texture.wrapT = THREE.RepeatWrapping;
14344
+ if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
14345
+ if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
14346
14346
14347
14347
}
14348
14348
14349
14349
if ( offset !== undefined ) {
14350
14350
14351
- texture.offset.set ( offset[ 0 ], offset[ 1 ] );
14351
+ texture.offset.fromArray ( offset );
14352
14352
14353
14353
}
14354
14354
@@ -14419,31 +14419,31 @@ THREE.Loader.prototype = {
14419
14419
if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial';
14420
14420
break;
14421
14421
case 'mapDiffuse':
14422
- json.map = loadTexture( value, json .mapDiffuseRepeat, json .mapDiffuseOffset, json .mapDiffuseWrap, json .mapDiffuseAnisotropy );
14422
+ json.map = loadTexture( value, m .mapDiffuseRepeat, m .mapDiffuseOffset, m .mapDiffuseWrap, m .mapDiffuseAnisotropy );
14423
14423
break;
14424
14424
case 'mapDiffuseRepeat':
14425
14425
case 'mapDiffuseOffset':
14426
14426
case 'mapDiffuseWrap':
14427
14427
case 'mapDiffuseAnisotropy':
14428
14428
break;
14429
14429
case 'mapLight':
14430
- json.lightMap = loadTexture( value, json .mapLightRepeat, json .mapLightOffset, json .mapLightWrap, json .mapLightAnisotropy );
14430
+ json.lightMap = loadTexture( value, m .mapLightRepeat, m .mapLightOffset, m .mapLightWrap, m .mapLightAnisotropy );
14431
14431
break;
14432
14432
case 'mapLightRepeat':
14433
14433
case 'mapLightOffset':
14434
14434
case 'mapLightWrap':
14435
14435
case 'mapLightAnisotropy':
14436
14436
break;
14437
14437
case 'mapAO':
14438
- json.aoMap = loadTexture( value, json .mapAORepeat, json .mapAOOffset, json .mapAOWrap, json .mapAOAnisotropy );
14438
+ json.aoMap = loadTexture( value, m .mapAORepeat, m .mapAOOffset, m .mapAOWrap, m .mapAOAnisotropy );
14439
14439
break;
14440
14440
case 'mapAORepeat':
14441
14441
case 'mapAOOffset':
14442
14442
case 'mapAOWrap':
14443
14443
case 'mapAOAnisotropy':
14444
14444
break;
14445
14445
case 'mapBump':
14446
- json.bumpMap = loadTexture( value, json .mapBumpRepeat, json .mapBumpOffset, json .mapBumpWrap, json .mapBumpAnisotropy );
14446
+ json.bumpMap = loadTexture( value, m .mapBumpRepeat, m .mapBumpOffset, m .mapBumpWrap, m .mapBumpAnisotropy );
14447
14447
break;
14448
14448
case 'mapBumpScale':
14449
14449
json.bumpScale = value;
@@ -14454,7 +14454,7 @@ THREE.Loader.prototype = {
14454
14454
case 'mapBumpAnisotropy':
14455
14455
break;
14456
14456
case 'mapNormal':
14457
- json.normalMap = loadTexture( value, json .mapNormalRepeat, json .mapNormalOffset, json .mapNormalWrap, json .mapNormalAnisotropy );
14457
+ json.normalMap = loadTexture( value, m .mapNormalRepeat, m .mapNormalOffset, m .mapNormalWrap, m .mapNormalAnisotropy );
14458
14458
break;
14459
14459
case 'mapNormalFactor':
14460
14460
json.normalScale = [ value, value ];
@@ -14465,15 +14465,15 @@ THREE.Loader.prototype = {
14465
14465
case 'mapNormalAnisotropy':
14466
14466
break;
14467
14467
case 'mapSpecular':
14468
- json.specularMap = loadTexture( value, json .mapSpecularRepeat, json .mapSpecularOffset, json .mapSpecularWrap, json .mapSpecularAnisotropy );
14468
+ json.specularMap = loadTexture( value, m .mapSpecularRepeat, m .mapSpecularOffset, m .mapSpecularWrap, m .mapSpecularAnisotropy );
14469
14469
break;
14470
14470
case 'mapSpecularRepeat':
14471
14471
case 'mapSpecularOffset':
14472
14472
case 'mapSpecularWrap':
14473
14473
case 'mapSpecularAnisotropy':
14474
14474
break;
14475
14475
case 'mapAlpha':
14476
- json.alphaMap = loadTexture( value, json .mapAlphaRepeat, json .mapAlphaOffset, json .mapAlphaWrap, json .mapAlphaAnisotropy );
14476
+ json.alphaMap = loadTexture( value, m .mapAlphaRepeat, m .mapAlphaOffset, m .mapAlphaWrap, m .mapAlphaAnisotropy );
14477
14477
break;
14478
14478
case 'mapAlphaRepeat':
14479
14479
case 'mapAlphaOffset':
@@ -16260,11 +16260,9 @@ THREE.TextureLoader.prototype = {
16260
16260
16261
16261
load: function ( url, onLoad, onProgress, onError ) {
16262
16262
16263
- var scope = this;
16264
-
16265
16263
var texture = new THREE.Texture();
16266
16264
16267
- var loader = new THREE.ImageLoader( scope .manager );
16265
+ var loader = new THREE.ImageLoader( this .manager );
16268
16266
loader.setCrossOrigin( this.crossOrigin );
16269
16267
loader.load( url, function ( image ) {
16270
16268
@@ -16291,6 +16289,69 @@ THREE.TextureLoader.prototype = {
16291
16289
16292
16290
};
16293
16291
16292
+ // File:src/loaders/CubeTextureLoader.js
16293
+
16294
+ /**
16295
+ * @author mrdoob / http://mrdoob.com/
16296
+ */
16297
+
16298
+ THREE.CubeTextureLoader = function ( manager ) {
16299
+
16300
+ this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
16301
+
16302
+ };
16303
+
16304
+ THREE.CubeTextureLoader.prototype = {
16305
+
16306
+ constructor: THREE.CubeTextureLoader,
16307
+
16308
+ load: function ( urls, onLoad, onProgress, onError ) {
16309
+
16310
+ var texture = new THREE.CubeTexture( [] );
16311
+
16312
+ var loader = new THREE.ImageLoader();
16313
+ loader.setCrossOrigin( this.crossOrigin );
16314
+
16315
+ var loaded = 0;
16316
+
16317
+ function loadTexture( i ) {
16318
+
16319
+ loader.load( urls[ i ], function ( image ) {
16320
+
16321
+ texture.images[ i ] = image;
16322
+
16323
+ loaded ++;
16324
+
16325
+ if ( loaded === 6 ) {
16326
+
16327
+ texture.needsUpdate = true;
16328
+
16329
+ if ( onLoad ) onLoad( texture );
16330
+
16331
+ }
16332
+
16333
+ }, undefined, onError );
16334
+
16335
+ }
16336
+
16337
+ for ( var i = 0; i < urls.length; ++ i ) {
16338
+
16339
+ loadTexture( i );
16340
+
16341
+ }
16342
+
16343
+ return texture;
16344
+
16345
+ },
16346
+
16347
+ setCrossOrigin: function ( value ) {
16348
+
16349
+ this.crossOrigin = value;
16350
+
16351
+ }
16352
+
16353
+ };
16354
+
16294
16355
// File:src/loaders/BinaryTextureLoader.js
16295
16356
16296
16357
/**
@@ -28207,58 +28268,27 @@ THREE.ImageUtils = {
28207
28268
28208
28269
loadTexture: function ( url, mapping, onLoad, onError ) {
28209
28270
28271
+ console.warn( 'THREE.ImageUtils.loadTexture is being deprecated. Use THREE.TextureLoader() instead.' );
28272
+
28210
28273
var loader = new THREE.TextureLoader();
28211
28274
loader.setCrossOrigin( this.crossOrigin );
28212
28275
28213
- var texture = loader.load( url, function ( texture ) {
28214
-
28215
- if ( onLoad ) onLoad( texture );
28216
-
28217
- }, undefined, onError );
28218
-
28276
+ var texture = loader.load( url, onLoad, undefined, onError );
28219
28277
texture.mapping = mapping;
28220
- texture.sourceFile = url;
28221
28278
28222
28279
return texture;
28223
28280
28224
28281
},
28225
28282
28226
- loadTextureCube: function ( array, mapping, onLoad, onError ) {
28227
-
28228
- var images = [];
28229
-
28230
- var loader = new THREE.ImageLoader();
28231
- loader.crossOrigin = this.crossOrigin;
28232
-
28233
- var texture = new THREE.CubeTexture( images, mapping );
28234
-
28235
- var loaded = 0;
28236
-
28237
- function loadTexture( i ) {
28238
-
28239
- loader.load( array[ i ], function ( image ) {
28240
-
28241
- texture.images[ i ] = image;
28242
-
28243
- loaded += 1;
28244
-
28245
- if ( loaded === 6 ) {
28246
-
28247
- texture.needsUpdate = true;
28248
-
28249
- if ( onLoad ) onLoad( texture );
28283
+ loadTextureCube: function ( urls, mapping, onLoad, onError ) {
28250
28284
28251
- }
28252
-
28253
- }, undefined, onError );
28254
-
28255
- }
28285
+ console.warn( 'THREE.ImageUtils.loadTextureCube is being deprecated. Use THREE.CubeTextureLoader() instead.' );
28256
28286
28257
- for ( var i = 0, il = array.length; i < il; ++ i ) {
28258
-
28259
- loadTexture( i );
28287
+ var loader = new THREE.CubeTextureLoader();
28288
+ loader.setCrossOrigin( this.crossOrigin );
28260
28289
28261
- }
28290
+ var texture = loader.load( urls, onLoad, undefined, onError );
28291
+ texture.mapping = mapping;
28262
28292
28263
28293
return texture;
28264
28294
@@ -28274,133 +28304,6 @@ THREE.ImageUtils = {
28274
28304
28275
28305
console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' )
28276
28306
28277
- },
28278
-
28279
- getNormalMap: function ( image, depth ) {
28280
-
28281
- // Adapted from http://www.paulbrunt.co.uk/lab/heightnormal/
28282
-
28283
- function cross( a, b ) {
28284
-
28285
- return [ a[ 1 ] * b[ 2 ] - a[ 2 ] * b[ 1 ], a[ 2 ] * b[ 0 ] - a[ 0 ] * b[ 2 ], a[ 0 ] * b[ 1 ] - a[ 1 ] * b[ 0 ] ];
28286
-
28287
- }
28288
-
28289
- function subtract( a, b ) {
28290
-
28291
- return [ a[ 0 ] - b[ 0 ], a[ 1 ] - b[ 1 ], a[ 2 ] - b[ 2 ] ];
28292
-
28293
- }
28294
-
28295
- function normalize( a ) {
28296
-
28297
- var l = Math.sqrt( a[ 0 ] * a[ 0 ] + a[ 1 ] * a[ 1 ] + a[ 2 ] * a[ 2 ] );
28298
- return [ a[ 0 ] / l, a[ 1 ] / l, a[ 2 ] / l ];
28299
-
28300
- }
28301
-
28302
- depth = depth | 1;
28303
-
28304
- var width = image.width;
28305
- var height = image.height;
28306
-
28307
- var canvas = document.createElement( 'canvas' );
28308
- canvas.width = width;
28309
- canvas.height = height;
28310
-
28311
- var context = canvas.getContext( '2d' );
28312
- context.drawImage( image, 0, 0 );
28313
-
28314
- var data = context.getImageData( 0, 0, width, height ).data;
28315
- var imageData = context.createImageData( width, height );
28316
- var output = imageData.data;
28317
-
28318
- for ( var x = 0; x < width; x ++ ) {
28319
-
28320
- for ( var y = 0; y < height; y ++ ) {
28321
-
28322
- var ly = y - 1 < 0 ? 0 : y - 1;
28323
- var uy = y + 1 > height - 1 ? height - 1 : y + 1;
28324
- var lx = x - 1 < 0 ? 0 : x - 1;
28325
- var ux = x + 1 > width - 1 ? width - 1 : x + 1;
28326
-
28327
- var points = [];
28328
- var origin = [ 0, 0, data[ ( y * width + x ) * 4 ] / 255 * depth ];
28329
- points.push( [ - 1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] );
28330
- points.push( [ - 1, - 1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] );
28331
- points.push( [ 0, - 1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] );
28332
- points.push( [ 1, - 1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] );
28333
- points.push( [ 1, 0, data[ ( y * width + ux ) * 4 ] / 255 * depth ] );
28334
- points.push( [ 1, 1, data[ ( uy * width + ux ) * 4 ] / 255 * depth ] );
28335
- points.push( [ 0, 1, data[ ( uy * width + x ) * 4 ] / 255 * depth ] );
28336
- points.push( [ - 1, 1, data[ ( uy * width + lx ) * 4 ] / 255 * depth ] );
28337
-
28338
- var normals = [];
28339
- var num_points = points.length;
28340
-
28341
- for ( var i = 0; i < num_points; i ++ ) {
28342
-
28343
- var v1 = points[ i ];
28344
- var v2 = points[ ( i + 1 ) % num_points ];
28345
- v1 = subtract( v1, origin );
28346
- v2 = subtract( v2, origin );
28347
- normals.push( normalize( cross( v1, v2 ) ) );
28348
-
28349
- }
28350
-
28351
- var normal = [ 0, 0, 0 ];
28352
-
28353
- for ( var i = 0; i < normals.length; i ++ ) {
28354
-
28355
- normal[ 0 ] += normals[ i ][ 0 ];
28356
- normal[ 1 ] += normals[ i ][ 1 ];
28357
- normal[ 2 ] += normals[ i ][ 2 ];
28358
-
28359
- }
28360
-
28361
- normal[ 0 ] /= normals.length;
28362
- normal[ 1 ] /= normals.length;
28363
- normal[ 2 ] /= normals.length;
28364
-
28365
- var idx = ( y * width + x ) * 4;
28366
-
28367
- output[ idx ] = ( ( normal[ 0 ] + 1.0 ) / 2.0 * 255 ) | 0;
28368
- output[ idx + 1 ] = ( ( normal[ 1 ] + 1.0 ) / 2.0 * 255 ) | 0;
28369
- output[ idx + 2 ] = ( normal[ 2 ] * 255 ) | 0;
28370
- output[ idx + 3 ] = 255;
28371
-
28372
- }
28373
-
28374
- }
28375
-
28376
- context.putImageData( imageData, 0, 0 );
28377
-
28378
- return canvas;
28379
-
28380
- },
28381
-
28382
- generateDataTexture: function ( width, height, color ) {
28383
-
28384
- var size = width * height;
28385
- var data = new Uint8Array( 3 * size );
28386
-
28387
- var r = Math.floor( color.r * 255 );
28388
- var g = Math.floor( color.g * 255 );
28389
- var b = Math.floor( color.b * 255 );
28390
-
28391
- for ( var i = 0; i < size; i ++ ) {
28392
-
28393
- data[ i * 3 ] = r;
28394
- data[ i * 3 + 1 ] = g;
28395
- data[ i * 3 + 2 ] = b;
28396
-
28397
- }
28398
-
28399
- var texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat );
28400
- texture.needsUpdate = true;
28401
-
28402
- return texture;
28403
-
28404
28307
}
28405
28308
28406
28309
};
0 commit comments