From 36f4f45ab4e902b1f58b84bcb22c8aa786371a8a Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 14 Oct 2015 14:00:26 -0400 Subject: [PATCH] Updated builds. --- build/three.js | 265 ++++++++++++++------------------------------- build/three.min.js | 31 +++--- 2 files changed, 99 insertions(+), 197 deletions(-) diff --git a/build/three.js b/build/three.js index 453c3c6d59..ca07552099 100644 --- a/build/three.js +++ b/build/three.js @@ -14339,16 +14339,16 @@ THREE.Loader.prototype = { if ( repeat !== undefined ) { - texture.repeat.set( repeat[ 0 ], repeat[ 1 ] ); + texture.repeat.fromArray( repeat ); - if ( repeat[ 0 ] > 1 ) texture.wrapS = THREE.RepeatWrapping; - if ( repeat[ 1 ] > 1 ) texture.wrapT = THREE.RepeatWrapping; + if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping; + if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping; } if ( offset !== undefined ) { - texture.offset.set( offset[ 0 ], offset[ 1 ] ); + texture.offset.fromArray( offset ); } @@ -14419,7 +14419,7 @@ THREE.Loader.prototype = { if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; break; case 'mapDiffuse': - json.map = loadTexture( value, json.mapDiffuseRepeat, json.mapDiffuseOffset, json.mapDiffuseWrap, json.mapDiffuseAnisotropy ); + json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy ); break; case 'mapDiffuseRepeat': case 'mapDiffuseOffset': @@ -14427,7 +14427,7 @@ THREE.Loader.prototype = { case 'mapDiffuseAnisotropy': break; case 'mapLight': - json.lightMap = loadTexture( value, json.mapLightRepeat, json.mapLightOffset, json.mapLightWrap, json.mapLightAnisotropy ); + json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy ); break; case 'mapLightRepeat': case 'mapLightOffset': @@ -14435,7 +14435,7 @@ THREE.Loader.prototype = { case 'mapLightAnisotropy': break; case 'mapAO': - json.aoMap = loadTexture( value, json.mapAORepeat, json.mapAOOffset, json.mapAOWrap, json.mapAOAnisotropy ); + json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy ); break; case 'mapAORepeat': case 'mapAOOffset': @@ -14443,7 +14443,7 @@ THREE.Loader.prototype = { case 'mapAOAnisotropy': break; case 'mapBump': - json.bumpMap = loadTexture( value, json.mapBumpRepeat, json.mapBumpOffset, json.mapBumpWrap, json.mapBumpAnisotropy ); + json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy ); break; case 'mapBumpScale': json.bumpScale = value; @@ -14454,7 +14454,7 @@ THREE.Loader.prototype = { case 'mapBumpAnisotropy': break; case 'mapNormal': - json.normalMap = loadTexture( value, json.mapNormalRepeat, json.mapNormalOffset, json.mapNormalWrap, json.mapNormalAnisotropy ); + json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy ); break; case 'mapNormalFactor': json.normalScale = [ value, value ]; @@ -14465,7 +14465,7 @@ THREE.Loader.prototype = { case 'mapNormalAnisotropy': break; case 'mapSpecular': - json.specularMap = loadTexture( value, json.mapSpecularRepeat, json.mapSpecularOffset, json.mapSpecularWrap, json.mapSpecularAnisotropy ); + json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy ); break; case 'mapSpecularRepeat': case 'mapSpecularOffset': @@ -14473,7 +14473,7 @@ THREE.Loader.prototype = { case 'mapSpecularAnisotropy': break; case 'mapAlpha': - json.alphaMap = loadTexture( value, json.mapAlphaRepeat, json.mapAlphaOffset, json.mapAlphaWrap, json.mapAlphaAnisotropy ); + json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy ); break; case 'mapAlphaRepeat': case 'mapAlphaOffset': @@ -16260,11 +16260,9 @@ THREE.TextureLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { - var scope = this; - var texture = new THREE.Texture(); - var loader = new THREE.ImageLoader( scope.manager ); + var loader = new THREE.ImageLoader( this.manager ); loader.setCrossOrigin( this.crossOrigin ); loader.load( url, function ( image ) { @@ -16291,6 +16289,69 @@ THREE.TextureLoader.prototype = { }; +// File:src/loaders/CubeTextureLoader.js + +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.CubeTextureLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.CubeTextureLoader.prototype = { + + constructor: THREE.CubeTextureLoader, + + load: function ( urls, onLoad, onProgress, onError ) { + + var texture = new THREE.CubeTexture( [] ); + + var loader = new THREE.ImageLoader(); + loader.setCrossOrigin( this.crossOrigin ); + + var loaded = 0; + + function loadTexture( i ) { + + loader.load( urls[ i ], function ( image ) { + + texture.images[ i ] = image; + + loaded ++; + + if ( loaded === 6 ) { + + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture ); + + } + + }, undefined, onError ); + + } + + for ( var i = 0; i < urls.length; ++ i ) { + + loadTexture( i ); + + } + + return texture; + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + + } + +}; + // File:src/loaders/BinaryTextureLoader.js /** @@ -28207,58 +28268,27 @@ THREE.ImageUtils = { loadTexture: function ( url, mapping, onLoad, onError ) { + console.warn( 'THREE.ImageUtils.loadTexture is being deprecated. Use THREE.TextureLoader() instead.' ); + var loader = new THREE.TextureLoader(); loader.setCrossOrigin( this.crossOrigin ); - var texture = loader.load( url, function ( texture ) { - - if ( onLoad ) onLoad( texture ); - - }, undefined, onError ); - + var texture = loader.load( url, onLoad, undefined, onError ); texture.mapping = mapping; - texture.sourceFile = url; return texture; }, - loadTextureCube: function ( array, mapping, onLoad, onError ) { - - var images = []; - - var loader = new THREE.ImageLoader(); - loader.crossOrigin = this.crossOrigin; - - var texture = new THREE.CubeTexture( images, mapping ); - - var loaded = 0; - - function loadTexture( i ) { - - loader.load( array[ i ], function ( image ) { - - texture.images[ i ] = image; - - loaded += 1; - - if ( loaded === 6 ) { - - texture.needsUpdate = true; - - if ( onLoad ) onLoad( texture ); + loadTextureCube: function ( urls, mapping, onLoad, onError ) { - } - - }, undefined, onError ); - - } + console.warn( 'THREE.ImageUtils.loadTextureCube is being deprecated. Use THREE.CubeTextureLoader() instead.' ); - for ( var i = 0, il = array.length; i < il; ++ i ) { - - loadTexture( i ); + var loader = new THREE.CubeTextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); - } + var texture = loader.load( urls, onLoad, undefined, onError ); + texture.mapping = mapping; return texture; @@ -28274,133 +28304,6 @@ THREE.ImageUtils = { console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' ) - }, - - getNormalMap: function ( image, depth ) { - - // Adapted from http://www.paulbrunt.co.uk/lab/heightnormal/ - - function cross( a, b ) { - - 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 ] ]; - - } - - function subtract( a, b ) { - - return [ a[ 0 ] - b[ 0 ], a[ 1 ] - b[ 1 ], a[ 2 ] - b[ 2 ] ]; - - } - - function normalize( a ) { - - var l = Math.sqrt( a[ 0 ] * a[ 0 ] + a[ 1 ] * a[ 1 ] + a[ 2 ] * a[ 2 ] ); - return [ a[ 0 ] / l, a[ 1 ] / l, a[ 2 ] / l ]; - - } - - depth = depth | 1; - - var width = image.width; - var height = image.height; - - var canvas = document.createElement( 'canvas' ); - canvas.width = width; - canvas.height = height; - - var context = canvas.getContext( '2d' ); - context.drawImage( image, 0, 0 ); - - var data = context.getImageData( 0, 0, width, height ).data; - var imageData = context.createImageData( width, height ); - var output = imageData.data; - - for ( var x = 0; x < width; x ++ ) { - - for ( var y = 0; y < height; y ++ ) { - - var ly = y - 1 < 0 ? 0 : y - 1; - var uy = y + 1 > height - 1 ? height - 1 : y + 1; - var lx = x - 1 < 0 ? 0 : x - 1; - var ux = x + 1 > width - 1 ? width - 1 : x + 1; - - var points = []; - var origin = [ 0, 0, data[ ( y * width + x ) * 4 ] / 255 * depth ]; - points.push( [ - 1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] ); - points.push( [ - 1, - 1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] ); - points.push( [ 0, - 1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] ); - points.push( [ 1, - 1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] ); - points.push( [ 1, 0, data[ ( y * width + ux ) * 4 ] / 255 * depth ] ); - points.push( [ 1, 1, data[ ( uy * width + ux ) * 4 ] / 255 * depth ] ); - points.push( [ 0, 1, data[ ( uy * width + x ) * 4 ] / 255 * depth ] ); - points.push( [ - 1, 1, data[ ( uy * width + lx ) * 4 ] / 255 * depth ] ); - - var normals = []; - var num_points = points.length; - - for ( var i = 0; i < num_points; i ++ ) { - - var v1 = points[ i ]; - var v2 = points[ ( i + 1 ) % num_points ]; - v1 = subtract( v1, origin ); - v2 = subtract( v2, origin ); - normals.push( normalize( cross( v1, v2 ) ) ); - - } - - var normal = [ 0, 0, 0 ]; - - for ( var i = 0; i < normals.length; i ++ ) { - - normal[ 0 ] += normals[ i ][ 0 ]; - normal[ 1 ] += normals[ i ][ 1 ]; - normal[ 2 ] += normals[ i ][ 2 ]; - - } - - normal[ 0 ] /= normals.length; - normal[ 1 ] /= normals.length; - normal[ 2 ] /= normals.length; - - var idx = ( y * width + x ) * 4; - - output[ idx ] = ( ( normal[ 0 ] + 1.0 ) / 2.0 * 255 ) | 0; - output[ idx + 1 ] = ( ( normal[ 1 ] + 1.0 ) / 2.0 * 255 ) | 0; - output[ idx + 2 ] = ( normal[ 2 ] * 255 ) | 0; - output[ idx + 3 ] = 255; - - } - - } - - context.putImageData( imageData, 0, 0 ); - - return canvas; - - }, - - generateDataTexture: function ( width, height, color ) { - - var size = width * height; - var data = new Uint8Array( 3 * size ); - - var r = Math.floor( color.r * 255 ); - var g = Math.floor( color.g * 255 ); - var b = Math.floor( color.b * 255 ); - - for ( var i = 0; i < size; i ++ ) { - - data[ i * 3 ] = r; - data[ i * 3 + 1 ] = g; - data[ i * 3 + 2 ] = b; - - } - - var texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); - texture.needsUpdate = true; - - return texture; - } }; diff --git a/build/three.min.js b/build/three.min.js index c42cf88716..ae3ab61a92 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -320,12 +320,12 @@ THREE.PointLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight THREE.SpotLight=function(a,b,c,d,e,g){THREE.Light.call(this,a);this.type="SpotLight";this.position.set(0,1,0);this.updateMatrix();this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.exponent=void 0!==e?e:10;this.decay=void 0!==g?g:1;this.shadow=new THREE.LightShadow(new THREE.PerspectiveCamera(50,1,50,5E3))};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype);THREE.SpotLight.prototype.constructor=THREE.SpotLight; THREE.SpotLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.intensity=a.intensity;this.distance=a.distance;this.angle=a.angle;this.exponent=a.exponent;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this};THREE.Cache={enabled:!1,files:{},add:function(a,b){!1!==this.enabled&&(this.files[a]=b)},get:function(a){if(!1!==this.enabled)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}}; THREE.Loader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}; -THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:void 0,extractUrlBase:function(a){a=a.split("/");if(1===a.length)return"./";a.pop();return a.join("/")+"/"},initMaterials:function(a,b,c){for(var d=[],e=0;el.opacity&&(l.transparent=!0);c.setTextures(h);return c.parse(l)}}()};THREE.Loader.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;cp-1?0:p-1,q=p+1>e-1?e-1:p+1,t=0>n-1?0:n-1,s=n+1>d-1?d-1:n+1,u=[],w=[0,0,h[4*(p*d+n)]/255*b];u.push([-1,0,h[4*(p*d+t)]/255*b]);u.push([-1,-1,h[4*(m*d+t)]/255*b]);u.push([0,-1,h[4*(m*d+n)]/255*b]);u.push([1,-1,h[4*(m*d+s)]/255*b]);u.push([1,0,h[4*(p*d+s)]/255*b]);u.push([1,1,h[4*(q*d+s)]/255*b]);u.push([0,1,h[4*(q*d+n)]/255*b]);u.push([-1,1,h[4*(q*d+t)]/255*b]);m=[];t=u.length;for(q=0;q