diff --git a/build/three.js b/build/three.js index 527b98adb8bb4143a8a1ff968946314d4bb93902..2b79b1d5f67cbc3313bd7b778c93f010ecc0963e 100644 --- a/build/three.js +++ b/build/three.js @@ -11132,6 +11132,43 @@ THREE.SpotLight.prototype.clone = function () { }; +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.Cache = { + + files: {}, + + add: function ( key, file ) { + + // console.log( 'THREE.Cache', 'Adding key:', key ); + + this.files[ key ] = file; + + }, + + get: function ( key ) { + + // console.log( 'THREE.Cache', 'Checking key:', key ); + + return this.files[ key ]; + + }, + + remove: function ( key ) { + + delete this.files[ key ]; + + }, + + clear: function () { + + this.files = {} + + } + +}; /** * @author alteredq / http://alteredqualia.com/ */ @@ -11237,13 +11274,6 @@ THREE.Loader.prototype = { var _this = this; - function is_pow2( n ) { - - var l = Math.log( n ) / Math.LN2; - return Math.floor( l ) == l; - - } - function nearest_pow2( n ) { var l = Math.log( n ) / Math.LN2; @@ -11251,36 +11281,6 @@ THREE.Loader.prototype = { } - function load_image( where, url ) { - - var image = new Image(); - - image.onload = function () { - - if ( !is_pow2( this.width ) || !is_pow2( this.height ) ) { - - var width = nearest_pow2( this.width ); - var height = nearest_pow2( this.height ); - - where.image.width = width; - where.image.height = height; - where.image.getContext( '2d' ).drawImage( this, 0, 0, width, height ); - - } else { - - where.image = this; - - } - - where.needsUpdate = true; - - }; - - if ( _this.crossOrigin !== undefined ) image.crossOrigin = _this.crossOrigin; - image.src = url; - - } - function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) { var isCompressed = /\.dds$/i.test( sourceFile ); @@ -11338,7 +11338,31 @@ THREE.Loader.prototype = { if ( ! isCompressed ) { - load_image( where[ name ], fullPath ); + var texture = where[ name ]; + + var loader = new THREE.ImageLoader(); + loader.crossOrigin = _this.crossOrigin; + loader.load( fullPath, function ( image ) { + + if ( THREE.Math.isPowerOfTwo( image.width ) === false || + THREE.Math.isPowerOfTwo( image.height ) === false ) { + + var width = nearest_pow2( image.width ); + var height = nearest_pow2( image.height ); + + texture.image.width = width; + texture.image.height = height; + texture.image.getContext( '2d' ).drawImage( image, 0, 0, width, height ); + + } else { + + texture.image = image; + + } + + texture.needsUpdate = true; + + } ); } @@ -11595,6 +11619,15 @@ THREE.XHRLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { + var cached = THREE.Cache.get( url ); + + if ( cached !== undefined ) { + + onLoad( cached ); + return; + + } + var scope = this; var request = new XMLHttpRequest(); @@ -11602,6 +11635,8 @@ THREE.XHRLoader.prototype = { request.addEventListener( 'load', function ( event ) { + THREE.Cache.add( url, event.target.responseText ); + onLoad( event.target.responseText ); scope.manager.itemEnd( url ); @@ -11662,6 +11697,15 @@ THREE.ImageLoader.prototype = { load: function ( url, onLoad, onProgress, onError ) { + var cached = THREE.Cache.get( url ); + + if ( cached !== undefined ) { + + onLoad( cached ); + return; + + } + var scope = this; var image = document.createElement( 'img' ); @@ -11669,8 +11713,10 @@ THREE.ImageLoader.prototype = { image.addEventListener( 'load', function ( event ) { - scope.manager.itemEnd( url ); + THREE.Cache.add( url, this ); + onLoad( this ); + scope.manager.itemEnd( url ); }, false ); diff --git a/build/three.min.js b/build/three.min.js index ac92c3c1e83ecf241f98e7615cc04279ed7ecc1c..7df49d31e004448bdb337c77405382035b10e3ad 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -88,22 +88,22 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,g,h, multiplyVector3Array:function(a){console.warn("DEPRECATED: Matrix3's .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},applyToVector3Array:function(){var a=new THREE.Vector3;return function(b){for(var c=0,d=b.length;c=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<= this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius); return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}};THREE.Frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==f?f:new THREE.Plane]}; -THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],n=c[8],q=c[9],s=c[10],r=c[11],u=c[12],p=c[13],v=c[14],c=c[15];b[0].setComponents(f-a,l-g,r-n,c-u).normalize();b[1].setComponents(f+ -a,l+g,r+n,c+u).normalize();b[2].setComponents(f+d,l+h,r+q,c+p).normalize();b[3].setComponents(f-d,l-h,r-q,c-p).normalize();b[4].setComponents(f-e,l-k,r-s,c-v).normalize();b[5].setComponents(f+e,l+k,r+s,c+v).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes, +THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],n=c[8],q=c[9],s=c[10],r=c[11],t=c[12],p=c[13],v=c[14],c=c[15];b[0].setComponents(f-a,l-g,r-n,c-t).normalize();b[1].setComponents(f+ +a,l+g,r+n,c+t).normalize();b[2].setComponents(f+d,l+h,r+q,c+p).normalize();b[3].setComponents(f-d,l-h,r-q,c-p).normalize();b[4].setComponents(f-e,l-k,r-s,c-v).normalize();b[5].setComponents(f+e,l+k,r+s,c+v).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes, c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0g&&0>f)return!1}return!0}}(), containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0},clone:function(){return(new THREE.Frustum).copy(this)}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0}; THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d, @@ -145,13 +145,13 @@ THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=thi a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}};THREE.EventDispatcher=function(){}; THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(a){a.addEventListener=THREE.EventDispatcher.prototype.addEventListener;a.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener;a.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener;a.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&& c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)?!0:!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexOf(b);-1!==d&&c.splice(d,1)}}},dispatchEvent:function(){var a=[];return function(b){if(void 0!==this._listeners){var c=this._listeners[b.type];if(void 0!==c){b.target=this;for(var d=c.length,e=0;ef.scale.x)return r;r.push({distance:u,point:f.position,face:null,object:f})}else if(f instanceof -a.LOD)d.setFromMatrixPosition(f.matrixWorld),u=n.ray.origin.distanceTo(d),l(f.getObjectForDistance(u),n,r);else if(f instanceof a.Mesh){var p=f.geometry;null===p.boundingSphere&&p.computeBoundingSphere();b.copy(p.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return r;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(null!==p.boundingBox&&!1===c.isIntersectionBox(p.boundingBox))return r;if(p instanceof a.BufferGeometry){var v=f.material;if(void 0=== -v)return r;var w=p.attributes,t,x,H=n.precision;if(void 0!==w.index)for(var G=p.offsets,P=w.index.array,F=w.position.array,D=0,K=G.length;Dn.far||r.push({distance:u,point:I,indices:[w,t,x],face:null,faceIndex:null,object:f}))}else for(F=w.position.array,p=0,E=w.position.array.length;pn.far||r.push({distance:u,point:I, -indices:[w,t,x],face:null,faceIndex:null,object:f}))}else if(p instanceof a.Geometry)for(P=f.material instanceof a.MeshFaceMaterial,F=!0===P?f.material.materials:null,H=n.precision,G=p.vertices,D=0,K=p.faces.length;Dn.far||r.push({distance:u,point:I,face:y,faceIndex:D,object:f}))}}else if(f instanceof -a.Line){H=n.linePrecision;v=H*H;p=f.geometry;null===p.boundingSphere&&p.computeBoundingSphere();b.copy(p.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return r;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(p instanceof a.Geometry)for(G=p.vertices,H=G.length,w=new a.Vector3,t=new a.Vector3,x=f.type===a.LineStrip?1:2,p=0;pv||(u=c.origin.distanceTo(t),un.far||r.push({distance:u,point:w.clone().applyMatrix4(f.matrixWorld), +b)}}}}()};(function(a){a.Raycaster=function(b,c,d,e){this.ray=new a.Ray(b,c);this.near=d||0;this.far=e||Infinity};var b=new a.Sphere,c=new a.Ray;new a.Plane;new a.Vector3;var d=new a.Vector3,e=new a.Matrix4,f=function(a,b){return a.distance-b.distance},g=new a.Vector3,h=new a.Vector3,k=new a.Vector3,l=function(f,n,r){if(f instanceof a.Sprite){d.setFromMatrixPosition(f.matrixWorld);var t=n.ray.distanceToPoint(d);if(t>f.scale.x)return r;r.push({distance:t,point:f.position,face:null,object:f})}else if(f instanceof +a.LOD)d.setFromMatrixPosition(f.matrixWorld),t=n.ray.origin.distanceTo(d),l(f.getObjectForDistance(t),n,r);else if(f instanceof a.Mesh){var p=f.geometry;null===p.boundingSphere&&p.computeBoundingSphere();b.copy(p.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return r;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(null!==p.boundingBox&&!1===c.isIntersectionBox(p.boundingBox))return r;if(p instanceof a.BufferGeometry){var v=f.material;if(void 0=== +v)return r;var w=p.attributes,u,x,H=n.precision;if(void 0!==w.index)for(var G=p.offsets,P=w.index.array,F=w.position.array,D=0,K=G.length;Dn.far||r.push({distance:t,point:I,indices:[w,u,x],face:null,faceIndex:null,object:f}))}else for(F=w.position.array,p=0,E=w.position.array.length;pn.far||r.push({distance:t,point:I, +indices:[w,u,x],face:null,faceIndex:null,object:f}))}else if(p instanceof a.Geometry)for(P=f.material instanceof a.MeshFaceMaterial,F=!0===P?f.material.materials:null,H=n.precision,G=p.vertices,D=0,K=p.faces.length;Dn.far||r.push({distance:t,point:I,face:y,faceIndex:D,object:f}))}}else if(f instanceof +a.Line){H=n.linePrecision;v=H*H;p=f.geometry;null===p.boundingSphere&&p.computeBoundingSphere();b.copy(p.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return r;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(p instanceof a.Geometry)for(G=p.vertices,H=G.length,w=new a.Vector3,u=new a.Vector3,x=f.type===a.LineStrip?1:2,p=0;pv||(t=c.origin.distanceTo(u),tn.far||r.push({distance:t,point:w.clone().applyMatrix4(f.matrixWorld), face:null,faceIndex:null,object:f}))}},n=function(a,b,c){a=a.getDescendants();for(var d=0,e=a.length;de&&0>f||0>g&& -0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(de&&0>f||0>g&& +0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z},k=function(a,b,c){return!0===a.visible&&!0===b.visible&&!0===c.visible},n=function(a,b, c){A[0]=a.positionScreen;A[1]=b.positionScreen;A[2]=c.positionScreen;return z.isIntersectionBox(M.setFromPoints(A))?0>(c.positionScreen.x-a.positionScreen.x)*(b.positionScreen.y-a.positionScreen.y)-(c.positionScreen.y-a.positionScreen.y)*(b.positionScreen.x-a.positionScreen.x):!1};return{setObject:function(a){e=a;f=e.material;g.getNormalMatrix(e.matrixWorld);d.length=0},projectVertex:h,checkVerticesVisibility:k,checkTriangleVisibility:n,pushVertex:function(b,c,d){l=a();l.position.set(b,c,d);h(l)}, pushNormal:function(a,b,c){d.push(a,b,c)},pushLine:function(a,b){var d=q[a],f=q[b];w=c();w.id=e.id;w.v1.copy(d);w.v2.copy(f);w.z=(d.positionScreen.z+f.positionScreen.z)/2;w.material=e.material;K.elements.push(w)},pushTriangle:function(a,c,h){var l=q[a],p=q[c],s=q[h];if(!1!==k(l,p,s)&&(f.side===THREE.DoubleSide||!0===n(l,p,s))){r=b();r.id=e.id;r.v1.copy(l);r.v2.copy(p);r.v3.copy(s);r.z=(l.positionScreen.z+p.positionScreen.z+s.positionScreen.z)/3;for(l=0;3>l;l++)p=3*arguments[l],s=r.vertexNormalsModel[l], -s.set(d[p+0],d[p+1],d[p+2]),s.applyMatrix3(g).normalize();r.vertexNormalsLength=3;r.material=e.material;K.elements.push(r)}}}};this.projectScene=function(f,h,k,l){var p,s,v,x,H,C,z,A,M;P=t=u=0;K.elements.length=0;!0===f.autoUpdate&&f.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();J.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));Y.multiplyMatrices(h.projectionMatrix,J);X.setFromMatrix(Y);g=0;K.objects.length=0;K.lights.length=0;ea(f);!0===k&&K.objects.sort(d);f=0;for(k=K.objects.length;f< +s.set(d[p+0],d[p+1],d[p+2]),s.applyMatrix3(g).normalize();r.vertexNormalsLength=3;r.material=e.material;K.elements.push(r)}}}};this.projectScene=function(f,h,k,l){var p,s,v,x,H,C,z,A,M;P=u=t=0;K.elements.length=0;!0===f.autoUpdate&&f.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();J.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));Y.multiplyMatrices(h.projectionMatrix,J);X.setFromMatrix(Y);g=0;K.objects.length=0;K.lights.length=0;ea(f);!0===k&&K.objects.sort(d);f=0;for(k=K.objects.length;f< k;f++)if(p=K.objects[f].object,s=p.geometry,B.setObject(p),R=p.matrixWorld,n=0,p instanceof THREE.Mesh)if(s instanceof THREE.BufferGeometry){if(C=s.attributes,p=s.offsets,void 0!==C.position){A=C.position.array;s=0;for(x=A.length;sb.max.x&&(b.max.x=e);fb.max.y&&(b.max.y=f);gb.max.z&&(b.max.z=g)}}if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){var a=new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){a.makeEmpty();for(var d=this.boundingSphere.center,e=0,f=c.length;eHa?-1:1;h[4*a]=T.x;h[4*a+1]=T.y;h[4*a+2]=T.z;h[4*a+3]=Ja}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()"); -else{var c=this.attributes.index.array,d=this.attributes.position.array,e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&(this.attributes.tangent={itemSize:4,array:new Float32Array(4*g)});for(var h=this.attributes.tangent.array,k=[],l=[],n=0;np;p++)u=a[3*c+p],-1==s[u]?(q[2*p]=u,q[2*p+1]=-1,n++):s[u]k.index+b)for(k={start:f,count:0,index:g},h.push(k),n=0;6>n;n+=2)p=q[n+1],-1n;n+=2)u=q[n],p=q[n+1],-1===p&&(p=g++), -s[u]=p,r[p]=u,e[f++]=p-k.index,k.count++}this.reorderBuffers(e,r,g);return this.offsets=h},reorderBuffers:function(a,b,c){var d={},e=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],f;for(f in this.attributes)if("index"!=f)for(var g=this.attributes[f].array,h=0,k=e.length;hp;p++)t=a[3*c+p],-1==s[t]?(q[2*p]=t,q[2*p+1]=-1,n++):s[t]k.index+b)for(k={start:f,count:0,index:g},h.push(k),n=0;6>n;n+=2)p=q[n+1],-1n;n+=2)t=q[n],p=q[n+1],-1===p&&(p=g++), +s[t]=p,r[p]=t,e[f++]=p-k.index,k.count++}this.reorderBuffers(e,r,g);return this.offsets=h},reorderBuffers:function(a,b,c){var d={},e=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],f;for(f in this.attributes)if("index"!=f)for(var g=this.attributes[f].array,h=0,k=e.length;hd?-1:1,e.vertexTangents[c]=new THREE.Vector4(H.x,H.y,H.z,d);this.hasTangents=!0},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;cd?-1:1,e.vertexTangents[c]=new THREE.Vector4(H.x,H.y,H.z,d);this.hasTangents=!0},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;cd;d++)if(e[d]==e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;cc&&(h[f].counter+=1,g=h[f].hash+"_"+h[f].counter,g in this.geometryGroups||(this.geometryGroups[g]={faces3:[],materialIndex:f,vertices:0,numMorphTargets:k,numMorphNormals:l})),this.geometryGroups[g].faces3.push(d), @@ -227,24 +227,26 @@ this.shadowCameraVisible;a.shadowBias=this.shadowBias;a.shadowDarkness=this.shad a.shadowCascadeFarZ=this.shadowCascadeFarZ.slice(0);return a};THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a);this.position.set(0,100,0);this.groundColor=new THREE.Color(b);this.intensity=void 0!==c?c:1};THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype);THREE.HemisphereLight.prototype.clone=function(){var a=new THREE.HemisphereLight;THREE.Light.prototype.clone.call(this,a);a.groundColor.copy(this.groundColor);a.intensity=this.intensity;return a};THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.PointLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight.prototype.clone=function(){var a=new THREE.PointLight;THREE.Light.prototype.clone.call(this,a);a.intensity=this.intensity;a.distance=this.distance;return a};THREE.SpotLight=function(a,b,c,d,e){THREE.Light.call(this,a);this.position.set(0,1,0);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.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=this.shadowCamera=this.shadowMapSize= this.shadowMap=null};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype); THREE.SpotLight.prototype.clone=function(){var a=new THREE.SpotLight;THREE.Light.prototype.clone.call(this,a);a.target=this.target.clone();a.intensity=this.intensity;a.distance=this.distance;a.angle=this.angle;a.exponent=this.exponent;a.castShadow=this.castShadow;a.onlyShadow=this.onlyShadow;a.shadowCameraNear=this.shadowCameraNear;a.shadowCameraFar=this.shadowCameraFar;a.shadowCameraFov=this.shadowCameraFov;a.shadowCameraVisible=this.shadowCameraVisible;a.shadowBias=this.shadowBias;a.shadowDarkness= -this.shadowDarkness;a.shadowMapWidth=this.shadowMapWidth;a.shadowMapHeight=this.shadowMapHeight;return a};THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}; +this.shadowDarkness;a.shadowMapWidth=this.shadowMapWidth;a.shadowMapHeight=this.shadowMapHeight;return a};THREE.Cache={files:{},add:function(a,b){this.files[a]=b},get:function(a){return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}; THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:void 0,addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/a.total).toFixed(0)+ -"%"):b+((a.loaded/1024).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");if(1===a.length)return"./";a.pop();return a.join("/")+"/"},initMaterials:function(a,b){for(var c=[],d=0;da.opacity)l.transparent=a.transparent;void 0!==a.depthTest&&(l.depthTest=a.depthTest);void 0!==a.depthWrite&&(l.depthWrite=a.depthWrite);void 0!==a.visible&&(l.visible=a.visible);void 0!==a.flipSided&&(l.side=THREE.BackSide); -void 0!==a.doubleSided&&(l.side=THREE.DoubleSide);void 0!==a.wireframe&&(l.wireframe=a.wireframe);void 0!==a.vertexColors&&("face"===a.vertexColors?l.vertexColors=THREE.FaceColors:a.vertexColors&&(l.vertexColors=THREE.VertexColors));a.colorDiffuse?l.color=g(a.colorDiffuse):a.DbgColor&&(l.color=a.DbgColor);a.colorSpecular&&(l.specular=g(a.colorSpecular));a.colorAmbient&&(l.ambient=g(a.colorAmbient));a.transparency&&(l.opacity=a.transparency);a.specularCoef&&(l.shininess=a.specularCoef);a.mapDiffuse&& -b&&f(l,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&f(l,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&f(l,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&f(l,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&f(l,"specularMap",a.mapSpecular,a.mapSpecularRepeat, -a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);a.mapBumpScale&&(l.bumpScale=a.mapBumpScale);a.mapNormal?(k=THREE.ShaderLib.normalmap,n=THREE.UniformsUtils.clone(k.uniforms),n.tNormal.value=l.normalMap,a.mapNormalFactor&&n.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),l.map&&(n.tDiffuse.value=l.map,n.enableDiffuse.value=!0),l.specularMap&&(n.tSpecular.value=l.specularMap,n.enableSpecular.value=!0),l.lightMap&&(n.tAO.value=l.lightMap,n.enableAO.value=!0),n.diffuse.value.setHex(l.color), -n.specular.value.setHex(l.specular),n.ambient.value.setHex(l.ambient),n.shininess.value=l.shininess,void 0!==l.opacity&&(n.opacity.value=l.opacity),k=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:n,lights:!0,fog:!0}),l.transparent&&(k.transparent=!0)):k=new THREE[k](l);void 0!==a.DbgName&&(k.name=a.DbgName);return k}};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=this,f=new XMLHttpRequest;void 0!==b&&f.addEventListener("load",function(c){b(c.target.responseText);e.manager.itemEnd(a)},!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(c){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);return f},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)}; +"%"):b+((a.loaded/1024).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");if(1===a.length)return"./";a.pop();return a.join("/")+"/"},initMaterials:function(a,b){for(var c=[],d=0;da.opacity)h.transparent=a.transparent;void 0!==a.depthTest&&(h.depthTest=a.depthTest);void 0!==a.depthWrite&&(h.depthWrite=a.depthWrite);void 0!==a.visible&&(h.visible=a.visible);void 0!==a.flipSided&&(h.side=THREE.BackSide);void 0!==a.doubleSided&&(h.side=THREE.DoubleSide); +void 0!==a.wireframe&&(h.wireframe=a.wireframe);void 0!==a.vertexColors&&("face"===a.vertexColors?h.vertexColors=THREE.FaceColors:a.vertexColors&&(h.vertexColors=THREE.VertexColors));a.colorDiffuse?h.color=e(a.colorDiffuse):a.DbgColor&&(h.color=a.DbgColor);a.colorSpecular&&(h.specular=e(a.colorSpecular));a.colorAmbient&&(h.ambient=e(a.colorAmbient));a.transparency&&(h.opacity=a.transparency);a.specularCoef&&(h.shininess=a.specularCoef);a.mapDiffuse&&b&&d(h,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset, +a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&d(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&d(h,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&d(h,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&d(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy); +a.mapBumpScale&&(h.bumpScale=a.mapBumpScale);a.mapNormal?(g=THREE.ShaderLib.normalmap,k=THREE.UniformsUtils.clone(g.uniforms),k.tNormal.value=h.normalMap,a.mapNormalFactor&&k.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),h.map&&(k.tDiffuse.value=h.map,k.enableDiffuse.value=!0),h.specularMap&&(k.tSpecular.value=h.specularMap,k.enableSpecular.value=!0),h.lightMap&&(k.tAO.value=h.lightMap,k.enableAO.value=!0),k.diffuse.value.setHex(h.color),k.specular.value.setHex(h.specular),k.ambient.value.setHex(h.ambient), +k.shininess.value=h.shininess,void 0!==h.opacity&&(k.opacity.value=h.opacity),g=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:k,lights:!0,fog:!0}),h.transparent&&(g.transparent=!0)):g=new THREE[g](h);void 0!==a.DbgName&&(g.name=a.DbgName);return g}};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=THREE.Cache.get(a);if(void 0!==e)b(e);else{var f=this,e=new XMLHttpRequest;void 0!==b&&e.addEventListener("load",function(c){THREE.Cache.add(a,c.target.responseText);b(c.target.responseText);f.manager.itemEnd(a)},!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);f.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=THREE.Cache.get(a);if(void 0!==e)b(e);else{var f=this,e=document.createElement("img");void 0!==b&&e.addEventListener("load",function(c){THREE.Cache.add(a,this);b(this);f.manager.itemEnd(a)},!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;f.manager.itemStart(a);return e}}, +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);if(void 0!==h.metadata&&"scene"===h.metadata.type){console.error('THREE.JSONLoader: "'+b+'" seems to be a Scene. Use THREE.SceneLoader instead.');return}h=a.parse(h,d);c(h.geometry,h.materials)}else console.error('THREE.JSONLoader: "'+b+'" seems to be unreachable or the file 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;(function(b){var d,g,h,k,l,n,q,s,r,u,p,v,w,t=a.faces;n=a.vertices;var x=a.normals,H=a.colors,G=0;if(void 0!==a.uvs){for(d=0;dg;g++)s=t[k++],w=v[2*s],s=v[2*s+1],w=new THREE.Vector2(w,s),2!==g&&c.faceVertexUvs[d][h].push(w),0!==g&&c.faceVertexUvs[d][h+1].push(w);q&&(q=3*t[k++],r.normal.set(x[q++],x[q++],x[q]),p.normal.copy(r.normal));if(u)for(d=0;4>d;d++)q=3*t[k++],u=new THREE.Vector3(x[q++], -x[q++],x[q]),2!==d&&r.vertexNormals.push(u),0!==d&&p.vertexNormals.push(u);n&&(n=t[k++],n=H[n],r.color.setHex(n),p.color.setHex(n));if(b)for(d=0;4>d;d++)n=t[k++],n=H[n],2!==d&&r.vertexColors.push(new THREE.Color(n)),0!==d&&p.vertexColors.push(new THREE.Color(n));c.faces.push(r);c.faces.push(p)}else{r=new THREE.Face3;r.a=t[k++];r.b=t[k++];r.c=t[k++];h&&(h=t[k++],r.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)s=t[k++],w=v[2*s],s=v[2*s+1], -w=new THREE.Vector2(w,s),c.faceVertexUvs[d][h].push(w);q&&(q=3*t[k++],r.normal.set(x[q++],x[q++],x[q]));if(u)for(d=0;3>d;d++)q=3*t[k++],u=new THREE.Vector3(x[q++],x[q++],x[q]),r.vertexNormals.push(u);n&&(n=t[k++],r.color.setHex(H[n]));if(b)for(d=0;3>d;d++)n=t[k++],r.vertexColors.push(new THREE.Color(H[n]));c.faces.push(r)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dg;g++)s=u[k++],w=v[2*s],s=v[2*s+1],w=new THREE.Vector2(w,s),2!==g&&c.faceVertexUvs[d][h].push(w),0!==g&&c.faceVertexUvs[d][h+1].push(w);q&&(q=3*u[k++],r.normal.set(x[q++],x[q++],x[q]),p.normal.copy(r.normal));if(t)for(d=0;4>d;d++)q=3*u[k++],t=new THREE.Vector3(x[q++], +x[q++],x[q]),2!==d&&r.vertexNormals.push(t),0!==d&&p.vertexNormals.push(t);n&&(n=u[k++],n=H[n],r.color.setHex(n),p.color.setHex(n));if(b)for(d=0;4>d;d++)n=u[k++],n=H[n],2!==d&&r.vertexColors.push(new THREE.Color(n)),0!==d&&p.vertexColors.push(new THREE.Color(n));c.faces.push(r);c.faces.push(p)}else{r=new THREE.Face3;r.a=u[k++];r.b=u[k++];r.c=u[k++];h&&(h=u[k++],r.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)s=u[k++],w=v[2*s],s=v[2*s+1], +w=new THREE.Vector2(w,s),c.faceVertexUvs[d][h].push(w);q&&(q=3*u[k++],r.normal.set(x[q++],x[q++],x[q]));if(t)for(d=0;3>d;d++)q=3*u[k++],t=new THREE.Vector3(x[q++],x[q++],x[q]),r.vertexNormals.push(t);n&&(n=u[k++],r.color.setHex(H[n]));if(b)for(d=0;3>d;d++)n=u[k++],r.vertexColors.push(new THREE.Color(H[n]));c.faces.push(r)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dz.parameters.opacity&&(z.parameters.transparent=!0);z.parameters.normalMap?(E=THREE.ShaderLib.normalmap,C=THREE.UniformsUtils.clone(E.uniforms), -t=z.parameters.color,N=z.parameters.specular,w=z.parameters.ambient,I=z.parameters.shininess,C.tNormal.value=D.textures[z.parameters.normalMap],z.parameters.normalScale&&C.uNormalScale.value.set(z.parameters.normalScale[0],z.parameters.normalScale[1]),z.parameters.map&&(C.tDiffuse.value=z.parameters.map,C.enableDiffuse.value=!0),z.parameters.envMap&&(C.tCube.value=z.parameters.envMap,C.enableReflection.value=!0,C.reflectivity.value=z.parameters.reflectivity),z.parameters.lightMap&&(C.tAO.value=z.parameters.lightMap, -C.enableAO.value=!0),z.parameters.specularMap&&(C.tSpecular.value=D.textures[z.parameters.specularMap],C.enableSpecular.value=!0),z.parameters.displacementMap&&(C.tDisplacement.value=D.textures[z.parameters.displacementMap],C.enableDisplacement.value=!0,C.uDisplacementBias.value=z.parameters.displacementBias,C.uDisplacementScale.value=z.parameters.displacementScale),C.diffuse.value.setHex(t),C.specular.value.setHex(N),C.ambient.value.setHex(w),C.shininess.value=I,z.parameters.opacity&&(C.opacity.value= -z.parameters.opacity),p=new THREE.ShaderMaterial({fragmentShader:E.fragmentShader,vertexShader:E.vertexShader,uniforms:C,lights:!0,fog:!0})):p=new THREE[z.type](z.parameters);p.name=M;D.materials[M]=p}for(M in y.materials)if(z=y.materials[M],z.parameters.materials){A=[];for(t=0;tI&&y.clearRect(V.min.x|0,V.min.y|0,V.max.x-V.min.x|0,V.max.y-V.min.y|0),0X.positionScreen.z||1O.positionScreen.z||1S.positionScreen.z||1=J||(J*=I.intensity,m.add(Da.multiplyScalar(J)))):I instanceof THREE.PointLight&&(N=Ea.setFromMatrixPosition(I.matrixWorld),J=P.dot(Ea.subVectors(N,E).normalize()), @@ -397,14 +399,14 @@ function c(a,b){var c=b.geometry,g=a.faces3,h=3*g.length,k=1*g.length,l=3*g.leng !0}function d(a,b){return a.material instanceof THREE.MeshFaceMaterial?a.material.materials[b.materialIndex]:a.material}function e(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){return a.map||a.lightMap||a.bumpMap||a.normalMap||a.specularMap||a instanceof THREE.ShaderMaterial?!0:!1}function g(a,b,c,d){for(var e in b){var f=b[e],g=c[e];if(0<= f)if(g){var h=g.itemSize;m.bindBuffer(m.ARRAY_BUFFER,g.buffer);k(f);m.vertexAttribPointer(f,h,m.FLOAT,!1,0,d*h*4)}else a.defaultAttributeValues&&(2===a.defaultAttributeValues[e].length?m.vertexAttrib2fv(f,a.defaultAttributeValues[e]):3===a.defaultAttributeValues[e].length&&m.vertexAttrib3fv(f,a.defaultAttributeValues[e]))}l()}function h(){for(var a=0,b=na.length;ad.numSupportedMorphTargets? -(n.sort(q),n.length=d.numSupportedMorphTargets):n.length>d.numSupportedMorphNormals?n.sort(q):0===n.length&&n.push([0,0]);for(p=0;pd.numSupportedMorphTargets? +(p.sort(q),p.length=d.numSupportedMorphTargets):p.length>d.numSupportedMorphNormals?p.sort(q):0===p.length&&p.push([0,0]);for(n=0;na?b(c,e-1):l[e]< a?b(e+1,d):e}return b(0,l.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,k=0,l=[],n,q,s;for(e=0;e>8&255,l>>16&255,l>>24&255)),e}e.mipmapCount=1;k[2]&131072&&!1!==b&&(e.mipmapCount=Math.max(1,k[7]));e.isCubemap=k[28]&512?!0:!1;e.width=k[4];e.height=k[3];for(var k=k[1]+4,g=e.width,h=e.height,l=e.isCubemap?6:1,q=0;qq-1?0:q-1,r=q+1>e-1?e-1:q+1,u=0>n-1?0:n-1,p=n+1>d-1?d-1:n+1,v=[],w=[0,0,h[4*(q*d+n)]/255*b];v.push([-1,0,h[4*(q*d+u)]/255*b]);v.push([-1,-1,h[4*(s*d+u)]/255*b]);v.push([0,-1,h[4*(s*d+n)]/255*b]);v.push([1,-1,h[4*(s*d+p)]/255*b]);v.push([1,0,h[4*(q*d+p)]/255*b]);v.push([1,1,h[4*(r*d+p)]/255*b]);v.push([0,1,h[4*(r*d+n)]/255*b]);v.push([-1,1,h[4*(r*d+u)]/255*b]);s=[];u=v.length;for(r=0;rq-1?0:q-1,r=q+1>e-1?e-1:q+1,t=0>n-1?0:n-1,p=n+1>d-1?d-1:n+1,v=[],w=[0,0,h[4*(q*d+n)]/255*b];v.push([-1,0,h[4*(q*d+t)]/255*b]);v.push([-1,-1,h[4*(s*d+t)]/255*b]);v.push([0,-1,h[4*(s*d+n)]/255*b]);v.push([1,-1,h[4*(s*d+p)]/255*b]);v.push([1,0,h[4*(q*d+p)]/255*b]);v.push([1,1,h[4*(r*d+p)]/255*b]);v.push([0,1,h[4*(r*d+n)]/255*b]);v.push([-1,1,h[4*(r*d+t)]/255*b]);s=[];t=v.length;for(r=0;re)return null;var f=[],g=[],h=[],k,l,n;if(0=q--){console.log("Warning, unable to triangulate polygon!");break}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);n=l+1;e<=n&&(n=0);var s;a:{var r=s=void 0,u=void 0,p=void 0,v=void 0,w=void 0,t=void 0,x=void 0,H= -void 0,r=a[g[k]].x,u=a[g[k]].y,p=a[g[l]].x,v=a[g[l]].y,w=a[g[n]].x,t=a[g[n]].y;if(1E-10>(p-r)*(t-u)-(v-u)*(w-r))s=!1;else{var G=void 0,P=void 0,F=void 0,D=void 0,K=void 0,y=void 0,E=void 0,I=void 0,C=void 0,N=void 0,C=I=E=H=x=void 0,G=w-p,P=t-v,F=r-w,D=u-t,K=p-r,y=v-u;for(s=0;se)return null;var f=[],g=[],h=[],k,l,n;if(0=q--){console.log("Warning, unable to triangulate polygon!");break}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);n=l+1;e<=n&&(n=0);var s;a:{var r=s=void 0,t=void 0,p=void 0,v=void 0,w=void 0,u=void 0,x=void 0,H= +void 0,r=a[g[k]].x,t=a[g[k]].y,p=a[g[l]].x,v=a[g[l]].y,w=a[g[n]].x,u=a[g[n]].y;if(1E-10>(p-r)*(u-t)-(v-t)*(w-r))s=!1;else{var G=void 0,P=void 0,F=void 0,D=void 0,K=void 0,y=void 0,E=void 0,I=void 0,C=void 0,N=void 0,C=I=E=H=x=void 0,G=w-p,P=u-v,F=r-w,D=t-u,K=p-r,y=v-t;for(s=0;sk)g=d+1;else if(0b&&(b=0);1Math.abs(d.x-c[0].x)&&1E-10>Math.abs(d.y-c[0].y)&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; THREE.Path.prototype.toShapes=function(a){function b(a,b){for(var c=b.length,d=!1,e=c-1,f=0;fl&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y==g.y){if(a.x==g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0==e)return!0;0>e||(d=!d)}}else if(a.y==g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var c,d,e,f,g=[],h=new THREE.Path;c=0;for(d=this.actions.length;ca.length-2?l:l+1;c[3]=l>a.length-3?l:l+2;l=a[c[0]];q=a[c[1]];s=a[c[2]];r=a[c[3]];c=k*k;n=k*c;h[0]=d(l[0],q[0],s[0],r[0],k,c,n);h[1]=d(l[1],q[1],s[1],r[1],k,c,n);h[2]=d(l[2],q[2],s[2],r[2],k,c,n);return h},d=function(a,b,c,d,k,l,n){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*n+(-3*(b-c)-2*a-d)*l+a*k+b};return function(d){if(!1!== this.isPlaying){this.currentTime+=d*this.timeScale;var f;d=["pos","rot","scl"];var g=this.data.length;if(!0===this.loop&&this.currentTime>g)this.currentTime%=g,this.reset();else if(!1===this.loop&&this.currentTime>g){this.stop();return}this.currentTime=Math.min(this.currentTime,g);for(var g=0,h=this.hierarchy.length;gn;n++){f=d[n];var q=l.prevKey[f],s=l.nextKey[f];if(s.time<=this.currentTime){q=this.data.hierarchy[g].keys[0];for(s=this.getNextKeyWith(f, -g,1);s.timeq.index;)q=s,s=this.getNextKeyWith(f,g,s.index+1);l.prevKey[f]=q;l.nextKey[f]=s}k.matrixAutoUpdate=!0;k.matrixWorldNeedsUpdate=!0;var r=(this.currentTime-q.time)/(s.time-q.time),u=q[f],p=s[f];0>r&&(r=0);1q.index;)q=s,s=this.getNextKeyWith(f,g,s.index+1);l.prevKey[f]=q;l.nextKey[f]=s}k.matrixAutoUpdate=!0;k.matrixWorldNeedsUpdate=!0;var r=(this.currentTime-q.time)/(s.time-q.time),t=q[f],p=s[f];0>r&&(r=0);1=e)return new THREE.Vector2(c,a);e=Math.sqrt(e/2)}else a=!1,1E-10e?-1E-10>g&& -(a=!0):d(f)==d(h)&&(a=!0),a?(c=-f,a=e,e=Math.sqrt(k)):(c=e,a=f,e=Math.sqrt(k/2));return new THREE.Vector2(c/e,a/e)}function e(c,d){var e,f;for(O=c.length;0<=--O;){e=O;f=O-1;0>f&&(f=c.length-1);for(var g=0,h=r+2*n,g=0;gf&&(f=c.length-1);for(var g=0,h=r+2*n,g=0;gMath.abs(c-k)?[new THREE.Vector2(b,1-e),new THREE.Vector2(d,1-f),new THREE.Vector2(l,1-g),new THREE.Vector2(q,1-a)]:[new THREE.Vector2(c,1-e),new THREE.Vector2(k,1-f),new THREE.Vector2(n,1-g),new THREE.Vector2(s,1-a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2; THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);!1===a instanceof Array&&(a=[a]);this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;cc&&1===a.x&&(a=new THREE.Vector2(a.x-1,a.y));0===b.x&&0===b.z&&(a=new THREE.Vector2(c/2/ -Math.PI+0.5,a.y));return a.clone()}THREE.Geometry.call(this);c=c||1;d=d||0;for(var k=this,l=0,n=a.length;lr&&(0.2>d&&(b[0].x+=1),0.2>a&&(b[1].x+=1),0.2>q&&(b[2].x+=1));l=0;for(n=this.vertices.length;lr&&(0.2>d&&(b[0].x+=1),0.2>a&&(b[1].x+=1),0.2>q&&(b[2].x+=1));l=0;for(n=this.vertices.length;lc.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}(); THREE.ArrowHelper.prototype.setLength=function(a,b,c){void 0===b&&(b=0.2*a);void 0===c&&(c=0.2*b);this.line.scale.set(1,a,1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};THREE.BoxHelper=function(a){var b=[new THREE.Vector3(1,1,1),new THREE.Vector3(-1,1,1),new THREE.Vector3(-1,-1,1),new THREE.Vector3(1,-1,1),new THREE.Vector3(1,1,-1),new THREE.Vector3(-1,1,-1),new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,-1,-1)];this.vertices=b;var c=new THREE.Geometry;c.vertices.push(b[0],b[1],b[1],b[2],b[2],b[3],b[3],b[0],b[4],b[5],b[5],b[6],b[6],b[7],b[7],b[4],b[0],b[4],b[1],b[5],b[2],b[6],b[3],b[7]);THREE.Line.call(this,c,new THREE.LineBasicMaterial({color:16776960}),THREE.LinePieces); @@ -668,7 +670,7 @@ THREE.CameraHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THR 1.1,-1);d("u2",-0.7,1.1,-1);d("u3",0,2,-1);d("cf1",-1,0,1);d("cf2",1,0,1);d("cf3",0,-1,1);d("cf4",0,1,1);d("cn1",-1,0,-1);d("cn2",1,0,-1);d("cn3",0,-1,-1);d("cn4",0,1,-1);this.geometry.verticesNeedUpdate=!0}}();THREE.DirectionalLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrixWorld=a.matrixWorld;this.matrixAutoUpdate=!1;b=b||1;var c=new THREE.Geometry;c.vertices.push(new THREE.Vector3(-b,b,0),new THREE.Vector3(b,b,0),new THREE.Vector3(b,-b,0),new THREE.Vector3(-b,-b,0),new THREE.Vector3(-b,b,0));var d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.lightPlane=new THREE.Line(c,d);this.add(this.lightPlane); c=new THREE.Geometry;c.vertices.push(new THREE.Vector3,new THREE.Vector3);d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine=new THREE.Line(c,d);this.add(this.targetLine);this.update()};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype); THREE.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()}; -THREE.DirectionalLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,a);this.lightPlane.lookAt(c);this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine.geometry.vertices[1].copy(c);this.targetLine.geometry.verticesNeedUpdate=!0;this.targetLine.material.color.copy(this.lightPlane.material.color)}}();THREE.EdgesHelper=function(a,b){var c=void 0!==b?b:16777215,d=[0,0],e={},f=function(a,b){return a-b},g=["a","b","c"],h=new THREE.BufferGeometry,k=a.geometry.clone();k.mergeVertices();k.computeFaceNormals();for(var l=k.vertices,k=k.faces,n=0,q=0,s=k.length;qu;u++){d[0]=r[g[u]];d[1]=r[g[(u+1)%3]];d.sort(f);var p=d.toString();void 0===e[p]?(e[p]={vert1:d[0],vert2:d[1],face1:q,face2:void 0},n++):e[p].face2=q}h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d=h.attributes.position.array; +THREE.DirectionalLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,a);this.lightPlane.lookAt(c);this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine.geometry.vertices[1].copy(c);this.targetLine.geometry.verticesNeedUpdate=!0;this.targetLine.material.color.copy(this.lightPlane.material.color)}}();THREE.EdgesHelper=function(a,b){var c=void 0!==b?b:16777215,d=[0,0],e={},f=function(a,b){return a-b},g=["a","b","c"],h=new THREE.BufferGeometry,k=a.geometry.clone();k.mergeVertices();k.computeFaceNormals();for(var l=k.vertices,k=k.faces,n=0,q=0,s=k.length;qt;t++){d[0]=r[g[t]];d[1]=r[g[(t+1)%3]];d.sort(f);var p=d.toString();void 0===e[p]?(e[p]={vert1:d[0],vert2:d[1],face1:q,face2:void 0},n++):e[p].face2=q}h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d=h.attributes.position.array; f=0;for(p in e)if(g=e[p],void 0===g.face2||0.9999>k[g.face1].normal.dot(k[g.face2].normal))n=l[g.vert1],d[f++]=n.x,d[f++]=n.y,d[f++]=n.z,n=l[g.vert2],d[f++]=n.x,d[f++]=n.y,d[f++]=n.z;THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.EdgesHelper.prototype=Object.create(THREE.Line.prototype);THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=new THREE.Geometry;c=0;for(var e=this.object.geometry.faces.length;cb;b++)a.faces[b].color=this.colors[4>b?0:1];b=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0});this.lightSphere=new THREE.Mesh(a,b);this.add(this.lightSphere); @@ -680,8 +682,8 @@ THREE.VertexNormalsHelper.prototype=Object.create(THREE.Line.prototype); THREE.VertexNormalsHelper.prototype.update=function(a){var b=new THREE.Vector3;return function(a){a=["a","b","c","d"];this.object.updateMatrixWorld(!0);this.normalMatrix.getNormalMatrix(this.object.matrixWorld);for(var d=this.geometry.vertices,e=this.object.geometry.vertices,f=this.object.geometry.faces,g=this.object.matrixWorld,h=0,k=0,l=f.length;kp;p++){d[0]=u[g[p]];d[1]=u[g[(p+1)%3]];d.sort(f);var v=d.toString();void 0===e[v]&&(q[2*n]=d[0],q[2*n+1]=d[1],e[v]=!0,n++)}h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d= -h.attributes.position.array;s=0;for(r=n;sp;p++)n=k[q[2*s+p]],g=6*s+3*p,d[g+0]=n.x,d[g+1]=n.y,d[g+2]=n.z}else if(a.geometry instanceof THREE.BufferGeometry&&void 0!==a.geometry.attributes.index){for(var k=a.geometry.attributes.position.array,r=a.geometry.attributes.index.array,l=a.geometry.offsets,n=0,q=new Uint32Array(2*r.length),u=0,w=l.length;up;p++)d[0]=g+r[s+p],d[1]=g+r[s+(p+1)%3],d.sort(f),v=d.toString(), +h+=1}this.geometry.verticesNeedUpdate=!0;return this}}();THREE.WireframeHelper=function(a,b){var c=void 0!==b?b:16777215,d=[0,0],e={},f=function(a,b){return a-b},g=["a","b","c"],h=new THREE.BufferGeometry;if(a.geometry instanceof THREE.Geometry){for(var k=a.geometry.vertices,l=a.geometry.faces,n=0,q=new Uint32Array(6*l.length),s=0,r=l.length;sp;p++){d[0]=t[g[p]];d[1]=t[g[(p+1)%3]];d.sort(f);var v=d.toString();void 0===e[v]&&(q[2*n]=d[0],q[2*n+1]=d[1],e[v]=!0,n++)}h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d= +h.attributes.position.array;s=0;for(r=n;sp;p++)n=k[q[2*s+p]],g=6*s+3*p,d[g+0]=n.x,d[g+1]=n.y,d[g+2]=n.z}else if(a.geometry instanceof THREE.BufferGeometry&&void 0!==a.geometry.attributes.index){for(var k=a.geometry.attributes.position.array,r=a.geometry.attributes.index.array,l=a.geometry.offsets,n=0,q=new Uint32Array(2*r.length),t=0,w=l.length;tp;p++)d[0]=g+r[s+p],d[1]=g+r[s+(p+1)%3],d.sort(f),v=d.toString(), void 0===e[v]&&(q[2*n]=d[0],q[2*n+1]=d[1],e[v]=!0,n++);h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d=h.attributes.position.array;s=0;for(r=n;sp;p++)g=6*s+3*p,n=3*q[2*s+p],d[g+0]=k[n],d[g+1]=k[n+1],d[g+2]=k[n+2]}else if(a.geometry instanceof THREE.BufferGeometry)for(k=a.geometry.attributes.position.array,n=k.length/3,q=n/3,h.addAttribute("position",new THREE.Float32Attribute(2*n,3)),d=h.attributes.position.array,s=0,r=q;sp;p++)g=18*s+6*p,q=9*s+3*p, d[g+0]=k[q],d[g+1]=k[q+1],d[g+2]=k[q+2],n=9*s+(p+1)%3*3,d[g+3]=k[n],d[g+4]=k[n+1],d[g+5]=k[n+2];THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.WireframeHelper.prototype=Object.create(THREE.Line.prototype);THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(a){}};THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype); THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new THREE.Color(16777215));void 0===d&&(d=THREE.NormalBlending);c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:e,blending:d})}; @@ -692,36 +694,36 @@ THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=thi THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b}; THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1}; THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;bd.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight; -f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};THREE.LensFlarePlugin=function(){function a(a,c){var d=b.createProgram(),e=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER),g="precision "+c+" float;\n";b.shaderSource(e,g+a.fragmentShader);b.shaderSource(f,g+a.vertexShader);b.compileShader(e);b.compileShader(f);b.attachShader(d,e);b.attachShader(d,f);b.linkProgram(d);return d}var b,c,d,e,f,g,h,k,l,n,q,s,r;this.init=function(u){b=u.context;c=u;d=u.getPrecision();e=new Float32Array(16);f=new Uint16Array(6);u=0;e[u++]=-1;e[u++]=-1; -e[u++]=0;e[u++]=0;e[u++]=1;e[u++]=-1;e[u++]=1;e[u++]=0;e[u++]=1;e[u++]=1;e[u++]=1;e[u++]=1;e[u++]=-1;e[u++]=1;e[u++]=0;e[u++]=1;u=0;f[u++]=0;f[u++]=1;f[u++]=2;f[u++]=0;f[u++]=2;f[u++]=3;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,e,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);k=b.createTexture();l=b.createTexture();b.bindTexture(b.TEXTURE_2D,k);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16, +f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};THREE.LensFlarePlugin=function(){function a(a,c){var d=b.createProgram(),e=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER),g="precision "+c+" float;\n";b.shaderSource(e,g+a.fragmentShader);b.shaderSource(f,g+a.vertexShader);b.compileShader(e);b.compileShader(f);b.attachShader(d,e);b.attachShader(d,f);b.linkProgram(d);return d}var b,c,d,e,f,g,h,k,l,n,q,s,r;this.init=function(t){b=t.context;c=t;d=t.getPrecision();e=new Float32Array(16);f=new Uint16Array(6);t=0;e[t++]=-1;e[t++]=-1; +e[t++]=0;e[t++]=0;e[t++]=1;e[t++]=-1;e[t++]=1;e[t++]=0;e[t++]=1;e[t++]=1;e[t++]=1;e[t++]=1;e[t++]=-1;e[t++]=1;e[t++]=0;e[t++]=1;t=0;f[t++]=0;f[t++]=1;f[t++]=2;f[t++]=0;f[t++]=2;f[t++]=3;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,e,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);k=b.createTexture();l=b.createTexture();b.bindTexture(b.TEXTURE_2D,k);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16, 0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,l);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE); b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(n=!1,q=a(THREE.ShaderFlares.lensFlare,d)):(n=!0,q=a(THREE.ShaderFlares.lensFlareVertexTexture,d));s={};r={};s.vertex=b.getAttribLocation(q,"position");s.uv=b.getAttribLocation(q,"uv");r.renderType=b.getUniformLocation(q,"renderType");r.map=b.getUniformLocation(q,"map");r.occlusionMap=b.getUniformLocation(q,"occlusionMap");r.opacity= -b.getUniformLocation(q,"opacity");r.color=b.getUniformLocation(q,"color");r.scale=b.getUniformLocation(q,"scale");r.rotation=b.getUniformLocation(q,"rotation");r.screenPosition=b.getUniformLocation(q,"screenPosition")};this.render=function(a,d,e,f){a=a.__webglFlares;var t=a.length;if(t){var x=new THREE.Vector3,H=f/e,G=0.5*e,P=0.5*f,F=16/f,D=new THREE.Vector2(F*H,F),K=new THREE.Vector3(1,1,0),y=new THREE.Vector2(1,1),E=r,F=s;b.useProgram(q);b.enableVertexAttribArray(s.vertex);b.enableVertexAttribArray(s.uv); -b.uniform1i(E.occlusionMap,0);b.uniform1i(E.map,1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(F.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(F.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var I,C,N,z,M;for(I=0;ID;D++)H[D]=new THREE.Vector3,t[D]=new THREE.Vector3;H=G.shadowCascadeNearZ[x];G=G.shadowCascadeFarZ[x];t[0].set(-1,-1,H);t[1].set(1,-1,H);t[2].set(-1, -1,H);t[3].set(1,1,H);t[4].set(-1,-1,G);t[5].set(1,-1,G);t[6].set(-1,1,G);t[7].set(1,1,G);F.originalCamera=s;t=new THREE.Gyroscope;t.position.copy(p.shadowCascadeOffset);t.add(F);t.add(F.target);s.add(t);p.shadowCascadeArray[w]=F;console.log("Created virtualLight",F)}x=p;H=w;G=x.shadowCascadeArray[H];G.position.copy(x.position);G.target.position.copy(x.target.position);G.lookAt(G.target);G.shadowCameraVisible=x.shadowCameraVisible;G.shadowDarkness=x.shadowDarkness;G.shadowBias=x.shadowCascadeBias[H]; -t=x.shadowCascadeNearZ[H];x=x.shadowCascadeFarZ[H];G=G.pointsFrustum;G[0].z=t;G[1].z=t;G[2].z=t;G[3].z=t;G[4].z=x;G[5].z=x;G[6].z=x;G[7].z=x;P[v]=F;v++}else P[v]=p,v++;r=0;for(u=P.length;rD;D++)H[D]=new THREE.Vector3,u[D]=new THREE.Vector3;H=G.shadowCascadeNearZ[x];G=G.shadowCascadeFarZ[x];u[0].set(-1,-1,H);u[1].set(1,-1,H);u[2].set(-1, +1,H);u[3].set(1,1,H);u[4].set(-1,-1,G);u[5].set(1,-1,G);u[6].set(-1,1,G);u[7].set(1,1,G);F.originalCamera=s;u=new THREE.Gyroscope;u.position.copy(p.shadowCascadeOffset);u.add(F);u.add(F.target);s.add(u);p.shadowCascadeArray[w]=F;console.log("Created virtualLight",F)}x=p;H=w;G=x.shadowCascadeArray[H];G.position.copy(x.position);G.target.position.copy(x.target.position);G.lookAt(G.target);G.shadowCameraVisible=x.shadowCameraVisible;G.shadowDarkness=x.shadowDarkness;G.shadowBias=x.shadowCascadeBias[H]; +u=x.shadowCascadeNearZ[H];x=x.shadowCascadeFarZ[H];G=G.pointsFrustum;G[0].z=u;G[1].z=u;G[2].z=u;G[3].z=u;G[4].z=x;G[5].z=x;G[6].z=x;G[7].z=x;P[v]=F;v++}else P[v]=p,v++;r=0;for(t=P.length;rx;x++)H=G[x],H.copy(t[x]),THREE.ShadowMapPlugin.__projector.unprojectVector(H,w),H.applyMatrix4(v.matrixWorldInverse),H.xl.x&&(l.x=H.x),H.yl.y&&(l.y=H.y),H.zl.z&&(l.z=H.z);v.left=k.x;v.right=l.x;v.top=l.y;v.bottom=k.y;v.updateProjectionMatrix()}v=p.shadowMap;t=p.shadowMatrix;w=p.shadowCamera;w.position.setFromMatrixPosition(p.matrixWorld);n.setFromMatrixPosition(p.target.matrixWorld);w.lookAt(n);w.updateMatrixWorld();w.matrixWorldInverse.getInverse(w.matrixWorld);p.cameraHelper&&(p.cameraHelper.visible=p.shadowCameraVisible);p.shadowCameraVisible&&p.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5, -0,0,0.5,0.5,0,0,0,1);t.multiply(w.projectionMatrix);t.multiply(w.matrixWorldInverse);h.multiplyMatrices(w.projectionMatrix,w.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(v);b.clear();G=q.__webglObjects;p=0;for(v=G.length;p 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -t.compileShader(E);t.compileShader(I);t.attachShader(w,E);t.attachShader(w,I);t.linkProgram(w);K=w;p=t.getAttribLocation(K,"position");v=t.getAttribLocation(K,"uv");a=t.getUniformLocation(K,"uvOffset");b=t.getUniformLocation(K,"uvScale");c=t.getUniformLocation(K,"rotation");d=t.getUniformLocation(K,"scale");e=t.getUniformLocation(K,"color");f=t.getUniformLocation(K,"map");g=t.getUniformLocation(K,"opacity");h=t.getUniformLocation(K,"modelViewMatrix");k=t.getUniformLocation(K,"projectionMatrix");l= -t.getUniformLocation(K,"fogType");n=t.getUniformLocation(K,"fogDensity");q=t.getUniformLocation(K,"fogNear");s=t.getUniformLocation(K,"fogFar");r=t.getUniformLocation(K,"fogColor");u=t.getUniformLocation(K,"alphaTest");w=document.createElement("canvas");w.width=8;w.height=8;E=w.getContext("2d");E.fillStyle="#ffffff";E.fillRect(0,0,w.width,w.height);H=new THREE.Texture(w);H.needsUpdate=!0};this.render=function(y,E,G,C){G=y.__webglSprites;if(C=G.length){t.useProgram(K);t.enableVertexAttribArray(p); -t.enableVertexAttribArray(v);t.disable(t.CULL_FACE);t.enable(t.BLEND);t.bindBuffer(t.ARRAY_BUFFER,F);t.vertexAttribPointer(p,2,t.FLOAT,!1,16,0);t.vertexAttribPointer(v,2,t.FLOAT,!1,16,8);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,D);t.uniformMatrix4fv(k,!1,E.projectionMatrix.elements);t.activeTexture(t.TEXTURE0);t.uniform1i(f,0);var N=0,z=0,M=y.fog;M?(t.uniform3f(r,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(t.uniform1f(q,M.near),t.uniform1f(s,M.far),t.uniform1i(l,1),z=N=1):M instanceof THREE.FogExp2&& -(t.uniform1f(n,M.density),t.uniform1i(l,2),z=N=2)):(t.uniform1i(l,0),z=N=0);for(var A,J=[],M=0;Mx;x++)H=G[x],H.copy(u[x]),THREE.ShadowMapPlugin.__projector.unprojectVector(H,w),H.applyMatrix4(v.matrixWorldInverse),H.xl.x&&(l.x=H.x),H.yl.y&&(l.y=H.y),H.zl.z&&(l.z=H.z);v.left=k.x;v.right=l.x;v.top=l.y;v.bottom=k.y;v.updateProjectionMatrix()}v=p.shadowMap;u=p.shadowMatrix;w=p.shadowCamera;w.position.setFromMatrixPosition(p.matrixWorld);n.setFromMatrixPosition(p.target.matrixWorld);w.lookAt(n);w.updateMatrixWorld();w.matrixWorldInverse.getInverse(w.matrixWorld);p.cameraHelper&&(p.cameraHelper.visible=p.shadowCameraVisible);p.shadowCameraVisible&&p.cameraHelper.update();u.set(0.5,0,0,0.5,0,0.5,0,0.5, +0,0,0.5,0.5,0,0,0,1);u.multiply(w.projectionMatrix);u.multiply(w.matrixWorldInverse);h.multiplyMatrices(w.projectionMatrix,w.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(v);b.clear();G=q.__webglObjects;p=0;for(v=G.length;p 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); +u.compileShader(E);u.compileShader(I);u.attachShader(w,E);u.attachShader(w,I);u.linkProgram(w);K=w;p=u.getAttribLocation(K,"position");v=u.getAttribLocation(K,"uv");a=u.getUniformLocation(K,"uvOffset");b=u.getUniformLocation(K,"uvScale");c=u.getUniformLocation(K,"rotation");d=u.getUniformLocation(K,"scale");e=u.getUniformLocation(K,"color");f=u.getUniformLocation(K,"map");g=u.getUniformLocation(K,"opacity");h=u.getUniformLocation(K,"modelViewMatrix");k=u.getUniformLocation(K,"projectionMatrix");l= +u.getUniformLocation(K,"fogType");n=u.getUniformLocation(K,"fogDensity");q=u.getUniformLocation(K,"fogNear");s=u.getUniformLocation(K,"fogFar");r=u.getUniformLocation(K,"fogColor");t=u.getUniformLocation(K,"alphaTest");w=document.createElement("canvas");w.width=8;w.height=8;E=w.getContext("2d");E.fillStyle="#ffffff";E.fillRect(0,0,w.width,w.height);H=new THREE.Texture(w);H.needsUpdate=!0};this.render=function(y,E,G,C){G=y.__webglSprites;if(C=G.length){u.useProgram(K);u.enableVertexAttribArray(p); +u.enableVertexAttribArray(v);u.disable(u.CULL_FACE);u.enable(u.BLEND);u.bindBuffer(u.ARRAY_BUFFER,F);u.vertexAttribPointer(p,2,u.FLOAT,!1,16,0);u.vertexAttribPointer(v,2,u.FLOAT,!1,16,8);u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,D);u.uniformMatrix4fv(k,!1,E.projectionMatrix.elements);u.activeTexture(u.TEXTURE0);u.uniform1i(f,0);var N=0,z=0,M=y.fog;M?(u.uniform3f(r,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(u.uniform1f(q,M.near),u.uniform1f(s,M.far),u.uniform1i(l,1),z=N=1):M instanceof THREE.FogExp2&& +(u.uniform1f(n,M.density),u.uniform1i(l,2),z=N=2)):(u.uniform1i(l,0),z=N=0);for(var A,J=[],M=0;M