From 9731c88b1970e7e6998c8818d5e326137e83bc66 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 3 Jun 2013 12:39:08 +0200 Subject: [PATCH] Updated builds. --- build/three.js | 87 +++++++++------------------------------------- build/three.min.js | 8 ++--- 2 files changed, 21 insertions(+), 74 deletions(-) diff --git a/build/three.js b/build/three.js index 7c9c605e7f..9c854601ed 100644 --- a/build/three.js +++ b/build/three.js @@ -9971,12 +9971,14 @@ THREE.XHRLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { + var scope = this; var request = new XMLHttpRequest(); if ( onLoad !== undefined ) { request.addEventListener( 'load', function ( event ) { + scope.manager.itemEnd( url ); onLoad( event.target.responseText ); }, false ); @@ -10008,6 +10010,8 @@ THREE.XHRLoader.prototype = { request.open( 'GET', url, true ); request.send( null ); + scope.manager.itemStart( url ); + }, setCrossOrigin: function ( value ) { @@ -10034,12 +10038,14 @@ THREE.ImageLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { + var scope = this; var image = document.createElement( 'img' ); if ( onLoad !== undefined ) { image.addEventListener( 'load', function ( event ) { + scope.manager.itemEnd( url ); onLoad( this ); }, false ); @@ -10070,6 +10076,8 @@ THREE.ImageLoader.prototype = { image.src = url; + scope.manager.itemStart( url ); + }, setCrossOrigin: function ( value ) { @@ -10529,93 +10537,30 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { * @author mrdoob / http://mrdoob.com/ */ -THREE.LoadingManager = function ( onLoad, onProgress, onError ) { +THREE.LoadingManager = function ( onItemLoad ) { var scope = this; - var loaders = {}; - var queue = []; - var cache = {}; - var loaded = 0, total = 0; - var loadNext = function () { - - var item = queue[ 0 ]; - - if ( cache[ item.url ] === undefined ) { - - var loader = loaders[ item.type ]; - - if ( loader !== undefined ) { - - loader.load( item.url, function ( event ) { - - if ( item.onLoad !== undefined ) { - - item.onLoad( event ); - - } - - cache[ item.url ] = event; - - onItemLoaded( item ); - - } ); - - } - - } else { - - if ( item.onLoad !== undefined ) { - - item.onLoad( cache[ item.url ] ); + this.itemStart = function ( url ) { - } - - onLoad( item ); - - } - - queue.shift(); + total ++; }; - var onItemLoaded = function ( item ) { + this.itemEnd = function ( url ) { loaded ++; - onProgress( item, loaded, total ); - - if ( queue.length > 0 ) { - - loadNext(); - - } - - if ( loaded === total ) { + if ( onItemLoad !== undefined ) { - onLoad(); + onItemLoad( url, loaded, total ); } }; - this.add = function ( url, onLoad, onProgress, onError ) { - - total ++; - - queue.push( { - url: url, - onLoad: onLoad, - onProgress: onProgress, - onError: onError - } ); - - loadNext(); - - }; - }; THREE.DefaultLoadingManager = new THREE.LoadingManager(); @@ -12325,7 +12270,9 @@ THREE.TextureLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { - var loader = new THREE.ImageLoader(); + var scope = this; + + var loader = new THREE.ImageLoader( scope.manager ); loader.setCrossOrigin( this.crossOrigin ); loader.load( url, function ( image ) { diff --git a/build/three.min.js b/build/three.min.js index f21aa1bd5c..10a4b1af32 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -205,15 +205,15 @@ void 0!==a.doubleSided&&(i.side=THREE.DoubleSide);void 0!==a.wireframe&&(i.wiref b&&e(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&e(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&e(i,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&e(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&e(i,"specularMap",a.mapSpecular,a.mapSpecularRepeat, a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);a.mapBumpScale&&(i.bumpScale=a.mapBumpScale);a.mapNormal?(h=THREE.ShaderLib.normalmap,j=THREE.UniformsUtils.clone(h.uniforms),j.tNormal.value=i.normalMap,a.mapNormalFactor&&j.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),i.map&&(j.tDiffuse.value=i.map,j.enableDiffuse.value=!0),i.specularMap&&(j.tSpecular.value=i.specularMap,j.enableSpecular.value=!0),i.lightMap&&(j.tAO.value=i.lightMap,j.enableAO.value=!0),j.uDiffuseColor.value.setHex(i.color), j.uSpecularColor.value.setHex(i.specular),j.uAmbientColor.value.setHex(i.ambient),j.uShininess.value=i.shininess,void 0!==i.opacity&&(j.uOpacity.value=i.opacity),h=new THREE.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:j,lights:!0,fog:!0}),i.transparent&&(h.transparent=!0)):h=new THREE[h](i);void 0!==a.DbgName&&(h.name=a.DbgName);return h}};THREE.XHRLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager}; -THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){var e=new XMLHttpRequest;void 0!==b&&e.addEventListener("load",function(a){b(a.target.responseText)},!1);void 0!==c&&e.addEventListener("progress",function(a){c(a)},!1);void 0!==d&&e.addEventListener("error",function(a){d(a)},!1);void 0!==this.crossOrigin&&(e.crossOrigin=this.crossOrigin);e.open("GET",a,!0);e.send(null)},setCrossOrigin:function(a){this.crossOrigin=a}};THREE.ImageLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager}; -THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){var e=document.createElement("img");void 0!==b&&e.addEventListener("load",function(){b(this)},!1);void 0!==c&&e.addEventListener("progress",function(a){c(a)},!1);void 0!==d&&e.addEventListener("error",function(a){d(a)},!1);void 0!==this.crossOrigin&&(e.crossOrigin=this.crossOrigin);e.src=a},setCrossOrigin:function(a){this.crossOrigin=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a);this.withCredentials=!1};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);THREE.JSONLoader.prototype.load=function(a,b,c){c=c&&"string"===typeof c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)}; +THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){var e=this,f=new XMLHttpRequest;void 0!==b&&f.addEventListener("load",function(c){e.manager.itemEnd(a);b(c.target.responseText)},!1);void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1);void 0!==d&&f.addEventListener("error",function(a){d(a)},!1);void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin);f.open("GET",a,!0);f.send(null);e.manager.itemStart(a)},setCrossOrigin:function(a){this.crossOrigin=a}};THREE.ImageLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager}; +THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){var e=this,f=document.createElement("img");void 0!==b&&f.addEventListener("load",function(){e.manager.itemEnd(a);b(this)},!1);void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1);void 0!==d&&f.addEventListener("error",function(a){d(a)},!1);void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin);f.src=a;e.manager.itemStart(a)},setCrossOrigin:function(a){this.crossOrigin=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a);this.withCredentials=!1};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);THREE.JSONLoader.prototype.load=function(a,b,c){c=c&&"string"===typeof c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)}; THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(f.readyState===f.DONE)if(200===f.status||0===f.status){if(f.responseText){var h=JSON.parse(f.responseText),h=a.parse(h,d);c(h.geometry,h.materials)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+f.status+"]");else f.readyState===f.LOADING?e&&(0===g&& (g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):f.readyState===f.HEADERS_RECEIVED&&void 0!==e&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.withCredentials=this.withCredentials;f.send(null)}; THREE.JSONLoader.prototype.parse=function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/a.scale:1,e,f,g,h,i,j,l,n,m,q,t,p,r,s,v,z=a.faces;q=a.vertices;var G=a.normals,C=a.colors,H=0;for(e=0;ew.parameters.opacity&&(w.parameters.transparent=!0);w.parameters.normalMap?(J=THREE.ShaderLib.normalmap,y=THREE.UniformsUtils.clone(J.uniforms),s=w.parameters.color,M=w.parameters.specular,r=w.parameters.ambient,N=w.parameters.shininess,y.tNormal.value=A.textures[w.parameters.normalMap],w.parameters.normalScale&&y.uNormalScale.value.set(w.parameters.normalScale[0],w.parameters.normalScale[1]),w.parameters.map&&(y.tDiffuse.value= w.parameters.map,y.enableDiffuse.value=!0),w.parameters.envMap&&(y.tCube.value=w.parameters.envMap,y.enableReflection.value=!0,y.uReflectivity.value=w.parameters.reflectivity),w.parameters.lightMap&&(y.tAO.value=w.parameters.lightMap,y.enableAO.value=!0),w.parameters.specularMap&&(y.tSpecular.value=A.textures[w.parameters.specularMap],y.enableSpecular.value=!0),w.parameters.displacementMap&&(y.tDisplacement.value=A.textures[w.parameters.displacementMap],y.enableDisplacement.value=!0,y.uDisplacementBias.value= w.parameters.displacementBias,y.uDisplacementScale.value=w.parameters.displacementScale),y.uDiffuseColor.value.setHex(s),y.uSpecularColor.value.setHex(M),y.uAmbientColor.value.setHex(r),y.uShininess.value=N,w.parameters.opacity&&(y.uOpacity.value=w.parameters.opacity),t=new THREE.ShaderMaterial({fragmentShader:J.fragmentShader,vertexShader:J.vertexShader,uniforms:y,lights:!0,fog:!0})):t=new THREE[w.type](w.parameters);t.name=Z;A.materials[Z]=t}for(Z in B.materials)if(w=B.materials[Z],w.parameters.materials){L= -[];for(s=0;s