From 15a3f8e92b4df278849ff60c359de7835f58249f Mon Sep 17 00:00:00 2001 From: alteredq Date: Wed, 11 Jul 2012 22:28:18 +0200 Subject: [PATCH] Added computeVertexNormals to BufferGeometry. --- build/Three.js | 702 +++++++++++++++--------------- build/custom/ThreeExtras.js | 144 +++--- build/custom/ThreeWebGL.js | 470 ++++++++++---------- src/extras/core/BufferGeometry.js | 109 +++++ 4 files changed, 770 insertions(+), 655 deletions(-) diff --git a/build/Three.js b/build/Three.js index 49559f675f..64ca9f9448 100644 --- a/build/Three.js +++ b/build/Three.js @@ -17,55 +17,55 @@ THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a; a;this.z=this.z+a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x=this.x*a.x;this.y=this.y*a.y;this.z=this.z*a.z;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;return this},divideSelf:function(a){this.x=this.x/a.x;this.y= this.y/a.y;this.z=this.z/a.z;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a}else this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())}, setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this, -a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],k=d[5],j=d[9],l=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-j,d);this.z=Math.atan2(-f,e)}else{this.x=Math.atan2(h,k);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(j));if(Math.abs(j)< -0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(h,k)}else{this.y=Math.atan2(-l,e);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-l,d);this.z=Math.atan2(-f,k)}else{this.y=0;this.z=Math.atan2(g,e)}}else if(b==="ZYX"){this.y=Math.asin(-c(l));if(Math.abs(l)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(h,e)}else{this.x=0;this.z=Math.atan2(-f,k)}}else if(b==="YZX"){this.z=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-j,k);this.y=Math.atan2(-l, -e)}else{this.x=0;this.y=Math.atan2(l,d)}}else if(b==="XZY"){this.z=Math.asin(-c(f));if(Math.abs(f)<0.99999){this.x=Math.atan2(o,k);this.y=Math.atan2(g,e)}else{this.x=Math.atan2(-g,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,g=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-e+f);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-e-f)}else if(b=== +a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],k=d[9],l=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-k,d);this.z=Math.atan2(-f,e)}else{this.x=Math.atan2(h,i);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(k));if(Math.abs(k)< +0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(h,i)}else{this.y=Math.atan2(-l,e);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-l,d);this.z=Math.atan2(-f,i)}else{this.y=0;this.z=Math.atan2(g,e)}}else if(b==="ZYX"){this.y=Math.asin(-c(l));if(Math.abs(l)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(h,e)}else{this.x=0;this.z=Math.atan2(-f,i)}}else if(b==="YZX"){this.z=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-k,i);this.y=Math.atan2(-l, +e)}else{this.x=0;this.y=Math.atan2(l,d)}}else if(b==="XZY"){this.z=Math.asin(-c(f));if(Math.abs(f)<0.99999){this.x=Math.atan2(o,i);this.y=Math.atan2(g,e)}else{this.x=Math.atan2(-g,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,g=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-e+f);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-e-f)}else if(b=== "YXZ"){this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g-d-e+f);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+e-f)}else if(b==="ZXY"){this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-e+f);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+e-f)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-e+f);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-e-f)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z* a.y),g-d+e-f);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-e-f);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)))}else if(b==="XZY"){this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),g-d+e-f);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+d-e-f);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)))}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x= b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},isZero:function(){return this.lengthSq()<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;this.w=this.w+a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x= this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;this.w=this.w-a.w;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a;this.w=this.w/a}else{this.z=this.y=this.x=0;this.w=1}return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;this.w=this.w+(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1.0E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y= -a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var j=a[10];if(Math.abs(d-g)<0.01&&Math.abs(f-c)<0.01&&Math.abs(k-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(f+c)<0.1&&Math.abs(k+b)<0.1&&Math.abs(e+h+j-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;e=(e+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;if(e>h&&e>j)if(e<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(e);c=d/b;d=f/b}else if(h> -j)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=k/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=f/d;c=k/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}}; +a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var k=a[10];if(Math.abs(d-g)<0.01&&Math.abs(f-c)<0.01&&Math.abs(i-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(f+c)<0.1&&Math.abs(i+b)<0.1&&Math.abs(e+h+k-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;e=(e+1)/2;h=(h+1)/2;k=(k+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;if(e>h&&e>k)if(e<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(e);c=d/b;d=f/b}else if(h> +k)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=i/c}else if(k<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(k);b=f/d;c=i/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+k-1)/2);return this}}; THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]}; -THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],j=c[7],l=c[8],o=c[9],m=c[10],p=c[11],r=c[12],n=c[13],q=c[14],c=c[15];b[0].set(f-a,j-g,p-l,c-r);b[1].set(f+a,j+g,p+l,c+r);b[2].set(f+d,j+h,p+o,c+n);b[3].set(f-d,j-h,p-o,c-n);b[4].set(f-e,j-k,p-m,c-q);b[5].set(f+e,j+k,p+m,c+q);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; +THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],i=c[6],k=c[7],l=c[8],o=c[9],m=c[10],p=c[11],r=c[12],n=c[13],q=c[14],c=c[15];b[0].set(f-a,k-g,p-l,c-r);b[1].set(f+a,k+g,p+l,c+r);b[2].set(f+d,k+h,p+o,c+n);b[3].set(f-d,k-h,p-o,c-n);b[4].set(f-e,k-i,p-m,c-q);b[5].set(f+e,k+i,p+m,c+q);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),e=0;e<6;e++){b=c[e].x*d[12]+c[e].y*d[13]+c[e].z*d[14]+c[e].w;if(b<=a)return false}return true};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,m=new THREE.Vector3,p=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,t,u,w,s=function(a,b,c){r.sub(c,a);t=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(t)); -return w=c.distanceTo(u)},x,F,C,z,v,H,I,N,R=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);x=r.dot(r);F=r.dot(n);C=r.dot(q);z=n.dot(n);v=n.dot(q);H=1/(x*z-F*F);I=(z*C-F*v)*H;N=(x*v-F*C)*H;return I>=0&&N>=0&&I+N<1},Y=1.0E-4;this.setPrecision=function(a){Y=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var i=0,n=a.children.length;ia.scale.x)return[];c={distance:w,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){i=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());i=a.geometry.boundingSphere.radius*Math.max(i.x,Math.max(i.y,i.z));w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>i)return d;var r,q,t=a.geometry,u=t.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);i=0;for(n=t.faces.length;i< -n;i++){c=t.faces[i];k.copy(this.origin);j.copy(this.direction);v=a.matrixWorld;l=v.multiplyVector3(l.copy(c.centroid)).subSelf(k);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=j.dot(o);if(!(Math.abs(r)0:r<0))){m.add(k,j.multiplyScalar(q));w=k.distanceTo(m);if(!(wthis.far))if(c instanceof THREE.Face3){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c])); +THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,m=new THREE.Vector3,p=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,s,u,w,t=function(a,b,c){r.sub(c,a);s=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(s)); +return w=c.distanceTo(u)},x,F,C,z,v,H,I,N,R=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);x=r.dot(r);F=r.dot(n);C=r.dot(q);z=n.dot(n);v=n.dot(q);H=1/(x*z-F*F);I=(z*C-F*v)*H;N=(x*v-F*C)*H;return I>=0&&N>=0&&I+N<1},Y=1.0E-4;this.setPrecision=function(a){Y=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var j=0,n=a.children.length;ja.scale.x)return[];c={distance:w,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){j=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());j=a.geometry.boundingSphere.radius*Math.max(j.x,Math.max(j.y,j.z));w=t(this.origin,this.direction,a.matrixWorld.getPosition());if(w>j)return d;var r,q,s=a.geometry,u=s.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);j=0;for(n=s.faces.length;j< +n;j++){c=s.faces[j];i.copy(this.origin);k.copy(this.direction);v=a.matrixWorld;l=v.multiplyVector3(l.copy(c.centroid)).subSelf(i);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=k.dot(o);if(!(Math.abs(r)0:r<0))){m.add(i,k.multiplyScalar(q));w=i.distanceTo(m);if(!(wthis.far))if(c instanceof THREE.Face3){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c])); if(R(m,e,f,g)){c={distance:w,point:m.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c]));h=v.multiplyVector3(h.copy(u[c.d]));if(R(m,e,f,h)||R(m,f,g,h)){c={distance:w,point:m.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(p);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,e=a.length;df?d:f;e=e>g?e:g}a()};this.add3Points=function(f,g,l,o,m,p){if(h===true){h=false;b=fl?f>m?f:m:l>m?l:m;e=g>o?g>p?g:p:o>p?o:p}else{b=fl?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d;e=g>o?g>p?g>e?g:e:p>e?p:e:o>p?o>e?o:e:p>e?p:e}a()};this.addRectangle=function(f){if(h===true){h=false;b=f.getLeft();c=f.getTop();d=f.getRight();e=f.getBottom()}else{b=bf.getRight()?d:f.getRight();e=e>f.getBottom()?e:f.getBottom()}a()};this.inflate=function(f){b=b-f;c=c-f;d=d+f;e=e+f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?false:true};this.empty=function(){h=true;e=d=c=b=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a0?1:0}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],k=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*e;l[4]=b*f;l[5]=b*g;l[6]=b*h;l[7]=b*k;l[8]=b*j;return this}, -transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,k,j,l,o,m,p,r,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,k||0,j||0,l!==void 0?l:1,o||0,m||0,p||0,r||0,n!==void 0?n:1)}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,j,l,o,m,p,r,n){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=k;q[6]=j;q[10]=l;q[14]=o;q[3]=m;q[7]=p;q[11]=r;q[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, -e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x=g.x+1.0E-4;e.cross(c,g).normalize()}f.cross(g,e);d[0]=e.x;d[4]=f.x;d[8]=g.x;d[1]=e.y;d[5]=f.y;d[9]=g.y;d[2]=e.z;d[6]=f.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],j=c[1],l=c[5],o=c[9],m=c[13],p=c[2],r=c[6],n=c[10],q=c[14],t=c[3],u=c[7],w=c[11],c=c[15],s=d[0],x=d[4], -F=d[8],C=d[12],z=d[1],v=d[5],H=d[9],I=d[13],N=d[2],R=d[6],Y=d[10],B=d[14],G=d[3],Q=d[7],D=d[11],d=d[15];e[0]=f*s+g*z+h*N+k*G;e[4]=f*x+g*v+h*R+k*Q;e[8]=f*F+g*H+h*Y+k*D;e[12]=f*C+g*I+h*B+k*d;e[1]=j*s+l*z+o*N+m*G;e[5]=j*x+l*v+o*R+m*Q;e[9]=j*F+l*H+o*Y+m*D;e[13]=j*C+l*I+o*B+m*d;e[2]=p*s+r*z+n*N+q*G;e[6]=p*x+r*v+n*R+q*Q;e[10]=p*F+r*H+n*Y+q*D;e[14]=p*C+r*I+n*B+q*d;e[3]=t*s+u*z+w*N+c*G;e[7]=t*x+u*v+w*R+c*Q;e[11]=t*F+u*H+w*Y+c*D;e[15]=t*C+u*I+w*B+c*d;return this},multiplySelf:function(a){return this.multiply(this, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],k=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*e;l[4]=b*f;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*k;return this}, +transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,k,l,o,m,p,r,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,i||0,k||0,l!==void 0?l:1,o||0,m||0,p||0,r||0,n!==void 0?n:1)}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,k,l,o,m,p,r,n){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=i;q[6]=k;q[10]=l;q[14]=o;q[3]=m;q[7]=p;q[11]=r;q[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, +e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x=g.x+1.0E-4;e.cross(c,g).normalize()}f.cross(g,e);d[0]=e.x;d[4]=f.x;d[8]=g.x;d[1]=e.y;d[5]=f.y;d[9]=g.y;d[2]=e.z;d[6]=f.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],i=c[12],k=c[1],l=c[5],o=c[9],m=c[13],p=c[2],r=c[6],n=c[10],q=c[14],s=c[3],u=c[7],w=c[11],c=c[15],t=d[0],x=d[4], +F=d[8],C=d[12],z=d[1],v=d[5],H=d[9],I=d[13],N=d[2],R=d[6],Y=d[10],B=d[14],G=d[3],Q=d[7],D=d[11],d=d[15];e[0]=f*t+g*z+h*N+i*G;e[4]=f*x+g*v+h*R+i*Q;e[8]=f*F+g*H+h*Y+i*D;e[12]=f*C+g*I+h*B+i*d;e[1]=k*t+l*z+o*N+m*G;e[5]=k*x+l*v+o*R+m*Q;e[9]=k*F+l*H+o*Y+m*D;e[13]=k*C+l*I+o*B+m*d;e[2]=p*t+r*z+n*N+q*G;e[6]=p*x+r*v+n*R+q*Q;e[10]=p*F+r*H+n*Y+q*D;e[14]=p*C+r*I+n*B+q*d;e[3]=s*t+u*z+w*N+c*G;e[7]=s*x+u*v+w*R+c*Q;e[11]=s*F+u*H+w*Y+c*D;e[15]=s*C+u*I+w*B+c*d;return this},multiplySelf:function(a){return this.multiply(this, a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]= b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=1/(b[3]*c+b[7]*d+b[11]*e+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*e+b[12])*f;a.y=(b[1]*c+b[5]*d+b[9]*e+b[13])*f;a.z=(b[2]*c+b[6]*d+b[10]*e+b[14])*f;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w;a.x=b[0]*c+b[4]*d+b[8]*e+b[12]*f;a.y=b[1]*c+b[5]*d+b[9]*e+b[13]*f;a.z=b[2]*c+b[6]*d+b[10]*e+b[14]*f;a.w=b[3]*c+b[7]*d+b[11]*e+b[15]*f;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1, c=0,d=a.length;c=0&&f>=0&&g>=0&&h>=0)return true;if(e<0&&f<0||g<0&&h<0)return false;e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f)));g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d, -g/(g-h)));if(d=0&&f>=0&&g>=0&&h>=0)return true;if(e<0&&f<0||g<0&&h<0)return false;e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f)));g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d, +g/(g-h)));if(dg&&h.positionScreen.zg&&h.positionScreen.z0)){K=j[k-2];I.copy(aa.positionScreen);N.copy(K.positionScreen);if(d(I,N)===true){I.multiplyScalar(1/I.w);N.multiplyScalar(1/N.w);X=void 0;if(q===t.length){X=new THREE.RenderableLine;t.push(X)}else X=t[q];q++;n=X;n.v1.positionScreen.copy(I);n.v2.positionScreen.copy(N);n.z=Math.max(I.z,N.z);n.material=O.material;x.elements.push(n)}}}}}a=0;for(i=x.sprites.length;a0&&C.z<1){g=void 0;if(w===s.length){g=new THREE.RenderableParticle;s.push(g)}else g=s[w];w++;u=g;u.x=C.x/C.w;u.y=C.y/C.w;u.z=C.z;u.rotation=O.rotation.z;u.scale.x=O.scale.x*Math.abs(u.x-(C.x+e.projectionMatrix.elements[0])/(C.w+e.projectionMatrix.elements[12]));u.scale.y=O.scale.y*Math.abs(u.y-(C.y+e.projectionMatrix.elements[5])/(C.w+e.projectionMatrix.elements[13])); +THREE.LinePieces?2:1;P=1;for(L=S.length;P0)){K=k[i-2];I.copy(aa.positionScreen);N.copy(K.positionScreen);if(d(I,N)===true){I.multiplyScalar(1/I.w);N.multiplyScalar(1/N.w);X=void 0;if(q===s.length){X=new THREE.RenderableLine;s.push(X)}else X=s[q];q++;n=X;n.v1.positionScreen.copy(I);n.v2.positionScreen.copy(N);n.z=Math.max(I.z,N.z);n.material=O.material;x.elements.push(n)}}}}}a=0;for(j=x.sprites.length;a0&&C.z<1){g=void 0;if(w===t.length){g=new THREE.RenderableParticle;t.push(g)}else g=t[w];w++;u=g;u.x=C.x/C.w;u.y=C.y/C.w;u.z=C.z;u.rotation=O.rotation.z;u.scale.x=O.scale.x*Math.abs(u.x-(C.x+e.projectionMatrix.elements[0])/(C.w+e.projectionMatrix.elements[12]));u.scale.y=O.scale.y*Math.abs(u.y-(C.y+e.projectionMatrix.elements[5])/(C.w+e.projectionMatrix.elements[13])); u.material=O.material;x.elements.push(u)}}}f&&x.elements.sort(c);return x}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),e=Math.cos(a.z/2),f=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=f*d*e+c*g*h;this.y=c*g*e-f*d*h;this.z=c*d*h+f*g*e;this.w=c*d*e-f*g*h}else if(b==="YXZ"){this.x=f*d*e+c*g*h;this.y=c*g*e-f*d*h;this.z= c*d*h-f*g*e;this.w=c*d*e+f*g*h}else if(b==="ZXY"){this.x=f*d*e-c*g*h;this.y=c*g*e+f*d*h;this.z=c*d*h+f*g*e;this.w=c*d*e-f*g*h}else if(b==="ZYX"){this.x=f*d*e-c*g*h;this.y=c*g*e+f*d*h;this.z=c*d*h-f*g*e;this.w=c*d*e+f*g*h}else if(b==="YZX"){this.x=f*d*e+c*g*h;this.y=c*g*e+f*d*h;this.z=c*d*h-f*g*e;this.w=c*d*e-f*g*h}else if(b==="XZY"){this.x=f*d*e-c*g*h;this.y=c*g*e-f*d*h;this.z=c*d*h+f*g*e;this.w=c*d*e+f*g*h}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y* -d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],j=c+f+b;if(j>0){c=0.5/Math.sqrt(j+1);this.w=0.25/c;this.x=(k-g)*c;this.y=(d-h)*c;this.z=(e-a)*c}else if(c>f&&c>b){c=2*Math.sqrt(1+c-f-b);this.w=(k-g)/c;this.x=0.25*c;this.y=(a+e)/c;this.z=(d+h)/c}else if(f>b){c=2*Math.sqrt(1+f-c-b);this.w=(d-h)/c;this.x=(a+e)/c;this.y=0.25*c;this.z=(g+k)/c}else{c=2*Math.sqrt(1+b-c-f);this.w=(e-a)/c;this.x= -(d+h)/c;this.y=(g+k)/c;this.z=0.25*c}return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= +d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],i=b[6],b=b[10],k=c+f+b;if(k>0){c=0.5/Math.sqrt(k+1);this.w=0.25/c;this.x=(i-g)*c;this.y=(d-h)*c;this.z=(e-a)*c}else if(c>f&&c>b){c=2*Math.sqrt(1+c-f-b);this.w=(i-g)/c;this.x=0.25*c;this.y=(a+e)/c;this.z=(d+h)/c}else if(f>b){c=2*Math.sqrt(1+f-c-b);this.w=(d-h)/c;this.x=(a+e)/c;this.y=0.25*c;this.z=(g+i)/c}else{c=2*Math.sqrt(1+b-c-f);this.w=(e-a)/c;this.x= +(d+h)/c;this.y=(g+i)/c;this.z=0.25*c}return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z, -f=this.x,g=this.y,h=this.z,k=this.w,j=k*c+g*e-h*d,l=k*d+h*c-f*e,o=k*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*k+c*-f+l*-h-o*-g;b.y=l*k+c*-g+o*-f-j*-h;b.z=o*k+c*-h+j*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=f;this.x=c;this.y=d;this.z=e;return this}var h=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){this.w=0.5*(f+this.w);this.x=0.5*(c+this.x); -this.y=0.5*(d+this.y);this.z=0.5*(e+this.z);return this}g=Math.sin((1-b)*h)/k;h=Math.sin(b*h)/k;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+this.y*h;this.z=e*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; +f=this.x,g=this.y,h=this.z,i=this.w,k=i*c+g*e-h*d,l=i*d+h*c-f*e,o=i*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=k*i+c*-f+l*-h-o*-g;b.y=l*i+c*-g+o*-f-k*-h;b.z=o*i+c*-h+k*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=f;this.x=c;this.y=d;this.z=e;return this}var h=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.0010){this.w=0.5*(f+this.w);this.x=0.5*(c+this.x); +this.y=0.5*(d+this.y);this.z=0.5*(e+this.z);return this}g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+this.y*h;this.z=e*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;dc.x)c.x= a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g,h;f=0;for(g=this.vertices.length;f0;a--)if(d.indexOf(e["abcd"[a]])!=a){d.splice(a,1);this.faces[f]=new THREE.Face3(d[0],d[1],d[2]);e=0;for(d=this.faceVertexUvs.length;ethis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: -f+2;j=this.points[c[0]];l=this.points[c[1]];o=this.points[c[2]];m=this.points[c[3]];h=g*g;k=g*h;d.x=b(j.x,l.x,o.x,m.x,g,h,k);d.y=b(j.y,l.y,o.y,m.y,g,h,k);d.z=b(j.z,l.z,o.z,m.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: +f+2;k=this.points[c[0]];l=this.points[c[1]];o=this.points[c[2]];m=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,l.x,o.x,m.x,g,h,i);d.y=b(k.y,l.y,o.y,m.y,g,h,i);d.z=b(k.z,l.z,o.z,m.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a1&&(N=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(I,N);a.name=m;if(u){a.matrixAutoUpdate=false;a.matrix.set(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])}else{a.position.set(x[0],x[1],x[2]);if(C){a.quaternion.set(C[0],C[1],C[2],C[3]);a.useQuaternion=true}else a.rotation.set(F[0],F[1],F[2]);a.scale.set(z[0],z[1],z[2])}a.visible=t.visible;a.doubleSided=t.doubleSided;a.castShadow=t.castShadow;a.receiveShadow=t.receiveShadow;L.scene.add(a);L.objects[m]=a}}else{x=t.position;F=t.rotation;C=t.quaternion; -z=t.scale;C=0;a=new THREE.Object3D;a.name=m;a.position.set(x[0],x[1],x[2]);if(C){a.quaternion.set(C[0],C[1],C[2],C[3]);a.useQuaternion=true}else a.rotation.set(F[0],F[1],F[2]);a.scale.set(z[0],z[1],z[2]);a.visible=t.visible!==void 0?t.visible:false;L.scene.add(a);L.objects[m]=a;L.empties[m]=a}}}function f(a){return function(b){L.geometries[a]=b;e();Q=Q-1;k.onLoadComplete();h()}}function g(a){return function(b){L.geometries[a]=b}}function h(){k.callbackProgress({totalModels:i,totalTextures:P,loadedModels:i- -Q,loadedTextures:P-D},L);k.onLoadProgress();Q===0&&D===0&&b(L)}var k=this,j=THREE.Loader.prototype.extractUrlBase(c),l,o,m,p,r,n,q,t,u,w,s,x,F,C,z,v,H,I,N,R,Y,B,G,Q,D,i,P,L;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;D=Q=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(B.transform){a=B.transform.position;w=B.transform.rotation;v=B.transform.scale;a&&L.scene.position.set(a[0],a[1],a[2]);w&&L.scene.rotation.set(w[0],w[1], -w[2]);v&&L.scene.scale.set(v[0],v[1],v[2]);if(a||w||v){L.scene.updateMatrix();L.scene.updateMatrixWorld()}}a=function(a){return function(){D=D-a;h();k.onLoadComplete()}};for(r in B.cameras){v=B.cameras[r];v.type==="perspective"?R=new THREE.PerspectiveCamera(v.fov,v.aspect,v.near,v.far):v.type==="ortho"&&(R=new THREE.OrthographicCamera(v.left,v.right,v.top,v.bottom,v.near,v.far));x=v.position;w=v.target;v=v.up;R.position.set(x[0],x[1],x[2]);R.target=new THREE.Vector3(w[0],w[1],w[2]);v&&R.up.set(v[0], -v[1],v[2]);L.cameras[r]=R}for(p in B.lights){w=B.lights[p];r=w.color!==void 0?w.color:16777215;R=w.intensity!==void 0?w.intensity:1;if(w.type==="directional"){x=w.direction;s=new THREE.DirectionalLight(r,R);s.position.set(x[0],x[1],x[2]);s.position.normalize()}else if(w.type==="point"){x=w.position;s=w.distance;s=new THREE.PointLight(r,R,s);s.position.set(x[0],x[1],x[2])}else w.type==="ambient"&&(s=new THREE.AmbientLight(r));L.scene.add(s);L.lights[p]=s}for(n in B.fogs){p=B.fogs[n];p.type==="linear"? -Y=new THREE.Fog(0,p.near,p.far):p.type==="exp2"&&(Y=new THREE.FogExp2(0,p.density));v=p.color;Y.color.setRGB(v[0],v[1],v[2]);L.fogs[n]=Y}if(L.cameras&&B.defaults.camera)L.currentCamera=L.cameras[B.defaults.camera];if(L.fogs&&B.defaults.fog)L.scene.fog=L.fogs[B.defaults.fog];v=B.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(v[0],v[1],v[2]);L.bgColorAlpha=B.defaults.bgalpha;for(l in B.geometries){n=B.geometries[l];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Q=Q+1;k.onLoadStart()}}i=Q; +THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function e(){var a;for(m in B.objects)if(!L.objects[m]){s=B.objects[m];if(s.geometry!==void 0){if(I=L.geometries[s.geometry]){a=false;N=L.materials[s.materials[0]];(a=N instanceof THREE.ShaderMaterial)&&I.computeTangents();x=s.position;F=s.rotation;C=s.quaternion;z=s.scale;u=s.matrix;C=0;s.materials.length==0&&(N=new THREE.MeshFaceMaterial);s.materials.length>1&&(N=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(I,N);a.name=m;if(u){a.matrixAutoUpdate=false;a.matrix.set(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])}else{a.position.set(x[0],x[1],x[2]);if(C){a.quaternion.set(C[0],C[1],C[2],C[3]);a.useQuaternion=true}else a.rotation.set(F[0],F[1],F[2]);a.scale.set(z[0],z[1],z[2])}a.visible=s.visible;a.doubleSided=s.doubleSided;a.castShadow=s.castShadow;a.receiveShadow=s.receiveShadow;L.scene.add(a);L.objects[m]=a}}else{x=s.position;F=s.rotation;C=s.quaternion; +z=s.scale;C=0;a=new THREE.Object3D;a.name=m;a.position.set(x[0],x[1],x[2]);if(C){a.quaternion.set(C[0],C[1],C[2],C[3]);a.useQuaternion=true}else a.rotation.set(F[0],F[1],F[2]);a.scale.set(z[0],z[1],z[2]);a.visible=s.visible!==void 0?s.visible:false;L.scene.add(a);L.objects[m]=a;L.empties[m]=a}}}function f(a){return function(b){L.geometries[a]=b;e();Q=Q-1;i.onLoadComplete();h()}}function g(a){return function(b){L.geometries[a]=b}}function h(){i.callbackProgress({totalModels:j,totalTextures:P,loadedModels:j- +Q,loadedTextures:P-D},L);i.onLoadProgress();Q===0&&D===0&&b(L)}var i=this,k=THREE.Loader.prototype.extractUrlBase(c),l,o,m,p,r,n,q,s,u,w,t,x,F,C,z,v,H,I,N,R,Y,B,G,Q,D,j,P,L;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;D=Q=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(B.transform){a=B.transform.position;w=B.transform.rotation;v=B.transform.scale;a&&L.scene.position.set(a[0],a[1],a[2]);w&&L.scene.rotation.set(w[0],w[1], +w[2]);v&&L.scene.scale.set(v[0],v[1],v[2]);if(a||w||v){L.scene.updateMatrix();L.scene.updateMatrixWorld()}}a=function(a){return function(){D=D-a;h();i.onLoadComplete()}};for(r in B.cameras){v=B.cameras[r];v.type==="perspective"?R=new THREE.PerspectiveCamera(v.fov,v.aspect,v.near,v.far):v.type==="ortho"&&(R=new THREE.OrthographicCamera(v.left,v.right,v.top,v.bottom,v.near,v.far));x=v.position;w=v.target;v=v.up;R.position.set(x[0],x[1],x[2]);R.target=new THREE.Vector3(w[0],w[1],w[2]);v&&R.up.set(v[0], +v[1],v[2]);L.cameras[r]=R}for(p in B.lights){w=B.lights[p];r=w.color!==void 0?w.color:16777215;R=w.intensity!==void 0?w.intensity:1;if(w.type==="directional"){x=w.direction;t=new THREE.DirectionalLight(r,R);t.position.set(x[0],x[1],x[2]);t.position.normalize()}else if(w.type==="point"){x=w.position;t=w.distance;t=new THREE.PointLight(r,R,t);t.position.set(x[0],x[1],x[2])}else w.type==="ambient"&&(t=new THREE.AmbientLight(r));L.scene.add(t);L.lights[p]=t}for(n in B.fogs){p=B.fogs[n];p.type==="linear"? +Y=new THREE.Fog(0,p.near,p.far):p.type==="exp2"&&(Y=new THREE.FogExp2(0,p.density));v=p.color;Y.color.setRGB(v[0],v[1],v[2]);L.fogs[n]=Y}if(L.cameras&&B.defaults.camera)L.currentCamera=L.cameras[B.defaults.camera];if(L.fogs&&B.defaults.fog)L.scene.fog=L.fogs[B.defaults.fog];v=B.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(v[0],v[1],v[2]);L.bgColorAlpha=B.defaults.bgalpha;for(l in B.geometries){n=B.geometries[l];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Q=Q+1;i.onLoadStart()}}j=Q; for(l in B.geometries){n=B.geometries[l];if(n.type==="cube"){I=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);L.geometries[l]=I}else if(n.type==="plane"){I=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight);L.geometries[l]=I}else if(n.type==="sphere"){I=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight);L.geometries[l]=I}else if(n.type==="cylinder"){I=new THREE.CylinderGeometry(n.topRad, n.botRad,n.height,n.radSegs,n.heightSegs);L.geometries[l]=I}else if(n.type==="torus"){I=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT);L.geometries[l]=I}else if(n.type==="icosahedron"){I=new THREE.IcosahedronGeometry(n.radius,n.subdivisions);L.geometries[l]=I}else if(n.type==="bin_mesh")c.load(d(n.url,B.urlBaseType),f(l));else if(n.type==="ascii_mesh")G.load(d(n.url,B.urlBaseType),f(l));else if(n.type==="embedded_mesh"){n=B.embeds[n.id];n.metadata=B.metadata;n&&G.createModel(n,g(l), -"")}}for(q in B.textures){l=B.textures[q];if(l.url instanceof Array){D=D+l.url.length;for(n=0;n0){c(THREE.NormalBlending); -b(1);e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+t+")");n.fillRect(Math.floor(Ca.getX()),Math.floor(Ca.getY()),Math.floor(Ca.getWidth()),Math.floor(Ca.getHeight()))}Ca.empty()}};this.render=function(a,l){function m(a){var b,c,d,e;wa.setRGB(0,0,0);Ra.setRGB(0,0,0);Fa.setRGB(0,0,0);b=0;for(c=a.length;b>1;m=l.height>>1;g=f.scale.x*p;k=f.scale.y*r;i=g*j;h=k*m;za.set(a.x-i,a.y-h,a.x+i,a.y+h);if(bb.intersects(za)!==false){n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(g,-k);n.translate(-j,-m);n.drawImage(l,0,0);n.restore()}}}else if(g instanceof THREE.ParticleCanvasMaterial){i= -f.scale.x*p;h=f.scale.y*r;za.set(a.x-i,a.y-h,a.x+i,a.y+h);if(bb.intersects(za)!==false){d(g.color.getContextStyle());e(g.color.getContextStyle());n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(i,h);g.program(n);n.restore()}}}function t(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(F!==a)F=n.lineWidth=a;a=g.linecap; -if(C!==a)C=n.lineCap=a;a=g.linejoin;if(z!==a)z=n.lineJoin=a;d(g.color.getContextStyle());n.stroke();za.inflate(g.linewidth*2)}}function s(a,d,e,g,h,j,m,n){f.info.render.vertices=f.info.render.vertices+3;f.info.render.faces++;b(n.opacity);c(n.blending);B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;i=e.positionScreen.x;P=e.positionScreen.y;w(B,G,Q,D,i,P);if(n instanceof THREE.MeshBasicMaterial)if(n.map!==null){if(n.map.mapping instanceof THREE.UVMapping){fb=m.uvs[0]; -bd(B,G,Q,D,i,P,fb[g].u,fb[g].v,fb[h].u,fb[h].v,fb[j].u,fb[j].v,n.map)}}else if(n.envMap!==null){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=l.matrixWorldInverse;ja.copy(m.vertexNormalsWorld[g]);gb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;$a=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[h]);ob=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;kb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ -ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[j]);pb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;hb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;bd(B,G,Q,D,i,P,gb,$a,ob,kb,pb,hb,n.envMap)}}else n.wireframe===true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color);else if(n instanceof THREE.MeshLambertMaterial)if(lb===true)if(n.wireframe===false&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3){Z.r= -$.r=X.r=wa.r;Z.g=$.g=X.g=wa.g;Z.b=$.b=X.b=wa.b;o(k,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(k,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(k,m.v3.positionWorld,m.vertexNormalsWorld[2],X);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0, -Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ua=Dc(Z,$,X,ia);ic(B,G,Q,D,i,P,0,0,1,0,0,1,Ua)}else{O.r=wa.r;O.g=wa.g;O.b=wa.b;o(k,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else n.wireframe===true?Nb(n.color,n.wireframeLinewidth, -n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color);else if(n instanceof THREE.MeshDepthMaterial){Pa=l.near;Qa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Pa,Qa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Pa,Qa);X.r=X.g=X.b=1-cc(e.positionScreen.z,Pa,Qa);ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ua=Dc(Z,$,X,ia);ic(B,G,Q,D,i,P,0,0,1,0,0,1,Ua)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);n.wireframe===true?Nb(O,n.wireframeLinewidth, -n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}}function u(a,d,e,g,h,j,m,n,ga){f.info.render.vertices=f.info.render.vertices+4;f.info.render.faces++;b(n.opacity);c(n.blending);if(n.map!==null||n.envMap!==null){s(a,d,g,0,1,3,m,n,ga);s(h,e,j,1,2,3,m,n,ga)}else{B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;i=e.positionScreen.x;P=e.positionScreen.y;L=g.positionScreen.x;S=g.positionScreen.y;aa=h.positionScreen.x;K=h.positionScreen.y;ca=j.positionScreen.x;ha=j.positionScreen.y; -if(n instanceof THREE.MeshBasicMaterial){x(B,G,Q,D,i,P,L,S);n.wireframe===true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color)}else if(n instanceof THREE.MeshLambertMaterial)if(lb===true)if(!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4){Z.r=$.r=X.r=ia.r=wa.r;Z.g=$.g=X.g=ia.g=wa.g;Z.b=$.b=X.b=ia.b=wa.b;o(k,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(k,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(k,m.v4.positionWorld,m.vertexNormalsWorld[3], -X);o(k,m.v3.positionWorld,m.vertexNormalsWorld[2],ia);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0,Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=Math.max(0,Math.min(n.color.r*ia.r,1));ia.g=Math.max(0,Math.min(n.color.g* -ia.g,1));ia.b=Math.max(0,Math.min(n.color.b*ia.b,1));Ua=Dc(Z,$,X,ia);w(B,G,Q,D,L,S);ic(B,G,Q,D,L,S,0,0,1,0,0,1,Ua);w(aa,K,i,P,ca,ha);ic(aa,K,i,P,ca,ha,1,0,1,1,0,1,Ua)}else{O.r=wa.r;O.g=wa.g;O.b=wa.b;o(k,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));x(B,G,Q,D,i,P,L,S);n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else{x(B,G,Q,D,i,P,L,S);n.wireframe=== -true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);x(B,G,Q,D,i,P,L,S);n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else if(n instanceof THREE.MeshDepthMaterial){Pa=l.near;Qa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Pa,Qa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Pa,Qa);X.r=X.g=X.b=1-cc(g.positionScreen.z, -Pa,Qa);ia.r=ia.g=ia.b=1-cc(e.positionScreen.z,Pa,Qa);Ua=Dc(Z,$,X,ia);w(B,G,Q,D,L,S);ic(B,G,Q,D,L,S,0,0,1,0,0,1,Ua);w(aa,K,i,P,ca,ha);ic(aa,K,i,P,ca,ha,1,0,1,1,0,1,Ua)}}}function w(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b)}function x(a,b,c,d,e,f,g,i){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(g,i);n.lineTo(a,b)}function Nb(a,b,c,e){if(F!==b)F=n.lineWidth=b;if(C!==c)C=n.lineCap=c;if(z!==e)z=n.lineJoin=e;d(a.getContextStyle());n.stroke(); -za.inflate(b*2)}function Hb(a){e(a.getContextStyle());n.fill()}function bd(a,b,c,d,f,g,i,h,k,j,l,m,o){if(!(o.image===void 0||o.image.width===0)){if(o.needsUpdate===true||ya[o.id]===void 0){var ga=o.wrapS==THREE.RepeatWrapping,p=o.wrapT==THREE.RepeatWrapping;ya[o.id]=n.createPattern(o.image,ga===true&&p===true?"repeat":ga===true&&p===false?"repeat-x":ga===false&&p===true?"repeat-y":"no-repeat");o.needsUpdate=false}e(ya[o.id]);var ga=o.offset.x/o.repeat.x,p=o.offset.y/o.repeat.y,r=o.image.width*o.repeat.x, -q=o.image.height*o.repeat.y,i=(i+ga)*r,h=(h+p)*q,c=c-a,d=d-b,f=f-a,g=g-b,k=(k+ga)*r-i,j=(j+p)*q-h,l=(l+ga)*r-i,m=(m+p)*q-h,ga=k*m-l*j;if(ga===0){if(Ia[o.id]===void 0){b=document.createElement("canvas");b.width=o.image.width;b.height=o.image.height;b=b.getContext("2d");b.drawImage(o.image,0,0);Ia[o.id]=b.getImageData(0,0,o.image.width,o.image.height).data}b=Ia[o.id];i=(Math.floor(i)+Math.floor(h)*o.image.width)*4;O.setRGB(b[i]/255,b[i+1]/255,b[i+2]/255);Hb(O)}else{ga=1/ga;o=(m*c-j*f)*ga;j=(m*d-j*g)* -ga;c=(k*f-l*c)*ga;d=(k*g-l*d)*ga;a=a-o*i-c*h;i=b-j*i-d*h;n.save();n.transform(o,j,c,d,a,i);n.fill();n.restore()}}}function ic(a,b,c,d,e,f,g,i,h,k,j,l,m){var o,ga;o=m.width-1;ga=m.height-1;g=g*o;i=i*ga;c=c-a;d=d-b;e=e-a;f=f-b;h=h*o-g;k=k*ga-i;j=j*o-g;l=l*ga-i;ga=1/(h*l-j*k);o=(l*c-k*e)*ga;k=(l*d-k*f)*ga;c=(h*e-j*c)*ga;d=(h*f-j*d)*ga;a=a-o*g-c*i;b=b-k*g-d*i;n.save();n.transform(o,k,c,d,a,b);n.clip();n.drawImage(m,0,0);n.restore()}function Dc(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g= -~~(b.r*255),i=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),k=~~(c.g*255),c=~~(c.b*255),j=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ga[0]=e<0?0:e>255?255:e;ga[1]=f<0?0:f>255?255:f;ga[2]=a<0?0:a>255?255:a;ga[4]=g<0?0:g>255?255:g;ga[5]=i<0?0:i>255?255:i;ga[6]=b<0?0:b>255?255:b;ga[8]=h<0?0:h>255?255:h;ga[9]=k<0?0:k>255?255:k;ga[10]=c<0?0:c>255?255:c;ga[12]=j<0?0:j>255?255:j;ga[13]=l<0?0:l>255?255:l;ga[14]=d<0?0:d>255?255:d;ab.putImageData(bc,0,0);Cc.drawImage(qb,0,0);return qc}function cc(a,b,c){a=(a-b)/(c- -b);return a*a*(3-2*a)}function jc(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ob(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;if(e!==0){e=1/Math.sqrt(e);c=c*e;d=d*e;b.x=b.x+c;b.y=b.y+d;a.x=a.x-c;a.y=a.y-d}}var Ec,cd,Ma,ib;this.autoClear===true?this.clear():n.setTransform(1,0,0,-1,p,r);f.info.render.vertices=0;f.info.render.faces=0;g=j.projectScene(a,l,this.sortElements);h=g.elements;k=g.lights;lb=k.length>0;lb===true&&m(k);Ec=0;for(cd=h.length;Ec0){c(THREE.NormalBlending); +b(1);e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+s+")");n.fillRect(Math.floor(Ca.getX()),Math.floor(Ca.getY()),Math.floor(Ca.getWidth()),Math.floor(Ca.getHeight()))}Ca.empty()}};this.render=function(a,l){function m(a){var b,c,d,e;wa.setRGB(0,0,0);Ra.setRGB(0,0,0);Fa.setRGB(0,0,0);b=0;for(c=a.length;b>1;m=l.height>>1;g=f.scale.x*p;i=f.scale.y*r;h=g*k;j=i*m;za.set(a.x-h,a.y-j,a.x+h,a.y+j);if(bb.intersects(za)!==false){n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(g,-i);n.translate(-k,-m);n.drawImage(l,0,0);n.restore()}}}else if(g instanceof THREE.ParticleCanvasMaterial){h= +f.scale.x*p;j=f.scale.y*r;za.set(a.x-h,a.y-j,a.x+h,a.y+j);if(bb.intersects(za)!==false){d(g.color.getContextStyle());e(g.color.getContextStyle());n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(h,j);g.program(n);n.restore()}}}function s(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(F!==a)F=n.lineWidth=a;a=g.linecap; +if(C!==a)C=n.lineCap=a;a=g.linejoin;if(z!==a)z=n.lineJoin=a;d(g.color.getContextStyle());n.stroke();za.inflate(g.linewidth*2)}}function t(a,d,e,g,h,k,m,n){f.info.render.vertices=f.info.render.vertices+3;f.info.render.faces++;b(n.opacity);c(n.blending);B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;j=e.positionScreen.x;P=e.positionScreen.y;w(B,G,Q,D,j,P);if(n instanceof THREE.MeshBasicMaterial)if(n.map!==null){if(n.map.mapping instanceof THREE.UVMapping){fb=m.uvs[0]; +bd(B,G,Q,D,j,P,fb[g].u,fb[g].v,fb[h].u,fb[h].v,fb[k].u,fb[k].v,n.map)}}else if(n.envMap!==null){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=l.matrixWorldInverse;ja.copy(m.vertexNormalsWorld[g]);gb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;$a=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[h]);ob=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;kb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ +ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[k]);pb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;hb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;bd(B,G,Q,D,j,P,gb,$a,ob,kb,pb,hb,n.envMap)}}else n.wireframe===true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color);else if(n instanceof THREE.MeshLambertMaterial)if(lb===true)if(n.wireframe===false&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3){Z.r= +$.r=X.r=wa.r;Z.g=$.g=X.g=wa.g;Z.b=$.b=X.b=wa.b;o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],X);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0, +Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ua=Dc(Z,$,X,ia);ic(B,G,Q,D,j,P,0,0,1,0,0,1,Ua)}else{O.r=wa.r;O.g=wa.g;O.b=wa.b;o(i,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else n.wireframe===true?Nb(n.color,n.wireframeLinewidth, +n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color);else if(n instanceof THREE.MeshDepthMaterial){Pa=l.near;Qa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Pa,Qa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Pa,Qa);X.r=X.g=X.b=1-cc(e.positionScreen.z,Pa,Qa);ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ua=Dc(Z,$,X,ia);ic(B,G,Q,D,j,P,0,0,1,0,0,1,Ua)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);n.wireframe===true?Nb(O,n.wireframeLinewidth, +n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}}function u(a,d,e,g,h,k,m,n,ga){f.info.render.vertices=f.info.render.vertices+4;f.info.render.faces++;b(n.opacity);c(n.blending);if(n.map!==null||n.envMap!==null){t(a,d,g,0,1,3,m,n,ga);t(h,e,k,1,2,3,m,n,ga)}else{B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;j=e.positionScreen.x;P=e.positionScreen.y;L=g.positionScreen.x;S=g.positionScreen.y;aa=h.positionScreen.x;K=h.positionScreen.y;ca=k.positionScreen.x;ha=k.positionScreen.y; +if(n instanceof THREE.MeshBasicMaterial){x(B,G,Q,D,j,P,L,S);n.wireframe===true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color)}else if(n instanceof THREE.MeshLambertMaterial)if(lb===true)if(!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4){Z.r=$.r=X.r=ia.r=wa.r;Z.g=$.g=X.g=ia.g=wa.g;Z.b=$.b=X.b=ia.b=wa.b;o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(i,m.v4.positionWorld,m.vertexNormalsWorld[3], +X);o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ia);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0,Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=Math.max(0,Math.min(n.color.r*ia.r,1));ia.g=Math.max(0,Math.min(n.color.g* +ia.g,1));ia.b=Math.max(0,Math.min(n.color.b*ia.b,1));Ua=Dc(Z,$,X,ia);w(B,G,Q,D,L,S);ic(B,G,Q,D,L,S,0,0,1,0,0,1,Ua);w(aa,K,j,P,ca,ha);ic(aa,K,j,P,ca,ha,1,0,1,1,0,1,Ua)}else{O.r=wa.r;O.g=wa.g;O.b=wa.b;o(i,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));x(B,G,Q,D,j,P,L,S);n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else{x(B,G,Q,D,j,P,L,S);n.wireframe=== +true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);x(B,G,Q,D,j,P,L,S);n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else if(n instanceof THREE.MeshDepthMaterial){Pa=l.near;Qa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Pa,Qa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Pa,Qa);X.r=X.g=X.b=1-cc(g.positionScreen.z, +Pa,Qa);ia.r=ia.g=ia.b=1-cc(e.positionScreen.z,Pa,Qa);Ua=Dc(Z,$,X,ia);w(B,G,Q,D,L,S);ic(B,G,Q,D,L,S,0,0,1,0,0,1,Ua);w(aa,K,j,P,ca,ha);ic(aa,K,j,P,ca,ha,1,0,1,1,0,1,Ua)}}}function w(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b)}function x(a,b,c,d,e,f,g,h){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(g,h);n.lineTo(a,b)}function Nb(a,b,c,e){if(F!==b)F=n.lineWidth=b;if(C!==c)C=n.lineCap=c;if(z!==e)z=n.lineJoin=e;d(a.getContextStyle());n.stroke(); +za.inflate(b*2)}function Hb(a){e(a.getContextStyle());n.fill()}function bd(a,b,c,d,f,g,h,j,i,k,l,m,o){if(!(o.image===void 0||o.image.width===0)){if(o.needsUpdate===true||ya[o.id]===void 0){var ga=o.wrapS==THREE.RepeatWrapping,p=o.wrapT==THREE.RepeatWrapping;ya[o.id]=n.createPattern(o.image,ga===true&&p===true?"repeat":ga===true&&p===false?"repeat-x":ga===false&&p===true?"repeat-y":"no-repeat");o.needsUpdate=false}e(ya[o.id]);var ga=o.offset.x/o.repeat.x,p=o.offset.y/o.repeat.y,r=o.image.width*o.repeat.x, +q=o.image.height*o.repeat.y,h=(h+ga)*r,j=(j+p)*q,c=c-a,d=d-b,f=f-a,g=g-b,i=(i+ga)*r-h,k=(k+p)*q-j,l=(l+ga)*r-h,m=(m+p)*q-j,ga=i*m-l*k;if(ga===0){if(Ia[o.id]===void 0){b=document.createElement("canvas");b.width=o.image.width;b.height=o.image.height;b=b.getContext("2d");b.drawImage(o.image,0,0);Ia[o.id]=b.getImageData(0,0,o.image.width,o.image.height).data}b=Ia[o.id];h=(Math.floor(h)+Math.floor(j)*o.image.width)*4;O.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);Hb(O)}else{ga=1/ga;o=(m*c-k*f)*ga;k=(m*d-k*g)* +ga;c=(i*f-l*c)*ga;d=(i*g-l*d)*ga;a=a-o*h-c*j;h=b-k*h-d*j;n.save();n.transform(o,k,c,d,a,h);n.fill();n.restore()}}}function ic(a,b,c,d,e,f,g,h,j,i,k,l,m){var o,ga;o=m.width-1;ga=m.height-1;g=g*o;h=h*ga;c=c-a;d=d-b;e=e-a;f=f-b;j=j*o-g;i=i*ga-h;k=k*o-g;l=l*ga-h;ga=1/(j*l-k*i);o=(l*c-i*e)*ga;i=(l*d-i*f)*ga;c=(j*e-k*c)*ga;d=(j*f-k*d)*ga;a=a-o*g-c*h;b=b-i*g-d*h;n.save();n.transform(o,i,c,d,a,b);n.clip();n.drawImage(m,0,0);n.restore()}function Dc(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g= +~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),j=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ga[0]=e<0?0:e>255?255:e;ga[1]=f<0?0:f>255?255:f;ga[2]=a<0?0:a>255?255:a;ga[4]=g<0?0:g>255?255:g;ga[5]=h<0?0:h>255?255:h;ga[6]=b<0?0:b>255?255:b;ga[8]=j<0?0:j>255?255:j;ga[9]=i<0?0:i>255?255:i;ga[10]=c<0?0:c>255?255:c;ga[12]=k<0?0:k>255?255:k;ga[13]=l<0?0:l>255?255:l;ga[14]=d<0?0:d>255?255:d;ab.putImageData(bc,0,0);Cc.drawImage(qb,0,0);return qc}function cc(a,b,c){a=(a-b)/(c- +b);return a*a*(3-2*a)}function jc(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ob(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;if(e!==0){e=1/Math.sqrt(e);c=c*e;d=d*e;b.x=b.x+c;b.y=b.y+d;a.x=a.x-c;a.y=a.y-d}}var Ec,cd,Ma,ib;this.autoClear===true?this.clear():n.setTransform(1,0,0,-1,p,r);f.info.render.vertices=0;f.info.render.faces=0;g=k.projectScene(a,l,this.sortElements);h=g.elements;i=g.lights;lb=i.length>0;lb===true&&m(i);Ec=0;for(cd=h.length;Ec=0)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?false:a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?true:false}function f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length; -var k=a.colors,j=k.length,l=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a.verticesNeedUpdate,p=a.colorsNeedUpdate,r=a.__webglCustomAttributesList;if(c.sortParticles){wa.copy(lb);wa.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(d.needsUpdate){d.program&&D.deallocateMaterial(d);D.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(D.maxMorphTargets);var f=false,g=d.program,h=g.uniforms,k=d.uniforms;if(g!==S){i.useProgram(g);S=g;f=true}if(d.id!==K){K=d.id;f=true}if(f||a!==ha){i.uniformMatrix4fv(h.projectionMatrix, -false,a._projectionMatrixArray);a!==ha&&(ha=a)}if(f){if(c&&d.fog){k.fogColor.value=c.color;if(c instanceof THREE.Fog){k.fogNear.value=c.near;k.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ja){for(var j,l=0,m=0,n=0,o,r,p,q=qb,t=q.directional.colors,u=q.directional.positions,v=q.point.colors,w=q.point.positions,x=q.point.distances,F=q.spot.colors,B=q.spot.positions,H=q.spot.distances, -Z=q.spot.directions,I=q.spot.angles,G=q.spot.exponents,N=0,X=0,L=0,O=p=0,c=O=0,f=b.length;c=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(d.needsUpdate){d.program&&D.deallocateMaterial(d);D.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(D.maxMorphTargets);var f=false,g=d.program,h=g.uniforms,i=d.uniforms;if(g!==S){j.useProgram(g);S=g;f=true}if(d.id!==K){K=d.id;f=true}if(f||a!==ha){j.uniformMatrix4fv(h.projectionMatrix, +false,a._projectionMatrixArray);a!==ha&&(ha=a)}if(f){if(c&&d.fog){i.fogColor.value=c.color;if(c instanceof THREE.Fog){i.fogNear.value=c.near;i.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ja){for(var k,l=0,m=0,n=0,o,p,r,q=qb,s=q.directional.colors,u=q.directional.positions,v=q.point.colors,w=q.point.positions,x=q.point.distances,F=q.spot.colors,B=q.spot.positions,H=q.spot.distances, +Z=q.spot.directions,I=q.spot.angles,G=q.spot.exponents,N=0,X=0,L=0,O=r=0,c=O=0,f=b.length;c0};this.setSize= -function(a,b){z.width=a;z.height=b;this.setViewport(0,0,z.width,z.height)};this.setViewport=function(a,b,c,d){ob=a;kb=b;pb=c;hb=d;i.viewport(ob,kb,pb,hb)};this.setScissor=function(a,b,c,d){i.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?i.enable(i.SCISSOR_TEST):i.disable(i.SCISSOR_TEST)};this.setClearColorHex=function(a,b){B.setHex(a);G=b;i.clearColor(B.r,B.g,B.b,G)};this.setClearColor=function(a,b){B.copy(a);G=b;i.clearColor(B.r,B.g,B.b,G)};this.getClearColor=function(){return B};this.getClearAlpha= -function(){return G};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|i.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|i.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|i.STENCIL_BUFFER_BIT;i.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix; -delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._objectMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];i.deleteBuffer(c.__webglVertexBuffer);i.deleteBuffer(c.__webglNormalBuffer);i.deleteBuffer(c.__webglTangentBuffer);i.deleteBuffer(c.__webglColorBuffer);i.deleteBuffer(c.__webglUVBuffer);i.deleteBuffer(c.__webglUV2Buffer);i.deleteBuffer(c.__webglSkinVertexABuffer);i.deleteBuffer(c.__webglSkinVertexBBuffer); -i.deleteBuffer(c.__webglSkinIndicesBuffer);i.deleteBuffer(c.__webglSkinWeightsBuffer);i.deleteBuffer(c.__webglFaceBuffer);i.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d1&&(b=true);d=0;for(c=f.length;d=0&&e.vertexNormalBuffer){g=e.vertexNormalBuffer.itemSize;i.bindBuffer(i.ARRAY_BUFFER,e.vertexNormalBuffer);i.vertexAttribPointer(a.normal, -g,i.FLOAT,false,0,f[d].index*g*4)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){g=e.vertexUvBuffer.itemSize;i.bindBuffer(i.ARRAY_BUFFER,e.vertexUvBuffer);i.vertexAttribPointer(a.uv,g,i.FLOAT,false,0,f[d].index*g*4);i.enableVertexAttribArray(a.uv)}else i.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){g=e.vertexColorBuffer.itemSize;i.bindBuffer(i.ARRAY_BUFFER,e.vertexColorBuffer);i.vertexAttribPointer(a.color,g,i.FLOAT,false,0,f[d].index*g*4)}i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, -e.vertexIndexBuffer)}i.drawElements(i.TRIANGLES,f[d].count,i.UNSIGNED_SHORT,f[d].start*2);D.info.render.calls++;D.info.render.vertices=D.info.render.vertices+f[d].count;D.info.render.faces=D.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,k,c=q(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){i.bindBuffer(i.ARRAY_BUFFER,e.__webglVertexBuffer);i.vertexAttribPointer(b.position, -3,i.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){i.bindBuffer(i.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);i.vertexAttribPointer(c.position,3,i.FLOAT,false,0,0)}else if(c.position>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglVertexBuffer);i.vertexAttribPointer(c.position,3,i.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var j=0;k=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;j0&&k.push([l,j])}if(k.length>d.numSupportedMorphTargets){k.sort(h);k.length=d.numSupportedMorphTargets}else k.length>d.numSupportedMorphNormals? -k.sort(h):k.length===0&&k.push([0,0]);for(j=0;j=0){i.bindBuffer(i.ARRAY_BUFFER,c.buffer);i.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,i.FLOAT,false,0,0)}}}if(b.color>=0){i.bindBuffer(i.ARRAY_BUFFER, -e.__webglColorBuffer);i.vertexAttribPointer(b.color,3,i.FLOAT,false,0,0)}if(b.normal>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglNormalBuffer);i.vertexAttribPointer(b.normal,3,i.FLOAT,false,0,0)}if(b.tangent>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglTangentBuffer);i.vertexAttribPointer(b.tangent,4,i.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){i.bindBuffer(i.ARRAY_BUFFER,e.__webglUVBuffer);i.vertexAttribPointer(b.uv,2,i.FLOAT,false,0,0);i.enableVertexAttribArray(b.uv)}else i.disableVertexAttribArray(b.uv); -if(b.uv2>=0)if(e.__webglUV2Buffer){i.bindBuffer(i.ARRAY_BUFFER,e.__webglUV2Buffer);i.vertexAttribPointer(b.uv2,2,i.FLOAT,false,0,0);i.enableVertexAttribArray(b.uv2)}else i.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinVertexABuffer);i.vertexAttribPointer(b.skinVertexA,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);i.vertexAttribPointer(b.skinVertexB,4,i.FLOAT, -false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);i.vertexAttribPointer(b.skinIndex,4,i.FLOAT,false,0,0);i.bindBuffer(i.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);i.vertexAttribPointer(b.skinWeight,4,i.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==$a){i.lineWidth(d);$a=d}a&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);i.drawElements(i.LINES,e.__webglLineCount,i.UNSIGNED_SHORT,0)}else{a&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer); -i.drawElements(i.TRIANGLES,e.__webglFaceCount,i.UNSIGNED_SHORT,0)}D.info.render.calls++;D.info.render.vertices=D.info.render.vertices+e.__webglFaceCount;D.info.render.faces=D.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?i.LINE_STRIP:i.LINES;d=d.linewidth;if(d!==$a){i.lineWidth(d);$a=d}i.drawArrays(f,0,e.__webglLineCount);D.info.render.calls++}else if(f instanceof THREE.ParticleSystem){i.drawArrays(i.POINTS,0,e.__webglParticleCount);D.info.render.calls++; -D.info.render.points=D.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){i.drawArrays(i.TRIANGLE_STRIP,0,e.__webglVertexCount);D.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,h,m,n=a.__lights,o=a.fog;K=-1;ja=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray= -new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);lb.multiply(b.projectionMatrix,b.matrixWorldInverse);za.setFromMatrix(lb);this.autoUpdateObjects&&this.initWebGLObjects(a);k(this.renderPluginsPre,a,b);D.info.render.calls=0;D.info.render.vertices=0;D.info.render.faces=0;D.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor, -this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d=0){s=p.geometry.materials[s];if(s.transparent){r.transparent=s;r.opaque=null}else{r.opaque=s;r.transparent=null}}}else if(s)if(s.transparent){r.transparent= -s;r.opaque=null}else{r.opaque=s;r.transparent=null}f.render=true;if(this.sortObjects)if(h.renderDepth)f.z=h.renderDepth;else{Ra.copy(h.matrixWorld.getPosition());lb.multiplyVector3(Ra);f.z=Ra.z}}}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d65535){F[x].counter=F[x].counter+1;z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:B})}v instanceof THREE.Face3?q.geometryGroups[z].faces3.push(s):q.geometryGroups[z].faces4.push(s);q.geometryGroups[z].vertices=q.geometryGroups[z].vertices+w}q.geometryGroupsList=[];var H=void 0;for(H in q.geometryGroups){q.geometryGroups[H].id= -O++;q.geometryGroupsList.push(q.geometryGroups[H])}}for(k in j.geometryGroups){l=j.geometryGroups[k];if(!l.__webglVertexBuffer){var K=l;K.__webglVertexBuffer=i.createBuffer();K.__webglNormalBuffer=i.createBuffer();K.__webglTangentBuffer=i.createBuffer();K.__webglColorBuffer=i.createBuffer();K.__webglUVBuffer=i.createBuffer();K.__webglUV2Buffer=i.createBuffer();K.__webglSkinVertexABuffer=i.createBuffer();K.__webglSkinVertexBBuffer=i.createBuffer();K.__webglSkinIndicesBuffer=i.createBuffer();K.__webglSkinWeightsBuffer= -i.createBuffer();K.__webglFaceBuffer=i.createBuffer();K.__webglLineBuffer=i.createBuffer();var Z=void 0,I=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];Z=0;for(I=K.numMorphTargets;Z0};this.setSize= +function(a,b){z.width=a;z.height=b;this.setViewport(0,0,z.width,z.height)};this.setViewport=function(a,b,c,d){ob=a;kb=b;pb=c;hb=d;j.viewport(ob,kb,pb,hb)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){B.setHex(a);G=b;j.clearColor(B.r,B.g,B.b,G)};this.setClearColor=function(a,b){B.copy(a);G=b;j.clearColor(B.r,B.g,B.b,G)};this.getClearColor=function(){return B};this.getClearAlpha= +function(){return G};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|j.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|j.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix; +delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._objectMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer); +j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d1&&(b=true);d=0;for(c=f.length;d=0&&e.vertexNormalBuffer){g=e.vertexNormalBuffer.itemSize;j.bindBuffer(j.ARRAY_BUFFER,e.vertexNormalBuffer);j.vertexAttribPointer(a.normal, +g,j.FLOAT,false,0,f[d].index*g*4)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){g=e.vertexUvBuffer.itemSize;j.bindBuffer(j.ARRAY_BUFFER,e.vertexUvBuffer);j.vertexAttribPointer(a.uv,g,j.FLOAT,false,0,f[d].index*g*4);j.enableVertexAttribArray(a.uv)}else j.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){g=e.vertexColorBuffer.itemSize;j.bindBuffer(j.ARRAY_BUFFER,e.vertexColorBuffer);j.vertexAttribPointer(a.color,g,j.FLOAT,false,0,f[d].index*g*4)}j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, +e.vertexIndexBuffer)}j.drawElements(j.TRIANGLES,f[d].count,j.UNSIGNED_SHORT,f[d].start*2);D.info.render.calls++;D.info.render.vertices=D.info.render.vertices+f[d].count;D.info.render.faces=D.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,i,c=q(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer);j.vertexAttribPointer(b.position, +3,j.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);j.vertexAttribPointer(c.position,3,j.FLOAT,false,0,0)}else if(c.position>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer);j.vertexAttribPointer(c.position,3,j.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var k=0;i=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;k0&&i.push([l,k])}if(i.length>d.numSupportedMorphTargets){i.sort(h);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals? +i.sort(h):i.length===0&&i.push([0,0]);for(k=0;k=0){j.bindBuffer(j.ARRAY_BUFFER,c.buffer);j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,false,0,0)}}}if(b.color>=0){j.bindBuffer(j.ARRAY_BUFFER, +e.__webglColorBuffer);j.vertexAttribPointer(b.color,3,j.FLOAT,false,0,0)}if(b.normal>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer);j.vertexAttribPointer(b.normal,3,j.FLOAT,false,0,0)}if(b.tangent>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer);j.vertexAttribPointer(b.tangent,4,j.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer);j.vertexAttribPointer(b.uv,2,j.FLOAT,false,0,0);j.enableVertexAttribArray(b.uv)}else j.disableVertexAttribArray(b.uv); +if(b.uv2>=0)if(e.__webglUV2Buffer){j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer);j.vertexAttribPointer(b.uv2,2,j.FLOAT,false,0,0);j.enableVertexAttribArray(b.uv2)}else j.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer);j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,false,0,0);j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT, +false,0,0);j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,false,0,0);j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==$a){j.lineWidth(d);$a=d}a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)}else{a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer); +j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)}D.info.render.calls++;D.info.render.vertices=D.info.render.vertices+e.__webglFaceCount;D.info.render.faces=D.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES;d=d.linewidth;if(d!==$a){j.lineWidth(d);$a=d}j.drawArrays(f,0,e.__webglLineCount);D.info.render.calls++}else if(f instanceof THREE.ParticleSystem){j.drawArrays(j.POINTS,0,e.__webglParticleCount);D.info.render.calls++; +D.info.render.points=D.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount);D.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,h,m,n=a.__lights,o=a.fog;K=-1;ja=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray= +new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);lb.multiply(b.projectionMatrix,b.matrixWorldInverse);za.setFromMatrix(lb);this.autoUpdateObjects&&this.initWebGLObjects(a);i(this.renderPluginsPre,a,b);D.info.render.calls=0;D.info.render.vertices=0;D.info.render.faces=0;D.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor, +this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d=0){t=r.geometry.materials[t];if(t.transparent){p.transparent=t;p.opaque=null}else{p.opaque=t;p.transparent=null}}}else if(t)if(t.transparent){p.transparent= +t;p.opaque=null}else{p.opaque=t;p.transparent=null}f.render=true;if(this.sortObjects)if(h.renderDepth)f.z=h.renderDepth;else{Ra.copy(h.matrixWorld.getPosition());lb.multiplyVector3(Ra);f.z=Ra.z}}}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d65535){F[x].counter=F[x].counter+1;z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:B})}u instanceof THREE.Face3?q.geometryGroups[z].faces3.push(s):q.geometryGroups[z].faces4.push(s);q.geometryGroups[z].vertices=q.geometryGroups[z].vertices+w}q.geometryGroupsList=[];var H=void 0;for(H in q.geometryGroups){q.geometryGroups[H].id= +O++;q.geometryGroupsList.push(q.geometryGroups[H])}}for(i in k.geometryGroups){l=k.geometryGroups[i];if(!l.__webglVertexBuffer){var K=l;K.__webglVertexBuffer=j.createBuffer();K.__webglNormalBuffer=j.createBuffer();K.__webglTangentBuffer=j.createBuffer();K.__webglColorBuffer=j.createBuffer();K.__webglUVBuffer=j.createBuffer();K.__webglUV2Buffer=j.createBuffer();K.__webglSkinVertexABuffer=j.createBuffer();K.__webglSkinVertexBBuffer=j.createBuffer();K.__webglSkinIndicesBuffer=j.createBuffer();K.__webglSkinWeightsBuffer= +j.createBuffer();K.__webglFaceBuffer=j.createBuffer();K.__webglLineBuffer=j.createBuffer();var Z=void 0,I=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];Z=0;for(I=K.numMorphTargets;Z0||X.faceVertexUvs.length>0)G.__uvArray=new Float32Array(S*2);if(X.faceUvs.length>1||X.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(S*2)}if(L.geometry.skinWeights.length&&L.geometry.skinIndices.length){G.__skinVertexAArray= new Float32Array(S*4);G.__skinVertexBArray=new Float32Array(S*4);G.__skinIndexArray=new Float32Array(S*4);G.__skinWeightArray=new Float32Array(S*4)}G.__faceArray=new Uint16Array(Q*3);G.__lineArray=new Uint16Array(R*2);var ca=void 0,ia=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];ca=0;for(ia=G.numMorphTargets;ca0){i.bindBuffer(i.ARRAY_BUFFER,ea.__webglSkinVertexABuffer);i.bufferData(i.ARRAY_BUFFER, -ra,Xa);i.bindBuffer(i.ARRAY_BUFFER,ea.__webglSkinVertexBBuffer);i.bufferData(i.ARRAY_BUFFER,sa,Xa);i.bindBuffer(i.ARRAY_BUFFER,ea.__webglSkinIndicesBuffer);i.bufferData(i.ARRAY_BUFFER,ta,Xa);i.bindBuffer(i.ARRAY_BUFFER,ea.__webglSkinWeightsBuffer);i.bufferData(i.ARRAY_BUFFER,ua,Xa)}}if(ud&&Uc){E=0;for(T=la.length;E0){i.bindBuffer(i.ARRAY_BUFFER,ea.__webglColorBuffer);i.bufferData(i.ARRAY_BUFFER, +ra[J+3]=1;ra[J+4]=Rb.x;ra[J+5]=Rb.y;ra[J+6]=Rb.z;ra[J+7]=1;ra[J+8]=Sb.x;ra[J+9]=Sb.y;ra[J+10]=Sb.z;ra[J+11]=1;ra[J+12]=Hc.x;ra[J+13]=Hc.y;ra[J+14]=Hc.z;ra[J+15]=1;Tb=gc[M.a];Ub=gc[M.b];Vb=gc[M.c];Ic=gc[M.d];sa[J]=Tb.x;sa[J+1]=Tb.y;sa[J+2]=Tb.z;sa[J+3]=1;sa[J+4]=Ub.x;sa[J+5]=Ub.y;sa[J+6]=Ub.z;sa[J+7]=1;sa[J+8]=Vb.x;sa[J+9]=Vb.y;sa[J+10]=Vb.z;sa[J+11]=1;sa[J+12]=Ic.x;sa[J+13]=Ic.y;sa[J+14]=Ic.z;sa[J+15]=1;J=J+16}if(J>0){j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinVertexABuffer);j.bufferData(j.ARRAY_BUFFER, +ra,Xa);j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinVertexBBuffer);j.bufferData(j.ARRAY_BUFFER,sa,Xa);j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinIndicesBuffer);j.bufferData(j.ARRAY_BUFFER,ta,Xa);j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinWeightsBuffer);j.bufferData(j.ARRAY_BUFFER,ua,Xa)}}if(ud&&Uc){E=0;for(T=la.length;E0){j.bindBuffer(j.ARRAY_BUFFER,ea.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER, La,Xa)}}if(td&&Ta.hasTangents){E=0;for(T=la.length;E0){i.bindBuffer(i.ARRAY_BUFFER,ea.__webglUVBuffer);i.bufferData(i.ARRAY_BUFFER,wc,Xa)}}if(hd&&Zc&&ed){E=0;for(T=la.length;E0){i.bindBuffer(i.ARRAY_BUFFER, -ea.__webglUV2Buffer);i.bufferData(i.ARRAY_BUFFER,xc,Xa)}}if(rd){E=0;for(T=la.length;E0){j.bindBuffer(j.ARRAY_BUFFER,ea.__webglUVBuffer);j.bufferData(j.ARRAY_BUFFER,wc,Xa)}}if(hd&&Zc&&ed){E=0;for(T=la.length;E0){j.bindBuffer(j.ARRAY_BUFFER, +ea.__webglUV2Buffer);j.bufferData(j.ARRAY_BUFFER,xc,Xa)}}if(rd){E=0;for(T=la.length;E +a.uniforms=THREE.UniformsUtils.clone(h.uniforms);a.vertexShader=h.vertexShader;a.fragmentShader=h.fragmentShader}var i,k,l,m,n;i=m=n=h=0;for(k=b.length;i 0?"#define VERTEX_TEXTURES":"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR": "",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); -j=["precision "+v+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP": +k=["precision "+v+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP": "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n"); -k=w("fragment",j+k);d=w("vertex",d+n);i.attachShader(q,d);i.attachShader(q,k);i.linkProgram(q);i.getProgramParameter(q,i.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+i.getProgramParameter(q,i.VALIDATE_STATUS)+", gl error ["+i.getError()+"]");i.deleteShader(k);i.deleteShader(d);q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in h)d.push(s); -s=d;d=0;for(h=s.length;d=0&&i.enableVertexAttribArray(p.position);p.color>=0&&i.enableVertexAttribArray(p.color);p.normal>=0&&i.enableVertexAttribArray(p.normal);p.tangent>=0&&i.enableVertexAttribArray(p.tangent);if(a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0){i.enableVertexAttribArray(p.skinVertexA);i.enableVertexAttribArray(p.skinVertexB);i.enableVertexAttribArray(p.skinIndex);i.enableVertexAttribArray(p.skinWeight)}if(a.attributes)for(f in a.attributes)p[f]!==void 0&&p[f]>= -0&&i.enableVertexAttribArray(p[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f=0){i.enableVertexAttribArray(p[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f=0){i.enableVertexAttribArray(p[s]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a, -b){if(a){!b||b==="ccw"?i.frontFace(i.CCW):i.frontFace(i.CW);a==="back"?i.cullFace(i.BACK):a==="front"?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK);i.enable(i.CULL_FACE)}else i.disable(i.CULL_FACE)};this.setObjectFaces=function(a){if(Z!==a.doubleSided){a.doubleSided?i.disable(i.CULL_FACE):i.enable(i.CULL_FACE);Z=a.doubleSided}if($!==a.flipSided){a.flipSided?i.frontFace(i.CW):i.frontFace(i.CCW);$=a.flipSided}};this.setDepthTest=function(a){if(Pa!==a){a?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST); -Pa=a}};this.setDepthWrite=function(a){if(Qa!==a){i.depthMask(a);Qa=a}};this.setBlending=function(a,b,c,d){if(a!==X){if(a===THREE.NoBlending)i.disable(i.BLEND);else if(a===THREE.AdditiveBlending){i.enable(i.BLEND);i.blendEquation(i.FUNC_ADD);i.blendFunc(i.SRC_ALPHA,i.ONE)}else if(a===THREE.SubtractiveBlending){i.enable(i.BLEND);i.blendEquation(i.FUNC_ADD);i.blendFunc(i.ZERO,i.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){i.enable(i.BLEND);i.blendEquation(i.FUNC_ADD);i.blendFunc(i.ZERO,i.SRC_COLOR)}else if(a=== -THREE.CustomBlending)i.enable(i.BLEND);else{i.enable(i.BLEND);i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD);i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA)}X=a}if(a===THREE.CustomBlending){if(b!==ia){i.blendEquation(C(b));ia=b}if(c!==ya||d!==Ia){i.blendFunc(C(c),C(d));ya=c;Ia=d}}else Ia=ya=ia=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=i.createTexture();D.info.memory.textures++}i.activeTexture(i.TEXTURE0+ -b);i.bindTexture(i.TEXTURE_2D,a.__webglTexture);i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,a.flipY);i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=C(a.format),f=C(a.type);s(i.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?i.texImage2D(i.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):i.texImage2D(i.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&i.generateMipmap(i.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{i.activeTexture(i.TEXTURE0+ -b);i.bindTexture(i.TEXTURE_2D,a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=i.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=C(a.format),e=C(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];i.bindTexture(i.TEXTURE_CUBE_MAP,a.__webglTexture);s(i.TEXTURE_CUBE_MAP,a,c); -for(var f=0;f<6;f++){a.__webglFramebuffer[f]=i.createFramebuffer();a.__webglRenderbuffer[f]=i.createRenderbuffer();i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=i.TEXTURE_CUBE_MAP_POSITIVE_X+f;i.bindFramebuffer(i.FRAMEBUFFER,a.__webglFramebuffer[f]);i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,h,g.__webglTexture,0);x(a.__webglRenderbuffer[f],a)}c&&i.generateMipmap(i.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=i.createFramebuffer();a.__webglRenderbuffer= -i.createRenderbuffer();i.bindTexture(i.TEXTURE_2D,a.__webglTexture);s(i.TEXTURE_2D,a,c);i.texImage2D(i.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=i.TEXTURE_2D;i.bindFramebuffer(i.FRAMEBUFFER,a.__webglFramebuffer);i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,d,a.__webglTexture,0);x(a.__webglRenderbuffer,a);c&&i.generateMipmap(i.TEXTURE_2D)}b?i.bindTexture(i.TEXTURE_CUBE_MAP,null):i.bindTexture(i.TEXTURE_2D,null);i.bindRenderbuffer(i.RENDERBUFFER,null);i.bindFramebuffer(i.FRAMEBUFFER, -null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=pb;a=hb;d=ob;e=kb}if(b!==aa){i.bindFramebuffer(i.FRAMEBUFFER,b);i.viewport(d,e,c,a);aa=b}bb=c;Ca=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +i=w("fragment",k+i);d=w("vertex",d+n);j.attachShader(q,d);j.attachShader(q,i);j.linkProgram(q);j.getProgramParameter(q,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(q,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");j.deleteShader(i);j.deleteShader(d);q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in h)d.push(s); +s=d;d=0;for(h=s.length;d=0&&j.enableVertexAttribArray(r.position);r.color>=0&&j.enableVertexAttribArray(r.color);r.normal>=0&&j.enableVertexAttribArray(r.normal);r.tangent>=0&&j.enableVertexAttribArray(r.tangent);if(a.skinning&&r.skinVertexA>=0&&r.skinVertexB>=0&&r.skinIndex>=0&&r.skinWeight>=0){j.enableVertexAttribArray(r.skinVertexA);j.enableVertexAttribArray(r.skinVertexB);j.enableVertexAttribArray(r.skinIndex);j.enableVertexAttribArray(r.skinWeight)}if(a.attributes)for(f in a.attributes)r[f]!==void 0&&r[f]>= +0&&j.enableVertexAttribArray(r[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f=0){j.enableVertexAttribArray(r[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f=0){j.enableVertexAttribArray(r[s]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a, +b){if(a){!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW);a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK);j.enable(j.CULL_FACE)}else j.disable(j.CULL_FACE)};this.setObjectFaces=function(a){if(Z!==a.doubleSided){a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE);Z=a.doubleSided}if($!==a.flipSided){a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW);$=a.flipSided}};this.setDepthTest=function(a){if(Pa!==a){a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST); +Pa=a}};this.setDepthWrite=function(a){if(Qa!==a){j.depthMask(a);Qa=a}};this.setBlending=function(a,b,c,d){if(a!==X){if(a===THREE.NoBlending)j.disable(j.BLEND);else if(a===THREE.AdditiveBlending){j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE)}else if(a===THREE.SubtractiveBlending){j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR)}else if(a=== +THREE.CustomBlending)j.enable(j.BLEND);else{j.enable(j.BLEND);j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD);j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}X=a}if(a===THREE.CustomBlending){if(b!==ia){j.blendEquation(C(b));ia=b}if(c!==ya||d!==Ia){j.blendFunc(C(c),C(d));ya=c;Ia=d}}else Ia=ya=ia=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=j.createTexture();D.info.memory.textures++}j.activeTexture(j.TEXTURE0+ +b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,a.flipY);j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=C(a.format),f=C(a.type);t(j.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{j.activeTexture(j.TEXTURE0+ +b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=j.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=C(a.format),e=C(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);t(j.TEXTURE_CUBE_MAP,a,c); +for(var f=0;f<6;f++){a.__webglFramebuffer[f]=j.createFramebuffer();a.__webglRenderbuffer[f]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=j.TEXTURE_CUBE_MAP_POSITIVE_X+f;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[f]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,h,g.__webglTexture,0);x(a.__webglRenderbuffer[f],a)}c&&j.generateMipmap(j.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=j.createFramebuffer();a.__webglRenderbuffer= +j.createRenderbuffer();j.bindTexture(j.TEXTURE_2D,a.__webglTexture);t(j.TEXTURE_2D,a,c);j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=j.TEXTURE_2D;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0);x(a.__webglRenderbuffer,a);c&&j.generateMipmap(j.TEXTURE_2D)}b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER, +null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=pb;a=hb;d=ob;e=kb}if(b!==aa){j.bindFramebuffer(j.FRAMEBUFFER,b);j.viewport(d,e,c,a);aa=b}bb=c;Ca=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:true;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:true;this.generateMipmaps=true}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; @@ -446,31 +446,31 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=(c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h)/6;c<0&&(c=c+1);c>1&&(c=c-1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,l=a.faceVertexUvs[0],o=f.faceVertexUvs[0],m={},p=0;p1){d=1-d;e=1-e}f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3){d=b.vertices[a.a];e=b.vertices[a.b];f=b.vertices[a.c];return THREE.GeometryUtils.randomPointInTriangle(d,e,f)}if(a instanceof THREE.Face4){d=b.vertices[a.a];e=b.vertices[a.b];f=b.vertices[a.c];var b=b.vertices[a.d],g;if(c)if(a._area1&&a._area2){c=a._area1;g=a._area2}else{c=THREE.GeometryUtils.triangleArea(d,e,b);g=THREE.GeometryUtils.triangleArea(e,f,b);a._area1=c;a._area2=g}else{c=THREE.GeometryUtils.triangleArea(d,e,b);g=THREE.GeometryUtils.triangleArea(e,f,b)}return THREE.GeometryUtils.random()* -(c+g)a?b(c,e-1):j[e]a?b(c,e-1):k[e] -b||r>b||m>b){k=a.vertices.length;w=e.clone();s=e.clone();if(p>=r&&p>=m){j=j.clone();j.lerpSelf(l,0.5);w.a=f;w.b=k;w.c=h;s.a=k;s.b=g;s.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);w.vertexNormals[1].copy(f);s.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);w.vertexColors[1].copy(f);s.vertexColors[0].copy(f)}e=0}else if(r>=p&&r>=m){j=l.clone();j.lerpSelf(o,0.5);w.a=f;w.b=g;w.c= -k;s.a=k;s.b=h;s.c=f;if(e.vertexNormals.length===3){f=e.vertexNormals[1].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);s.vertexNormals[0].copy(f);s.vertexNormals[1].copy(e.vertexNormals[2]);s.vertexNormals[2].copy(e.vertexNormals[0])}if(e.vertexColors.length===3){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);s.vertexColors[0].copy(f);s.vertexColors[1].copy(e.vertexColors[2]);s.vertexColors[2].copy(e.vertexColors[0])}e=1}else{j=j.clone(); -j.lerpSelf(o,0.5);w.a=f;w.b=g;w.c=k;s.a=k;s.b=g;s.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);s.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);s.vertexColors[0].copy(f)}e=2}x.push(w,s);a.vertices.push(j);f=0;for(g=a.faceVertexUvs.length;fb||r>b||n>b||q>b){t=a.vertices.length;u=a.vertices.length+1;w=e.clone();s=e.clone();if(p>=r&&p>=n&&p>=q||n>=r&&n>=p&&n>=q){p=j.clone();p.lerpSelf(l,0.5);l=o.clone();l.lerpSelf(m,0.5);w.a=f;w.b=t;w.c=u;w.d=k;s.a=t;s.b=g;s.c=h;s.d=u;if(e.vertexNormals.length===4){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);g=e.vertexNormals[2].clone();g.lerpSelf(e.vertexNormals[3],0.5);w.vertexNormals[1].copy(f); -w.vertexNormals[2].copy(g);s.vertexNormals[0].copy(f);s.vertexNormals[3].copy(g)}if(e.vertexColors.length===4){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);g=e.vertexColors[2].clone();g.lerpSelf(e.vertexColors[3],0.5);w.vertexColors[1].copy(f);w.vertexColors[2].copy(g);s.vertexColors[0].copy(f);s.vertexColors[3].copy(g)}e=0}else{p=l.clone();p.lerpSelf(o,0.5);l=m.clone();l.lerpSelf(j,0.5);w.a=f;w.b=g;w.c=t;w.d=u;s.a=u;s.b=t;s.c=h;s.d=k;if(e.vertexNormals.length===4){f=e.vertexNormals[1].clone(); -f.lerpSelf(e.vertexNormals[2],0.5);g=e.vertexNormals[3].clone();g.lerpSelf(e.vertexNormals[0],0.5);w.vertexNormals[2].copy(f);w.vertexNormals[3].copy(g);s.vertexNormals[0].copy(g);s.vertexNormals[1].copy(f)}if(e.vertexColors.length===4){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);g=e.vertexColors[3].clone();g.lerpSelf(e.vertexColors[0],0.5);w.vertexColors[2].copy(f);w.vertexColors[3].copy(g);s.vertexColors[0].copy(g);s.vertexColors[1].copy(f)}e=1}x.push(w,s);a.vertices.push(p,l); -f=0;for(g=a.faceVertexUvs.length;f +b||r>b||m>b){i=a.vertices.length;w=e.clone();t=e.clone();if(p>=r&&p>=m){k=k.clone();k.lerpSelf(l,0.5);w.a=f;w.b=i;w.c=h;t.a=i;t.b=g;t.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);w.vertexNormals[1].copy(f);t.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);w.vertexColors[1].copy(f);t.vertexColors[0].copy(f)}e=0}else if(r>=p&&r>=m){k=l.clone();k.lerpSelf(o,0.5);w.a=f;w.b=g;w.c= +i;t.a=i;t.b=h;t.c=f;if(e.vertexNormals.length===3){f=e.vertexNormals[1].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);t.vertexNormals[0].copy(f);t.vertexNormals[1].copy(e.vertexNormals[2]);t.vertexNormals[2].copy(e.vertexNormals[0])}if(e.vertexColors.length===3){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);t.vertexColors[0].copy(f);t.vertexColors[1].copy(e.vertexColors[2]);t.vertexColors[2].copy(e.vertexColors[0])}e=1}else{k=k.clone(); +k.lerpSelf(o,0.5);w.a=f;w.b=g;w.c=i;t.a=i;t.b=g;t.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);t.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);t.vertexColors[0].copy(f)}e=2}x.push(w,t);a.vertices.push(k);f=0;for(g=a.faceVertexUvs.length;fb||r>b||n>b||q>b){s=a.vertices.length;u=a.vertices.length+1;w=e.clone();t=e.clone();if(p>=r&&p>=n&&p>=q||n>=r&&n>=p&&n>=q){p=k.clone();p.lerpSelf(l,0.5);l=o.clone();l.lerpSelf(m,0.5);w.a=f;w.b=s;w.c=u;w.d=i;t.a=s;t.b=g;t.c=h;t.d=u;if(e.vertexNormals.length===4){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);g=e.vertexNormals[2].clone();g.lerpSelf(e.vertexNormals[3],0.5);w.vertexNormals[1].copy(f); +w.vertexNormals[2].copy(g);t.vertexNormals[0].copy(f);t.vertexNormals[3].copy(g)}if(e.vertexColors.length===4){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);g=e.vertexColors[2].clone();g.lerpSelf(e.vertexColors[3],0.5);w.vertexColors[1].copy(f);w.vertexColors[2].copy(g);t.vertexColors[0].copy(f);t.vertexColors[3].copy(g)}e=0}else{p=l.clone();p.lerpSelf(o,0.5);l=m.clone();l.lerpSelf(k,0.5);w.a=f;w.b=g;w.c=s;w.d=u;t.a=u;t.b=s;t.c=h;t.d=i;if(e.vertexNormals.length===4){f=e.vertexNormals[1].clone(); +f.lerpSelf(e.vertexNormals[2],0.5);g=e.vertexNormals[3].clone();g.lerpSelf(e.vertexNormals[0],0.5);w.vertexNormals[2].copy(f);w.vertexNormals[3].copy(g);t.vertexNormals[0].copy(g);t.vertexNormals[1].copy(f)}if(e.vertexColors.length===4){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);g=e.vertexColors[3].clone();g.lerpSelf(e.vertexColors[0],0.5);w.vertexColors[2].copy(f);w.vertexColors[3].copy(g);t.vertexColors[0].copy(g);t.vertexColors[1].copy(f)}e=1}x.push(w,t);a.vertices.push(p,l); +f=0;for(g=a.faceVertexUvs.length;fe-1?e-1:o+1,r= -l-1<0?0:l-1,n=l+1>d-1?d-1:l+1,q=[],t=[0,0,h[(o*d+l)*4]/255*b];q.push([-1,0,h[(o*d+r)*4]/255*b]);q.push([-1,-1,h[(m*d+r)*4]/255*b]);q.push([0,-1,h[(m*d+l)*4]/255*b]);q.push([1,-1,h[(m*d+n)*4]/255*b]);q.push([1,0,h[(o*d+n)*4]/255*b]);q.push([1,1,h[(p*d+n)*4]/255*b]);q.push([0,1,h[(p*d+l)*4]/255*b]);q.push([-1,1,h[(p*d+r)*4]/255*b]);m=[];r=q.length;for(p=0;pe-1?e-1:o+1,r= +l-1<0?0:l-1,n=l+1>d-1?d-1:l+1,q=[],s=[0,0,h[(o*d+l)*4]/255*b];q.push([-1,0,h[(o*d+r)*4]/255*b]);q.push([-1,-1,h[(m*d+r)*4]/255*b]);q.push([0,-1,h[(m*d+l)*4]/255*b]);q.push([1,-1,h[(m*d+n)*4]/255*b]);q.push([1,0,h[(o*d+n)*4]/255*b]);q.push([1,1,h[(p*d+n)*4]/255*b]);q.push([0,1,h[(p*d+l)*4]/255*b]);q.push([-1,1,h[(p*d+r)*4]/255*b]);m=[];r=q.length;for(p=0;p 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif", THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}}); THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d= -0,e=(""+a).split(""),f=e.length,g=[],a=0;a0)for(j=0;j2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");break}k=j;e<=k&&(k=0);j=k+1;e<=j&&(j=0);l=j+1;e<=l&&(l=0);var m;a:{m=a;var p=k,r=j,n=l,q=e,t=g,u=void 0,w=void 0,s=void 0,x=void 0,F=void 0, -C=void 0,z=void 0,v=void 0,H=void 0,w=m[t[p]].x,s=m[t[p]].y,x=m[t[r]].x,F=m[t[r]].y,C=m[t[n]].x,z=m[t[n]].y;if(1.0E-10>(x-w)*(z-s)-(F-s)*(C-w))m=false;else{for(u=0;u=0&&R>=0&&B>=0){m=false;break a}}m=true}}if(m){f.push([a[g[k]], -a[g[j]],a[g[l]]]);h.push([g[k],g[j],g[l]]);k=j;for(l=j+1;l0)for(k=0;k2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var m;a:{m=a;var p=i,r=k,n=l,q=e,s=g,u=void 0,w=void 0,t=void 0,x=void 0,F=void 0, +C=void 0,z=void 0,v=void 0,H=void 0,w=m[s[p]].x,t=m[s[p]].y,x=m[s[r]].x,F=m[s[r]].y,C=m[s[n]].x,z=m[s[n]].y;if(1.0E-10>(x-w)*(z-t)-(F-t)*(C-w))m=false;else{for(u=0;u=0&&R>=0&&B>=0){m=false;break a}}m=true}}if(m){f.push([a[g[i]], +a[g[k]],a[g[l]]]);h.push([g[i],g[k],g[l]]);i=k;for(l=k+1;lb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(eb.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var a=this.vertexPositionArray; -if(a){for(var b,c=0,d,e,f=0,g=a.length;fc&&(c=b)}this.boundingSphere.radius=c}}};THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c}; -THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]}; +if(a){for(var b,c=0,d,e,f=0,g=a.length;fc&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){var a=this.vertexIndexArray,b=this.vertexPositionArray;if(b&&a){var c,d,e,f;c=b.length;if(this.vertexNormalArray===void 0)this.vertexNormalArray=new Float32Array(c);else{c=0;for(d=this.vertexNormalArray.length;c0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; +THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,i;g<=h;){d=Math.floor(g+(h-g)/2);i=c[d]-f;if(i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; THREE.Curve.prototype.getTangent=function(a){var b=a-1.0E-4,a=a+1.0E-4;b<0&&(b=0);a>1&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){return this.getTangent(this.getUtoTmapping(a))};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().subSelf(this.v1);b.multiplyScalar(a).addSelf(this.v1);return b}; THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){return this.v2.clone().subSelf(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype); THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b}; @@ -518,10 +520,10 @@ THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[] d[c[1]].z,d[c[2]].z,d[c[3]].z,e);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=false};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))}; THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a=b){b=c[a]-b;a=this.curves[a];b=1-b/a.getLength();return a.getPointAt(b)}a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;cb)b=f.x;else if(f.xc)c=f.y;else if(f.yb)b=f.x;else if(f.xc)c=f.y;else if(f.y0){g=c[c.length-1]; -p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b2(n,p,o,h);n=THREE.Shape.Utils.b2(n,r,m,k);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];k=f[5];o=f[0];m=f[1];j=f[2];l=f[3];if(c.length>0){g=c[c.length-1];p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b3(n,p,o,j,h);n=THREE.Shape.Utils.b3(n,r,m,l,k);c.push(new THREE.Vector2(g, -n))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;n=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;n=n.concat(f[0]);n=new THREE.SplineCurve(n);for(f=1;f<=g;f++)c.push(n.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];k=f[1];m=f[2];j=f[3];g=f[4];o=!!f[5];p=g-j;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=j+n*p;g=h+m*Math.cos(n);n=k+m*Math.sin(n);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.ELLIPSE:h=f[0];k=f[1];m=f[2];l=f[3];j=f[4];g=f[5]; -o=!!f[6];p=g-j;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=j+n*p;g=h+m*Math.cos(n);n=k+l*Math.sin(n);c.push(new THREE.Vector2(g,n))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1.0E-10&&Math.abs(d.y-c[0].y)<1.0E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; +THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints){console.log("tata");return this.getSpacedPoints(a,b)}var a=a||12,c=[],d,e,f,g,h,i,k,l,o,m,p,r,n;d=0;for(e=this.actions.length;d0){g=c[c.length-1]; +p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b2(n,p,o,h);n=THREE.Shape.Utils.b2(n,r,m,i);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];m=f[1];k=f[2];l=f[3];if(c.length>0){g=c[c.length-1];p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b3(n,p,o,k,h);n=THREE.Shape.Utils.b3(n,r,m,l,i);c.push(new THREE.Vector2(g, +n))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;n=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;n=n.concat(f[0]);n=new THREE.SplineCurve(n);for(f=1;f<=g;f++)c.push(n.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];m=f[2];k=f[3];g=f[4];o=!!f[5];p=g-k;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=k+n*p;g=h+m*Math.cos(n);n=i+m*Math.sin(n);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];m=f[2];l=f[3];k=f[4];g=f[5]; +o=!!f[6];p=g-k;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=k+n*p;g=h+m*Math.cos(n);n=i+l*Math.sin(n);c.push(new THREE.Vector2(g,n))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1.0E-10&&Math.abs(d.y-c[0].y)<1.0E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;a=0;for(b=this.actions.length;a=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var n=[j[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var q=[j[g],j[f],c[h]];m=THREE.FontUtils.Triangulate.area(q);p=h;l=g;h=h+1;g=g+ --1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;n=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[j[g],j[f],c[h]];q=THREE.FontUtils.Triangulate.area(q);if(o+m>n+q){h=p;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1}o=c.slice(0,h);m=c.slice(h);p=j.slice(g);l=j.slice(0,g);f=[j[g],j[f],c[h]];r.push([j[g],c[h],c[e]]);r.push(f);c=o.concat(p).concat(l).concat(m)}return{shape:c, -isolatedPts:r,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,k,j={};f=0;for(g=d.length;f=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1;var n=[k[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var q=[k[g],k[f],c[h]];m=THREE.FontUtils.Triangulate.area(q);p=h;l=g;h=h+1;g=g+ +-1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+k.length);g=g%k.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1;n=[k[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[k[g],k[f],c[h]];q=THREE.FontUtils.Triangulate.area(q);if(o+m>n+q){h=p;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+k.length);g=g%k.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1}o=c.slice(0,h);m=c.slice(h);p=k.slice(g);l=k.slice(0,g);f=[k[g],k[f],c[h]];r.push([k[g],c[h],c[e]]);r.push(f);c=o.concat(p).concat(l).concat(m)}return{shape:c, +isolatedPts:r,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,i,k={};f=0;for(g=d.length;f1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType=== +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,i,k,l=this.data.JIT.hierarchy,o,m;m=this.currentTime=this.currentTime+a*this.timeScale;o=this.currentTime=this.currentTime%this.data.length;k=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,r=this.hierarchy.length;p1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType=== THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",p,g.index-1).pos;this.points[1]=e;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",p,h.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);c.x=e[0];c.y=e[1];c.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x, -this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}}}}if(this.JITCompile&&l[0][j]===void 0){this.hierarchy[0].updateMatrixWorld(true);for(p=0;pa.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];k=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],k[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],k[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],k[2],j[2],e,c,g);return d}; +this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}}}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].updateMatrixWorld(true);for(p=0;pa.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],k[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],k[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],k[2],e,c,g);return d}; THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(true); +THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,e,f=this.data.JIT.hierarchy,g,h,i;h=this.currentTime=this.currentTime+a*this.timeScale;g=this.currentTime=this.currentTime%this.data.length;if(g=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(true); for(a=0;a=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]}; THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new THREE.Vector3(-1,0,0));this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1);f.lookAt(new THREE.Vector3(0,1,0));this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90, -1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var k=new THREE.PerspectiveCamera(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new THREE.Vector3(0,0,-1));this.add(k);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,m=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace= -2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=m;c.activeCubeFace=5;a.render(b,k,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,e,f,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,f,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()}; +1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var i=new THREE.PerspectiveCamera(90,1,a,b);i.up.set(0,-1,0);i.lookAt(new THREE.Vector3(0,0,-1));this.add(i);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,m=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace= +2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=m;c.activeCubeFace=5;a.render(b,i,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,e,f,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,f,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()}; THREE.CombinedCamera.prototype=Object.create(THREE.Camera.prototype);THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPerspectiveMode=true;this.inOrthographicMode=false}; THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPerspectiveMode=false;this.inOrthographicMode=true}; THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2};THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){if(this.inPerspectiveMode)this.toPerspective();else{this.toPerspective();this.toOrthographic()}}; @@ -589,7 +591,7 @@ this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon=this.lon+this.mouseX*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*a*b;this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi, 0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),false);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),false);this.domElement.addEventListener("mouseup", c(this,this.onMouseUp),false);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),false);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),false);this.handleResize()}; -THREE.PathControls=function(a,b){function c(a){return(a=a*2)<1?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),q=g.length,t=0;f=q-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f0||this.autoForward&&!(k<0)?1:k));this.object.translateX(b*j);this.object.translateY(b*l);if(g)this.roll=this.roll+this.rollSpeed*a*h;if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*k);this.object.translateY(b*l);if(g)this.roll=this.roll+this.rollSpeed*a*h;if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y1?d.normalize():d.z=Math.sqrt(1-e*e);g.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e}; -this.rotateCamera=function(){var a=Math.acos(h.dot(k)/h.length()/k.length());if(a){var b=(new THREE.Vector3).cross(h,k).normalize(),d=new THREE.Quaternion,a=a*c.rotateSpeed;d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(k);if(c.staticMoving)h=k;else{d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1));d.multiplyVector3(h)}}};this.zoomCamera=function(){var a=1+(l.y-j.y)*c.zoomSpeed;if(a!==1&&a>0){g.multiplyScalar(a);c.staticMoving?j=l:j.y=j.y+(l.y-j.y)* +this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion,a=a*c.rotateSpeed;d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(i);if(c.staticMoving)h=i;else{d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1));d.multiplyVector3(h)}}};this.zoomCamera=function(){var a=1+(l.y-k.y)*c.zoomSpeed;if(a!==1&&a>0){g.multiplyScalar(a);c.staticMoving?k=l:k.y=k.y+(l.y-k.y)* this.dynamicDampingFactor}};this.panCamera=function(){var a=m.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y));c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=m:o.addSelf(a.sub(m,o).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan){c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance); g.lengthSq()0){c.dispatchEvent(p);d.copy(c.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false); -this.domElement.addEventListener("mousemove",function(a){if(c.enabled){if(e){h=k=c.getMouseProjectionOnBall(a.clientX,a.clientY);j=l=c.getMouseOnScreen(a.clientX,a.clientY);o=m=c.getMouseOnScreen(a.clientX,a.clientY);e=false}f!==-1&&(f===0&&!c.noRotate?k=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,a.clientY):f===2&&!c.noPan&&(m=c.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(c.enabled){a.preventDefault(); -a.stopPropagation();if(f===-1){f=a.button;f===0&&!c.noRotate?h=k=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?j=l=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(o=m=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled&&f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom? +this.domElement.addEventListener("mousemove",function(a){if(c.enabled){if(e){h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY);k=l=c.getMouseOnScreen(a.clientX,a.clientY);o=m=c.getMouseOnScreen(a.clientX,a.clientY);e=false}f!==-1&&(f===0&&!c.noRotate?i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,a.clientY):f===2&&!c.noPan&&(m=c.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(c.enabled){a.preventDefault(); +a.stopPropagation();if(f===-1){f=a.button;f===0&&!c.noRotate?h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?k=l=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(o=m=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled&&f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom? f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2);f!==-1&&(e=true)}},false);window.addEventListener("keyup",function(){c.enabled&&f!==-1&&(f=-1)},false);this.handleResize()}; -THREE.OrbitControls=function(a,b){var c,d,e;function f(){return 2*Math.PI/60/60*k.autoRotateSpeed}function g(a){a.preventDefault();if(s===c){o.set(a.clientX,a.clientY);m.sub(o,l);k.rotateLeft(2*Math.PI*m.x/j*k.userRotateSpeed);k.rotateUp(2*Math.PI*m.y/j*k.userRotateSpeed);l.copy(o)}else if(s===d){r.set(a.clientX,a.clientY);n.sub(r,p);n.y>0?k.zoomIn():k.zoomOut();p.copy(r)}}function h(){if(k.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false); -s=e}}THREE.EventTarget.call(this);this.object=a;this.domElement=b!==void 0?b:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var k=this,j=1800,l=new THREE.Vector2,o=new THREE.Vector2,m=new THREE.Vector2,p=new THREE.Vector2,r=new THREE.Vector2,n=new THREE.Vector2,q=0,t=0,u=1,w=new THREE.Vector3;e=-1;c=0;d=1;var s=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); -t=t-a};this.rotateRight=function(a){a===void 0&&(a=f());t=t+a};this.rotateUp=function(a){a===void 0&&(a=f());q=q-a};this.rotateDown=function(a){a===void 0&&(a=f());q=q+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,k.userZoomSpeed));u=u/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,k.userZoomSpeed));u=u*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),c=Math.atan2(b.x,b.z),d=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&this.rotateLeft(f()); -var c=c+t,d=d+q,d=Math.max(1.0E-6,Math.min(Math.PI-1.0E-6,d)),e=b.length();b.x=e*Math.sin(d)*Math.sin(c);b.y=e*Math.cos(d);b.z=e*Math.sin(d)*Math.cos(c);b.multiplyScalar(u);a.copy(this.center).addSelf(b);this.object.lookAt(this.center);q=t=0;u=1;if(w.distanceTo(this.object.position)>0){this.dispatchEvent(x);w.copy(this.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousedown",function(a){if(k.userRotate){a.preventDefault(); -if(a.button===0||a.button===2){s=c;l.set(a.clientX,a.clientY)}else if(a.button===1){s=d;p.set(a.clientX,a.clientY)}document.addEventListener("mousemove",g,false);document.addEventListener("mouseup",h,false)}},false);this.domElement.addEventListener("mousewheel",function(a){k.userZoom&&(a.wheelDelta>0?k.zoomOut():k.zoomIn())},false)}; -THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function k(a,b,c,g,h,k,l,m){var n,o=d||1,p=e||1,r=h/2,q=k/2,t=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=f||1}var u=o+1,i=p+1,w=h/o,L=k/p,S=new THREE.Vector3;S[n]=l>0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vector3(0, -g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h0?i.zoomIn():i.zoomOut();p.copy(r)}}function h(){if(i.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false); +t=e}}THREE.EventTarget.call(this);this.object=a;this.domElement=b!==void 0?b:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var i=this,k=1800,l=new THREE.Vector2,o=new THREE.Vector2,m=new THREE.Vector2,p=new THREE.Vector2,r=new THREE.Vector2,n=new THREE.Vector2,q=0,s=0,u=1,w=new THREE.Vector3;e=-1;c=0;d=1;var t=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); +s=s-a};this.rotateRight=function(a){a===void 0&&(a=f());s=s+a};this.rotateUp=function(a){a===void 0&&(a=f());q=q-a};this.rotateDown=function(a){a===void 0&&(a=f());q=q+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));u=u/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));u=u*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),c=Math.atan2(b.x,b.z),d=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&this.rotateLeft(f()); +var c=c+s,d=d+q,d=Math.max(1.0E-6,Math.min(Math.PI-1.0E-6,d)),e=b.length();b.x=e*Math.sin(d)*Math.sin(c);b.y=e*Math.cos(d);b.z=e*Math.sin(d)*Math.cos(c);b.multiplyScalar(u);a.copy(this.center).addSelf(b);this.object.lookAt(this.center);q=s=0;u=1;if(w.distanceTo(this.object.position)>0){this.dispatchEvent(x);w.copy(this.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousedown",function(a){if(i.userRotate){a.preventDefault(); +if(a.button===0||a.button===2){t=c;l.set(a.clientX,a.clientY)}else if(a.button===1){t=d;p.set(a.clientX,a.clientY)}document.addEventListener("mousemove",g,false);document.addEventListener("mouseup",h,false)}},false);this.domElement.addEventListener("mousewheel",function(a){i.userZoom&&(a.wheelDelta>0?i.zoomOut():i.zoomIn())},false)}; +THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,l,m){var n,o=d||1,p=e||1,r=h/2,q=i/2,s=k.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=f||1}var u=o+1,j=p+1,w=h/o,L=i/p,S=new THREE.Vector3;S[n]=l>0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vector3(0, +g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;ha&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(K=c.length;--K>=0;){e=K;f=K-1;f<0&&(f= -c.length-1);for(var g=0,h=m+l*2,g=0;g=0;G--){D=G/l;i=k*(1-D);Q=j*Math.sin(D*Math.PI/2);K=0;for(D=B.length;K=0;G--){D=G/l;j=i*(1-D);Q=k*Math.sin(D*Math.PI/2);K=0;for(D=B.length;K1.0E-4){h.normalize();d=Math.acos(e[j-1].dot(e[j]));k.makeRotationAxis(h,d).multiplyVector3(f[j])}g[j].cross(e[j],f[j])}if(c){d=Math.acos(f[0].dot(f[b-1]));d=d/(b-1);e[0].dot(h.cross(f[0],f[b-1]))>0&&(d=-d);for(j=1;j1.0E-4){h.normalize();d=Math.acos(e[k-1].dot(e[k]));i.makeRotationAxis(h,d).multiplyVector3(f[k])}g[k].cross(e[k],f[k])}if(c){d=Math.acos(f[0].dot(f[b-1]));d=d/(b-1);e[0].dot(h.cross(f[0],f[b-1]))>0&&(d=-d);for(k=1;k=j){for(k=0;k<3;k++){j=[h[k],h[(k+1)%3]];t=true;for(u=0;u=k){for(i=0;i<3;i++){k=[h[i],h[(i+1)%3]];s=true;for(u=0;u0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function b(){m.debug&&console.log.apply(console,arguments)}function c(){console&&console.log.apply(console,arguments)}function d(a,c,d,e,g,h,i){var k=new THREE.Face4(a,c,d,e,null,g.color,g.materialIndex);if(m.useOldVertexColors){k.vertexColors=[];for(var j,n,p,q=0;q<4;q++){p=h[q];j=new THREE.Color;j.setRGB(0,0,0);for(var r=0;r=w&&a1){var k=h[1];d[k]||(d[k]={start:Infinity,end:-Infinity});h=d[k];if(fh.end)h.end=f;c||(c=k)}}for(k in d){h=d[k];this.createAnimation(k,h.start,h.end,a)}this.firstAnimation=c}; +THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)(\d+)/,c,d={},e=this.geometry,f=0,g=e.morphTargets.length;f1){var i=h[1];d[i]||(d[i]={start:Infinity,end:-Infinity});h=d[i];if(fh.end)h.end=f;c||(c=i)}}for(i in d){h=d[i];this.createAnimation(i,h.start,h.end,a)}this.firstAnimation=c}; THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a]){a.direction=1;a.directionBackwards=false}};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a]){a.direction=-1;a.directionBackwards=true}};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];if(c){c.fps=b;c.duration=(c.end-c.start)/c.fps}}; THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];if(c){c.duration=b;c.fps=(c.end-c.start)/c.duration}};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];if(c)c.weight=b};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];if(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];if(b){b.time=0;b.active=true}else console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=false}; THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;bd.duration||d.time<0){d.direction=d.direction*-1;if(d.time>d.duration){d.time=d.duration;d.directionBackwards=true}if(d.time<0){d.time=0;d.directionBackwards=false}}}else{d.time=d.time%d.duration;if(d.time<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;if(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){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,k,j,l,o,m,p;this.init=function(r){b=r.context;c=r;d=new Float32Array(16);e=new Uint16Array(6);r=0;d[r++]=-1;d[r++]=-1;d[r++]=0;d[r++]=0;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]= -0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;e[r++]=0;e[r++]=1;e[r++]=2;e[r++]=0;e[r++]=2;e[r++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);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,k);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);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){j=false;l=a(THREE.ShaderFlares.lensFlare)}else{j=true;l=a(THREE.ShaderFlares.lensFlareVertexTexture)}o={};m={};o.vertex=b.getAttribLocation(l,"position");o.uv=b.getAttribLocation(l,"uv");m.renderType=b.getUniformLocation(l,"renderType");m.map=b.getUniformLocation(l,"map");m.occlusionMap=b.getUniformLocation(l,"occlusionMap");m.opacity=b.getUniformLocation(l,"opacity");m.color=b.getUniformLocation(l, -"color");m.scale=b.getUniformLocation(l,"scale");m.rotation=b.getUniformLocation(l,"rotation");m.screenPosition=b.getUniformLocation(l,"screenPosition");p=false};this.render=function(a,d,e,t){var a=a.__webglFlares,u=a.length;if(u){var w=new THREE.Vector3,s=t/e,x=e*0.5,F=t*0.5,C=16/t,z=new THREE.Vector2(C*s,C),v=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),I=m,C=o;b.useProgram(l);if(!p){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);p=true}b.uniform1i(I.occlusionMap,0);b.uniform1i(I.map, -1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(C.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(C.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var N,R,Y,B,G;for(N=0;N0&&H.x0&& -H.y0.0010&&G.scale>0.0010){v.x=G.x;v.y=G.y;v.z=G.z;C=G.size*G.scale/t;z.x=C*s;z.y=C;b.uniform3f(I.screenPosition,v.x,v.y,v.z);b.uniform2f(I.scale,z.x,z.y);b.uniform1f(I.rotation,G.rotation);b.uniform1f(I.opacity,G.opacity); +THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,k,l,o,m,p;this.init=function(r){b=r.context;c=r;d=new Float32Array(16);e=new Uint16Array(6);r=0;d[r++]=-1;d[r++]=-1;d[r++]=0;d[r++]=0;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]= +0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;e[r++]=0;e[r++]=1;e[r++]=2;e[r++]=0;e[r++]=2;e[r++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);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,i);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);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){k=false;l=a(THREE.ShaderFlares.lensFlare)}else{k=true;l=a(THREE.ShaderFlares.lensFlareVertexTexture)}o={};m={};o.vertex=b.getAttribLocation(l,"position");o.uv=b.getAttribLocation(l,"uv");m.renderType=b.getUniformLocation(l,"renderType");m.map=b.getUniformLocation(l,"map");m.occlusionMap=b.getUniformLocation(l,"occlusionMap");m.opacity=b.getUniformLocation(l,"opacity");m.color=b.getUniformLocation(l, +"color");m.scale=b.getUniformLocation(l,"scale");m.rotation=b.getUniformLocation(l,"rotation");m.screenPosition=b.getUniformLocation(l,"screenPosition");p=false};this.render=function(a,d,e,s){var a=a.__webglFlares,u=a.length;if(u){var w=new THREE.Vector3,t=s/e,x=e*0.5,F=s*0.5,C=16/s,z=new THREE.Vector2(C*t,C),v=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),I=m,C=o;b.useProgram(l);if(!p){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);p=true}b.uniform1i(I.occlusionMap,0);b.uniform1i(I.map, +1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(C.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(C.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var N,R,Y,B,G;for(N=0;N0&&H.x0&& +H.y0.0010&&G.scale>0.0010){v.x=G.x;v.y=G.y;v.z=G.z;C=G.size*G.scale/s;z.x=C*t;z.y=C;b.uniform3f(I.screenPosition,v.x,v.y,v.z);b.uniform2f(I.scale,z.x,z.y);b.uniform1f(I.rotation,G.rotation);b.uniform1f(I.opacity,G.opacity); b.uniform3f(I.color,G.color.r,G.color.g,G.color.b);c.setBlending(G.blending,G.blendEquation,G.blendSrc,G.blendDst);c.setTexture(G.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}}; THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:true});c._shadowPass=true;d._shadowPass=true};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(k,j){var l,o,m,p,r,n,q,t,u,w=[];p=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);l=0;for(o=k.__lights.length;lh.x)h.x=t.x;if(t.yh.y)h.y=t.y;if(t.zh.z)h.z=t.z}p.left=g.x;p.right=h.x;p.top=h.y;p.bottom=g.y;p.updateProjectionMatrix()}p=m.shadowMap;n=m.shadowMatrix;r=m.shadowCamera;r.position.copy(m.matrixWorld.getPosition());r.lookAt(m.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld); +m.shadowCameraTop,m.shadowCameraBottom,m.shadowCameraNear,m.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}i.add(m.shadowCamera);b.autoUpdateScene&&i.updateMatrixWorld()}if(m.shadowCameraVisible&&!m.cameraHelper){m.cameraHelper=new THREE.CameraHelper(m.shadowCamera);m.shadowCamera.add(m.cameraHelper)}if(m.isVirtual&&t.originalCamera==k){r=k;p=m.shadowCamera;n=m.pointsFrustum;u=m.pointsWorld;g.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(q= +0;q<8;q++){s=u[q];s.copy(n[q]);THREE.ShadowMapPlugin.__projector.unprojectVector(s,r);p.matrixWorldInverse.multiplyVector3(s);if(s.xh.x)h.x=s.x;if(s.yh.y)h.y=s.y;if(s.zh.z)h.z=s.z}p.left=g.x;p.right=h.x;p.top=h.y;p.bottom=g.y;p.updateProjectionMatrix()}p=m.shadowMap;n=m.shadowMatrix;r=m.shadowCamera;r.position.copy(m.matrixWorld.getPosition());r.lookAt(m.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld); if(m.cameraHelper)m.cameraHelper.lines.visible=m.shadowCameraVisible;m.shadowCameraVisible&&m.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(r.projectionMatrix);n.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);f.multiply(r.projectionMatrix, -r.matrixWorldInverse);e.setFromMatrix(f);b.setRenderTarget(p);b.clear();u=k.__webglObjects;m=0;for(p=u.length;mc&&(c+=1);1a?b(c,e-1):j[e]a||o>a||k>a){i=b.vertices.length;v=e.clone();p=e.clone();m>=o&&m>=k?(j=j.clone(), -j.lerpSelf(l,0.5),v.a=f,v.b=i,v.c=h,p.a=i,p.b=g,p.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),v.vertexNormals[1].copy(f),p.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),v.vertexColors[1].copy(f),p.vertexColors[0].copy(f)),e=0):o>=m&&o>=k?(j=l.clone(),j.lerpSelf(n,0.5),v.a=f,v.b=g,v.c=i,p.a=i,p.b=h,p.c=f,3===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2], -0.5),v.vertexNormals[2].copy(f),p.vertexNormals[0].copy(f),p.vertexNormals[1].copy(e.vertexNormals[2]),p.vertexNormals[2].copy(e.vertexNormals[0])),3===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),v.vertexColors[2].copy(f),p.vertexColors[0].copy(f),p.vertexColors[1].copy(e.vertexColors[2]),p.vertexColors[2].copy(e.vertexColors[0])),e=1):(j=j.clone(),j.lerpSelf(n,0.5),v.a=f,v.b=g,v.c=i,p.a=i,p.b=g,p.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(), -f.lerpSelf(e.vertexNormals[2],0.5),v.vertexNormals[2].copy(f),p.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[2],0.5),v.vertexColors[2].copy(f),p.vertexColors[0].copy(f)),e=2);x.push(v,p);b.vertices.push(j);f=0;for(g=b.faceVertexUvs.length;fa||o>a||q>a||r>a){s=b.vertices.length;t= -b.vertices.length+1;v=e.clone();p=e.clone();m>=o&&m>=q&&m>=r||q>=o&&q>=m&&q>=r?(m=j.clone(),m.lerpSelf(l,0.5),l=n.clone(),l.lerpSelf(k,0.5),v.a=f,v.b=s,v.c=t,v.d=i,p.a=s,p.b=g,p.c=h,p.d=t,4===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),g=e.vertexNormals[2].clone(),g.lerpSelf(e.vertexNormals[3],0.5),v.vertexNormals[1].copy(f),v.vertexNormals[2].copy(g),p.vertexNormals[0].copy(f),p.vertexNormals[3].copy(g)),4===e.vertexColors.length&&(f=e.vertexColors[0].clone(), -f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),v.vertexColors[1].copy(f),v.vertexColors[2].copy(g),p.vertexColors[0].copy(f),p.vertexColors[3].copy(g)),e=0):(m=l.clone(),m.lerpSelf(n,0.5),l=k.clone(),l.lerpSelf(j,0.5),v.a=f,v.b=g,v.c=s,v.d=t,p.a=t,p.b=s,p.c=h,p.d=i,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5),v.vertexNormals[2].copy(f),v.vertexNormals[3].copy(g), -p.vertexNormals[0].copy(g),p.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),v.vertexColors[2].copy(f),v.vertexColors[3].copy(g),p.vertexColors[0].copy(g),p.vertexColors[1].copy(f)),e=1);x.push(v,p);b.vertices.push(m,l);f=0;for(g=b.faceVertexUvs.length;fa||o>a||k>a){i=b.vertices.length;v=e.clone();q=e.clone();m>=o&&m>=k?(j=j.clone(), +j.lerpSelf(l,0.5),v.a=f,v.b=i,v.c=h,q.a=i,q.b=g,q.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),v.vertexNormals[1].copy(f),q.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),v.vertexColors[1].copy(f),q.vertexColors[0].copy(f)),e=0):o>=m&&o>=k?(j=l.clone(),j.lerpSelf(n,0.5),v.a=f,v.b=g,v.c=i,q.a=i,q.b=h,q.c=f,3===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2], +0.5),v.vertexNormals[2].copy(f),q.vertexNormals[0].copy(f),q.vertexNormals[1].copy(e.vertexNormals[2]),q.vertexNormals[2].copy(e.vertexNormals[0])),3===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),v.vertexColors[2].copy(f),q.vertexColors[0].copy(f),q.vertexColors[1].copy(e.vertexColors[2]),q.vertexColors[2].copy(e.vertexColors[0])),e=1):(j=j.clone(),j.lerpSelf(n,0.5),v.a=f,v.b=g,v.c=i,q.a=i,q.b=g,q.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(), +f.lerpSelf(e.vertexNormals[2],0.5),v.vertexNormals[2].copy(f),q.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[2],0.5),v.vertexColors[2].copy(f),q.vertexColors[0].copy(f)),e=2);x.push(v,q);b.vertices.push(j);f=0;for(g=b.faceVertexUvs.length;fa||o>a||p>a||r>a){s=b.vertices.length;t= +b.vertices.length+1;v=e.clone();q=e.clone();m>=o&&m>=p&&m>=r||p>=o&&p>=m&&p>=r?(m=j.clone(),m.lerpSelf(l,0.5),l=n.clone(),l.lerpSelf(k,0.5),v.a=f,v.b=s,v.c=t,v.d=i,q.a=s,q.b=g,q.c=h,q.d=t,4===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),g=e.vertexNormals[2].clone(),g.lerpSelf(e.vertexNormals[3],0.5),v.vertexNormals[1].copy(f),v.vertexNormals[2].copy(g),q.vertexNormals[0].copy(f),q.vertexNormals[3].copy(g)),4===e.vertexColors.length&&(f=e.vertexColors[0].clone(), +f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),v.vertexColors[1].copy(f),v.vertexColors[2].copy(g),q.vertexColors[0].copy(f),q.vertexColors[3].copy(g)),e=0):(m=l.clone(),m.lerpSelf(n,0.5),l=k.clone(),l.lerpSelf(j,0.5),v.a=f,v.b=g,v.c=s,v.d=t,q.a=t,q.b=s,q.c=h,q.d=i,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5),v.vertexNormals[2].copy(f),v.vertexNormals[3].copy(g), +q.vertexNormals[0].copy(g),q.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),v.vertexColors[2].copy(f),v.vertexColors[3].copy(g),q.vertexColors[0].copy(g),q.vertexColors[1].copy(f)),e=1);x.push(v,q);b.vertices.push(m,l);f=0;for(g=b.faceVertexUvs.length;fn-1?0:n-1,m=n+1>e-1?e-1:n+1,o=0>l-1?0:l-1,q=l+1>d-1?d- -1:l+1,r=[],s=[0,0,h[4*(n*d+l)]/255*a];r.push([-1,0,h[4*(n*d+o)]/255*a]);r.push([-1,-1,h[4*(k*d+o)]/255*a]);r.push([0,-1,h[4*(k*d+l)]/255*a]);r.push([1,-1,h[4*(k*d+q)]/255*a]);r.push([1,0,h[4*(n*d+q)]/255*a]);r.push([1,1,h[4*(m*d+q)]/255*a]);r.push([0,1,h[4*(m*d+l)]/255*a]);r.push([-1,1,h[4*(m*d+o)]/255*a]);k=[];o=r.length;for(m=0;mn-1?0:n-1,m=n+1>e-1?e-1:n+1,o=0>l-1?0:l-1,p=l+1>d-1?d- +1:l+1,r=[],s=[0,0,h[4*(n*d+l)]/255*a];r.push([-1,0,h[4*(n*d+o)]/255*a]);r.push([-1,-1,h[4*(k*d+o)]/255*a]);r.push([0,-1,h[4*(k*d+l)]/255*a]);r.push([1,-1,h[4*(k*d+p)]/255*a]);r.push([1,0,h[4*(n*d+p)]/255*a]);r.push([1,1,h[4*(m*d+p)]/255*a]);r.push([0,1,h[4*(m*d+l)]/255*a]);r.push([-1,1,h[4*(m*d+o)]/255*a]);k=[];o=r.length;for(m=0;m 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif", THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}}); THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(b){var a=b.familyName.toLowerCase();this.faces[a]=this.faces[a]||{};this.faces[a][b.cssFontWeight]=this.faces[a][b.cssFontWeight]||{};this.faces[a][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[a][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var a=this.getFace(),c=this.size/a.resolution,d= -0,e=(""+b).split(""),f=e.length,g=[],b=0;b0)for(j=0;j2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);l=j+1;e<=l&&(l=0);var k;a:{k=b;var m=i,o=j,q=l,r=e,s=g,t=void 0,v=void 0,p=void 0,x=void 0,z=void 0, -A=void 0,w=void 0,u=void 0,C=void 0,v=k[s[m]].x,p=k[s[m]].y,x=k[s[o]].x,z=k[s[o]].y,A=k[s[q]].x,w=k[s[q]].y;if(1.0E-10>(x-v)*(w-p)-(z-p)*(A-v))k=false;else{for(t=0;t=0&&G>=0&&H>=0){k=false;break a}}k=true}}if(k){f.push([b[g[i]], +(function(b){var a=function(a){for(var b=a.length,e=0,f=b-1,g=0;g0)for(j=0;j2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);l=j+1;e<=l&&(l=0);var k;a:{k=b;var m=i,o=j,p=l,r=e,s=g,t=void 0,v=void 0,q=void 0,x=void 0,z=void 0, +A=void 0,w=void 0,u=void 0,C=void 0,v=k[s[m]].x,q=k[s[m]].y,x=k[s[o]].x,z=k[s[o]].y,A=k[s[p]].x,w=k[s[p]].y;if(1.0E-10>(x-v)*(w-q)-(z-q)*(A-v))k=false;else{for(t=0;t=0&&G>=0&&H>=0){k=false;break a}}k=true}}if(k){f.push([b[g[i]], b[g[j]],b[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;la.max.x)a.max.x=c;if(da.max.y)a.max.y=d;if(ea.max.z)a.max.z=e}if(b===void 0||b.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var b=this.vertexPositionArray; -if(b){for(var a,c=0,d,e,f=0,g=b.length;fc&&(c=a)}this.boundingSphere.radius=c}}};THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var a,c=[];for(a=0;a<=b;a++)c.push(this.getPoint(a/b));return c}; -THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var a,c=[];for(a=0;a<=b;a++)c.push(this.getPointAt(a/b));return c};THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]}; +if(b){for(var a,c=0,d,e,f=0,g=b.length;fc&&(c=a)}this.boundingSphere.radius=c}},computeVertexNormals:function(){var b=this.vertexIndexArray,a=this.vertexPositionArray;if(a&&b){var c,d,e,f;c=a.length;if(this.vertexNormalArray===void 0)this.vertexNormalArray=new Float32Array(c);else{c=0;for(d=this.vertexNormalArray.length;c0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; THREE.Curve.prototype.getTangent=function(b){var a=b-1.0E-4,b=b+1.0E-4;a<0&&(a=0);b>1&&(b=1);a=this.getPoint(a);return this.getPoint(b).clone().subSelf(a).normalize()};THREE.Curve.prototype.getTangentAt=function(b){return this.getTangent(this.getUtoTmapping(b))};THREE.LineCurve=function(b,a){this.v1=b;this.v2=a};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(b){var a=this.v2.clone().subSelf(this.v1);a.multiplyScalar(b).addSelf(this.v1);return a}; @@ -84,16 +86,16 @@ THREE.Path.prototype.bezierCurveTo=function(b,a,c,d,e,f){var g=Array.prototype.s THREE.Path.prototype.splineThru=function(b){var a=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,b);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:a})};THREE.Path.prototype.ellipse=function(b,a,c,d,e,f,g){var h=this.actions[this.actions.length-1];this.absellipse(h.x+b,h.y+a,c,d,e,f,g)}; THREE.Path.prototype.arc=function(b,a,c,d,e,f){var g=this.actions[this.actions.length-1];this.absarc(g.x+b,g.y+a,c,d,e,f)};THREE.Path.prototype.absellipse=function(b,a,c,d,e,f,g){var h=Array.prototype.slice.call(arguments),i=new THREE.EllipseCurve(b,a,c,d,e,f,g);this.curves.push(i);i=i.getPoint(g?1:0);h.push(i.x);h.push(i.y);this.actions.push({action:THREE.PathActions.ELLIPSE,args:h})};THREE.Path.prototype.absarc=function(b,a,c,d,e,f){this.absellipse(b,a,c,c,d,e,f)}; THREE.Path.prototype.getSpacedPoints=function(b){b||(b=40);for(var a=[],c=0;c0){g=c[c.length-1]; -m=g.x;o=g.y}else{g=this.actions[d-1].args;m=g[g.length-2];o=g[g.length-1]}for(f=1;f<=b;f++){q=f/b;g=THREE.Shape.Utils.b2(q,m,n,h);q=THREE.Shape.Utils.b2(q,o,k,i);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];n=f[0];k=f[1];j=f[2];l=f[3];if(c.length>0){g=c[c.length-1];m=g.x;o=g.y}else{g=this.actions[d-1].args;m=g[g.length-2];o=g[g.length-1]}for(f=1;f<=b;f++){q=f/b;g=THREE.Shape.Utils.b3(q,m,n,j,h);q=THREE.Shape.Utils.b3(q,o,k,l,i);c.push(new THREE.Vector2(g, -q))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;q=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=b*f[0].length;q=q.concat(f[0]);q=new THREE.SplineCurve(q);for(f=1;f<=g;f++)c.push(q.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];k=f[2];j=f[3];g=f[4];n=!!f[5];m=g-j;o=b*2;for(f=1;f<=o;f++){q=f/o;n||(q=1-q);q=j+q*m;g=h+k*Math.cos(q);q=i+k*Math.sin(q);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];k=f[2];l=f[3];j=f[4];g=f[5]; -n=!!f[6];m=g-j;o=b*2;for(f=1;f<=o;f++){q=f/o;n||(q=1-q);q=j+q*m;g=h+k*Math.cos(q);q=i+l*Math.sin(q);c.push(new THREE.Vector2(g,q))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1.0E-10&&Math.abs(d.y-c[0].y)<1.0E-10&&c.splice(c.length-1,1);a&&c.push(c[0]);return c}; +THREE.Path.prototype.getPoints=function(b,a){if(this.useSpacedPoints){console.log("tata");return this.getSpacedPoints(b,a)}var b=b||12,c=[],d,e,f,g,h,i,j,l,n,k,m,o,p;d=0;for(e=this.actions.length;d0){g=c[c.length-1]; +m=g.x;o=g.y}else{g=this.actions[d-1].args;m=g[g.length-2];o=g[g.length-1]}for(f=1;f<=b;f++){p=f/b;g=THREE.Shape.Utils.b2(p,m,n,h);p=THREE.Shape.Utils.b2(p,o,k,i);c.push(new THREE.Vector2(g,p))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];n=f[0];k=f[1];j=f[2];l=f[3];if(c.length>0){g=c[c.length-1];m=g.x;o=g.y}else{g=this.actions[d-1].args;m=g[g.length-2];o=g[g.length-1]}for(f=1;f<=b;f++){p=f/b;g=THREE.Shape.Utils.b3(p,m,n,j,h);p=THREE.Shape.Utils.b3(p,o,k,l,i);c.push(new THREE.Vector2(g, +p))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;p=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=b*f[0].length;p=p.concat(f[0]);p=new THREE.SplineCurve(p);for(f=1;f<=g;f++)c.push(p.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];k=f[2];j=f[3];g=f[4];n=!!f[5];m=g-j;o=b*2;for(f=1;f<=o;f++){p=f/o;n||(p=1-p);p=j+p*m;g=h+k*Math.cos(p);p=i+k*Math.sin(p);c.push(new THREE.Vector2(g,p))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];k=f[2];l=f[3];j=f[4];g=f[5]; +n=!!f[6];m=g-j;o=b*2;for(f=1;f<=o;f++){p=f/o;n||(p=1-p);p=j+p*m;g=h+k*Math.cos(p);p=i+l*Math.sin(p);c.push(new THREE.Vector2(g,p))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1.0E-10&&Math.abs(d.y-c[0].y)<1.0E-10&&c.splice(c.length-1,1);a&&c.push(c[0]);return c}; THREE.Path.prototype.toShapes=function(){var b,a,c,d,e=[],f=new THREE.Path;b=0;for(a=this.actions.length;b=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var q=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(q);var r=[j[g],j[f],c[h]];k=THREE.FontUtils.Triangulate.area(r);m=h;l=g;h=h+1;g=g+ --1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;q=[j[g],c[h],c[e]];q=THREE.FontUtils.Triangulate.area(q);r=[j[g],j[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);if(n+k>q+r){h=m;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1}n=c.slice(0,h);k=c.slice(h);m=j.slice(g);l=j.slice(0,g);f=[j[g],j[f],c[h]];o.push([j[g],c[h],c[e]]);o.push(f);c=n.concat(m).concat(l).concat(k)}return{shape:c, +THREE.Shape.Utils={removeHoles:function(b,a){var c=b.concat(),d=c.concat(),e,f,g,h,i,j,l,n,k,m,o=[];for(i=0;i=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var p=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(p);var r=[j[g],j[f],c[h]];k=THREE.FontUtils.Triangulate.area(r);m=h;l=g;h=h+1;g=g+ +-1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;p=[j[g],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(p);r=[j[g],j[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);if(n+k>p+r){h=m;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1}n=c.slice(0,h);k=c.slice(h);m=j.slice(g);l=j.slice(0,g);f=[j[g],j[f],c[h]];o.push([j[g],c[h],c[e]]);o.push(f);c=n.concat(m).concat(l).concat(k)}return{shape:c, isolatedPts:o,allpoints:d}},triangulateShape:function(b,a){var c=THREE.Shape.Utils.removeHoles(b,a),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,i,j={};f=0;for(g=d.length;f1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m);d=d<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType=== THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",m,g.index-1).pos;this.points[1]=e;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);c.x=e[0];c.y=e[1];c.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x, this.target.z);b.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,b.quaternion,d);else if(c==="scl"){c=b.scale;c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}}}}if(this.JITCompile&&l[0][j]===void 0){this.hierarchy[0].updateMatrixWorld(true);for(m=0;m0?i.zoomIn():i.zoomOut();m.copy(o)}}function h(){if(i.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false); -p=e}}THREE.EventTarget.call(this);this.object=b;this.domElement=a!==void 0?a:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var i=this,j=1800,l=new THREE.Vector2,n=new THREE.Vector2,k=new THREE.Vector2,m=new THREE.Vector2,o=new THREE.Vector2,q=new THREE.Vector2,r=0,s=0,t=1,v=new THREE.Vector3;e=-1;c=0;d=1;var p=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); +THREE.OrbitControls=function(b,a){var c,d,e;function f(){return 2*Math.PI/60/60*i.autoRotateSpeed}function g(a){a.preventDefault();if(q===c){n.set(a.clientX,a.clientY);k.sub(n,l);i.rotateLeft(2*Math.PI*k.x/j*i.userRotateSpeed);i.rotateUp(2*Math.PI*k.y/j*i.userRotateSpeed);l.copy(n)}else if(q===d){o.set(a.clientX,a.clientY);p.sub(o,m);p.y>0?i.zoomIn():i.zoomOut();m.copy(o)}}function h(){if(i.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false); +q=e}}THREE.EventTarget.call(this);this.object=b;this.domElement=a!==void 0?a:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var i=this,j=1800,l=new THREE.Vector2,n=new THREE.Vector2,k=new THREE.Vector2,m=new THREE.Vector2,o=new THREE.Vector2,p=new THREE.Vector2,r=0,s=0,t=1,v=new THREE.Vector3;e=-1;c=0;d=1;var q=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); s=s-a};this.rotateRight=function(a){a===void 0&&(a=f());s=s+a};this.rotateUp=function(a){a===void 0&&(a=f());r=r-a};this.rotateDown=function(a){a===void 0&&(a=f());r=r+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));t=t/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));t=t*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),c=Math.atan2(b.x,b.z),d=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&this.rotateLeft(f()); var c=c+s,d=d+r,d=Math.max(1.0E-6,Math.min(Math.PI-1.0E-6,d)),e=b.length();b.x=e*Math.sin(d)*Math.sin(c);b.y=e*Math.cos(d);b.z=e*Math.sin(d)*Math.cos(c);b.multiplyScalar(t);a.copy(this.center).addSelf(b);this.object.lookAt(this.center);r=s=0;t=1;if(v.distanceTo(this.object.position)>0){this.dispatchEvent(x);v.copy(this.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousedown",function(a){if(i.userRotate){a.preventDefault(); -if(a.button===0||a.button===2){p=c;l.set(a.clientX,a.clientY)}else if(a.button===1){p=d;m.set(a.clientX,a.clientY)}document.addEventListener("mousemove",g,false);document.addEventListener("mouseup",h,false)}},false);this.domElement.addEventListener("mousewheel",function(a){i.userZoom&&(a.wheelDelta>0?i.zoomOut():i.zoomIn())},false)}; -THREE.CubeGeometry=function(b,a,c,d,e,f,g,h){function i(a,b,c,g,h,i,k,m){var l,n=d||1,o=e||1,q=h/2,r=i/2,s=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")l="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){l="y";o=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){l="x";n=f||1}var t=n+1,v=o+1,I=h/n,M=i/o,J=new THREE.Vector3;J[l]=k>0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vector3(0, -g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h0?i.zoomOut():i.zoomIn())},false)}; +THREE.CubeGeometry=function(b,a,c,d,e,f,g,h){function i(a,b,c,g,h,i,k,m){var l,n=d||1,o=e||1,p=h/2,r=i/2,s=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")l="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){l="y";o=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){l="x";n=f||1}var t=n+1,v=o+1,I=h/n,M=i/o,J=new THREE.Vector3;J[l]=k>0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vector3(0, +g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;ha&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);a=new THREE.Vector2(a,c)}else a=d.multiplyScalar(g).addSelf(h).subSelf(a).clone();return a}function e(c,d){var e,f;for(y=c.length;--y>=0;){e=y;f=y-1;f<0&& -(f=c.length-1);for(var g=0,h=k+l*2,g=0;g=0;D--){F=D/l;N=i*(1-F);K=j*Math.sin(F*Math.PI/2);y=0;for(F=H.length;y=0;D--){F=D/l;N=i*(1-F);K=j*Math.sin(F*Math.PI/2);y=0;for(F=H.length;y=j){for(i=0;i<3;i++){j=[h[i],h[(i+1)%3]];s=true;for(t=0;t=j){for(i=0;i<3;i++){j=[h[i],h[(i+1)%3]];s=true;for(t=0;t0;)this.smooth(b)}; -THREE.SubdivisionModifier.prototype.smooth=function(b){function a(){k.debug&&console.log.apply(console,arguments)}function c(){console&&console.log.apply(console,arguments)}function d(b,c,d,e,g,h,i){var j=new THREE.Face4(b,c,d,e,null,g.color,g.materialIndex);if(k.useOldVertexColors){j.vertexColors=[];for(var m,o,q,p=0;p<4;p++){q=h[p];m=new THREE.Color;m.setRGB(0,0,0);for(var r=0;r=v&&b=v&&b0&&C.x0&& +"color");k.scale=a.getUniformLocation(l,"scale");k.rotation=a.getUniformLocation(l,"rotation");k.screenPosition=a.getUniformLocation(l,"screenPosition");m=false};this.render=function(b,d,e,s){var b=b.__webglFlares,t=b.length;if(t){var v=new THREE.Vector3,q=s/e,x=e*0.5,z=s*0.5,A=16/s,w=new THREE.Vector2(A*q,A),u=new THREE.Vector3(1,1,0),C=new THREE.Vector2(1,1),B=k,A=n;a.useProgram(l);if(!m){a.enableVertexAttribArray(n.vertex);a.enableVertexAttribArray(n.uv);m=true}a.uniform1i(B.occlusionMap,0);a.uniform1i(B.map, +1);a.bindBuffer(a.ARRAY_BUFFER,f);a.vertexAttribPointer(A.vertex,2,a.FLOAT,false,16,0);a.vertexAttribPointer(A.uv,2,a.FLOAT,false,16,8);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,g);a.disable(a.CULL_FACE);a.depthMask(false);var E,G,L,H,D;for(E=0;E0&&C.x0&& C.y0.0010&&D.scale>0.0010){u.x=D.x;u.y=D.y;u.z=D.z;A=D.size*D.scale/s;w.x=A*p;w.y=A;a.uniform3f(B.screenPosition,u.x,u.y,u.z);a.uniform2f(B.scale,w.x,w.y);a.uniform1f(B.rotation,D.rotation);a.uniform1f(B.opacity,D.opacity); +a.bindTexture(a.TEXTURE_2D,h);a.drawElements(a.TRIANGLES,6,a.UNSIGNED_SHORT,0);H.positionScreen.copy(u);H.customUpdateCallback?H.customUpdateCallback(H):H.updateLensFlares();a.uniform1i(B.renderType,2);a.enable(a.BLEND);G=0;for(L=H.lensFlares.length;G0.0010&&D.scale>0.0010){u.x=D.x;u.y=D.y;u.z=D.z;A=D.size*D.scale/s;w.x=A*q;w.y=A;a.uniform3f(B.screenPosition,u.x,u.y,u.z);a.uniform2f(B.scale,w.x,w.y);a.uniform1f(B.rotation,D.rotation);a.uniform1f(B.opacity,D.opacity); a.uniform3f(B.color,D.color.r,D.color.g,D.color.b);c.setBlending(D.blending,D.blendEquation,D.blendSrc,D.blendDst);c.setTexture(D.texture,1);a.drawElements(a.TRIANGLES,6,a.UNSIGNED_SHORT,0)}}}}a.enable(a.CULL_FACE);a.enable(a.DEPTH_TEST);a.depthMask(true)}}}; THREE.ShadowMapPlugin=function(){var b,a,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){b=e.context;a=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:true});c._shadowPass=true;d._shadowPass=true};this.render= -function(b,c){a.shadowMapEnabled&&a.shadowMapAutoUpdate&&this.update(b,c)};this.update=function(i,j){var l,n,k,m,o,q,r,s,t,v=[];m=0;b.clearColor(1,1,1,1);b.disable(b.BLEND);b.enable(b.CULL_FACE);a.shadowMapCullFrontFaces?b.cullFace(b.FRONT):b.cullFace(b.BACK);a.setDepthTest(true);l=0;for(n=i.__lights.length;lh.x)h.x=s.x;if(s.yh.y)h.y=s.y;if(s.zh.z)h.z=s.z}m.left=g.x;m.right=h.x;m.top=h.y;m.bottom=g.y;m.updateProjectionMatrix()}m=k.shadowMap;q=k.shadowMatrix;o=k.shadowCamera;o.position.copy(k.matrixWorld.getPosition());o.lookAt(k.target.matrixWorld.getPosition());o.updateMatrixWorld();o.matrixWorldInverse.getInverse(o.matrixWorld); -if(k.cameraHelper)k.cameraHelper.lines.visible=k.shadowCameraVisible;k.shadowCameraVisible&&k.cameraHelper.update();q.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);q.multiplySelf(o.projectionMatrix);q.multiplySelf(o.matrixWorldInverse);if(!o._viewMatrixArray)o._viewMatrixArray=new Float32Array(16);if(!o._projectionMatrixArray)o._projectionMatrixArray=new Float32Array(16);o.matrixWorldInverse.flattenToArray(o._viewMatrixArray);o.projectionMatrix.flattenToArray(o._projectionMatrixArray);f.multiply(o.projectionMatrix, -o.matrixWorldInverse);e.setFromMatrix(f);a.setRenderTarget(m);a.clear();t=i.__webglObjects;k=0;for(m=t.length;kh.x)h.x=s.x;if(s.yh.y)h.y=s.y;if(s.zh.z)h.z=s.z}m.left=g.x;m.right=h.x;m.top=h.y;m.bottom=g.y;m.updateProjectionMatrix()}m=k.shadowMap;p=k.shadowMatrix;o=k.shadowCamera;o.position.copy(k.matrixWorld.getPosition());o.lookAt(k.target.matrixWorld.getPosition());o.updateMatrixWorld();o.matrixWorldInverse.getInverse(o.matrixWorld); +if(k.cameraHelper)k.cameraHelper.lines.visible=k.shadowCameraVisible;k.shadowCameraVisible&&k.cameraHelper.update();p.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);p.multiplySelf(o.projectionMatrix);p.multiplySelf(o.matrixWorldInverse);if(!o._viewMatrixArray)o._viewMatrixArray=new Float32Array(16);if(!o._projectionMatrixArray)o._projectionMatrixArray=new Float32Array(16);o.matrixWorldInverse.flattenToArray(o._viewMatrixArray);o.projectionMatrix.flattenToArray(o._projectionMatrixArray);f.multiply(o.projectionMatrix, +o.matrixWorldInverse);e.setFromMatrix(f);a.setRenderTarget(m);a.clear();t=i.__webglObjects;k=0;for(m=t.length;k>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r=this.r+(a.r-this.r)*b;this.g=this.g+(a.g-this.g)*b;this.b=this.b+(a.b-this.b)*b;return this},getHex:function(){return Math.floor(this.r*255)<<16^Math.floor(this.g*255)<<8^Math.floor(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;return this},divideScalar:function(a){if(a){this.x= @@ -16,177 +16,177 @@ THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a; a;this.z=this.z+a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x=this.x*a.x;this.y=this.y*a.y;this.z=this.z*a.z;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;return this},divideSelf:function(a){this.x=this.x/a.x;this.y= this.y/a.y;this.z=this.z/a.z;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a}else this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())}, setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this, -a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],h=d[8],l=d[1],m=d[5],k=d[9],i=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-k,d);this.z=Math.atan2(-f,e)}else{this.x=Math.atan2(l,m);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(k));if(Math.abs(k)< -0.99999){this.y=Math.atan2(h,d);this.z=Math.atan2(l,m)}else{this.y=Math.atan2(-i,e);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-i,d);this.z=Math.atan2(-f,m)}else{this.y=0;this.z=Math.atan2(h,e)}}else if(b==="ZYX"){this.y=Math.asin(-c(i));if(Math.abs(i)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(l,e)}else{this.x=0;this.z=Math.atan2(-f,m)}}else if(b==="YZX"){this.z=Math.asin(c(l));if(Math.abs(l)<0.99999){this.x=Math.atan2(-k,m);this.y=Math.atan2(-i, -e)}else{this.x=0;this.y=Math.atan2(i,d)}}else if(b==="XZY"){this.z=Math.asin(-c(f));if(Math.abs(f)<0.99999){this.x=Math.atan2(o,m);this.y=Math.atan2(h,e)}else{this.x=Math.atan2(-h,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,h=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-d-e+f);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h+d-e-f)}else if(b=== -"YXZ"){this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h-d-e+f);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-d+e-f)}else if(b==="ZXY"){this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),h-d-e+f);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-d+e-f)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-d-e+f);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h+d-e-f)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z* -a.y),h-d+e-f);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+d-e-f);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)))}else if(b==="XZY"){this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),h-d+e-f);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+d-e-f);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)))}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x= +a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],h=d[8],k=d[1],m=d[5],l=d[9],i=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-l,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(k,m);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(l));if(Math.abs(l)< +0.99999){this.y=Math.atan2(h,d);this.z=Math.atan2(k,m)}else{this.y=Math.atan2(-i,f);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-i,d);this.z=Math.atan2(-e,m)}else{this.y=0;this.z=Math.atan2(h,f)}}else if(b==="ZYX"){this.y=Math.asin(-c(i));if(Math.abs(i)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(k,f)}else{this.x=0;this.z=Math.atan2(-e,m)}}else if(b==="YZX"){this.z=Math.asin(c(k));if(Math.abs(k)<0.99999){this.x=Math.atan2(-l,m);this.y=Math.atan2(-i, +f)}else{this.x=0;this.y=Math.atan2(i,d)}}else if(b==="XZY"){this.z=Math.asin(-c(e));if(Math.abs(e)<0.99999){this.x=Math.atan2(o,m);this.y=Math.atan2(h,f)}else{this.x=Math.atan2(-h,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,f=a.y*a.y,e=a.z*a.z,h=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-d-f+e);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h+d-f-e)}else if(b=== +"YXZ"){this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h-d-f+e);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-d+f-e)}else if(b==="ZXY"){this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),h-d-f+e);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-d+f-e)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-d-f+e);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h+d-f-e)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z* +a.y),h-d+f-e);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+d-f-e);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)))}else if(b==="XZY"){this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),h-d+f-e);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+d-f-e);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)))}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x= b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},isZero:function(){return this.lengthSq()<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;this.w=this.w+a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x= this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;this.w=this.w-a.w;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a;this.w=this.w/a}else{this.z=this.y=this.x=0;this.w=1}return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;this.w=this.w+(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1.0E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y= -a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],h=a[1],l=a[5],m=a[9];c=a[2];b=a[6];var k=a[10];if(Math.abs(d-h)<0.01&&Math.abs(f-c)<0.01&&Math.abs(m-b)<0.01){if(Math.abs(d+h)<0.1&&Math.abs(f+c)<0.1&&Math.abs(m+b)<0.1&&Math.abs(e+l+k-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;e=(e+1)/2;l=(l+1)/2;k=(k+1)/2;d=(d+h)/4;f=(f+c)/4;m=(m+b)/4;if(e>l&&e>k)if(e<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(e);c=d/b;d=f/b}else if(l> -k)if(l<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(l);b=d/c;d=m/c}else if(k<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(k);b=f/d;c=m/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-m)*(b-m)+(f-c)*(f-c)+(h-d)*(h-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-m)/a;this.y=(f-c)/a;this.z=(h-d)/a;this.w=Math.acos((e+l+k-1)/2);return this}}; +a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],h=a[1],k=a[5],m=a[9];c=a[2];b=a[6];var l=a[10];if(Math.abs(d-h)<0.01&&Math.abs(e-c)<0.01&&Math.abs(m-b)<0.01){if(Math.abs(d+h)<0.1&&Math.abs(e+c)<0.1&&Math.abs(m+b)<0.1&&Math.abs(f+k+l-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;k=(k+1)/2;l=(l+1)/2;d=(d+h)/4;e=(e+c)/4;m=(m+b)/4;if(f>k&&f>l)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(k> +l)if(k<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(k);b=d/c;d=m/c}else if(l<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(l);b=e/d;c=m/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-m)*(b-m)+(e-c)*(e-c)+(h-d)*(h-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-m)/a;this.y=(e-c)/a;this.z=(h-d)/a;this.w=Math.acos((f+k+l-1)/2);return this}}; THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]}; -THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],e=c[2],f=c[3],h=c[4],l=c[5],m=c[6],k=c[7],i=c[8],o=c[9],j=c[10],w=c[11],r=c[12],n=c[13],q=c[14],c=c[15];b[0].set(f-a,k-h,w-i,c-r);b[1].set(f+a,k+h,w+i,c+r);b[2].set(f+d,k+l,w+o,c+n);b[3].set(f-d,k-l,w-o,c-n);b[4].set(f-e,k-m,w-j,c-q);b[5].set(f+e,k+m,w+j,c+q);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; -THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),e=0;e<6;e++){b=c[e].x*d[12]+c[e].y*d[13]+c[e].z*d[14]+c[e].w;if(b<=a)return false}return true};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3,j=new THREE.Vector3,w=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,p,u,B,D=function(a,b,c){r.sub(c,a);p=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(p)); -return B=c.distanceTo(u)},s,J,A,M,E,Q,G,R,T=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);s=r.dot(r);J=r.dot(n);A=r.dot(q);M=n.dot(n);E=n.dot(q);Q=1/(s*M-J*J);G=(M*A-J*E)*Q;R=(s*E-J*A)*Q;return G>=0&&R>=0&&G+R<1},S=1.0E-4;this.setPrecision=function(a){S=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var g=0,n=a.children.length;ga.scale.x)return[];c={distance:B,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){g=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());g=a.geometry.boundingSphere.radius*Math.max(g.x,Math.max(g.y,g.z));B=D(this.origin,this.direction,a.matrixWorld.getPosition());if(B>g)return d;var r,q,p=a.geometry,u=p.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);g=0;for(n=p.faces.length;g< -n;g++){c=p.faces[g];m.copy(this.origin);k.copy(this.direction);s=a.matrixWorld;i=s.multiplyVector3(i.copy(c.centroid)).subSelf(m);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=k.dot(o);if(!(Math.abs(r)0:r<0))){j.add(m,k.multiplyScalar(q));B=m.distanceTo(j);if(!(Bthis.far))if(c instanceof THREE.Face3){e=s.multiplyVector3(e.copy(u[c.a]));f=s.multiplyVector3(f.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c])); -if(T(j,e,f,h)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){e=s.multiplyVector3(e.copy(u[c.a]));f=s.multiplyVector3(f.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c]));l=s.multiplyVector3(l.copy(u[c.d]));if(T(j,e,f,l)||T(j,f,h,l)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(w);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,g=a.length;d=0&&R>=0&&G+R<1},S=1.0E-4;this.setPrecision=function(a){S=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var g=0,n=a.children.length;ga.scale.x)return[];c={distance:B,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){g=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());g=a.geometry.boundingSphere.radius*Math.max(g.x,Math.max(g.y,g.z));B=D(this.origin,this.direction,a.matrixWorld.getPosition());if(B>g)return d;var p,r,q=a.geometry,u=q.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);g=0;for(n=q.faces.length;g< +n;g++){c=q.faces[g];m.copy(this.origin);l.copy(this.direction);s=a.matrixWorld;i=s.multiplyVector3(i.copy(c.centroid)).subSelf(m);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));p=l.dot(o);if(!(Math.abs(p)0:p<0))){j.add(m,l.multiplyScalar(r));B=m.distanceTo(j);if(!(Bthis.far))if(c instanceof THREE.Face3){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c])); +if(T(j,f,e,h)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c]));k=s.multiplyVector3(k.copy(u[c.d]));if(T(j,f,e,k)||T(j,e,h,k)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(v);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,g=a.length;df?d:f;e=e>h?e:h}a()};this.add3Points=function(f,h,i,o,j,w){if(l===true){l=false;b=fi?f>j?f:j:i>j?i:j;e=h>o?h>w?h:w:o>w?o:w}else{b=fi?f>j?f>d?f:d:j>d?j:d:i>j?i>d?i:d:j>d?j:d;e=h>o?h>w?h>e?h:e:w>e?w:e:o>w?o>e?o:e:w>e?w:e}a()};this.addRectangle=function(f){if(l===true){l=false;b=f.getLeft();c=f.getTop();d=f.getRight();e=f.getBottom()}else{b=bf.getRight()?d:f.getRight();e=e>f.getBottom()?e:f.getBottom()}a()};this.inflate=function(f){b=b-f;c=c-f;d=d+f;e=e+f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?false:true};this.empty=function(){l=true;e=d=c=b=0;a()};this.isEmpty=function(){return l}}; -THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a0?1:0}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],k=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*l;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,i=this.elements;i[0]=b*a;i[1]=b*c;i[2]=b*d;i[3]=b*e;i[4]=b*f;i[5]=b*h;i[6]=b*l;i[7]=b*m;i[8]=b*k;return this}, -transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,h,l,m,k,i,o,j,w,r,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,h||0,l||0,m||0,k||0,i!==void 0?i:1,o||0,j||0,w||0,r||0,n!==void 0?n:1)}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,h,l,m,k,i,o,j,w,r,n){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=h;q[13]=l;q[2]=m;q[6]=k;q[10]=i;q[14]=o;q[3]=j;q[7]=w;q[11]=r;q[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, -e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;e.cross(c,h).normalize();if(e.length()===0){h.x=h.x+1.0E-4;e.cross(c,h).normalize()}f.cross(h,e);d[0]=e.x;d[4]=f.x;d[8]=h.x;d[1]=e.y;d[5]=f.y;d[9]=h.y;d[2]=e.z;d[6]=f.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],h=c[4],l=c[8],m=c[12],k=c[1],i=c[5],o=c[9],j=c[13],w=c[2],r=c[6],n=c[10],q=c[14],p=c[3],u=c[7],B=c[11],c=c[15],D=d[0],s=d[4], -J=d[8],A=d[12],M=d[1],E=d[5],Q=d[9],G=d[13],R=d[2],T=d[6],S=d[10],y=d[14],L=d[3],Z=d[7],F=d[11],d=d[15];e[0]=f*D+h*M+l*R+m*L;e[4]=f*s+h*E+l*T+m*Z;e[8]=f*J+h*Q+l*S+m*F;e[12]=f*A+h*G+l*y+m*d;e[1]=k*D+i*M+o*R+j*L;e[5]=k*s+i*E+o*T+j*Z;e[9]=k*J+i*Q+o*S+j*F;e[13]=k*A+i*G+o*y+j*d;e[2]=w*D+r*M+n*R+q*L;e[6]=w*s+r*E+n*T+q*Z;e[10]=w*J+r*Q+n*S+q*F;e[14]=w*A+r*G+n*y+q*d;e[3]=p*D+u*M+B*R+c*L;e[7]=p*s+u*E+B*T+c*Z;e[11]=p*J+u*Q+B*S+c*F;e[15]=p*A+u*G+B*y+c*d;return this},multiplySelf:function(a){return this.multiply(this, +THREE.Rectangle=function(){function a(){e=d-b;h=f-c}var b=0,c=0,d=0,f=0,e=0,h=0,k=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,h,i,o){k=false;b=e;c=h;d=i;f=o;a()};this.addPoint=function(e,h){if(k===true){k=false;b=e;c=h;d=e;f=h}else{b=be?d:e;f=f>h?f:h}a()};this.add3Points=function(e,h,i,o,j,v){if(k===true){k=false;b=ei?e>j?e:j:i>j?i:j;f=h>o?h>v?h:v:o>v?o:v}else{b=ei?e>j?e>d?e:d:j>d?j:d:i>j?i>d?i:d:j>d?j:d;f=h>o?h>v?h>f?h:f:v>f?v:f:o>v?o>f?o:f:v>f?v:f}a()};this.addRectangle=function(e){if(k===true){k=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=be.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=da.getRight()||fa.getBottom()?false:true};this.empty=function(){k=true;f=d=c=b=0;a()};this.isEmpty=function(){return k}}; +THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a0?1:0}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],l=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*k;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,i=this.elements;i[0]=b*a;i[1]=b*c;i[2]=b*d;i[3]=b*f;i[4]=b*e;i[5]=b*h;i[6]=b*k;i[7]=b*m;i[8]=b*l;return this}, +transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,h,k,m,l,i,o,j,v,p,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,h||0,k||0,m||0,l||0,i!==void 0?i:1,o||0,j||0,v||0,p||0,n!==void 0?n:1)}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,h,k,m,l,i,o,j,v,p,n){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=f;r[5]=e;r[9]=h;r[13]=k;r[2]=m;r[6]=l;r[10]=i;r[14]=o;r[3]=j;r[7]=v;r[11]=p;r[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, +f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x=h.x+1.0E-4;f.cross(c,h).normalize()}e.cross(h,f);d[0]=f.x;d[4]=e.x;d[8]=h.x;d[1]=f.y;d[5]=e.y;d[9]=h.y;d[2]=f.z;d[6]=e.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],h=c[4],k=c[8],m=c[12],l=c[1],i=c[5],o=c[9],j=c[13],v=c[2],p=c[6],n=c[10],r=c[14],q=c[3],u=c[7],B=c[11],c=c[15],D=d[0],s=d[4], +J=d[8],A=d[12],M=d[1],E=d[5],Q=d[9],G=d[13],R=d[2],T=d[6],S=d[10],y=d[14],L=d[3],Z=d[7],F=d[11],d=d[15];f[0]=e*D+h*M+k*R+m*L;f[4]=e*s+h*E+k*T+m*Z;f[8]=e*J+h*Q+k*S+m*F;f[12]=e*A+h*G+k*y+m*d;f[1]=l*D+i*M+o*R+j*L;f[5]=l*s+i*E+o*T+j*Z;f[9]=l*J+i*Q+o*S+j*F;f[13]=l*A+i*G+o*y+j*d;f[2]=v*D+p*M+n*R+r*L;f[6]=v*s+p*E+n*T+r*Z;f[10]=v*J+p*Q+n*S+r*F;f[14]=v*A+p*G+n*y+r*d;f[3]=q*D+u*M+B*R+c*L;f[7]=q*s+u*E+B*T+c*Z;f[11]=q*J+u*Q+B*S+c*F;f[15]=q*A+u*G+B*y+c*d;return this},multiplySelf:function(a){return this.multiply(this, a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]= -b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=1/(b[3]*c+b[7]*d+b[11]*e+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*e+b[12])*f;a.y=(b[1]*c+b[5]*d+b[9]*e+b[13])*f;a.z=(b[2]*c+b[6]*d+b[10]*e+b[14])*f;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w;a.x=b[0]*c+b[4]*d+b[8]*e+b[12]*f;a.y=b[1]*c+b[5]*d+b[9]*e+b[13]*f;a.z=b[2]*c+b[6]*d+b[10]*e+b[14]*f;a.w=b[3]*c+b[7]*d+b[11]*e+b[15]*f;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1, -c=0,d=a.length;c=0&&e>=0&&g>=0&&h>=0)return true;if(f<0&&e<0||g<0&&h<0)return false;f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e)));g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d, -g/(g-h)));if(dh&&l.positionScreen.z=0&&f>=0&&g>=0&&h>=0)return true;if(e<0&&f<0||g<0&&h<0)return false;e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f)));g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d, +g/(g-h)));if(dh&&k.positionScreen.z0)){na=k[m-2];G.copy(H.positionScreen);R.copy(na.positionScreen);if(d(G,R)===true){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Ba=void 0;if(q===p.length){Ba=new THREE.RenderableLine;p.push(Ba)}else Ba=p[q];q++;n=Ba;n.v1.positionScreen.copy(G);n.v2.positionScreen.copy(R);n.z=Math.max(G.z,R.z);n.material=oa.material;s.elements.push(n)}}}}}a=0;for(g= -s.sprites.length;a0&&A.z<1){h=void 0;if(B===D.length){h=new THREE.RenderableParticle;D.push(h)}else h=D[B];B++;u=h;u.x=A.x/A.w;u.y=A.y/A.w;u.z=A.z;u.rotation=oa.rotation.z;u.scale.x=oa.scale.x*Math.abs(u.x-(A.x+f.projectionMatrix.elements[0])/(A.w+f.projectionMatrix.elements[12]));u.scale.y=oa.scale.y*Math.abs(u.y-(A.y+f.projectionMatrix.elements[5])/ -(A.w+f.projectionMatrix.elements[13]));u.material=oa.material;s.elements.push(u)}}}e&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),e=Math.cos(a.z/2),f=Math.sin(a.x/2),h=Math.sin(a.y/2),l=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=f*d*e+c*h*l;this.y=c*h*e-f*d*l;this.z=c*d*l+f*h*e;this.w=c*d*e-f*h*l}else if(b==="YXZ"){this.x=f*d*e+c*h*l;this.y=c*h*e-f*d*l;this.z= -c*d*l-f*h*e;this.w=c*d*e+f*h*l}else if(b==="ZXY"){this.x=f*d*e-c*h*l;this.y=c*h*e+f*d*l;this.z=c*d*l+f*h*e;this.w=c*d*e-f*h*l}else if(b==="ZYX"){this.x=f*d*e-c*h*l;this.y=c*h*e+f*d*l;this.z=c*d*l-f*h*e;this.w=c*d*e+f*h*l}else if(b==="YZX"){this.x=f*d*e+c*h*l;this.y=c*h*e+f*d*l;this.z=c*d*l-f*h*e;this.w=c*d*e-f*h*l}else if(b==="XZY"){this.x=f*d*e-c*h*l;this.y=c*h*e-f*d*l;this.z=c*d*l+f*h*e;this.w=c*d*e+f*h*l}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y* -d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],h=b[9],l=b[2],m=b[6],b=b[10],k=c+f+b;if(k>0){c=0.5/Math.sqrt(k+1);this.w=0.25/c;this.x=(m-h)*c;this.y=(d-l)*c;this.z=(e-a)*c}else if(c>f&&c>b){c=2*Math.sqrt(1+c-f-b);this.w=(m-h)/c;this.x=0.25*c;this.y=(a+e)/c;this.z=(d+l)/c}else if(f>b){c=2*Math.sqrt(1+f-c-b);this.w=(d-l)/c;this.x=(a+e)/c;this.y=0.25*c;this.z=(h+m)/c}else{c=2*Math.sqrt(1+b-c-f);this.w=(e-a)/c;this.x= -(d+l)/c;this.y=(h+m)/c;this.z=0.25*c}return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= -this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,h=a.y,l=a.z,a=a.w;this.x=b*a+e*f+c*l-d*h;this.y=c*a+e*h+d*f-b*l;this.z=d*a+e*l+b*h-c*f;this.w=e*a-b*f-c*h-d*l;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z, -f=this.x,h=this.y,l=this.z,m=this.w,k=m*c+h*e-l*d,i=m*d+l*c-f*e,o=m*e+f*d-h*c,c=-f*c-h*d-l*e;b.x=k*m+c*-f+i*-l-o*-h;b.y=i*m+c*-h+o*-f-k*-l;b.z=o*m+c*-l+k*-h-i*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,h=f*a.w+c*a.x+d*a.y+e*a.z;if(h<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;h=-h}else this.copy(a);if(h>=1){this.w=f;this.x=c;this.y=d;this.z=e;return this}var l=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.0010){this.w=0.5*(f+this.w);this.x=0.5*(c+this.x); -this.y=0.5*(d+this.y);this.z=0.5*(e+this.z);return this}h=Math.sin((1-b)*l)/m;l=Math.sin(b*l)/m;this.w=f*h+this.w*l;this.x=c*h+this.x*l;this.y=d*h+this.y*l;this.z=e*h+this.z*l;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; -THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; -THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; +Da=oa.type===THREE.LinePieces?2:1;X=1;for(I=Aa.length;X0)){na=l[m-2];G.copy(H.positionScreen);R.copy(na.positionScreen);if(d(G,R)===true){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Ba=void 0;if(r===q.length){Ba=new THREE.RenderableLine;q.push(Ba)}else Ba=q[r];r++;n=Ba;n.v1.positionScreen.copy(G);n.v2.positionScreen.copy(R);n.z=Math.max(G.z,R.z);n.material=oa.material;s.elements.push(n)}}}}}a=0;for(g= +s.sprites.length;a0&&A.z<1){h=void 0;if(B===D.length){h=new THREE.RenderableParticle;D.push(h)}else h=D[B];B++;u=h;u.x=A.x/A.w;u.y=A.y/A.w;u.z=A.z;u.rotation=oa.rotation.z;u.scale.x=oa.scale.x*Math.abs(u.x-(A.x+e.projectionMatrix.elements[0])/(A.w+e.projectionMatrix.elements[12]));u.scale.y=oa.scale.y*Math.abs(u.y-(A.y+e.projectionMatrix.elements[5])/ +(A.w+e.projectionMatrix.elements[13]));u.material=oa.material;s.elements.push(u)}}}f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),f=Math.cos(a.z/2),e=Math.sin(a.x/2),h=Math.sin(a.y/2),k=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=e*d*f+c*h*k;this.y=c*h*f-e*d*k;this.z=c*d*k+e*h*f;this.w=c*d*f-e*h*k}else if(b==="YXZ"){this.x=e*d*f+c*h*k;this.y=c*h*f-e*d*k;this.z= +c*d*k-e*h*f;this.w=c*d*f+e*h*k}else if(b==="ZXY"){this.x=e*d*f-c*h*k;this.y=c*h*f+e*d*k;this.z=c*d*k+e*h*f;this.w=c*d*f-e*h*k}else if(b==="ZYX"){this.x=e*d*f-c*h*k;this.y=c*h*f+e*d*k;this.z=c*d*k-e*h*f;this.w=c*d*f+e*h*k}else if(b==="YZX"){this.x=e*d*f+c*h*k;this.y=c*h*f+e*d*k;this.z=c*d*k-e*h*f;this.w=c*d*f-e*h*k}else if(b==="XZY"){this.x=e*d*f-c*h*k;this.y=c*h*f-e*d*k;this.z=c*d*k+e*h*f;this.w=c*d*f+e*h*k}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y* +d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],h=b[9],k=b[2],m=b[6],b=b[10],l=c+e+b;if(l>0){c=0.5/Math.sqrt(l+1);this.w=0.25/c;this.x=(m-h)*c;this.y=(d-k)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(m-h)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+k)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-k)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(h+m)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x= +(d+k)/c;this.y=(h+m)/c;this.z=0.25*c}return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= +this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,h=a.y,k=a.z,a=a.w;this.x=b*a+f*e+c*k-d*h;this.y=c*a+f*h+d*e-b*k;this.z=d*a+f*k+b*h-c*e;this.w=f*a-b*e-c*h-d*k;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z, +e=this.x,h=this.y,k=this.z,m=this.w,l=m*c+h*f-k*d,i=m*d+k*c-e*f,o=m*f+e*d-h*c,c=-e*c-h*d-k*f;b.x=l*m+c*-e+i*-k-o*-h;b.y=i*m+c*-h+o*-e-l*-k;b.z=o*m+c*-k+l*-h-i*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,h=e*a.w+c*a.x+d*a.y+f*a.z;if(h<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;h=-h}else this.copy(a);if(h>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var k=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x); +this.y=0.5*(d+this.y);this.z=0.5*(f+this.z);return this}h=Math.sin((1-b)*k)/m;k=Math.sin(b*k)/m;this.w=e*h+this.w*k;this.x=c*h+this.x*k;this.y=d*h+this.y*k;this.z=f*h+this.z*k;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; +THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;dc.x)c.x= -a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,h,l;f=0;for(h=this.vertices.length;f0;a--)if(d.indexOf(e["abcd"[a]])!=a){d.splice(a,1);this.faces[f]=new THREE.Face3(d[0],d[1],d[2]);e=0;for(d=this.faceVertexUvs.length;ethis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: -f+2;k=this.points[c[0]];i=this.points[c[1]];o=this.points[c[2]];j=this.points[c[3]];l=h*h;m=h*l;d.x=b(k.x,i.x,o.x,j.x,h,l,m);d.y=b(k.y,i.y,o.y,j.y,h,l,m);d.z=b(k.z,i.z,o.z,j.z,h,l,m);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=this.vertices.length;dc.x)c.x= +a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,h,k;e=0;for(h=this.vertices.length;e0;a--)if(d.indexOf(f["abcd"[a]])!=a){d.splice(a,1);this.faces[e]=new THREE.Face3(d[0],d[1],d[2]);f=0;for(d=this.faceVertexUvs.length;fthis.points.length-2?this.points.length-1:e+1;c[3]=e>this.points.length-3?this.points.length-1: +e+2;l=this.points[c[0]];i=this.points[c[1]];o=this.points[c[2]];j=this.points[c[3]];k=h*h;m=h*k;d.x=b(l.x,i.x,o.x,j.x,h,k,m);d.y=b(l.y,i.y,o.y,j.y,h,k,m);d.z=b(l.z,i.z,o.z,j.z,h,k,m);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a1&&(R=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(G,R);a.name=j;if(u){a.matrixAutoUpdate=false;a.matrix.set(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])}else{a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2])}a.visible=p.visible;a.doubleSided=p.doubleSided;a.castShadow=p.castShadow;a.receiveShadow=p.receiveShadow;I.scene.add(a);I.objects[j]=a}}else{s=p.position;J=p.rotation;A=p.quaternion; -M=p.scale;A=0;a=new THREE.Object3D;a.name=j;a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2]);a.visible=p.visible!==void 0?p.visible:false;I.scene.add(a);I.objects[j]=a;I.empties[j]=a}}}function f(a){return function(b){I.geometries[a]=b;e();Z=Z-1;m.onLoadComplete();l()}}function h(a){return function(b){I.geometries[a]=b}}function l(){m.callbackProgress({totalModels:g,totalTextures:X,loadedModels:g- -Z,loadedTextures:X-F},I);m.onLoadProgress();Z===0&&F===0&&b(I)}var m=this,k=THREE.Loader.prototype.extractUrlBase(c),i,o,j,w,r,n,q,p,u,B,D,s,J,A,M,E,Q,G,R,T,S,y,L,Z,F,g,X,I;y=a;c=new THREE.BinaryLoader;L=new THREE.JSONLoader;F=Z=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(y.transform){a=y.transform.position;B=y.transform.rotation;E=y.transform.scale;a&&I.scene.position.set(a[0],a[1],a[2]);B&&I.scene.rotation.set(B[0],B[1], -B[2]);E&&I.scene.scale.set(E[0],E[1],E[2]);if(a||B||E){I.scene.updateMatrix();I.scene.updateMatrixWorld()}}a=function(a){return function(){F=F-a;l();m.onLoadComplete()}};for(r in y.cameras){E=y.cameras[r];E.type==="perspective"?T=new THREE.PerspectiveCamera(E.fov,E.aspect,E.near,E.far):E.type==="ortho"&&(T=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far));s=E.position;B=E.target;E=E.up;T.position.set(s[0],s[1],s[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0], -E[1],E[2]);I.cameras[r]=T}for(w in y.lights){B=y.lights[w];r=B.color!==void 0?B.color:16777215;T=B.intensity!==void 0?B.intensity:1;if(B.type==="directional"){s=B.direction;D=new THREE.DirectionalLight(r,T);D.position.set(s[0],s[1],s[2]);D.position.normalize()}else if(B.type==="point"){s=B.position;D=B.distance;D=new THREE.PointLight(r,T,D);D.position.set(s[0],s[1],s[2])}else B.type==="ambient"&&(D=new THREE.AmbientLight(r));I.scene.add(D);I.lights[w]=D}for(n in y.fogs){w=y.fogs[n];w.type==="linear"? -S=new THREE.Fog(0,w.near,w.far):w.type==="exp2"&&(S=new THREE.FogExp2(0,w.density));E=w.color;S.color.setRGB(E[0],E[1],E[2]);I.fogs[n]=S}if(I.cameras&&y.defaults.camera)I.currentCamera=I.cameras[y.defaults.camera];if(I.fogs&&y.defaults.fog)I.scene.fog=I.fogs[y.defaults.fog];E=y.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(E[0],E[1],E[2]);I.bgColorAlpha=y.defaults.bgalpha;for(i in y.geometries){n=y.geometries[i];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Z=Z+1;m.onLoadStart()}}g=Z; +THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState===4)if(d.status===200||d.status===0){var f=JSON.parse(d.responseText);c.createScene(f,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,true);d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)}; +THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:l+"/"+a}function f(){var a;for(j in y.objects)if(!I.objects[j]){q=y.objects[j];if(q.geometry!==void 0){if(G=I.geometries[q.geometry]){a=false;R=I.materials[q.materials[0]];(a=R instanceof THREE.ShaderMaterial)&&G.computeTangents();s=q.position;J=q.rotation;A=q.quaternion;M=q.scale;u=q.matrix;A=0;q.materials.length==0&&(R=new THREE.MeshFaceMaterial);q.materials.length>1&&(R=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(G,R);a.name=j;if(u){a.matrixAutoUpdate=false;a.matrix.set(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])}else{a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2])}a.visible=q.visible;a.doubleSided=q.doubleSided;a.castShadow=q.castShadow;a.receiveShadow=q.receiveShadow;I.scene.add(a);I.objects[j]=a}}else{s=q.position;J=q.rotation;A=q.quaternion; +M=q.scale;A=0;a=new THREE.Object3D;a.name=j;a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2]);a.visible=q.visible!==void 0?q.visible:false;I.scene.add(a);I.objects[j]=a;I.empties[j]=a}}}function e(a){return function(b){I.geometries[a]=b;f();Z=Z-1;m.onLoadComplete();k()}}function h(a){return function(b){I.geometries[a]=b}}function k(){m.callbackProgress({totalModels:g,totalTextures:X,loadedModels:g- +Z,loadedTextures:X-F},I);m.onLoadProgress();Z===0&&F===0&&b(I)}var m=this,l=THREE.Loader.prototype.extractUrlBase(c),i,o,j,v,p,n,r,q,u,B,D,s,J,A,M,E,Q,G,R,T,S,y,L,Z,F,g,X,I;y=a;c=new THREE.BinaryLoader;L=new THREE.JSONLoader;F=Z=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(y.transform){a=y.transform.position;B=y.transform.rotation;E=y.transform.scale;a&&I.scene.position.set(a[0],a[1],a[2]);B&&I.scene.rotation.set(B[0],B[1], +B[2]);E&&I.scene.scale.set(E[0],E[1],E[2]);if(a||B||E){I.scene.updateMatrix();I.scene.updateMatrixWorld()}}a=function(a){return function(){F=F-a;k();m.onLoadComplete()}};for(p in y.cameras){E=y.cameras[p];E.type==="perspective"?T=new THREE.PerspectiveCamera(E.fov,E.aspect,E.near,E.far):E.type==="ortho"&&(T=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far));s=E.position;B=E.target;E=E.up;T.position.set(s[0],s[1],s[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0], +E[1],E[2]);I.cameras[p]=T}for(v in y.lights){B=y.lights[v];p=B.color!==void 0?B.color:16777215;T=B.intensity!==void 0?B.intensity:1;if(B.type==="directional"){s=B.direction;D=new THREE.DirectionalLight(p,T);D.position.set(s[0],s[1],s[2]);D.position.normalize()}else if(B.type==="point"){s=B.position;D=B.distance;D=new THREE.PointLight(p,T,D);D.position.set(s[0],s[1],s[2])}else B.type==="ambient"&&(D=new THREE.AmbientLight(p));I.scene.add(D);I.lights[v]=D}for(n in y.fogs){v=y.fogs[n];v.type==="linear"? +S=new THREE.Fog(0,v.near,v.far):v.type==="exp2"&&(S=new THREE.FogExp2(0,v.density));E=v.color;S.color.setRGB(E[0],E[1],E[2]);I.fogs[n]=S}if(I.cameras&&y.defaults.camera)I.currentCamera=I.cameras[y.defaults.camera];if(I.fogs&&y.defaults.fog)I.scene.fog=I.fogs[y.defaults.fog];E=y.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(E[0],E[1],E[2]);I.bgColorAlpha=y.defaults.bgalpha;for(i in y.geometries){n=y.geometries[i];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Z=Z+1;m.onLoadStart()}}g=Z; for(i in y.geometries){n=y.geometries[i];if(n.type==="cube"){G=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);I.geometries[i]=G}else if(n.type==="plane"){G=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight);I.geometries[i]=G}else if(n.type==="sphere"){G=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight);I.geometries[i]=G}else if(n.type==="cylinder"){G=new THREE.CylinderGeometry(n.topRad, -n.botRad,n.height,n.radSegs,n.heightSegs);I.geometries[i]=G}else if(n.type==="torus"){G=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT);I.geometries[i]=G}else if(n.type==="icosahedron"){G=new THREE.IcosahedronGeometry(n.radius,n.subdivisions);I.geometries[i]=G}else if(n.type==="bin_mesh")c.load(d(n.url,y.urlBaseType),f(i));else if(n.type==="ascii_mesh")L.load(d(n.url,y.urlBaseType),f(i));else if(n.type==="embedded_mesh"){n=y.embeds[n.id];n.metadata=y.metadata;n&&L.createModel(n,h(i), -"")}}for(q in y.textures){i=y.textures[q];if(i.url instanceof Array){F=F+i.url.length;for(n=0;n1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.elements[2]*this.matrixWorld.elements[12]+a.elements[6]*this.matrixWorld.elements[13]+a.elements[10]*this.matrixWorld.elements[14]+a.elements[14]);this.LODs[0].object3D.visible=true;for(var b=1;b=this.LODs[b].visibleAtDistance){this.LODs[b-1].object3D.visible=false;this.LODs[b].object3D.visible=true}else break;for(;b= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n#ifdef USE_MORPHTARGETS\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );\n#else\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n#endif\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif", linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; -THREE.UniformsUtils={merge:function(a){var b,c,d,e={};for(b=0;b=0)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?false:a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?true:false}function f(a,b,c){var d,e,f,h,i=a.vertices;h=i.length; -var j=a.colors,l=j.length,k=a.__vertexArray,m=a.__colorArray,o=a.__sortArray,n=a.verticesNeedUpdate,q=a.colorsNeedUpdate,r=a.__webglCustomAttributesList;if(c.sortParticles){Rb.copy(Sb);Rb.multiplySelf(c.matrixWorld);for(d=0;d=0)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?false:a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?true:false}function e(a,b,c){var d,e,f,h,i=a.vertices;h=i.length; +var k=a.colors,j=k.length,l=a.__vertexArray,m=a.__colorArray,o=a.__sortArray,n=a.verticesNeedUpdate,r=a.colorsNeedUpdate,p=a.__webglCustomAttributesList;if(c.sortParticles){Rb.copy(Sb);Rb.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,f){if(d.needsUpdate){d.program&&F.deallocateMaterial(d);F.initMaterial(d,b,c,f);d.needsUpdate=false}if(d.morphTargets&&!f.__webglMorphTargetInfluences)f.__webglMorphTargetInfluences=new Float32Array(F.maxMorphTargets);var e=false,h=d.program,i=h.uniforms,j=d.uniforms;if(h!==Aa){g.useProgram(h);Aa=h;e=true}if(d.id!==na){na=d.id;e=true}if(e||a!==da){g.uniformMatrix4fv(i.projectionMatrix, -false,a._projectionMatrixArray);a!==da&&(da=a)}if(e){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(pb){for(var l,k=0,m=0,o=0,n,r,q,p=bc,u=p.directional.colors,w=p.directional.positions,s=p.point.colors,y=p.point.positions,B=p.point.distances,E=p.spot.colors,I=p.spot.positions,J=p.spot.distances, -L=p.spot.directions,Q=p.spot.angles,G=p.spot.exponents,R=0,S=0,T=0,H=q=0,c=H=0,e=b.length;c=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,f){if(d.needsUpdate){d.program&&F.deallocateMaterial(d);F.initMaterial(d,b,c,f);d.needsUpdate=false}if(d.morphTargets&&!f.__webglMorphTargetInfluences)f.__webglMorphTargetInfluences=new Float32Array(F.maxMorphTargets);var e=false,h=d.program,i=h.uniforms,k=d.uniforms;if(h!==Aa){g.useProgram(h);Aa=h;e=true}if(d.id!==na){na=d.id;e=true}if(e||a!==da){g.uniformMatrix4fv(i.projectionMatrix, +false,a._projectionMatrixArray);a!==da&&(da=a)}if(e){if(c&&d.fog){k.fogColor.value=c.color;if(c instanceof THREE.Fog){k.fogNear.value=c.near;k.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(pb){for(var j,l=0,m=0,o=0,n,p,r,q=bc,u=q.directional.colors,v=q.directional.positions,s=q.point.colors,y=q.point.positions,B=q.point.distances,E=q.spot.colors,I=q.spot.positions,J=q.spot.distances, +L=q.spot.directions,Q=q.spot.angles,G=q.spot.exponents,R=0,S=0,T=0,H=r=0,c=H=0,e=b.length;c1&&(b=true);d=0;for(c=f.length;d=0&&e.vertexNormalBuffer){h=e.vertexNormalBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexNormalBuffer);g.vertexAttribPointer(a.normal, +r(a,b,c,d,f);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==ca){ca=d;b=true}if(f instanceof THREE.Mesh){f=e.offsets;f.length>1&&(b=true);d=0;for(c=f.length;d=0&&e.vertexNormalBuffer){h=e.vertexNormalBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexNormalBuffer);g.vertexAttribPointer(a.normal, h,g.FLOAT,false,0,f[d].index*h*4)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){h=e.vertexUvBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexUvBuffer);g.vertexAttribPointer(a.uv,h,g.FLOAT,false,0,f[d].index*h*4);g.enableVertexAttribArray(a.uv)}else g.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){h=e.vertexColorBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexColorBuffer);g.vertexAttribPointer(a.color,h,g.FLOAT,false,0,f[d].index*h*4)}g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, -e.vertexIndexBuffer)}g.drawElements(g.TRIANGLES,f[d].count,g.UNSIGNED_SHORT,f[d].start*2);F.info.render.calls++;F.info.render.vertices=F.info.render.vertices+f[d].count;F.info.render.faces=F.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var h,i,c=q(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(b.position, +e.vertexIndexBuffer)}g.drawElements(g.TRIANGLES,f[d].count,g.UNSIGNED_SHORT,f[d].start*2);F.info.render.calls++;F.info.render.vertices=F.info.render.vertices+f[d].count;F.info.render.faces=F.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var h,i,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(b.position, 3,g.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}else if(c.position>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var j=0;i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;j0&&i.push([k,j])}if(i.length>d.numSupportedMorphTargets){i.sort(l);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals? -i.sort(l):i.length===0&&i.push([0,0]);for(j=0;j0&&i.push([l,j])}if(i.length>d.numSupportedMorphTargets){i.sort(k);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals? +i.sort(k):i.length===0&&i.push([0,0]);for(j=0;j=0){g.bindBuffer(g.ARRAY_BUFFER,c.buffer);g.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,g.FLOAT,false,0,0)}}}if(b.color>=0){g.bindBuffer(g.ARRAY_BUFFER, e.__webglColorBuffer);g.vertexAttribPointer(b.color,3,g.FLOAT,false,0,0)}if(b.normal>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglNormalBuffer);g.vertexAttribPointer(b.normal,3,g.FLOAT,false,0,0)}if(b.tangent>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglTangentBuffer);g.vertexAttribPointer(b.tangent,4,g.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUVBuffer);g.vertexAttribPointer(b.uv,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv)}else g.disableVertexAttribArray(b.uv); if(b.uv2>=0)if(e.__webglUV2Buffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUV2Buffer);g.vertexAttribPointer(b.uv2,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv2)}else g.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexABuffer);g.vertexAttribPointer(b.skinVertexA,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);g.vertexAttribPointer(b.skinVertexB,4,g.FLOAT, false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);g.vertexAttribPointer(b.skinIndex,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);g.vertexAttribPointer(b.skinWeight,4,g.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==Ib){g.lineWidth(d);Ib=d}a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);g.drawElements(g.LINES,e.__webglLineCount,g.UNSIGNED_SHORT,0)}else{a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer); g.drawElements(g.TRIANGLES,e.__webglFaceCount,g.UNSIGNED_SHORT,0)}F.info.render.calls++;F.info.render.vertices=F.info.render.vertices+e.__webglFaceCount;F.info.render.faces=F.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?g.LINE_STRIP:g.LINES;d=d.linewidth;if(d!==Ib){g.lineWidth(d);Ib=d}g.drawArrays(f,0,e.__webglLineCount);F.info.render.calls++}else if(f instanceof THREE.ParticleSystem){g.drawArrays(g.POINTS,0,e.__webglParticleCount);F.info.render.calls++; -F.info.render.points=F.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);F.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,l,o=a.__lights,n=a.fog;na=-1;pb=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray= +F.info.render.points=F.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);F.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,k,o=a.__lights,n=a.fog;na=-1;pb=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray= new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Sb.multiply(b.projectionMatrix,b.matrixWorldInverse);dc.setFromMatrix(Sb);this.autoUpdateObjects&&this.initWebGLObjects(a);m(this.renderPluginsPre,a,b);F.info.render.calls=0;F.info.render.vertices=0;F.info.render.faces=0;F.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor, -this.autoClearDepth,this.autoClearStencil);l=a.__webglObjects;d=0;for(e=l.length;d=0){s=q.geometry.materials[s];if(s.transparent){r.transparent=s;r.opaque=null}else{r.opaque=s;r.transparent=null}}}else if(s)if(s.transparent){r.transparent= -s;r.opaque=null}else{r.opaque=s;r.transparent=null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{Pa.copy(j.matrixWorld.getPosition());Sb.multiplyVector3(Pa);f.z=Pa.z}}}this.sortObjects&&l.sort(h);l=a.__webglObjectsImmediate;d=0;for(e=l.length;d65535){E[A].counter=E[A].counter+1;B=E[A].hash+"_"+E[A].counter;p.geometryGroups[B]===void 0&&(p.geometryGroups[B]={faces3:[],faces4:[],materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J})}u instanceof THREE.Face3?p.geometryGroups[B].faces3.push(q):p.geometryGroups[B].faces4.push(q);p.geometryGroups[B].vertices=p.geometryGroups[B].vertices+D}p.geometryGroupsList=[];var L=void 0;for(L in p.geometryGroups){p.geometryGroups[L].id= -oa++;p.geometryGroupsList.push(p.geometryGroups[L])}}for(l in k.geometryGroups){m=k.geometryGroups[l];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=g.createBuffer();H.__webglSkinIndicesBuffer=g.createBuffer();H.__webglSkinWeightsBuffer= +this.autoClearDepth,this.autoClearStencil);k=a.__webglObjects;d=0;for(e=k.length;d=0){s=r.geometry.materials[s];if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent=null}}}else if(s)if(s.transparent){p.transparent= +s;p.opaque=null}else{p.opaque=s;p.transparent=null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{Pa.copy(j.matrixWorld.getPosition());Sb.multiplyVector3(Pa);f.z=Pa.z}}}this.sortObjects&&k.sort(h);k=a.__webglObjectsImmediate;d=0;for(e=k.length;d65535){E[A].counter=E[A].counter+1;B=E[A].hash+"_"+E[A].counter;q.geometryGroups[B]===void 0&&(q.geometryGroups[B]={faces3:[],faces4:[],materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J})}s instanceof THREE.Face3?q.geometryGroups[B].faces3.push(r):q.geometryGroups[B].faces4.push(r);q.geometryGroups[B].vertices=q.geometryGroups[B].vertices+D}q.geometryGroupsList=[];var L=void 0;for(L in q.geometryGroups){q.geometryGroups[L].id= +oa++;q.geometryGroupsList.push(q.geometryGroups[L])}}for(k in l.geometryGroups){m=l.geometryGroups[k];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=g.createBuffer();H.__webglSkinIndicesBuffer=g.createBuffer();H.__webglSkinWeightsBuffer= g.createBuffer();H.__webglFaceBuffer=g.createBuffer();H.__webglLineBuffer=g.createBuffer();var M=void 0,Q=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];M=0;for(Q=H.numMorphTargets;M0||R.faceVertexUvs.length>0)G.__uvArray=new Float32Array(X*2);if(R.faceUvs.length>1||R.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(X*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length){G.__skinVertexAArray= +1+Z.length*2,na=T.length*3+Z.length*4,da=c(S,G),Aa=f(da),Da=d(da),Ka=da.vertexColors?da.vertexColors:false;G.__vertexArray=new Float32Array(X*3);if(Da)G.__normalArray=new Float32Array(X*3);if(R.hasTangents)G.__tangentArray=new Float32Array(X*4);if(Ka)G.__colorArray=new Float32Array(X*3);if(Aa){if(R.faceUvs.length>0||R.faceVertexUvs.length>0)G.__uvArray=new Float32Array(X*2);if(R.faceUvs.length>1||R.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(X*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length){G.__skinVertexAArray= new Float32Array(X*4);G.__skinVertexBArray=new Float32Array(X*4);G.__skinIndexArray=new Float32Array(X*4);G.__skinWeightArray=new Float32Array(X*4)}G.__faceArray=new Uint16Array(ca*3);G.__lineArray=new Uint16Array(na*2);var Ba=void 0,Ea=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];Ba=0;for(Ea=G.numMorphTargets;Ba0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglUVBuffer);g.bufferData(g.ARRAY_BUFFER,nc,La)}}if(Xc&& Tc&&bc){x=0;for(K=aa.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglUV2Buffer);g.bufferData(g.ARRAY_BUFFER,oc,La)}}if(Mc){x=0;for(K=aa.length;x0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights, +m++;l instanceof THREE.PointLight&&o++;l instanceof THREE.SpotLight&&i++}}if(o+i+m<=Z){k=m;l=o;m=i}else{k=Math.ceil(Z*m/(o+m));m=l=Z-k}var n=0,i=0;for(o=b.length;i0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights, "#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled? "#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); k=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP": "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n"); -j=B("fragment",k+j);d=B("vertex",d+o);g.attachShader(q,d);g.attachShader(q,j);g.linkProgram(q);g.getProgramParameter(q,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(q,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(j);g.deleteShader(d);q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in i)d.push(s); -s=d;d=0;for(i=s.length;d=0&&g.enableVertexAttribArray(p.position);p.color>=0&&g.enableVertexAttribArray(p.color);p.normal>=0&&g.enableVertexAttribArray(p.normal);p.tangent>=0&&g.enableVertexAttribArray(p.tangent);if(a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0){g.enableVertexAttribArray(p.skinVertexA);g.enableVertexAttribArray(p.skinVertexB);g.enableVertexAttribArray(p.skinIndex);g.enableVertexAttribArray(p.skinWeight)}if(a.attributes)for(f in a.attributes)p[f]!==void 0&&p[f]>= 0&&g.enableVertexAttribArray(p[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a, b){if(a){!b||b==="ccw"?g.frontFace(g.CCW):g.frontFace(g.CW);a==="back"?g.cullFace(g.BACK):a==="front"?g.cullFace(g.FRONT):g.cullFace(g.FRONT_AND_BACK);g.enable(g.CULL_FACE)}else g.disable(g.CULL_FACE)};this.setObjectFaces=function(a){if(Da!==a.doubleSided){a.doubleSided?g.disable(g.CULL_FACE):g.enable(g.CULL_FACE);Da=a.doubleSided}if(Ka!==a.flipSided){a.flipSided?g.frontFace(g.CW):g.frontFace(g.CCW);Ka=a.flipSided}};this.setDepthTest=function(a){if(Ya!==a){a?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST); @@ -408,45 +408,47 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]}; THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){if(this.vertexPositionArray!==void 0){a.multiplyVector3Array(this.vertexPositionArray);this.verticesNeedUpdate=true}if(this.vertexNormalArray!==void 0){var b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(this.vertexNormalArray);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,Infinity),max:new THREE.Vector3(-Infinity, --Infinity,-Infinity)};var a=this.vertexPositionArray;if(a)for(var b=this.boundingBox,c,d,e,f=0,h=a.length;fb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(eb.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var a=this.vertexPositionArray; -if(a){for(var b,c=0,d,e,f=0,h=a.length;fc&&(c=b)}this.boundingSphere.radius=c}}};THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype); +-Infinity,-Infinity)};var a=this.vertexPositionArray;if(a)for(var b=this.boundingBox,c,d,f,e=0,h=a.length;eb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(fb.max.z)b.max.z=f}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var a=this.vertexPositionArray; +if(a){for(var b,c=0,d,f,e=0,h=a.length;ec&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){var a=this.vertexIndexArray,b=this.vertexPositionArray;if(b&&a){var c,d,f,e;c=b.length;if(this.vertexNormalArray===void 0)this.vertexNormalArray=new Float32Array(c);else{c=0;for(d=this.vertexNormalArray.length;c0&&Q.x0&& -Q.y0.0010&&L.scale>0.0010){E.x=L.x;E.y=L.y;E.z=L.z;A=L.size*L.scale/p;M.x=A*D;M.y=A;b.uniform3f(G.screenPosition,E.x,E.y,E.z);b.uniform2f(G.scale,M.x,M.y);b.uniform1f(G.rotation,L.rotation);b.uniform1f(G.opacity,L.opacity); +b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){l=false;i=a(THREE.ShaderFlares.lensFlare)}else{l=true;i=a(THREE.ShaderFlares.lensFlareVertexTexture)}o={};j={};o.vertex=b.getAttribLocation(i,"position");o.uv=b.getAttribLocation(i,"uv");j.renderType=b.getUniformLocation(i,"renderType");j.map=b.getUniformLocation(i,"map");j.occlusionMap=b.getUniformLocation(i,"occlusionMap");j.opacity=b.getUniformLocation(i,"opacity");j.color=b.getUniformLocation(i, +"color");j.scale=b.getUniformLocation(i,"scale");j.rotation=b.getUniformLocation(i,"rotation");j.screenPosition=b.getUniformLocation(i,"screenPosition");v=false};this.render=function(a,d,f,q){var a=a.__webglFlares,u=a.length;if(u){var B=new THREE.Vector3,D=q/f,s=f*0.5,J=q*0.5,A=16/q,M=new THREE.Vector2(A*D,A),E=new THREE.Vector3(1,1,0),Q=new THREE.Vector2(1,1),G=j,A=o;b.useProgram(i);if(!v){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);v=true}b.uniform1i(G.occlusionMap,0);b.uniform1i(G.map, +1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(A.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(A.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(false);var R,T,S,y,L;for(R=0;R0&&Q.x0&& +Q.y0.0010&&L.scale>0.0010){E.x=L.x;E.y=L.y;E.z=L.z;A=L.size*L.scale/q;M.x=A*D;M.y=A;b.uniform3f(G.screenPosition,E.x,E.y,E.z);b.uniform2f(G.scale,M.x,M.y);b.uniform1f(G.rotation,L.rotation);b.uniform1f(G.opacity,L.opacity); b.uniform3f(G.color,L.color.r,L.color.g,L.color.b);c.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst);c.setTexture(L.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}}; -THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,h=new THREE.Vector3,l=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:true});c._shadowPass=true;d._shadowPass=true};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,k){var i,o,j,w,r,n,q,p,u,B=[];w=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);i=0;for(o=m.__lights.length;il.x)l.x=p.x;if(p.yl.y)l.y=p.y;if(p.zl.z)l.z=p.z}w.left=h.x;w.right=l.x;w.top=l.y;w.bottom=h.y;w.updateProjectionMatrix()}w=j.shadowMap;n=j.shadowMatrix;r=j.shadowCamera;r.position.copy(j.matrixWorld.getPosition());r.lookAt(j.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld); -if(j.cameraHelper)j.cameraHelper.lines.visible=j.shadowCameraVisible;j.shadowCameraVisible&&j.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(r.projectionMatrix);n.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);f.multiply(r.projectionMatrix, -r.matrixWorldInverse);e.setFromMatrix(f);b.setRenderTarget(w);b.clear();u=m.__webglObjects;j=0;for(w=u.length;jk.x)k.x=q.x;if(q.yk.y)k.y=q.y;if(q.zk.z)k.z=q.z}v.left=h.x;v.right=k.x;v.top=k.y;v.bottom=h.y;v.updateProjectionMatrix()}v=j.shadowMap;n=j.shadowMatrix;p=j.shadowCamera;p.position.copy(j.matrixWorld.getPosition());p.lookAt(j.target.matrixWorld.getPosition());p.updateMatrixWorld();p.matrixWorldInverse.getInverse(p.matrixWorld); +if(j.cameraHelper)j.cameraHelper.lines.visible=j.shadowCameraVisible;j.shadowCameraVisible&&j.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(p.projectionMatrix);n.multiplySelf(p.matrixWorldInverse);if(!p._viewMatrixArray)p._viewMatrixArray=new Float32Array(16);if(!p._projectionMatrixArray)p._projectionMatrixArray=new Float32Array(16);p.matrixWorldInverse.flattenToArray(p._viewMatrixArray);p.projectionMatrix.flattenToArray(p._projectionMatrixArray);e.multiply(p.projectionMatrix, +p.matrixWorldInverse);f.setFromMatrix(e);b.setRenderTarget(v);b.clear();u=m.__webglObjects;j=0;for(v=u.length;j