From fca3aec67d027ece98f302430f587db43c757520 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 17 Dec 2010 19:49:23 +0000 Subject: [PATCH] Fixed `Projector::projectObjects`. --- build/Three.js | 236 +++++++++++++++---------------- build/ThreeDebug.js | 238 ++++++++++++++++---------------- build/ThreeExtras.js | 236 +++++++++++++++---------------- src/renderers/Projector.js | 9 +- src/renderers/WebGLRenderer2.js | 11 ++ 5 files changed, 371 insertions(+), 359 deletions(-) diff --git a/build/Three.js b/build/Three.js index 88365db6..78aee48a 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,61 +1,61 @@ // Three.js r31 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,b,f){this.r=a;this.g=b;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+ +THREE.Color.prototype={setRGB:function(a,b,g){this.r=a;this.g=b;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+ ","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={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},addSelf: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},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0}; -THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;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-=a.x;this.y-=a.y;this.z-=a.z;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,f=this.y,d=this.z;this.x=f*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-f*a.x;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*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= -a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a= +this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,g){this.x=a||0;this.y=b||0;this.z=g||0}; +THREE.Vector3.prototype={set:function(a,b,g){this.x=a;this.y=b;this.z=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;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-=a.x;this.y-=a.y;this.z-=a.z;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,g=this.y,d=this.z;this.x=g*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-g*a.x;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*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= +a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+g*g+a*a)},distanceToSquared:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return b*b+g*g+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a= Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}}; -THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1}; -THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=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+=a.x;this.y+=a.y;this.z+=a.z;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-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; +THREE.Vector4=function(a,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1}; +THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=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+=a.x;this.y+=a.y;this.z+=a.z;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-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,i=[];a=0;for(b=d.length;a0&&R>0&&m+R<1}var f,d,i,p,k,l,n,c,C,A, -y,r=a.geometry,G=r.vertices,M=[];f=0;for(d=r.faces.length;fn?d:n;i=i>c? -i:c}a()};this.add3Points=function(n,c,C,A,y,r){if(l){l=false;b=nC?n>y?n:y:C>y?C:y;i=c>A?c>r?c:r:A>r?A:r}else{b=nC?n>y?n>d?n:d:y>d?y:d:C>y?C>d?C:d:y>d?y:d;i=c>A?c>r?c>i?c:i:r>i?r:i:A>r?A>i?A:i:r>i?r:i}a()};this.addRectangle=function(n){if(l){l=false;b=n.getLeft();f=n.getTop();d=n.getRight();i=n.getBottom()}else{b=bn.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;f-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();f=f>n.getTop()?f:n.getTop();d=d=0&&Math.min(i,n.getBottom())-Math.max(f,n.getTop())>=0};this.empty=function(){l=true;i=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+p+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,f,d,i,p,k,l,n,c,C,A,y,r,G,M){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=p||1;this.n23=k||0;this.n24=l||0;this.n31=n||0;this.n32=c||0;this.n33=C||1;this.n34=A||0;this.n41=y||0;this.n42=r||0;this.n43=G||0;this.n44=M||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,f,d,i,p,k,l,n,c,C,A,y,r,G,M){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=p;this.n23=k;this.n24=l;this.n31=n;this.n32=c;this.n33=C;this.n34=A;this.n41=y;this.n42=r;this.n43=G;this.n44=M;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= -a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var d=new THREE.Vector3,i=new THREE.Vector3,p=new THREE.Vector3;p.sub(a,b).normalize();d.cross(f,p).normalize();i.cross(p,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=p.x; -this.n32=p.y;this.n33=p.z;this.n34=-p.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24* -i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*i;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,d=a.n12,i=a.n13,p=a.n14,k=a.n21,l=a.n22,n=a.n23,c=a.n24,C=a.n31,A=a.n32, -y=a.n33,r=a.n34,G=a.n41,M=a.n42,R=a.n43,D=a.n44,K=b.n11,F=b.n12,e=b.n13,m=b.n14,g=b.n21,q=b.n22,j=b.n23,h=b.n24,u=b.n31,x=b.n32,E=b.n33,o=b.n34,z=b.n41,P=b.n42,t=b.n43,U=b.n44;this.n11=f*K+d*g+i*u+p*z;this.n12=f*F+d*q+i*x+p*P;this.n13=f*e+d*j+i*E+p*t;this.n14=f*m+d*h+i*o+p*U;this.n21=k*K+l*g+n*u+c*z;this.n22=k*F+l*q+n*x+c*P;this.n23=k*e+l*j+n*E+c*t;this.n24=k*m+l*h+n*o+c*U;this.n31=C*K+A*g+y*u+r*z;this.n32=C*F+A*q+y*x+r*P;this.n33=C*e+A*j+y*E+r*t;this.n34=C*m+A*h+y*o+r*U;this.n41=G*K+M*g+R*u+D*z; -this.n42=G*F+M*q+R*x+D*P;this.n43=G*e+M*j+R*E+D*t;this.n44=G*m+M*h+R*o+D*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,p=this.n21,k=this.n22,l=this.n23,n=this.n24,c=this.n31,C=this.n32,A=this.n33,y=this.n34,r=this.n41,G=this.n42,M=this.n43,R=this.n44,D=a.n11,K=a.n21,F=a.n31,e=a.n41,m=a.n12,g=a.n22,q=a.n32,j=a.n42,h=a.n13,u=a.n23,x=a.n33,E=a.n43,o=a.n14,z=a.n24,P=a.n34;a=a.n44;this.n11=b*D+f*K+d*F+i*e;this.n12=b*m+f*g+d*q+i*j;this.n13=b*h+f*u+d*x+i*E;this.n14= -b*o+f*z+d*P+i*a;this.n21=p*D+k*K+l*F+n*e;this.n22=p*m+k*g+l*q+n*j;this.n23=p*h+k*u+l*x+n*E;this.n24=p*o+k*z+l*P+n*a;this.n31=c*D+C*K+A*F+y*e;this.n32=c*m+C*g+A*q+y*j;this.n33=c*h+C*u+A*x+y*E;this.n34=c*o+C*z+A*P+y*a;this.n41=r*D+G*K+M*F+R*e;this.n42=r*m+G*g+M*q+R*j;this.n43=r*h+G*u+M*x+R*E;this.n44=r*o+G*z+M*P+R*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= +THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,h=[];a=0;for(b=d.length;a0&&K>0&&m+K<1}var g,d,h,q,j,l,n,c,A,y, +x,s=a.geometry,G=s.vertices,N=[];g=0;for(d=s.faces.length;gn?d:n;h=h>c? +h:c}a()};this.add3Points=function(n,c,A,y,x,s){if(l){l=false;b=nA?n>x?n:x:A>x?A:x;h=c>y?c>s?c:s:y>s?y:s}else{b=nA?n>x?n>d?n:d:x>d?x:d:A>x?A>d?A:d:x>d?x:d;h=c>y?c>s?c>h?c:h:s>h?s:h:y>s?y>h?y:h:s>h?s:h}a()};this.addRectangle=function(n){if(l){l=false;b=n.getLeft();g=n.getTop();d=n.getRight();h=n.getBottom()}else{b=bn.getRight()?d:n.getRight();h=h>n.getBottom()?h:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;h+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d=0&&Math.min(h,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){l=true;h=d=g=b=0;a()};this.isEmpty=function(){return l};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+h+", width: "+q+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,g,d,h,q,j,l,n,c,A,y,x,s,G,N){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=h||0;this.n22=q||1;this.n23=j||0;this.n24=l||0;this.n31=n||0;this.n32=c||0;this.n33=A||1;this.n34=y||0;this.n41=x||0;this.n42=s||0;this.n43=G||0;this.n44=N||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,h,q,j,l,n,c,A,y,x,s,G,N){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=h;this.n22=q;this.n23=j;this.n24=l;this.n31=n;this.n32=c;this.n33=A;this.n34=y;this.n41=x;this.n42=s;this.n43=G;this.n44=N;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,h=new THREE.Vector3,q=new THREE.Vector3;q.sub(a,b).normalize();d.cross(g,q).normalize();h.cross(q,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=q.x; +this.n32=q.y;this.n33=q.z;this.n34=-q.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,h=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*h;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24* +h;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var g=a.n11,d=a.n12,h=a.n13,q=a.n14,j=a.n21,l=a.n22,n=a.n23,c=a.n24,A=a.n31,y=a.n32, +x=a.n33,s=a.n34,G=a.n41,N=a.n42,K=a.n43,J=a.n44,O=b.n11,D=b.n12,e=b.n13,m=b.n14,f=b.n21,p=b.n22,k=b.n23,i=b.n24,o=b.n31,C=b.n32,u=b.n33,t=b.n34,I=b.n41,B=b.n42,E=b.n43,U=b.n44;this.n11=g*O+d*f+h*o+q*I;this.n12=g*D+d*p+h*C+q*B;this.n13=g*e+d*k+h*u+q*E;this.n14=g*m+d*i+h*t+q*U;this.n21=j*O+l*f+n*o+c*I;this.n22=j*D+l*p+n*C+c*B;this.n23=j*e+l*k+n*u+c*E;this.n24=j*m+l*i+n*t+c*U;this.n31=A*O+y*f+x*o+s*I;this.n32=A*D+y*p+x*C+s*B;this.n33=A*e+y*k+x*u+s*E;this.n34=A*m+y*i+x*t+s*U;this.n41=G*O+N*f+K*o+J*I; +this.n42=G*D+N*p+K*C+J*B;this.n43=G*e+N*k+K*u+J*E;this.n44=G*m+N*i+K*t+J*U;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,h=this.n14,q=this.n21,j=this.n22,l=this.n23,n=this.n24,c=this.n31,A=this.n32,y=this.n33,x=this.n34,s=this.n41,G=this.n42,N=this.n43,K=this.n44,J=a.n11,O=a.n21,D=a.n31,e=a.n41,m=a.n12,f=a.n22,p=a.n32,k=a.n42,i=a.n13,o=a.n23,C=a.n33,u=a.n43,t=a.n14,I=a.n24,B=a.n34;a=a.n44;this.n11=b*J+g*O+d*D+h*e;this.n12=b*m+g*f+d*p+h*k;this.n13=b*i+g*o+d*C+h*u;this.n14= +b*t+g*I+d*B+h*a;this.n21=q*J+j*O+l*D+n*e;this.n22=q*m+j*f+l*p+n*k;this.n23=q*i+j*o+l*C+n*u;this.n24=q*t+j*I+l*B+n*a;this.n31=c*J+A*O+y*D+x*e;this.n32=c*m+A*f+y*p+x*k;this.n33=c*i+A*o+y*C+x*u;this.n34=c*t+A*I+y*B+x*a;this.n41=s*J+G*O+N*D+K*e;this.n42=s*m+G*f+N*p+K*k;this.n43=s*i+G*o+N*C+K*u;this.n44=s*t+G*I+N*B+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* -this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,d){var i=b[f];b[f]=b[d]; -b[d]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, -this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d}; -THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),p=1-d,k=a.x,l=a.y,n=a.z;f.n11=p*k*k+d;f.n12=p*k*l-i*n;f.n13=p*k*n+i*l;f.n21=p*k*l+i*n;f.n22=p*l*l+d;f.n23=p*l*n-i*k;f.n31=p*k*n-i*l;f.n32=p*l*n+i*k;f.n33=p*n*n+d;return f}; +this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var h=b[g];b[g]=b[d]; +b[d]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, +this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d}; +THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),h=Math.sin(b),q=1-d,j=a.x,l=a.y,n=a.z;g.n11=q*j*j+d;g.n12=q*j*l-h*n;g.n13=q*j*n+h*l;g.n21=q*j*l+h*n;g.n22=q*l*l+d;g.n23=q*l*n-h*j;g.n31=q*j*n-h*l;g.n32=q*l*n+h*j;g.n33=q*n*n+d;return g}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],p=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*p+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*p;a.m[4]=b*k;a.m[5]=b*l;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*C;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,d,i,p){var k,l,n;k=new THREE.Matrix4;l=2*i/(b-a);n=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(p+i)/(p-i);i=-2*p*i/(p-i);k.n11=l;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=n;k.n23=f;k.n24=0;k.n31=0;k.n32=0;k.n33=d;k.n34=i;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)}; -THREE.Matrix4.makeOrtho=function(a,b,f,d,i,p){var k,l,n,c;k=new THREE.Matrix4;l=b-a;n=f-d;c=p-i;a=(b+a)/l;f=(f+d)/n;i=(p+i)/c;k.n11=2/l;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/n;k.n23=0;k.n24=-f;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-i;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],q=-b[10]*b[4]+b[6]*b[8],j=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],A=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*q+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*h;a.m[3]=b*q;a.m[4]=b*j;a.m[5]=b*l;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*A;return a}; +THREE.Matrix4.makeFrustum=function(a,b,g,d,h,q){var j,l,n;j=new THREE.Matrix4;l=2*h/(b-a);n=2*h/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(q+h)/(q-h);h=-2*q*h/(q-h);j.n11=l;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=n;j.n23=g;j.n24=0;j.n31=0;j.n32=0;j.n33=d;j.n34=h;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,g,d){var h;a=g*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,g,d)}; +THREE.Matrix4.makeOrtho=function(a,b,g,d,h,q){var j,l,n,c;j=new THREE.Matrix4;l=b-a;n=g-d;c=q-h;a=(b+a)/l;g=(g+d)/n;h=(q+h)/c;j.n11=2/l;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/n;j.n23=0;j.n24=-g;j.n31=0;j.n32=0;j.n33=-2/c;j.n34=-h;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,b,f,d,i){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,f,d,i,p){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=p instanceof Array?p:[p]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face3=function(a,b,g,d,h){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,g,d,h,q){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=q instanceof Array?q:[q]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(C){var A=[];b=0;for(f=C.length;b65535){c[l].counter+=1;n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:k,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=p}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,f,d);this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i); -this.position.subSelf(i);this.target.position.subSelf(i)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; +vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(A){var y=[];b=0;for(g=A.length;b65535){c[l].counter+=1;n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:j,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=q}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h); +this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; @@ -85,93 +85,93 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,f,d,i,p){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=p!==undefined?p:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ +THREE.Texture=function(a,b,g,d,h,q){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=q!==undefined?q:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){}; THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; -THREE.Projector=function(){function a(q,j){var h=0,u=1,x=q.z+q.w,E=j.z+j.w,o=-q.z+q.w,z=-j.z+j.w;if(x>=0&&E>=0&&o>=0&&z>=0)return true;else if(x<0&&E<0||o<0&&z<0)return false;else{if(x<0)h=Math.max(h,x/(x-E));else if(E<0)u=Math.min(u,x/(x-E));if(o<0)h=Math.max(h,o/(o-z));else if(z<0)u=Math.min(u,o/(o-z));if(u0&&o.z<1}I=I.faces;x=0;for(E=I.length;x0&&D.z<1){r=M[G]=M[G]||new THREE.RenderableParticle; -r.x=D.x/D.w;r.y=D.y/D.w;r.z=D.z;r.rotation=t.rotation.z;r.scale.x=t.scale.x*Math.abs(r.x-(D.x+j.projectionMatrix.n11)/(D.w+j.projectionMatrix.n14));r.scale.y=t.scale.y*Math.abs(r.y-(D.y+j.projectionMatrix.n22)/(D.w+j.projectionMatrix.n24));r.material=t.material;f.push(r);G++}}}}f.sort(b);return f};this.unprojectVector=function(q,j){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(j.matrix),THREE.Matrix4.makeInvert(j.projectionMatrix));h.multiplyVector3(q);return q}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,p;this.domElement=document.createElement("div");this.setSize=function(k,l){f=k;d=l;i=f/2;p=d/2};this.render=function(k,l){var n,c,C,A,y,r,G,M;a=b.projectScene(k,l);n=0;for(c=a.length;n0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,Q);Y.normalize();W=J.dot(Y)*ba;if(W>0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}}}function La(v,Q,J){if(J.opacity!=0){Ba(J.opacity);wa(J.blending);var B,H,W,$,ba,ca;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){$=J.map;ba=$.width>>1;ca=$.height>>1;H=Q.scale.x*p;W=Q.scale.y*k;J=H*ba;B=W*ca;s.set(v.x-J,v.y-B,v.x+J,v.y+B);if(I.instersects(s)){l.save();l.translate(v.x,v.y);l.rotate(-Q.rotation); -l.scale(H,-W);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}else if(J instanceof THREE.ParticleCircleMaterial){if(N){S.r=L.r+T.r+aa.r;S.g=L.g+T.g+aa.g;S.b=L.b+T.b+aa.b;g.r=J.color.r*S.r;g.g=J.color.g*S.g;g.b=J.color.b*S.b;g.updateStyleString()}else g.__styleString=J.color.__styleString;J=Q.scale.x*p;B=Q.scale.y*k;s.set(v.x-J,v.y-B,v.x+J,v.y+B);if(I.instersects(s)){H=g.__styleString;if(A!=H)l.fillStyle=A=H;l.save();l.translate(v.x,v.y);l.rotate(-Q.rotation);l.scale(J,B);l.beginPath();l.arc(0, -0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(v,Q,J,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(Q.positionScreen.x,Q.positionScreen.y);l.closePath();if(B instanceof THREE.LineBasicMaterial){g.__styleString=B.color.__styleString;v=B.linewidth;if(y!=v)l.lineWidth=y=v;v=g.__styleString;if(C!=v)l.strokeStyle=C=v;l.stroke();s.inflate(B.linewidth*2)}}}function Fa(v,Q,J,B,H,W){if(H.opacity!=0){Ba(H.opacity);wa(H.blending); -R=v.positionScreen.x;D=v.positionScreen.y;K=Q.positionScreen.x;F=Q.positionScreen.y;e=J.positionScreen.x;m=J.positionScreen.y;l.beginPath();l.moveTo(R,D);l.lineTo(K,F);l.lineTo(e,m);l.lineTo(R,D);l.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,H.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){v= -ua.matrix;Y.copy(B.vertexNormalsWorld[0]);P=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;t=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);U=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;O=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);X=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;V=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;qa(R,D,K,F,e,m,H.env_map.image,P,t,U,O,X,V)}}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString);else if(H instanceof -THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){H.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,H.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!H.wireframe&&H.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){q.r=j.r=h.r=L.r;q.g=j.g=h.g=L.g;q.b=j.b=h.b=L.b;va(W,B.v1.positionWorld,B.vertexNormalsWorld[0],q);va(W,B.v2.positionWorld,B.vertexNormalsWorld[1],j);va(W,B.v3.positionWorld,B.vertexNormalsWorld[2], -h);u.r=(j.r+h.r)*0.5;u.g=(j.g+h.g)*0.5;u.b=(j.b+h.b)*0.5;z=Ga(q,j,h,u);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else{S.r=L.r;S.g=L.g;S.b=L.b;va(W,B.centroidWorld,B.normalWorld,S);g.r=H.color.r*S.r;g.g=H.color.g*S.g;g.b=H.color.b*S.b;g.updateStyleString();H.wireframe?xa(g.__styleString,H.wireframe_linewidth):ya(g.__styleString)}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){x=H.__2near;E=H.__farPlusNear;o=H.__farMinusNear; -q.r=q.g=q.b=1-x/(E-v.positionScreen.z*o);j.r=j.g=j.b=1-x/(E-Q.positionScreen.z*o);h.r=h.g=h.b=1-x/(E-J.positionScreen.z*o);u.r=(j.r+h.r)*0.5;u.g=(j.g+h.g)*0.5;u.b=(j.b+h.b)*0.5;z=Ga(q,j,h,u);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){g.r=Ca(B.normalWorld.x);g.g=Ca(B.normalWorld.y);g.b=Ca(B.normalWorld.z);g.updateStyleString();H.wireframe?xa(g.__styleString,H.wireframe_linewidth):ya(g.__styleString)}}}function xa(v,Q){if(C!=v)l.strokeStyle=C=v;if(y!=Q)l.lineWidth= -y=Q;l.stroke();s.inflate(Q*2)}function ya(v){if(A!=v)l.fillStyle=A=v;l.fill()}function qa(v,Q,J,B,H,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;J-=v;B-=Q;H-=v;W-=Q;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*J-ea*H)*ja;ea=(ra*B-ea*W)*ja;J=(ha*H-ia*J)*ja;B=(ha*W-ia*B)*ja;v=v-ka*ba-J*ca;Q=Q-ea*ba-B*ca;l.save();l.transform(ka,ea,J,B,v,Q);l.clip();l.drawImage($,0,0);l.restore()}function Ba(v){if(n!=v)l.globalAlpha=n=v}function wa(v){if(c!= -v){switch(v){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=v}}function Ga(v,Q,J,B){var H=~~(v.r*255),W=~~(v.g*255);v=~~(v.b*255);var $=~~(Q.r*255),ba=~~(Q.g*255);Q=~~(Q.b*255);var ca=~~(J.r*255),ha=~~(J.g*255);J=~~(J.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=H<0?0:H>255?255:H;da[1]=W<0?0:W>255?255:W;da[2]=v<0?0:v> -255?255:v;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=Q<0?0:Q>255?255:Q;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=J<0?0:J>255?255:J;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Da(v,Q){var J=Q.x-v.x,B=Q.y-v.y,H=1/Math.sqrt(J*J+B*B);J*=H;B*=H;Q.x+=J;Q.y+=B;v.x-=J;v.y-=B}var za,Ha,Z,fa,ma,Ea,Ia,sa;l.setTransform(1,0,0,-1, -p,k);this.autoClear&&this.clear();a=b.projectScene(ga,ua);(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}else if(s instanceof THREE.PointLight){h.sub(s.position,X.centroidWorld);h.normalize();N=X.normalWorld.dot(h)*s.intensity;if(N>0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}}}function b(O,X,V,I,w,s){o=d(z++);o.setAttribute("d","M "+O.positionScreen.x+ -" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(s,I,e);F.r=w.color.r*e.r;F.g=w.color.g*e.g;F.b=w.color.b*e.b;F.updateStyleString()}else F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){j=1-w.__2near/(w.__farPlusNear-I.z*w.__farMinusNear); -F.setRGB(j,j,j)}else w instanceof THREE.MeshNormalMaterial&&F.setRGB(i(I.normalWorld.x),i(I.normalWorld.y),i(I.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(o)}function f(O,X,V,I,w,s,N){o=d(z++);o.setAttribute("d", -"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(N,w,e);F.r=s.color.r*e.r;F.g=s.color.g*e.g;F.b=s.color.b*e.b;F.updateStyleString()}else F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){j= -1-s.__2near/(s.__farPlusNear-w.z*s.__farMinusNear);F.setRGB(j,j,j)}else s instanceof THREE.MeshNormalMaterial&&F.setRGB(i(w.normalWorld.x),i(w.normalWorld.y),i(w.normalWorld.z));s.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+s.opacity);l.appendChild(o)} -function d(O){if(u[O]==null){u[O]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&u[O].setAttribute("shape-rendering","crispEdges");return u[O]}return u[O]}function i(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var p=null,k=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,C,A,y,r,G,M,R=new THREE.Rectangle,D=new THREE.Rectangle,K=false,F=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),g=new THREE.Color(0), -q=new THREE.Color(0),j,h=new THREE.Vector3,u=[],x=[],E=[],o,z,P,t,U=1;this.domElement=l;this.autoClear=true;this.setQuality=function(O){switch(O){case "high":U=1;break;case "low":U=0}};this.setSize=function(O,X){n=O;c=X;C=n/2;A=c/2;l.setAttribute("viewBox",-C+" "+-A+" "+n+" "+c);l.setAttribute("width",n);l.setAttribute("height",c);R.set(-C,-A,C,A)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(O,X){var V,I,w,s,N,S,L,T;this.autoClear&&this.clear(); -p=k.projectScene(O,X);t=P=z=0;if(K=O.lights.length>0){L=O.lights;m.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);V=0;for(I=L.length;V0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(g,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ -e));c.attachShader(g,k("vertex",q+m));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function f(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, -c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, +THREE.Projector=function(){function a(f,p){var k=0,i=1,o=f.z+f.w,C=p.z+p.w,u=-f.z+f.w,t=-p.z+p.w;if(o>=0&&C>=0&&u>=0&&t>=0)return true;else if(o<0&&C<0||u<0&&t<0)return false;else{if(o<0)k=Math.max(k,o/(o-C));else if(C<0)i=Math.min(i,o/(o-C));if(u<0)k=Math.max(k,u/(u-t));else if(t<0)i=Math.min(i,u/(u-t));if(i0&&u.z<1}T=T.faces;o=0;for(C=T.length;o0&&K.z<1){s=N[G]=N[G]||new THREE.RenderableParticle; +s.x=K.x/K.w;s.y=K.y/K.w;s.z=K.z;s.rotation=B.rotation.z;s.scale.x=B.scale.x*Math.abs(s.x-(K.x+p.projectionMatrix.n11)/(K.w+p.projectionMatrix.n14));s.scale.y=B.scale.y*Math.abs(s.y-(K.y+p.projectionMatrix.n22)/(K.w+p.projectionMatrix.n24));s.material=B.material;g.push(s);G++}}}}g.sort(b);return g};this.unprojectVector=function(f,p){var k=new THREE.Matrix4;k.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));k.multiplyVector3(f);return f}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,h,q;this.domElement=document.createElement("div");this.setSize=function(j,l){g=j;d=l;h=g/2;q=d/2};this.render=function(j,l){var n,c,A,y,x,s,G,N;a=b.projectScene(j,l);n=0;for(c=a.length;n0){z.r+=$.r*V;z.g+=$.g*V;z.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,R);X.normalize();V=L.dot(X)*ba;if(V>0){z.r+=$.r*V;z.g+=$.g*V;z.b+=$.b*V}}}}function La(v,R,L){if(L.opacity!=0){Ba(L.opacity);wa(L.blending);var z,H,V,$,ba,ca;if(L instanceof THREE.ParticleBasicMaterial){if(L.map){$=L.map;ba=$.width>>1;ca=$.height>>1;H=R.scale.x*q;V=R.scale.y*j;L=H*ba;z=V*ca;w.set(v.x-L,v.y-z,v.x+L,v.y+z);if(F.instersects(w)){l.save();l.translate(v.x,v.y);l.rotate(-R.rotation); +l.scale(H,-V);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}else if(L instanceof THREE.ParticleCircleMaterial){if(Q){Y.r=M.r+S.r+aa.r;Y.g=M.g+S.g+aa.g;Y.b=M.b+S.b+aa.b;f.r=L.color.r*Y.r;f.g=L.color.g*Y.g;f.b=L.color.b*Y.b;f.updateStyleString()}else f.__styleString=L.color.__styleString;L=R.scale.x*q;z=R.scale.y*j;w.set(v.x-L,v.y-z,v.x+L,v.y+z);if(F.instersects(w)){H=f.__styleString;if(y!=H)l.fillStyle=y=H;l.save();l.translate(v.x,v.y);l.rotate(-R.rotation);l.scale(L,z);l.beginPath();l.arc(0, +0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(v,R,L,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(R.positionScreen.x,R.positionScreen.y);l.closePath();if(z instanceof THREE.LineBasicMaterial){f.__styleString=z.color.__styleString;v=z.linewidth;if(x!=v)l.lineWidth=x=v;v=f.__styleString;if(A!=v)l.strokeStyle=A=v;l.stroke();w.inflate(z.linewidth*2)}}}function Fa(v,R,L,z,H,V){if(H.opacity!=0){Ba(H.opacity);wa(H.blending); +K=v.positionScreen.x;J=v.positionScreen.y;O=R.positionScreen.x;D=R.positionScreen.y;e=L.positionScreen.x;m=L.positionScreen.y;l.beginPath();l.moveTo(K,J);l.lineTo(O,D);l.lineTo(e,m);l.lineTo(K,J);l.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,D,e,m,H.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){v= +ua.matrix;X.copy(z.vertexNormalsWorld[0]);B=(X.x*v.n11+X.y*v.n12+X.z*v.n13)*0.5+0.5;E=-(X.x*v.n21+X.y*v.n22+X.z*v.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[1]);U=(X.x*v.n11+X.y*v.n12+X.z*v.n13)*0.5+0.5;P=-(X.x*v.n21+X.y*v.n22+X.z*v.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[2]);W=(X.x*v.n11+X.y*v.n12+X.z*v.n13)*0.5+0.5;T=-(X.x*v.n21+X.y*v.n22+X.z*v.n23)*0.5+0.5;qa(K,J,O,D,e,m,H.env_map.image,B,E,U,P,W,T)}}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString);else if(H instanceof +THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,D,e,m,H.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(Q)if(!H.wireframe&&H.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){p.r=k.r=i.r=M.r;p.g=k.g=i.g=M.g;p.b=k.b=i.b=M.b;va(V,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(V,z.v2.positionWorld,z.vertexNormalsWorld[1],k);va(V,z.v3.positionWorld,z.vertexNormalsWorld[2], +i);o.r=(k.r+i.r)*0.5;o.g=(k.g+i.g)*0.5;o.b=(k.b+i.b)*0.5;I=Ga(p,k,i,o);qa(K,J,O,D,e,m,I,0,0,1,0,0,1)}else{Y.r=M.r;Y.g=M.g;Y.b=M.b;va(V,z.centroidWorld,z.normalWorld,Y);f.r=H.color.r*Y.r;f.g=H.color.g*Y.g;f.b=H.color.b*Y.b;f.updateStyleString();H.wireframe?xa(f.__styleString,H.wireframe_linewidth):ya(f.__styleString)}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){C=H.__2near;u=H.__farPlusNear;t=H.__farMinusNear; +p.r=p.g=p.b=1-C/(u-v.positionScreen.z*t);k.r=k.g=k.b=1-C/(u-R.positionScreen.z*t);i.r=i.g=i.b=1-C/(u-L.positionScreen.z*t);o.r=(k.r+i.r)*0.5;o.g=(k.g+i.g)*0.5;o.b=(k.b+i.b)*0.5;I=Ga(p,k,i,o);qa(K,J,O,D,e,m,I,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){f.r=Ca(z.normalWorld.x);f.g=Ca(z.normalWorld.y);f.b=Ca(z.normalWorld.z);f.updateStyleString();H.wireframe?xa(f.__styleString,H.wireframe_linewidth):ya(f.__styleString)}}}function xa(v,R){if(A!=v)l.strokeStyle=A=v;if(x!=R)l.lineWidth= +x=R;l.stroke();w.inflate(R*2)}function ya(v){if(y!=v)l.fillStyle=y=v;l.fill()}function qa(v,R,L,z,H,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;L-=v;z-=R;H-=v;V-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*L-ea*H)*ja;ea=(ra*z-ea*V)*ja;L=(ha*H-ia*L)*ja;z=(ha*V-ia*z)*ja;v=v-ka*ba-L*ca;R=R-ea*ba-z*ca;l.save();l.transform(ka,ea,L,z,v,R);l.clip();l.drawImage($,0,0);l.restore()}function Ba(v){if(n!=v)l.globalAlpha=n=v}function wa(v){if(c!= +v){switch(v){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=v}}function Ga(v,R,L,z){var H=~~(v.r*255),V=~~(v.g*255);v=~~(v.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b*255);var ca=~~(L.r*255),ha=~~(L.g*255);L=~~(L.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=H<0?0:H>255?255:H;da[1]=V<0?0:V>255?255:V;da[2]=v<0?0:v> +255?255:v;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=L<0?0:L>255?255:L;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Da(v,R){var L=R.x-v.x,z=R.y-v.y,H=1/Math.sqrt(L*L+z*z);L*=H;z*=H;R.x+=L;R.y+=z;v.x-=L;v.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;l.setTransform(1,0,0,-1, +q,j);this.autoClear&&this.clear();a=b.projectScene(ga,ua);(Q=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){T.r+=w.color.r*Q;T.g+=w.color.g*Q;T.b+=w.color.b*Q}}else if(w instanceof THREE.PointLight){i.sub(w.position,W.centroidWorld);i.normalize();Q=W.normalWorld.dot(i)*w.intensity;if(Q>0){T.r+=w.color.r*Q;T.g+=w.color.g*Q;T.b+=w.color.b*Q}}}}function b(P,W,T,F,r,w){t=d(I++);t.setAttribute("d","M "+P.positionScreen.x+ +" "+P.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(r instanceof THREE.MeshBasicMaterial)D.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshLambertMaterial)if(O){e.r=m.r;e.g=m.g;e.b=m.b;a(w,F,e);D.r=r.color.r*e.r;D.g=r.color.g*e.g;D.b=r.color.b*e.b;D.updateStyleString()}else D.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){k=1-r.__2near/(r.__farPlusNear-F.z*r.__farMinusNear); +D.setRGB(k,k,k)}else r instanceof THREE.MeshNormalMaterial&&D.setRGB(h(F.normalWorld.x),h(F.normalWorld.y),h(F.normalWorld.z));r.wireframe?t.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):t.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+r.opacity);l.appendChild(t)}function g(P,W,T,F,r,w,Q){t=d(I++);t.setAttribute("d", +"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)D.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(O){e.r=m.r;e.g=m.g;e.b=m.b;a(Q,r,e);D.r=w.color.r*e.r;D.g=w.color.g*e.g;D.b=w.color.b*e.b;D.updateStyleString()}else D.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){k= +1-w.__2near/(w.__farPlusNear-r.z*w.__farMinusNear);D.setRGB(k,k,k)}else w instanceof THREE.MeshNormalMaterial&&D.setRGB(h(r.normalWorld.x),h(r.normalWorld.y),h(r.normalWorld.z));w.wireframe?t.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):t.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(t)} +function d(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function h(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var q=null,j=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,A,y,x,s,G,N,K=new THREE.Rectangle,J=new THREE.Rectangle,O=false,D=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),f=new THREE.Color(0), +p=new THREE.Color(0),k,i=new THREE.Vector3,o=[],C=[],u=[],t,I,B,E,U=1;this.domElement=l;this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,W){n=P;c=W;A=n/2;y=c/2;l.setAttribute("viewBox",-A+" "+-y+" "+n+" "+c);l.setAttribute("width",n);l.setAttribute("height",c);K.set(-A,-y,A,y)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(P,W){var T,F,r,w,Q,Y,M,S;this.autoClear&&this.clear(); +q=j.projectScene(P,W);E=B=I=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);T=0;for(F=M.length;T0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(f,j("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +e));c.attachShader(f,j("vertex",p+m));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,l(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,l(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,l(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,l(e.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function i(e,m){var g,q,j;g=0;for(q=m.length;g=0&&c.enableVertexAttribArray(e.attributes[j])}}function k(e,m){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER); -c.shaderSource(g,m);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function l(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; -case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,C,A,y=new THREE.Matrix4,r,G=new Float32Array(16),M=new Float32Array(16),R=new Float32Array(16),D=new Float32Array(9),K=new Float32Array(16);a=function(e,m){if(e){var g,q,j,h=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=e.lights.length;g=0&&c.enableVertexAttribArray(e.attributes[k])}}function j(e,m){var f;if(e=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")f=c.createShader(c.VERTEX_SHADER); +c.shaderSource(f,m);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function l(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; +case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,A,y,x=new THREE.Matrix4,s,G=new Float32Array(16),N=new Float32Array(16),K=new Float32Array(16),J=new Float32Array(9),O=new Float32Array(16);a=function(e,m){if(e){var f,p,k,i=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=e.lights.length;f= 0.0 )": "",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": "",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -g=b(q,g);c.useProgram(g);i(g,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&i(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(g,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);p(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(e,m){n.width=e;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var g,q,j,h,u,x=[], -E=[],o=[];h=[];u=[];c.uniform1i(e.uniforms.enableLighting,m.length);g=0;for(q=m.length;g0){w.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}w.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);w.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -w.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);w.__webGLFaceCount=P.length;w.__webGLLineCount=t.length}};this.renderBuffer=function(e,m,g,q){var j,h,u,x,E,o,z,P,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)z.push(t);i(g.program,z);p(g.program,["position","normal","uv","tangent"])}t= -g.program}else t=A;if(t!=C){c.useProgram(t);C=t}t==A&&this.setupLights(t,m);this.loadCamera(t,e);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){u=g.wireframe;x=g.wireframe_linewidth;e=t;m=g.uniforms;var U;for(j in m){P=m[j].type;z=m[j].value;U=e.uniforms[j];if(P=="i")c.uniform1i(U,z);else if(P=="f")c.uniform1f(U,z);else if(P=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(P=="c")c.uniform3f(U,z.r,z.g,z.b);else if(P=="t"){c.uniform1i(U,z);if(P=m[j].texture)P.image instanceof Array&&P.image.length== -6?f(P,z):d(P,z)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){j=g.color;h=g.opacity;u=g.wireframe;x=g.wireframe_linewidth;E=g.map;o=g.env_map;m=g.combine==THREE.MixOperation;e=g.reflectivity;P=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;z=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,j.r*h,j.g*h,j.b*h,h);c.uniform1i(t.uniforms.mixEnvMap,m);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract, -P);c.uniform1f(t.uniforms.mRefractionRatio,z)}if(g instanceof THREE.MeshNormalMaterial){h=g.opacity;c.uniform1f(t.uniforms.mOpacity,h);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){h=g.opacity;u=g.wireframe;x=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,h);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof -THREE.MeshPhongMaterial){j=g.ambient;e=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,j.r,j.g,j.b,h);c.uniform4f(t.uniforms.mSpecular,e.r,e.g,e.b,h);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);o=g.env_map}if(E){d(E,0);c.uniform1i(t.uniforms.tMap, -0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(o){f(o,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);h=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);if(h.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0)}if(h.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); -c.vertexAttribPointer(h.tangent,4,c.FLOAT,false,0,0)}if(h.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(h.uv);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(h.uv);if(u){c.lineWidth(x);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, -0)}};this.renderPass=function(e,m,g,q,j,h){var u,x,E,o,z;E=0;for(o=g.material.length;E=0;g--){q=e.__webGLObjects[g].object;m==q&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();y.multiply(m.matrix,e.matrix);M.set(y.flatten());r=THREE.Matrix4.makeInvert3x3(y).transpose();D.set(r.m);K.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix, -false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,R);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,D);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,K)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, +f=b(p,f);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&h(f,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);q(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(e,m){n.width=e;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var f,p,k,i,o,C=[], +u=[],t=[];i=[];o=[];c.uniform1i(e.uniforms.enableLighting,m.length);f=0;for(p=m.length;f0){r.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}r.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(B),c.STATIC_DRAW);r.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +r.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),c.STATIC_DRAW);r.__webGLFaceCount=B.length;r.__webGLLineCount=E.length}};this.renderBuffer=function(e,m,f,p){var k,i,o,C,u,t,I,B,E;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in f.uniforms)I.push(E);h(f.program,I);q(f.program,["position","normal","uv","tangent"])}E= +f.program}else E=y;if(E!=A){c.useProgram(E);A=E}E==y&&this.setupLights(E,m);this.loadCamera(E,e);this.loadMatrices(E);if(f instanceof THREE.MeshShaderMaterial){o=f.wireframe;C=f.wireframe_linewidth;e=E;m=f.uniforms;var U;for(k in m){B=m[k].type;I=m[k].value;U=e.uniforms[k];if(B=="i")c.uniform1i(U,I);else if(B=="f")c.uniform1f(U,I);else if(B=="v3")c.uniform3f(U,I.x,I.y,I.z);else if(B=="c")c.uniform3f(U,I.r,I.g,I.b);else if(B=="t"){c.uniform1i(U,I);if(B=m[k].texture)B.image instanceof Array&&B.image.length== +6?g(B,I):d(B,I)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){k=f.color;i=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;u=f.map;t=f.env_map;m=f.combine==THREE.MixOperation;e=f.reflectivity;B=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;I=f.refraction_ratio;c.uniform4f(E.uniforms.mColor,k.r*i,k.g*i,k.b*i,i);c.uniform1i(E.uniforms.mixEnvMap,m);c.uniform1f(E.uniforms.mReflectivity,e);c.uniform1i(E.uniforms.useRefract, +B);c.uniform1f(E.uniforms.mRefractionRatio,I)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(E.uniforms.mOpacity,i);c.uniform1i(E.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,i);c.uniform1f(E.uniforms.m2Near,f.__2near);c.uniform1f(E.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(f instanceof +THREE.MeshPhongMaterial){k=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(E.uniforms.mAmbient,k.r,k.g,k.b,i);c.uniform4f(E.uniforms.mSpecular,e.r,e.g,e.b,i);c.uniform1f(E.uniforms.mShininess,f);c.uniform1i(E.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);t=f.env_map}if(u){d(u,0);c.uniform1i(E.uniforms.tMap, +0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(t){g(t,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);i=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); +c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(o){c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(e,m,f,p,k,i){var o,C,u,t,I;u=0;for(t=f.material.length;u=0;f--){p=e.__webGLObjects[f].object;m==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(m.matrix,e.matrix);N.set(x.flatten());s=THREE.Matrix4.makeInvert3x3(x).transpose();J.set(s.m);O.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix, +false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,O)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};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.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index f9b30891..3ec2eace 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,61 +1,61 @@ // ThreeDebug.js r31 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,b,f){this.r=a;this.g=b;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+ +THREE.Color.prototype={setRGB:function(a,b,g){this.r=a;this.g=b;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+ ","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={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},addSelf: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},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0}; -THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;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-=a.x;this.y-=a.y;this.z-=a.z;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,f=this.y,d=this.z;this.x=f*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-f*a.x;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*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= -a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a= +this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,g){this.x=a||0;this.y=b||0;this.z=g||0}; +THREE.Vector3.prototype={set:function(a,b,g){this.x=a;this.y=b;this.z=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;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-=a.x;this.y-=a.y;this.z-=a.z;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,g=this.y,d=this.z;this.x=g*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-g*a.x;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*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= +a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+g*g+a*a)},distanceToSquared:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return b*b+g*g+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a= Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}}; -THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1}; -THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=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+=a.x;this.y+=a.y;this.z+=a.z;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-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; +THREE.Vector4=function(a,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1}; +THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=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+=a.x;this.y+=a.y;this.z+=a.z;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-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,j=[];a=0;for(b=d.length;a0&&R>0&&m+R<1}var f,d,j,p,l,h,n,c,C,A, -y,r=a.geometry,G=r.vertices,M=[];f=0;for(d=r.faces.length;fn?d:n;j=j>c? -j:c}a()};this.add3Points=function(n,c,C,A,y,r){if(h){h=false;b=nC?n>y?n:y:C>y?C:y;j=c>A?c>r?c:r:A>r?A:r}else{b=nC?n>y?n>d?n:d:y>d?y:d:C>y?C>d?C:d:y>d?y:d;j=c>A?c>r?c>j?c:j:r>j?r:j:A>r?A>j?A:j:r>j?r:j}a()};this.addRectangle=function(n){if(h){h=false;b=n.getLeft();f=n.getTop();d=n.getRight();j=n.getBottom()}else{b=bn.getRight()?d:n.getRight();j=j>n.getBottom()?j:n.getBottom()}a()};this.inflate=function(n){b-=n;f-=n;d+=n;j+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();f=f>n.getTop()?f:n.getTop();d=d=0&&Math.min(j,n.getBottom())-Math.max(f,n.getTop())>=0};this.empty=function(){h=true;j=d=f=b=0;a()};this.isEmpty=function(){return h};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+j+", width: "+p+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,f,d,j,p,l,h,n,c,C,A,y,r,G,M){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=j||0;this.n22=p||1;this.n23=l||0;this.n24=h||0;this.n31=n||0;this.n32=c||0;this.n33=C||1;this.n34=A||0;this.n41=y||0;this.n42=r||0;this.n43=G||0;this.n44=M||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,f,d,j,p,l,h,n,c,C,A,y,r,G,M){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=j;this.n22=p;this.n23=l;this.n24=h;this.n31=n;this.n32=c;this.n33=C;this.n34=A;this.n41=y;this.n42=r;this.n43=G;this.n44=M;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= -a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var d=new THREE.Vector3,j=new THREE.Vector3,p=new THREE.Vector3;p.sub(a,b).normalize();d.cross(f,p).normalize();j.cross(p,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=p.x; -this.n32=p.y;this.n33=p.z;this.n34=-p.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,j=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*j;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*j;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,j=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*j;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24* -j;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*j;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*j;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,d=a.n12,j=a.n13,p=a.n14,l=a.n21,h=a.n22,n=a.n23,c=a.n24,C=a.n31,A=a.n32, -y=a.n33,r=a.n34,G=a.n41,M=a.n42,R=a.n43,D=a.n44,K=b.n11,F=b.n12,e=b.n13,m=b.n14,g=b.n21,q=b.n22,k=b.n23,i=b.n24,v=b.n31,x=b.n32,E=b.n33,o=b.n34,z=b.n41,P=b.n42,t=b.n43,U=b.n44;this.n11=f*K+d*g+j*v+p*z;this.n12=f*F+d*q+j*x+p*P;this.n13=f*e+d*k+j*E+p*t;this.n14=f*m+d*i+j*o+p*U;this.n21=l*K+h*g+n*v+c*z;this.n22=l*F+h*q+n*x+c*P;this.n23=l*e+h*k+n*E+c*t;this.n24=l*m+h*i+n*o+c*U;this.n31=C*K+A*g+y*v+r*z;this.n32=C*F+A*q+y*x+r*P;this.n33=C*e+A*k+y*E+r*t;this.n34=C*m+A*i+y*o+r*U;this.n41=G*K+M*g+R*v+D*z; -this.n42=G*F+M*q+R*x+D*P;this.n43=G*e+M*k+R*E+D*t;this.n44=G*m+M*i+R*o+D*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,j=this.n14,p=this.n21,l=this.n22,h=this.n23,n=this.n24,c=this.n31,C=this.n32,A=this.n33,y=this.n34,r=this.n41,G=this.n42,M=this.n43,R=this.n44,D=a.n11,K=a.n21,F=a.n31,e=a.n41,m=a.n12,g=a.n22,q=a.n32,k=a.n42,i=a.n13,v=a.n23,x=a.n33,E=a.n43,o=a.n14,z=a.n24,P=a.n34;a=a.n44;this.n11=b*D+f*K+d*F+j*e;this.n12=b*m+f*g+d*q+j*k;this.n13=b*i+f*v+d*x+j*E;this.n14= -b*o+f*z+d*P+j*a;this.n21=p*D+l*K+h*F+n*e;this.n22=p*m+l*g+h*q+n*k;this.n23=p*i+l*v+h*x+n*E;this.n24=p*o+l*z+h*P+n*a;this.n31=c*D+C*K+A*F+y*e;this.n32=c*m+C*g+A*q+y*k;this.n33=c*i+C*v+A*x+y*E;this.n34=c*o+C*z+A*P+y*a;this.n41=r*D+G*K+M*F+R*e;this.n42=r*m+G*g+M*q+R*k;this.n43=r*i+G*v+M*x+R*E;this.n44=r*o+G*z+M*P+R*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= +THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,i=[];a=0;for(b=d.length;a0&&K>0&&m+K<1}var g,d,i,q,k,h,n,c,A,y, +x,s=a.geometry,G=s.vertices,N=[];g=0;for(d=s.faces.length;gn?d:n;i=i>c? +i:c}a()};this.add3Points=function(n,c,A,y,x,s){if(h){h=false;b=nA?n>x?n:x:A>x?A:x;i=c>y?c>s?c:s:y>s?y:s}else{b=nA?n>x?n>d?n:d:x>d?x:d:A>x?A>d?A:d:x>d?x:d;i=c>y?c>s?c>i?c:i:s>i?s:i:y>s?y>i?y:i:s>i?s:i}a()};this.addRectangle=function(n){if(h){h=false;b=n.getLeft();g=n.getTop();d=n.getRight();i=n.getBottom()}else{b=bn.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d=0&&Math.min(i,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){h=true;i=d=g=b=0;a()};this.isEmpty=function(){return h};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+i+", width: "+q+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,g,d,i,q,k,h,n,c,A,y,x,s,G,N){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=i||0;this.n22=q||1;this.n23=k||0;this.n24=h||0;this.n31=n||0;this.n32=c||0;this.n33=A||1;this.n34=y||0;this.n41=x||0;this.n42=s||0;this.n43=G||0;this.n44=N||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,i,q,k,h,n,c,A,y,x,s,G,N){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=i;this.n22=q;this.n23=k;this.n24=h;this.n31=n;this.n32=c;this.n33=A;this.n34=y;this.n41=x;this.n42=s;this.n43=G;this.n44=N;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,i=new THREE.Vector3,q=new THREE.Vector3;q.sub(a,b).normalize();d.cross(g,q).normalize();i.cross(q,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=q.x; +this.n32=q.y;this.n33=q.z;this.n34=-q.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,i=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24* +i;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*i;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var g=a.n11,d=a.n12,i=a.n13,q=a.n14,k=a.n21,h=a.n22,n=a.n23,c=a.n24,A=a.n31,y=a.n32, +x=a.n33,s=a.n34,G=a.n41,N=a.n42,K=a.n43,J=a.n44,O=b.n11,E=b.n12,e=b.n13,m=b.n14,f=b.n21,p=b.n22,l=b.n23,j=b.n24,o=b.n31,C=b.n32,v=b.n33,t=b.n34,I=b.n41,B=b.n42,F=b.n43,U=b.n44;this.n11=g*O+d*f+i*o+q*I;this.n12=g*E+d*p+i*C+q*B;this.n13=g*e+d*l+i*v+q*F;this.n14=g*m+d*j+i*t+q*U;this.n21=k*O+h*f+n*o+c*I;this.n22=k*E+h*p+n*C+c*B;this.n23=k*e+h*l+n*v+c*F;this.n24=k*m+h*j+n*t+c*U;this.n31=A*O+y*f+x*o+s*I;this.n32=A*E+y*p+x*C+s*B;this.n33=A*e+y*l+x*v+s*F;this.n34=A*m+y*j+x*t+s*U;this.n41=G*O+N*f+K*o+J*I; +this.n42=G*E+N*p+K*C+J*B;this.n43=G*e+N*l+K*v+J*F;this.n44=G*m+N*j+K*t+J*U;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,i=this.n14,q=this.n21,k=this.n22,h=this.n23,n=this.n24,c=this.n31,A=this.n32,y=this.n33,x=this.n34,s=this.n41,G=this.n42,N=this.n43,K=this.n44,J=a.n11,O=a.n21,E=a.n31,e=a.n41,m=a.n12,f=a.n22,p=a.n32,l=a.n42,j=a.n13,o=a.n23,C=a.n33,v=a.n43,t=a.n14,I=a.n24,B=a.n34;a=a.n44;this.n11=b*J+g*O+d*E+i*e;this.n12=b*m+g*f+d*p+i*l;this.n13=b*j+g*o+d*C+i*v;this.n14= +b*t+g*I+d*B+i*a;this.n21=q*J+k*O+h*E+n*e;this.n22=q*m+k*f+h*p+n*l;this.n23=q*j+k*o+h*C+n*v;this.n24=q*t+k*I+h*B+n*a;this.n31=c*J+A*O+y*E+x*e;this.n32=c*m+A*f+y*p+x*l;this.n33=c*j+A*o+y*C+x*v;this.n34=c*t+A*I+y*B+x*a;this.n41=s*J+G*O+N*E+K*e;this.n42=s*m+G*f+N*p+K*l;this.n43=s*j+G*o+N*C+K*v;this.n44=s*t+G*I+N*B+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* -this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,d){var j=b[f];b[f]=b[d]; -b[d]=j}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, -this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d}; -THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),j=Math.sin(b),p=1-d,l=a.x,h=a.y,n=a.z;f.n11=p*l*l+d;f.n12=p*l*h-j*n;f.n13=p*l*n+j*h;f.n21=p*l*h+j*n;f.n22=p*h*h+d;f.n23=p*h*n-j*l;f.n31=p*l*n-j*h;f.n32=p*h*n+j*l;f.n33=p*n*n+d;return f}; +this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var i=b[g];b[g]=b[d]; +b[d]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, +this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d}; +THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),q=1-d,k=a.x,h=a.y,n=a.z;g.n11=q*k*k+d;g.n12=q*k*h-i*n;g.n13=q*k*n+i*h;g.n21=q*k*h+i*n;g.n22=q*h*h+d;g.n23=q*h*n-i*k;g.n31=q*k*n-i*h;g.n32=q*h*n+i*k;g.n33=q*n*n+d;return g}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],p=-b[10]*b[4]+b[6]*b[8],l=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*p+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*j;a.m[3]=b*p;a.m[4]=b*l;a.m[5]=b*h;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*C;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,d,j,p){var l,h,n;l=new THREE.Matrix4;h=2*j/(b-a);n=2*j/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(p+j)/(p-j);j=-2*p*j/(p-j);l.n11=h;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=n;l.n23=f;l.n24=0;l.n31=0;l.n32=0;l.n33=d;l.n34=j;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,f,d){var j;a=f*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,f,d)}; -THREE.Matrix4.makeOrtho=function(a,b,f,d,j,p){var l,h,n,c;l=new THREE.Matrix4;h=b-a;n=f-d;c=p-j;a=(b+a)/h;f=(f+d)/n;j=(p+j)/c;l.n11=2/h;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/n;l.n23=0;l.n24=-f;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-j;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],q=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],A=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*q+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*q;a.m[4]=b*k;a.m[5]=b*h;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*A;return a}; +THREE.Matrix4.makeFrustum=function(a,b,g,d,i,q){var k,h,n;k=new THREE.Matrix4;h=2*i/(b-a);n=2*i/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(q+i)/(q-i);i=-2*q*i/(q-i);k.n11=h;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=n;k.n23=g;k.n24=0;k.n31=0;k.n32=0;k.n33=d;k.n34=i;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,g,d){var i;a=g*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,g,d)}; +THREE.Matrix4.makeOrtho=function(a,b,g,d,i,q){var k,h,n,c;k=new THREE.Matrix4;h=b-a;n=g-d;c=q-i;a=(b+a)/h;g=(g+d)/n;i=(q+i)/c;k.n11=2/h;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/n;k.n23=0;k.n24=-g;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-i;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,b,f,d,j){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,f,d,j,p){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=p instanceof Array?p:[p]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face3=function(a,b,g,d,i){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,g,d,i,q){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=q instanceof Array?q:[q]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(C){var A=[];b=0;for(f=C.length;b65535){c[h].counter+=1;n=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:l,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=p}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,f,d);this.autoUpdateMatrix=true;this.translateX=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);j.cross(j.clone(),this.up);this.position.addSelf(j);this.target.position.addSelf(j)};this.translateZ=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j); -this.position.subSelf(j);this.target.position.subSelf(j)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; +vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(A){var y=[];b=0;for(g=A.length;b65535){c[h].counter+=1;n=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:k,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=q}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i); +this.position.subSelf(i);this.target.position.subSelf(i)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; @@ -85,94 +85,94 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,f,d,j,p){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=p!==undefined?p:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ +THREE.Texture=function(a,b,g,d,i,q){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=q!==undefined?q:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){}; THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; -THREE.Projector=function(){function a(q,k){var i=0,v=1,x=q.z+q.w,E=k.z+k.w,o=-q.z+q.w,z=-k.z+k.w;if(x>=0&&E>=0&&o>=0&&z>=0)return true;else if(x<0&&E<0||o<0&&z<0)return false;else{if(x<0)i=Math.max(i,x/(x-E));else if(E<0)v=Math.min(v,x/(x-E));if(o<0)i=Math.max(i,o/(o-z));else if(z<0)v=Math.min(v,o/(o-z));if(v0&&o.z<1}H=H.faces;x=0;for(E=H.length;x0&&D.z<1){r=M[G]=M[G]||new THREE.RenderableParticle; -r.x=D.x/D.w;r.y=D.y/D.w;r.z=D.z;r.rotation=t.rotation.z;r.scale.x=t.scale.x*Math.abs(r.x-(D.x+k.projectionMatrix.n11)/(D.w+k.projectionMatrix.n14));r.scale.y=t.scale.y*Math.abs(r.y-(D.y+k.projectionMatrix.n22)/(D.w+k.projectionMatrix.n24));r.material=t.material;f.push(r);G++}}}}f.sort(b);return f};this.unprojectVector=function(q,k){var i=new THREE.Matrix4;i.multiply(THREE.Matrix4.makeInvert(k.matrix),THREE.Matrix4.makeInvert(k.projectionMatrix));i.multiplyVector3(q);return q}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,j,p;this.domElement=document.createElement("div");this.setSize=function(l,h){f=l;d=h;j=f/2;p=d/2};this.render=function(l,h){var n,c,C,A,y,r,G,M;a=b.projectScene(l,h);n=0;for(c=a.length;n0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,Q);Y.normalize();W=J.dot(Y)*ba;if(W>0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}}}function La(u,Q,J){if(J.opacity!=0){Ba(J.opacity);wa(J.blending);var B,I,W,$,ba,ca;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){$=J.map;ba=$.width>>1;ca=$.height>>1;I=Q.scale.x*p;W=Q.scale.y*l;J=I*ba;B=W*ca;s.set(u.x-J,u.y-B,u.x+J,u.y+B);if(!H.instersects(s))return;h.save();h.translate(u.x,u.y);h.rotate(-Q.rotation); -h.scale(I,-W);h.translate(-ba,-ca);h.drawImage($,0,0);h.restore()}h.beginPath();h.moveTo(u.x-10,u.y);h.lineTo(u.x+10,u.y);h.moveTo(u.x,u.y-10);h.lineTo(u.x,u.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}else if(J instanceof THREE.ParticleCircleMaterial){if(N){S.r=L.r+T.r+aa.r;S.g=L.g+T.g+aa.g;S.b=L.b+T.b+aa.b;g.r=J.color.r*S.r;g.g=J.color.g*S.g;g.b=J.color.b*S.b;g.updateStyleString()}else g.__styleString=J.color.__styleString;J=Q.scale.x*p;B=Q.scale.y*l;s.set(u.x-J,u.y-B,u.x+J,u.y+ -B);if(H.instersects(s)){I=g.__styleString;if(A!=I)h.fillStyle=A=I;h.save();h.translate(u.x,u.y);h.rotate(-Q.rotation);h.scale(J,B);h.beginPath();h.arc(0,0,1,0,Ja,true);h.closePath();h.fill();h.restore()}}}}function Ma(u,Q,J,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);h.beginPath();h.moveTo(u.positionScreen.x,u.positionScreen.y);h.lineTo(Q.positionScreen.x,Q.positionScreen.y);h.closePath();if(B instanceof THREE.LineBasicMaterial){g.__styleString=B.color.__styleString;u=B.linewidth;if(y!=u)h.lineWidth= -y=u;u=g.__styleString;if(C!=u)h.strokeStyle=C=u;h.stroke();s.inflate(B.linewidth*2)}}}function Fa(u,Q,J,B,I,W){if(I.opacity!=0){Ba(I.opacity);wa(I.blending);R=u.positionScreen.x;D=u.positionScreen.y;K=Q.positionScreen.x;F=Q.positionScreen.y;e=J.positionScreen.x;m=J.positionScreen.y;h.beginPath();h.moveTo(R,D);h.lineTo(K,F);h.lineTo(e,m);h.lineTo(R,D);h.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,I.map.image, -B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){u=ua.matrix;Y.copy(B.vertexNormalsWorld[0]);P=(Y.x*u.n11+Y.y*u.n12+Y.z*u.n13)*0.5+0.5;t=-(Y.x*u.n21+Y.y*u.n22+Y.z*u.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);U=(Y.x*u.n11+Y.y*u.n12+Y.z*u.n13)*0.5+0.5;O=-(Y.x*u.n21+Y.y*u.n22+Y.z*u.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);X=(Y.x*u.n11+Y.y*u.n12+Y.z*u.n13)*0.5+0.5;V=-(Y.x* -u.n21+Y.y*u.n22+Y.z*u.n23)*0.5+0.5;qa(R,D,K,F,e,m,I.env_map.image,P,t,U,O,X,V)}}else I.wireframe?xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,I.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){q.r=k.r= -i.r=L.r;q.g=k.g=i.g=L.g;q.b=k.b=i.b=L.b;va(W,B.v1.positionWorld,B.vertexNormalsWorld[0],q);va(W,B.v2.positionWorld,B.vertexNormalsWorld[1],k);va(W,B.v3.positionWorld,B.vertexNormalsWorld[2],i);v.r=(k.r+i.r)*0.5;v.g=(k.g+i.g)*0.5;v.b=(k.b+i.b)*0.5;z=Ga(q,k,i,v);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else{S.r=L.r;S.g=L.g;S.b=L.b;va(W,B.centroidWorld,B.normalWorld,S);g.r=I.color.r*S.r;g.g=I.color.g*S.g;g.b=I.color.b*S.b;g.updateStyleString();I.wireframe?xa(g.__styleString,I.wireframe_linewidth):ya(g.__styleString)}else I.wireframe? -xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){x=I.__2near;E=I.__farPlusNear;o=I.__farMinusNear;q.r=q.g=q.b=1-x/(E-u.positionScreen.z*o);k.r=k.g=k.b=1-x/(E-Q.positionScreen.z*o);i.r=i.g=i.b=1-x/(E-J.positionScreen.z*o);v.r=(k.r+i.r)*0.5;v.g=(k.g+i.g)*0.5;v.b=(k.b+i.b)*0.5;z=Ga(q,k,i,v);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){g.r=Ca(B.normalWorld.x);g.g=Ca(B.normalWorld.y);g.b=Ca(B.normalWorld.z); -g.updateStyleString();I.wireframe?xa(g.__styleString,I.wireframe_linewidth):ya(g.__styleString)}}}function xa(u,Q){if(C!=u)h.strokeStyle=C=u;if(y!=Q)h.lineWidth=y=Q;h.stroke();s.inflate(Q*2)}function ya(u){if(A!=u)h.fillStyle=A=u;h.fill()}function qa(u,Q,J,B,I,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;J-=u;B-=Q;I-=u;W-=Q;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*J-ea*I)*ja;ea=(ra*B-ea*W)*ja;J=(ha*I-ia*J)*ja;B=(ha*W-ia*B)*ja;u= -u-ka*ba-J*ca;Q=Q-ea*ba-B*ca;h.save();h.transform(ka,ea,J,B,u,Q);h.clip();h.drawImage($,0,0);h.restore()}function Ba(u){if(n!=u)h.globalAlpha=n=u}function wa(u){if(c!=u){switch(u){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=u}}function Ga(u,Q,J,B){var I=~~(u.r*255),W=~~(u.g*255);u=~~(u.b*255);var $=~~(Q.r*255),ba=~~(Q.g*255);Q=~~(Q.b* -255);var ca=~~(J.r*255),ha=~~(J.g*255);J=~~(J.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=I<0?0:I>255?255:I;da[1]=W<0?0:W>255?255:W;da[2]=u<0?0:u>255?255:u;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=Q<0?0:Q>255?255:Q;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=J<0?0:J>255?255:J;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(u){u=(u+1)*0.5;return u<0? -0:u>1?1:u}function Da(u,Q){var J=Q.x-u.x,B=Q.y-u.y,I=1/Math.sqrt(J*J+B*B);J*=I;B*=I;Q.x+=J;Q.y+=B;u.x-=J;u.y-=B}var za,Ha,Z,fa,ma,Ea,Ia,sa;h.setTransform(1,0,0,-1,p,l);this.autoClear&&this.clear();a=b.projectScene(ga,ua);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(H.getX(),H.getY(),H.getWidth(),H.getHeight());(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}else if(s instanceof THREE.PointLight){i.sub(s.position,X.centroidWorld);i.normalize();N=X.normalWorld.dot(i)*s.intensity;if(N>0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}}}function b(O,X,V,H,w,s){o=d(z++);o.setAttribute("d","M "+O.positionScreen.x+ -" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(s,H,e);F.r=w.color.r*e.r;F.g=w.color.g*e.g;F.b=w.color.b*e.b;F.updateStyleString()}else F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){k=1-w.__2near/(w.__farPlusNear-H.z*w.__farMinusNear); -F.setRGB(k,k,k)}else w instanceof THREE.MeshNormalMaterial&&F.setRGB(j(H.normalWorld.x),j(H.normalWorld.y),j(H.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+w.opacity);h.appendChild(o)}function f(O,X,V,H,w,s,N){o=d(z++);o.setAttribute("d", -"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(N,w,e);F.r=s.color.r*e.r;F.g=s.color.g*e.g;F.b=s.color.b*e.b;F.updateStyleString()}else F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){k= -1-s.__2near/(s.__farPlusNear-w.z*s.__farMinusNear);F.setRGB(k,k,k)}else s instanceof THREE.MeshNormalMaterial&&F.setRGB(j(w.normalWorld.x),j(w.normalWorld.y),j(w.normalWorld.z));s.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+s.opacity);h.appendChild(o)} -function d(O){if(v[O]==null){v[O]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&v[O].setAttribute("shape-rendering","crispEdges");return v[O]}return v[O]}function j(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var p=null,l=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,C,A,y,r,G,M,R=new THREE.Rectangle,D=new THREE.Rectangle,K=false,F=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),g=new THREE.Color(0), -q=new THREE.Color(0),k,i=new THREE.Vector3,v=[],x=[],E=[],o,z,P,t,U=1;this.domElement=h;this.autoClear=true;this.setQuality=function(O){switch(O){case "high":U=1;break;case "low":U=0}};this.setSize=function(O,X){n=O;c=X;C=n/2;A=c/2;h.setAttribute("viewBox",-C+" "+-A+" "+n+" "+c);h.setAttribute("width",n);h.setAttribute("height",c);R.set(-C,-A,C,A)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(O,X){var V,H,w,s,N,S,L,T;this.autoClear&&this.clear(); -p=l.projectScene(O,X);t=P=z=0;if(K=O.lights.length>0){L=O.lights;m.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);V=0;for(H=L.length;V0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(g,l("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ -e));c.attachShader(g,l("vertex",q+m));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function f(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, -c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, +THREE.Projector=function(){function a(f,p){var l=0,j=1,o=f.z+f.w,C=p.z+p.w,v=-f.z+f.w,t=-p.z+p.w;if(o>=0&&C>=0&&v>=0&&t>=0)return true;else if(o<0&&C<0||v<0&&t<0)return false;else{if(o<0)l=Math.max(l,o/(o-C));else if(C<0)j=Math.min(j,o/(o-C));if(v<0)l=Math.max(l,v/(v-t));else if(t<0)j=Math.min(j,v/(v-t));if(j0&&v.z<1}T=T.faces;o=0;for(C=T.length;o0&&K.z<1){s=N[G]=N[G]||new THREE.RenderableParticle; +s.x=K.x/K.w;s.y=K.y/K.w;s.z=K.z;s.rotation=B.rotation.z;s.scale.x=B.scale.x*Math.abs(s.x-(K.x+p.projectionMatrix.n11)/(K.w+p.projectionMatrix.n14));s.scale.y=B.scale.y*Math.abs(s.y-(K.y+p.projectionMatrix.n22)/(K.w+p.projectionMatrix.n24));s.material=B.material;g.push(s);G++}}}}g.sort(b);return g};this.unprojectVector=function(f,p){var l=new THREE.Matrix4;l.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));l.multiplyVector3(f);return f}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,q;this.domElement=document.createElement("div");this.setSize=function(k,h){g=k;d=h;i=g/2;q=d/2};this.render=function(k,h){var n,c,A,y,x,s,G,N;a=b.projectScene(k,h);n=0;for(c=a.length;n0){z.r+=$.r*V;z.g+=$.g*V;z.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,R);X.normalize();V=L.dot(X)*ba;if(V>0){z.r+=$.r*V;z.g+=$.g*V;z.b+=$.b*V}}}}function La(u,R,L){if(L.opacity!=0){Ba(L.opacity);wa(L.blending);var z,H,V,$,ba,ca;if(L instanceof THREE.ParticleBasicMaterial){if(L.map){$=L.map;ba=$.width>>1;ca=$.height>>1;H=R.scale.x*q;V=R.scale.y*k;L=H*ba;z=V*ca;w.set(u.x-L,u.y-z,u.x+L,u.y+z);if(!D.instersects(w))return;h.save();h.translate(u.x,u.y);h.rotate(-R.rotation); +h.scale(H,-V);h.translate(-ba,-ca);h.drawImage($,0,0);h.restore()}h.beginPath();h.moveTo(u.x-10,u.y);h.lineTo(u.x+10,u.y);h.moveTo(u.x,u.y-10);h.lineTo(u.x,u.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}else if(L instanceof THREE.ParticleCircleMaterial){if(Q){Y.r=M.r+S.r+aa.r;Y.g=M.g+S.g+aa.g;Y.b=M.b+S.b+aa.b;f.r=L.color.r*Y.r;f.g=L.color.g*Y.g;f.b=L.color.b*Y.b;f.updateStyleString()}else f.__styleString=L.color.__styleString;L=R.scale.x*q;z=R.scale.y*k;w.set(u.x-L,u.y-z,u.x+L,u.y+ +z);if(D.instersects(w)){H=f.__styleString;if(y!=H)h.fillStyle=y=H;h.save();h.translate(u.x,u.y);h.rotate(-R.rotation);h.scale(L,z);h.beginPath();h.arc(0,0,1,0,Ja,true);h.closePath();h.fill();h.restore()}}}}function Ma(u,R,L,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);h.beginPath();h.moveTo(u.positionScreen.x,u.positionScreen.y);h.lineTo(R.positionScreen.x,R.positionScreen.y);h.closePath();if(z instanceof THREE.LineBasicMaterial){f.__styleString=z.color.__styleString;u=z.linewidth;if(x!=u)h.lineWidth= +x=u;u=f.__styleString;if(A!=u)h.strokeStyle=A=u;h.stroke();w.inflate(z.linewidth*2)}}}function Fa(u,R,L,z,H,V){if(H.opacity!=0){Ba(H.opacity);wa(H.blending);K=u.positionScreen.x;J=u.positionScreen.y;O=R.positionScreen.x;E=R.positionScreen.y;e=L.positionScreen.x;m=L.positionScreen.y;h.beginPath();h.moveTo(K,J);h.lineTo(O,E);h.lineTo(e,m);h.lineTo(K,J);h.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,E,e,m,H.map.image, +z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){u=ua.matrix;X.copy(z.vertexNormalsWorld[0]);B=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;F=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[1]);U=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;P=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[2]);W=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;T=-(X.x* +u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;qa(K,J,O,E,e,m,H.env_map.image,B,F,U,P,W,T)}}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,E,e,m,H.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(Q)if(!H.wireframe&&H.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){p.r=l.r= +j.r=M.r;p.g=l.g=j.g=M.g;p.b=l.b=j.b=M.b;va(V,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(V,z.v2.positionWorld,z.vertexNormalsWorld[1],l);va(V,z.v3.positionWorld,z.vertexNormalsWorld[2],j);o.r=(l.r+j.r)*0.5;o.g=(l.g+j.g)*0.5;o.b=(l.b+j.b)*0.5;I=Ga(p,l,j,o);qa(K,J,O,E,e,m,I,0,0,1,0,0,1)}else{Y.r=M.r;Y.g=M.g;Y.b=M.b;va(V,z.centroidWorld,z.normalWorld,Y);f.r=H.color.r*Y.r;f.g=H.color.g*Y.g;f.b=H.color.b*Y.b;f.updateStyleString();H.wireframe?xa(f.__styleString,H.wireframe_linewidth):ya(f.__styleString)}else H.wireframe? +xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){C=H.__2near;v=H.__farPlusNear;t=H.__farMinusNear;p.r=p.g=p.b=1-C/(v-u.positionScreen.z*t);l.r=l.g=l.b=1-C/(v-R.positionScreen.z*t);j.r=j.g=j.b=1-C/(v-L.positionScreen.z*t);o.r=(l.r+j.r)*0.5;o.g=(l.g+j.g)*0.5;o.b=(l.b+j.b)*0.5;I=Ga(p,l,j,o);qa(K,J,O,E,e,m,I,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){f.r=Ca(z.normalWorld.x);f.g=Ca(z.normalWorld.y);f.b=Ca(z.normalWorld.z); +f.updateStyleString();H.wireframe?xa(f.__styleString,H.wireframe_linewidth):ya(f.__styleString)}}}function xa(u,R){if(A!=u)h.strokeStyle=A=u;if(x!=R)h.lineWidth=x=R;h.stroke();w.inflate(R*2)}function ya(u){if(y!=u)h.fillStyle=y=u;h.fill()}function qa(u,R,L,z,H,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;L-=u;z-=R;H-=u;V-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*L-ea*H)*ja;ea=(ra*z-ea*V)*ja;L=(ha*H-ia*L)*ja;z=(ha*V-ia*z)*ja;u= +u-ka*ba-L*ca;R=R-ea*ba-z*ca;h.save();h.transform(ka,ea,L,z,u,R);h.clip();h.drawImage($,0,0);h.restore()}function Ba(u){if(n!=u)h.globalAlpha=n=u}function wa(u){if(c!=u){switch(u){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=u}}function Ga(u,R,L,z){var H=~~(u.r*255),V=~~(u.g*255);u=~~(u.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b* +255);var ca=~~(L.r*255),ha=~~(L.g*255);L=~~(L.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=H<0?0:H>255?255:H;da[1]=V<0?0:V>255?255:V;da[2]=u<0?0:u>255?255:u;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=L<0?0:L>255?255:L;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(u){u=(u+1)*0.5;return u<0? +0:u>1?1:u}function Da(u,R){var L=R.x-u.x,z=R.y-u.y,H=1/Math.sqrt(L*L+z*z);L*=H;z*=H;R.x+=L;R.y+=z;u.x-=L;u.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;h.setTransform(1,0,0,-1,q,k);this.autoClear&&this.clear();a=b.projectScene(ga,ua);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(D.getX(),D.getY(),D.getWidth(),D.getHeight());(Q=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){T.r+=w.color.r*Q;T.g+=w.color.g*Q;T.b+=w.color.b*Q}}else if(w instanceof THREE.PointLight){j.sub(w.position,W.centroidWorld);j.normalize();Q=W.normalWorld.dot(j)*w.intensity;if(Q>0){T.r+=w.color.r*Q;T.g+=w.color.g*Q;T.b+=w.color.b*Q}}}}function b(P,W,T,D,r,w){t=d(I++);t.setAttribute("d","M "+P.positionScreen.x+ +" "+P.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(r instanceof THREE.MeshBasicMaterial)E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshLambertMaterial)if(O){e.r=m.r;e.g=m.g;e.b=m.b;a(w,D,e);E.r=r.color.r*e.r;E.g=r.color.g*e.g;E.b=r.color.b*e.b;E.updateStyleString()}else E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){l=1-r.__2near/(r.__farPlusNear-D.z*r.__farMinusNear); +E.setRGB(l,l,l)}else r instanceof THREE.MeshNormalMaterial&&E.setRGB(i(D.normalWorld.x),i(D.normalWorld.y),i(D.normalWorld.z));r.wireframe?t.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):t.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+r.opacity);h.appendChild(t)}function g(P,W,T,D,r,w,Q){t=d(I++);t.setAttribute("d", +"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(O){e.r=m.r;e.g=m.g;e.b=m.b;a(Q,r,e);E.r=w.color.r*e.r;E.g=w.color.g*e.g;E.b=w.color.b*e.b;E.updateStyleString()}else E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){l= +1-w.__2near/(w.__farPlusNear-r.z*w.__farMinusNear);E.setRGB(l,l,l)}else w instanceof THREE.MeshNormalMaterial&&E.setRGB(i(r.normalWorld.x),i(r.normalWorld.y),i(r.normalWorld.z));w.wireframe?t.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):t.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+w.opacity);h.appendChild(t)} +function d(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function i(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var q=null,k=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,A,y,x,s,G,N,K=new THREE.Rectangle,J=new THREE.Rectangle,O=false,E=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),f=new THREE.Color(0), +p=new THREE.Color(0),l,j=new THREE.Vector3,o=[],C=[],v=[],t,I,B,F,U=1;this.domElement=h;this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,W){n=P;c=W;A=n/2;y=c/2;h.setAttribute("viewBox",-A+" "+-y+" "+n+" "+c);h.setAttribute("width",n);h.setAttribute("height",c);K.set(-A,-y,A,y)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(P,W){var T,D,r,w,Q,Y,M,S;this.autoClear&&this.clear(); +q=k.projectScene(P,W);F=B=I=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);T=0;for(D=M.length;T0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(f,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +e));c.attachShader(f,k("vertex",p+m));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(e.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,m){var g,q,k;g=0;for(q=m.length;g=0&&c.enableVertexAttribArray(e.attributes[k])}}function l(e,m){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER); -c.shaderSource(g,m);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function h(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; -case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,C,A,y=new THREE.Matrix4,r,G=new Float32Array(16),M=new Float32Array(16),R=new Float32Array(16),D=new Float32Array(9),K=new Float32Array(16);a=function(e,m){if(e){var g,q,k,i=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=e.lights.length;g=0&&c.enableVertexAttribArray(e.attributes[l])}}function k(e,m){var f;if(e=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")f=c.createShader(c.VERTEX_SHADER); +c.shaderSource(f,m);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function h(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; +case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,A,y,x=new THREE.Matrix4,s,G=new Float32Array(16),N=new Float32Array(16),K=new Float32Array(16),J=new Float32Array(9),O=new Float32Array(16);a=function(e,m){if(e){var f,p,l,j=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=e.lights.length;f= 0.0 )": "",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": "",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -g=b(q,g);c.useProgram(g);j(g,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&j(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&j(g,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);p(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(e,m){n.width=e;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var g,q,k,i,v,x=[], -E=[],o=[];i=[];v=[];c.uniform1i(e.uniforms.enableLighting,m.length);g=0;for(q=m.length;g0){w.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}w.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);w.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -w.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);w.__webGLFaceCount=P.length;w.__webGLLineCount=t.length}};this.renderBuffer=function(e,m,g,q){var k,i,v,x,E,o,z,P,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)z.push(t);j(g.program,z);p(g.program,["position","normal","uv","tangent"])}t= -g.program}else t=A;if(t!=C){c.useProgram(t);C=t}t==A&&this.setupLights(t,m);this.loadCamera(t,e);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){v=g.wireframe;x=g.wireframe_linewidth;e=t;m=g.uniforms;var U;for(k in m){P=m[k].type;z=m[k].value;U=e.uniforms[k];if(P=="i")c.uniform1i(U,z);else if(P=="f")c.uniform1f(U,z);else if(P=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(P=="c")c.uniform3f(U,z.r,z.g,z.b);else if(P=="t"){c.uniform1i(U,z);if(P=m[k].texture)P.image instanceof Array&&P.image.length== -6?f(P,z):d(P,z)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){k=g.color;i=g.opacity;v=g.wireframe;x=g.wireframe_linewidth;E=g.map;o=g.env_map;m=g.combine==THREE.MixOperation;e=g.reflectivity;P=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;z=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,k.r*i,k.g*i,k.b*i,i);c.uniform1i(t.uniforms.mixEnvMap,m);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract, -P);c.uniform1f(t.uniforms.mRefractionRatio,z)}if(g instanceof THREE.MeshNormalMaterial){i=g.opacity;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){i=g.opacity;v=g.wireframe;x=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof -THREE.MeshPhongMaterial){k=g.ambient;e=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,k.r,k.g,k.b,i);c.uniform4f(t.uniforms.mSpecular,e.r,e.g,e.b,i);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);o=g.env_map}if(E){d(E,0);c.uniform1i(t.uniforms.tMap, -0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(o){f(o,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);i=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); -c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(v){c.lineWidth(x);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, -0)}};this.renderPass=function(e,m,g,q,k,i){var v,x,E,o,z;E=0;for(o=g.material.length;E=0;g--){q=e.__webGLObjects[g].object;m==q&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();y.multiply(m.matrix,e.matrix);M.set(y.flatten());r=THREE.Matrix4.makeInvert3x3(y).transpose();D.set(r.m);K.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix, -false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,R);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,D);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,K)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, +f=b(p,f);c.useProgram(f);i(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&i(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(f,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);q(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(e,m){n.width=e;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var f,p,l,j,o,C=[], +v=[],t=[];j=[];o=[];c.uniform1i(e.uniforms.enableLighting,m.length);f=0;for(p=m.length;f0){r.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}r.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(B),c.STATIC_DRAW);r.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +r.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);r.__webGLFaceCount=B.length;r.__webGLLineCount=F.length}};this.renderBuffer=function(e,m,f,p){var l,j,o,C,v,t,I,B,F;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in f.uniforms)I.push(F);i(f.program,I);q(f.program,["position","normal","uv","tangent"])}F= +f.program}else F=y;if(F!=A){c.useProgram(F);A=F}F==y&&this.setupLights(F,m);this.loadCamera(F,e);this.loadMatrices(F);if(f instanceof THREE.MeshShaderMaterial){o=f.wireframe;C=f.wireframe_linewidth;e=F;m=f.uniforms;var U;for(l in m){B=m[l].type;I=m[l].value;U=e.uniforms[l];if(B=="i")c.uniform1i(U,I);else if(B=="f")c.uniform1f(U,I);else if(B=="v3")c.uniform3f(U,I.x,I.y,I.z);else if(B=="c")c.uniform3f(U,I.r,I.g,I.b);else if(B=="t"){c.uniform1i(U,I);if(B=m[l].texture)B.image instanceof Array&&B.image.length== +6?g(B,I):d(B,I)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){l=f.color;j=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;v=f.map;t=f.env_map;m=f.combine==THREE.MixOperation;e=f.reflectivity;B=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;I=f.refraction_ratio;c.uniform4f(F.uniforms.mColor,l.r*j,l.g*j,l.b*j,j);c.uniform1i(F.uniforms.mixEnvMap,m);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract, +B);c.uniform1f(F.uniforms.mRefractionRatio,I)}if(f instanceof THREE.MeshNormalMaterial){j=f.opacity;c.uniform1f(F.uniforms.mOpacity,j);c.uniform1i(F.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){j=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;c.uniform1f(F.uniforms.mOpacity,j);c.uniform1f(F.uniforms.m2Near,f.__2near);c.uniform1f(F.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(F.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(F.uniforms.material,3)}else if(f instanceof +THREE.MeshPhongMaterial){l=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(F.uniforms.mAmbient,l.r,l.g,l.b,j);c.uniform4f(F.uniforms.mSpecular,e.r,e.g,e.b,j);c.uniform1f(F.uniforms.mShininess,f);c.uniform1i(F.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(F.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(F.uniforms.material,5);t=f.env_map}if(v){d(v,0);c.uniform1i(F.uniforms.tMap, +0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(t){g(t,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);j=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);if(j.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0)}if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); +c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(o){c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(e,m,f,p,l,j){var o,C,v,t,I;v=0;for(t=f.material.length;v=0;f--){p=e.__webGLObjects[f].object;m==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(m.matrix,e.matrix);N.set(x.flatten());s=THREE.Matrix4.makeInvert3x3(x).transpose();J.set(s.m);O.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix, +false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,O)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};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.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 8f54a3f1..983b071e 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,21 +12,21 @@ THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=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+=a.x;this.y+=a.y;this.z+=a.z;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-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,g=[];a=0;for(b=d.length;a0&&N>0&&o+N<1}var e,d,g,l,h,f,j,c,t,y, -s,r=a.geometry,w=r.vertices,B=[];e=0;for(d=r.faces.length;e0&&J>0&&p+J<1}var e,d,g,l,h,f,j,c,t,y, +s,q=a.geometry,x=q.vertices,B=[];e=0;for(d=q.faces.length;ej?d:j;g=g>c? -g:c}a()};this.add3Points=function(j,c,t,y,s,r){if(f){f=false;b=jt?j>s?j:s:t>s?t:s;g=c>y?c>r?c:r:y>r?y:r}else{b=jt?j>s?j>d?j:d:s>d?s:d:t>s?t>d?t:d:s>d?s:d;g=c>y?c>r?c>g?c:g:r>g?r:g:y>r?y>g?y:g:r>g?r:g}a()};this.addRectangle=function(j){if(f){f=false;b=j.getLeft();e=j.getTop();d=j.getRight();g=j.getBottom()}else{b=bt?j>s?j:s:t>s?t:s;g=c>y?c>q?c:q:y>q?y:q}else{b=jt?j>s?j>d?j:d:s>d?s:d:t>s?t>d?t:d:s>d?s:d;g=c>y?c>q?c>g?c:g:q>g?q:g:y>q?y>g?y:g:q>g?q:g}a()};this.addRectangle=function(j){if(f){f=false;b=j.getLeft();e=j.getTop();d=j.getRight();g=j.getBottom()}else{b=bj.getRight()?d:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;d+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e:j.getTop();d=d=0&&Math.min(g,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){f=true;g=d=e=b=0;a()};this.isEmpty=function(){return f};this.toString= function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+g+", width: "+l+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,e,d,g,l,h,f,j,c,t,y,s,r,w,B){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=l||1;this.n23=h||0;this.n24=f||0;this.n31=j||0;this.n32=c||0;this.n33=t||1;this.n34=y||0;this.n41=s||0;this.n42=r||0;this.n43=w||0;this.n44=B||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,g,l,h,f,j,c,t,y,s,r,w,B){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=l;this.n23=h;this.n24=f;this.n31=j;this.n32=c;this.n33=t;this.n34=y;this.n41=s;this.n42=r;this.n43=w;this.n44=B;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Matrix4=function(a,b,e,d,g,l,h,f,j,c,t,y,s,q,x,B){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=l||1;this.n23=h||0;this.n24=f||0;this.n31=j||0;this.n32=c||0;this.n33=t||1;this.n34=y||0;this.n41=s||0;this.n42=q||0;this.n43=x||0;this.n44=B||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,g,l,h,f,j,c,t,y,s,q,x,B){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=l;this.n23=h;this.n24=f;this.n31=j;this.n32=c;this.n33=t;this.n34=y;this.n41=s;this.n42=q;this.n43=x;this.n44=B;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,e){var d=new THREE.Vector3,g=new THREE.Vector3,l=new THREE.Vector3;l.sub(a,b).normalize();d.cross(e,l).normalize();g.cross(l,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=l.x; this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,g=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24* g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var e=a.n11,d=a.n12,g=a.n13,l=a.n14,h=a.n21,f=a.n22,j=a.n23,c=a.n24,t=a.n31,y=a.n32, -s=a.n33,r=a.n34,w=a.n41,B=a.n42,N=a.n43,F=a.n44,A=b.n11,p=b.n12,i=b.n13,o=b.n14,k=b.n21,v=b.n22,n=b.n23,m=b.n24,z=b.n31,G=b.n32,L=b.n33,x=b.n34,J=b.n41,R=b.n42,D=b.n43,V=b.n44;this.n11=e*A+d*k+g*z+l*J;this.n12=e*p+d*v+g*G+l*R;this.n13=e*i+d*n+g*L+l*D;this.n14=e*o+d*m+g*x+l*V;this.n21=h*A+f*k+j*z+c*J;this.n22=h*p+f*v+j*G+c*R;this.n23=h*i+f*n+j*L+c*D;this.n24=h*o+f*m+j*x+c*V;this.n31=t*A+y*k+s*z+r*J;this.n32=t*p+y*v+s*G+r*R;this.n33=t*i+y*n+s*L+r*D;this.n34=t*o+y*m+s*x+r*V;this.n41=w*A+B*k+N*z+F*J; -this.n42=w*p+B*v+N*G+F*R;this.n43=w*i+B*n+N*L+F*D;this.n44=w*o+B*m+N*x+F*V;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,l=this.n21,h=this.n22,f=this.n23,j=this.n24,c=this.n31,t=this.n32,y=this.n33,s=this.n34,r=this.n41,w=this.n42,B=this.n43,N=this.n44,F=a.n11,A=a.n21,p=a.n31,i=a.n41,o=a.n12,k=a.n22,v=a.n32,n=a.n42,m=a.n13,z=a.n23,G=a.n33,L=a.n43,x=a.n14,J=a.n24,R=a.n34;a=a.n44;this.n11=b*F+e*A+d*p+g*i;this.n12=b*o+e*k+d*v+g*n;this.n13=b*m+e*z+d*G+g*L;this.n14= -b*x+e*J+d*R+g*a;this.n21=l*F+h*A+f*p+j*i;this.n22=l*o+h*k+f*v+j*n;this.n23=l*m+h*z+f*G+j*L;this.n24=l*x+h*J+f*R+j*a;this.n31=c*F+t*A+y*p+s*i;this.n32=c*o+t*k+y*v+s*n;this.n33=c*m+t*z+y*G+s*L;this.n34=c*x+t*J+y*R+s*a;this.n41=r*F+w*A+B*p+N*i;this.n42=r*o+w*k+B*v+N*n;this.n43=r*m+w*z+B*G+N*L;this.n44=r*x+w*J+B*R+N*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= +s=a.n33,q=a.n34,x=a.n41,B=a.n42,J=a.n43,H=a.n44,D=b.n11,n=b.n12,i=b.n13,p=b.n14,k=b.n21,w=b.n22,o=b.n23,m=b.n24,v=b.n31,L=b.n32,C=b.n33,A=b.n34,P=b.n41,I=b.n42,M=b.n43,W=b.n44;this.n11=e*D+d*k+g*v+l*P;this.n12=e*n+d*w+g*L+l*I;this.n13=e*i+d*o+g*C+l*M;this.n14=e*p+d*m+g*A+l*W;this.n21=h*D+f*k+j*v+c*P;this.n22=h*n+f*w+j*L+c*I;this.n23=h*i+f*o+j*C+c*M;this.n24=h*p+f*m+j*A+c*W;this.n31=t*D+y*k+s*v+q*P;this.n32=t*n+y*w+s*L+q*I;this.n33=t*i+y*o+s*C+q*M;this.n34=t*p+y*m+s*A+q*W;this.n41=x*D+B*k+J*v+H*P; +this.n42=x*n+B*w+J*L+H*I;this.n43=x*i+B*o+J*C+H*M;this.n44=x*p+B*m+J*A+H*W;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,l=this.n21,h=this.n22,f=this.n23,j=this.n24,c=this.n31,t=this.n32,y=this.n33,s=this.n34,q=this.n41,x=this.n42,B=this.n43,J=this.n44,H=a.n11,D=a.n21,n=a.n31,i=a.n41,p=a.n12,k=a.n22,w=a.n32,o=a.n42,m=a.n13,v=a.n23,L=a.n33,C=a.n43,A=a.n14,P=a.n24,I=a.n34;a=a.n44;this.n11=b*H+e*D+d*n+g*i;this.n12=b*p+e*k+d*w+g*o;this.n13=b*m+e*v+d*L+g*C;this.n14= +b*A+e*P+d*I+g*a;this.n21=l*H+h*D+f*n+j*i;this.n22=l*p+h*k+f*w+j*o;this.n23=l*m+h*v+f*L+j*C;this.n24=l*A+h*P+f*I+j*a;this.n31=c*H+t*D+y*n+s*i;this.n32=c*p+t*k+y*w+s*o;this.n33=c*m+t*v+y*L+s*C;this.n34=c*A+t*P+y*I+s*a;this.n41=q*H+x*D+B*n+J*i;this.n42=q*p+x*k+B*w+J*o;this.n43=q*m+x*v+B*L+J*C;this.n44=q*A+x*P+B*I+J*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,d){var g=b[e];b[e]=b[d]; b[d]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, @@ -47,10 +47,10 @@ THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){ THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +0;for(vl=this.vertices.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var y=[];b=0;for(e=t.length;b65535){c[f].counter+=1;j=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:h,vertices:0}}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; @@ -89,94 +89,94 @@ THREE.Texture=function(a,b,e,d,g,l){this.image=a;this.mapping=b!==undefined?b:ne this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){}; THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; -THREE.Projector=function(){function a(v,n){var m=0,z=1,G=v.z+v.w,L=n.z+n.w,x=-v.z+v.w,J=-n.z+n.w;if(G>=0&&L>=0&&x>=0&&J>=0)return true;else if(G<0&&L<0||x<0&&J<0)return false;else{if(G<0)m=Math.max(m,G/(G-L));else if(L<0)z=Math.min(z,G/(G-L));if(x<0)m=Math.max(m,x/(x-J));else if(J<0)z=Math.min(z,x/(x-J));if(z0&&x.z<1}O=O.faces;G=0;for(L=O.length;G0&&F.z<1){r=B[w]=B[w]||new THREE.RenderableParticle; -r.x=F.x/F.w;r.y=F.y/F.w;r.z=F.z;r.rotation=D.rotation.z;r.scale.x=D.scale.x*Math.abs(r.x-(F.x+n.projectionMatrix.n11)/(F.w+n.projectionMatrix.n14));r.scale.y=D.scale.y*Math.abs(r.y-(F.y+n.projectionMatrix.n22)/(F.w+n.projectionMatrix.n24));r.material=D.material;e.push(r);w++}}}}e.sort(b);return e};this.unprojectVector=function(v,n){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));m.multiplyVector3(v);return v}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,l;this.domElement=document.createElement("div");this.setSize=function(h,f){e=h;d=f;g=e/2;l=d/2};this.render=function(h,f){var j,c,t,y,s,r,w,B;a=b.projectScene(h,f);j=0;for(c=a.length;j0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,U);Y.normalize();Z=Q.dot(Y)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}}}function La(I,U,Q){if(Q.opacity!=0){Ca(Q.opacity);ya(Q.blending);var K,P,Z,ba,ca,da;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){ba=Q.map;ca=ba.width>>1;da=ba.height>>1;P=U.scale.x*l;Z=U.scale.y*h;Q=P*ca;K=Z*da;C.set(I.x-Q,I.y-K,I.x+Q,I.y+K);if(O.instersects(C)){f.save();f.translate(I.x,I.y); -f.rotate(-U.rotation);f.scale(P,-Z);f.translate(-ca,-da);f.drawImage(ba,0,0);f.restore()}}}else if(Q instanceof THREE.ParticleCircleMaterial){if(S){q.r=u.r+E.r+M.r;q.g=u.g+E.g+M.g;q.b=u.b+E.b+M.b;k.r=Q.color.r*q.r;k.g=Q.color.g*q.g;k.b=Q.color.b*q.b;k.updateStyleString()}else k.__styleString=Q.color.__styleString;Q=U.scale.x*l;K=U.scale.y*h;C.set(I.x-Q,I.y-K,I.x+Q,I.y+K);if(O.instersects(C)){P=k.__styleString;if(y!=P)f.fillStyle=y=P;f.save();f.translate(I.x,I.y);f.rotate(-U.rotation);f.scale(Q,K); -f.beginPath();f.arc(0,0,1,0,X,true);f.closePath();f.fill();f.restore()}}}}function Ma(I,U,Q,K){if(K.opacity!=0){Ca(K.opacity);ya(K.blending);f.beginPath();f.moveTo(I.positionScreen.x,I.positionScreen.y);f.lineTo(U.positionScreen.x,U.positionScreen.y);f.closePath();if(K instanceof THREE.LineBasicMaterial){k.__styleString=K.color.__styleString;I=K.linewidth;if(s!=I)f.lineWidth=s=I;I=k.__styleString;if(t!=I)f.strokeStyle=t=I;f.stroke();C.inflate(K.linewidth*2)}}}function Ga(I,U,Q,K,P,Z){if(P.opacity!= -0){Ca(P.opacity);ya(P.blending);N=I.positionScreen.x;F=I.positionScreen.y;A=U.positionScreen.x;p=U.positionScreen.y;i=Q.positionScreen.x;o=Q.positionScreen.y;f.beginPath();f.moveTo(N,F);f.lineTo(A,p);f.lineTo(i,o);f.lineTo(N,F);f.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&sa(N,F,A,p,i,o,P.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof -THREE.SphericalReflectionMapping){I=wa.matrix;Y.copy(K.vertexNormalsWorld[0]);R=(Y.x*I.n11+Y.y*I.n12+Y.z*I.n13)*0.5+0.5;D=-(Y.x*I.n21+Y.y*I.n22+Y.z*I.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[1]);V=(Y.x*I.n11+Y.y*I.n12+Y.z*I.n13)*0.5+0.5;T=-(Y.x*I.n21+Y.y*I.n22+Y.z*I.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[2]);$=(Y.x*I.n11+Y.y*I.n12+Y.z*I.n13)*0.5+0.5;W=-(Y.x*I.n21+Y.y*I.n22+Y.z*I.n23)*0.5+0.5;sa(N,F,A,p,i,o,P.env_map.image,R,D,V,T,$,W)}}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth): -Aa(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&sa(N,F,A,p,i,o,P.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);ya(THREE.SubtractiveBlending)}if(S)if(!P.wireframe&&P.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){v.r=n.r=m.r=u.r;v.g=n.g=m.g=u.g;v.b=n.b=m.b=u.b;xa(Z,K.v1.positionWorld,K.vertexNormalsWorld[0],v);xa(Z,K.v2.positionWorld,K.vertexNormalsWorld[1],n);xa(Z, -K.v3.positionWorld,K.vertexNormalsWorld[2],m);z.r=(n.r+m.r)*0.5;z.g=(n.g+m.g)*0.5;z.b=(n.b+m.b)*0.5;J=Ha(v,n,m,z);sa(N,F,A,p,i,o,J,0,0,1,0,0,1)}else{q.r=u.r;q.g=u.g;q.b=u.b;xa(Z,K.centroidWorld,K.normalWorld,q);k.r=P.color.r*q.r;k.g=P.color.g*q.g;k.b=P.color.b*q.b;k.updateStyleString();P.wireframe?za(k.__styleString,P.wireframe_linewidth):Aa(k.__styleString)}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):Aa(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){G=P.__2near; -L=P.__farPlusNear;x=P.__farMinusNear;v.r=v.g=v.b=1-G/(L-I.positionScreen.z*x);n.r=n.g=n.b=1-G/(L-U.positionScreen.z*x);m.r=m.g=m.b=1-G/(L-Q.positionScreen.z*x);z.r=(n.r+m.r)*0.5;z.g=(n.g+m.g)*0.5;z.b=(n.b+m.b)*0.5;J=Ha(v,n,m,z);sa(N,F,A,p,i,o,J,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){k.r=Da(K.normalWorld.x);k.g=Da(K.normalWorld.y);k.b=Da(K.normalWorld.z);k.updateStyleString();P.wireframe?za(k.__styleString,P.wireframe_linewidth):Aa(k.__styleString)}}}function za(I,U){if(t!=I)f.strokeStyle= -t=I;if(s!=U)f.lineWidth=s=U;f.stroke();C.inflate(U*2)}function Aa(I){if(y!=I)f.fillStyle=y=I;f.fill()}function sa(I,U,Q,K,P,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;Q-=I;K-=U;P-=I;Z-=U;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*Q-ga*P)*la;ga=(ta*K-ga*Z)*la;Q=(ja*P-ka*Q)*la;K=(ja*Z-ka*K)*la;I=I-na*ca-Q*da;U=U-ga*ca-K*da;f.save();f.transform(na,ga,Q,K,I,U);f.clip();f.drawImage(ba,0,0);f.restore()}function Ca(I){if(j!=I)f.globalAlpha= -j=I}function ya(I){if(c!=I){switch(I){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=I}}function Ha(I,U,Q,K){var P=~~(I.r*255),Z=~~(I.g*255);I=~~(I.b*255);var ba=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(Q.r*255),ja=~~(Q.g*255);Q=~~(Q.b*255);var ga=~~(K.r*255),ka=~~(K.g*255);K=~~(K.b*255);fa[0]=P<0?0:P>255?255:P;fa[1]=Z<0?0: -Z>255?255:Z;fa[2]=I<0?0:I>255?255:I;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=Q<0?0:Q>255?255:Q;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=K<0?0:K>255?255:K;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function Ea(I,U){var Q=U.x-I.x,K=U.y-I.y,P=1/Math.sqrt(Q*Q+K*K);Q*=P;K*=P;U.x+=Q;U.y+=K;I.x-=Q;I.y-=K}var Ba,Ia,aa,ha,qa,Fa, -Ja,ua;f.setTransform(1,0,0,-1,l,h);this.autoClear&&this.clear();a=b.projectScene(ia,wa);(S=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba0){W.r+=C.color.r*S;W.g+=C.color.g*S;W.b+=C.color.b*S}}else if(C instanceof THREE.PointLight){m.sub(C.position,$.centroidWorld);m.normalize();S=$.normalWorld.dot(m)*C.intensity;if(S>0){W.r+=C.color.r*S;W.g+=C.color.g*S;W.b+=C.color.b*S}}}}function b(T,$,W,O,H,C){x=d(J++);x.setAttribute("d","M "+T.positionScreen.x+ -" "+T.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)p.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(A){i.r=o.r;i.g=o.g;i.b=o.b;a(C,O,i);p.r=H.color.r*i.r;p.g=H.color.g*i.g;p.b=H.color.b*i.b;p.updateStyleString()}else p.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){n=1-H.__2near/(H.__farPlusNear-O.z*H.__farMinusNear); -p.setRGB(n,n,n)}else H instanceof THREE.MeshNormalMaterial&&p.setRGB(g(O.normalWorld.x),g(O.normalWorld.y),g(O.normalWorld.z));H.wireframe?x.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):x.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+H.opacity);f.appendChild(x)}function e(T,$,W,O,H,C,S){x=d(J++);x.setAttribute("d", -"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)p.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(A){i.r=o.r;i.g=o.g;i.b=o.b;a(S,H,i);p.r=C.color.r*i.r;p.g=C.color.g*i.g;p.b=C.color.b*i.b;p.updateStyleString()}else p.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){n= -1-C.__2near/(C.__farPlusNear-H.z*C.__farMinusNear);p.setRGB(n,n,n)}else C instanceof THREE.MeshNormalMaterial&&p.setRGB(g(H.normalWorld.x),g(H.normalWorld.y),g(H.normalWorld.z));C.wireframe?x.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):x.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+C.opacity);f.appendChild(x)} -function d(T){if(z[T]==null){z[T]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&z[T].setAttribute("shape-rendering","crispEdges");return z[T]}return z[T]}function g(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var l=null,h=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,y,s,r,w,B,N=new THREE.Rectangle,F=new THREE.Rectangle,A=false,p=new THREE.Color(16777215),i=new THREE.Color(16777215),o=new THREE.Color(0),k=new THREE.Color(0), -v=new THREE.Color(0),n,m=new THREE.Vector3,z=[],G=[],L=[],x,J,R,D,V=1;this.domElement=f;this.autoClear=true;this.setQuality=function(T){switch(T){case "high":V=1;break;case "low":V=0}};this.setSize=function(T,$){j=T;c=$;t=j/2;y=c/2;f.setAttribute("viewBox",-t+" "+-y+" "+j+" "+c);f.setAttribute("width",j);f.setAttribute("height",c);N.set(-t,-y,t,y)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(T,$){var W,O,H,C,S,q,u,E;this.autoClear&&this.clear(); -l=h.projectScene(T,$);D=R=J=0;if(A=T.lights.length>0){u=T.lights;o.setRGB(0,0,0);k.setRGB(0,0,0);v.setRGB(0,0,0);W=0;for(O=u.length;W0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(k,h("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ -i));c.attachShader(k,h("vertex",v+o));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};return k}function e(i,o){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, -c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP, -i.image.__webGLTextureCube)}}function d(i,o){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(i.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,o){var k,v,n;k=0;for(v=o.length;k=0&&c.enableVertexAttribArray(i.attributes[n])}}function h(i,o){var k;if(i=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")k=c.createShader(c.VERTEX_SHADER); -c.shaderSource(k,o);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function f(i){switch(i){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; -case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var j=document.createElement("canvas"),c,t,y,s=new THREE.Matrix4,r,w=new Float32Array(16),B=new Float32Array(16),N=new Float32Array(16),F=new Float32Array(9),A=new Float32Array(16);a=function(i,o){if(i){var k,v,n,m=pointLights=maxDirLights=maxPointLights=0;k=0;for(v=i.lights.length;k= 0.0 )": -"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;": +THREE.Projector=function(){function a(k,w){var o=0,m=1,v=k.z+k.w,L=w.z+w.w,C=-k.z+k.w,A=-w.z+w.w;if(v>=0&&L>=0&&C>=0&&A>=0)return true;else if(v<0&&L<0||C<0&&A<0)return false;else{if(v<0)o=Math.max(o,v/(v-L));else if(L<0)m=Math.min(m,v/(v-L));if(C<0)o=Math.max(o,C/(C-A));else if(A<0)m=Math.min(m,C/(C-A));if(m0&&C.z<1}V=V.faces;v=0;for(L=V.length;v0&&J.z<1){q=B[x]=B[x]||new THREE.RenderableParticle; +q.x=J.x/J.w;q.y=J.y/J.w;q.z=J.z;q.rotation=I.rotation.z;q.scale.x=I.scale.x*Math.abs(q.x-(J.x+w.projectionMatrix.n11)/(J.w+w.projectionMatrix.n14));q.scale.y=I.scale.y*Math.abs(q.y-(J.y+w.projectionMatrix.n22)/(J.w+w.projectionMatrix.n24));q.material=I.material;e.push(q);x++}}}}e.sort(b);return e};this.unprojectVector=function(k,w){var o=new THREE.Matrix4;o.multiply(THREE.Matrix4.makeInvert(w.matrix),THREE.Matrix4.makeInvert(w.projectionMatrix));o.multiplyVector3(k);return k}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,l;this.domElement=document.createElement("div");this.setSize=function(h,f){e=h;d=f;g=e/2;l=d/2};this.render=function(h,f){var j,c,t,y,s,q,x,B;a=b.projectScene(h,f);j=0;for(c=a.length;j0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,U);Y.normalize();Z=R.dot(Y)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}}}function La(G,U,R){if(R.opacity!=0){Ca(R.opacity);ya(R.blending);var K,Q,Z,ba,ca,da;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ba=R.map;ca=ba.width>>1;da=ba.height>>1;Q=U.scale.x*l;Z=U.scale.y*h;R=Q*ca;K=Z*da;F.set(G.x-R,G.y-K,G.x+R,G.y+K);if(N.instersects(F)){f.save();f.translate(G.x,G.y); +f.rotate(-U.rotation);f.scale(Q,-Z);f.translate(-ca,-da);f.drawImage(ba,0,0);f.restore()}}}else if(R instanceof THREE.ParticleCircleMaterial){if(T){r.r=u.r+E.r+O.r;r.g=u.g+E.g+O.g;r.b=u.b+E.b+O.b;k.r=R.color.r*r.r;k.g=R.color.g*r.g;k.b=R.color.b*r.b;k.updateStyleString()}else k.__styleString=R.color.__styleString;R=U.scale.x*l;K=U.scale.y*h;F.set(G.x-R,G.y-K,G.x+R,G.y+K);if(N.instersects(F)){Q=k.__styleString;if(y!=Q)f.fillStyle=y=Q;f.save();f.translate(G.x,G.y);f.rotate(-U.rotation);f.scale(R,K); +f.beginPath();f.arc(0,0,1,0,X,true);f.closePath();f.fill();f.restore()}}}}function Ma(G,U,R,K){if(K.opacity!=0){Ca(K.opacity);ya(K.blending);f.beginPath();f.moveTo(G.positionScreen.x,G.positionScreen.y);f.lineTo(U.positionScreen.x,U.positionScreen.y);f.closePath();if(K instanceof THREE.LineBasicMaterial){k.__styleString=K.color.__styleString;G=K.linewidth;if(s!=G)f.lineWidth=s=G;G=k.__styleString;if(t!=G)f.strokeStyle=t=G;f.stroke();F.inflate(K.linewidth*2)}}}function Ga(G,U,R,K,Q,Z){if(Q.opacity!= +0){Ca(Q.opacity);ya(Q.blending);J=G.positionScreen.x;H=G.positionScreen.y;D=U.positionScreen.x;n=U.positionScreen.y;i=R.positionScreen.x;p=R.positionScreen.y;f.beginPath();f.moveTo(J,H);f.lineTo(D,n);f.lineTo(i,p);f.lineTo(J,H);f.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(J,H,D,n,i,p,Q.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof +THREE.SphericalReflectionMapping){G=wa.matrix;Y.copy(K.vertexNormalsWorld[0]);I=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;M=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[1]);W=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;S=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[2]);$=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;V=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;sa(J,H,D,n,i,p,Q.env_map.image,I,M,W,S,$,V)}}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth): +Aa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(J,H,D,n,i,p,Q.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);ya(THREE.SubtractiveBlending)}if(T)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){w.r=o.r=m.r=u.r;w.g=o.g=m.g=u.g;w.b=o.b=m.b=u.b;xa(Z,K.v1.positionWorld,K.vertexNormalsWorld[0],w);xa(Z,K.v2.positionWorld,K.vertexNormalsWorld[1],o);xa(Z, +K.v3.positionWorld,K.vertexNormalsWorld[2],m);v.r=(o.r+m.r)*0.5;v.g=(o.g+m.g)*0.5;v.b=(o.b+m.b)*0.5;P=Ha(w,o,m,v);sa(J,H,D,n,i,p,P,0,0,1,0,0,1)}else{r.r=u.r;r.g=u.g;r.b=u.b;xa(Z,K.centroidWorld,K.normalWorld,r);k.r=Q.color.r*r.r;k.g=Q.color.g*r.g;k.b=Q.color.b*r.b;k.updateStyleString();Q.wireframe?za(k.__styleString,Q.wireframe_linewidth):Aa(k.__styleString)}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):Aa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){L=Q.__2near; +C=Q.__farPlusNear;A=Q.__farMinusNear;w.r=w.g=w.b=1-L/(C-G.positionScreen.z*A);o.r=o.g=o.b=1-L/(C-U.positionScreen.z*A);m.r=m.g=m.b=1-L/(C-R.positionScreen.z*A);v.r=(o.r+m.r)*0.5;v.g=(o.g+m.g)*0.5;v.b=(o.b+m.b)*0.5;P=Ha(w,o,m,v);sa(J,H,D,n,i,p,P,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){k.r=Da(K.normalWorld.x);k.g=Da(K.normalWorld.y);k.b=Da(K.normalWorld.z);k.updateStyleString();Q.wireframe?za(k.__styleString,Q.wireframe_linewidth):Aa(k.__styleString)}}}function za(G,U){if(t!=G)f.strokeStyle= +t=G;if(s!=U)f.lineWidth=s=U;f.stroke();F.inflate(U*2)}function Aa(G){if(y!=G)f.fillStyle=y=G;f.fill()}function sa(G,U,R,K,Q,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;R-=G;K-=U;Q-=G;Z-=U;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*R-ga*Q)*la;ga=(ta*K-ga*Z)*la;R=(ja*Q-ka*R)*la;K=(ja*Z-ka*K)*la;G=G-na*ca-R*da;U=U-ga*ca-K*da;f.save();f.transform(na,ga,R,K,G,U);f.clip();f.drawImage(ba,0,0);f.restore()}function Ca(G){if(j!=G)f.globalAlpha= +j=G}function ya(G){if(c!=G){switch(G){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=G}}function Ha(G,U,R,K){var Q=~~(G.r*255),Z=~~(G.g*255);G=~~(G.b*255);var ba=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(R.r*255),ja=~~(R.g*255);R=~~(R.b*255);var ga=~~(K.r*255),ka=~~(K.g*255);K=~~(K.b*255);fa[0]=Q<0?0:Q>255?255:Q;fa[1]=Z<0?0: +Z>255?255:Z;fa[2]=G<0?0:G>255?255:G;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=R<0?0:R>255?255:R;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=K<0?0:K>255?255:K;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ea(G,U){var R=U.x-G.x,K=U.y-G.y,Q=1/Math.sqrt(R*R+K*K);R*=Q;K*=Q;U.x+=R;U.y+=K;G.x-=R;G.y-=K}var Ba,Ia,aa,ha,qa,Fa, +Ja,ua;f.setTransform(1,0,0,-1,l,h);this.autoClear&&this.clear();a=b.projectScene(ia,wa);(T=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba0){V.r+=F.color.r*T;V.g+=F.color.g*T;V.b+=F.color.b*T}}else if(F instanceof THREE.PointLight){m.sub(F.position,$.centroidWorld);m.normalize();T=$.normalWorld.dot(m)*F.intensity;if(T>0){V.r+=F.color.r*T;V.g+=F.color.g*T;V.b+=F.color.b*T}}}}function b(S,$,V,N,z,F){A=d(P++);A.setAttribute("d","M "+S.positionScreen.x+ +" "+S.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(D){i.r=p.r;i.g=p.g;i.b=p.b;a(F,N,i);n.r=z.color.r*i.r;n.g=z.color.g*i.g;n.b=z.color.b*i.b;n.updateStyleString()}else n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){o=1-z.__2near/(z.__farPlusNear-N.z*z.__farMinusNear); +n.setRGB(o,o,o)}else z instanceof THREE.MeshNormalMaterial&&n.setRGB(g(N.normalWorld.x),g(N.normalWorld.y),g(N.normalWorld.z));z.wireframe?A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):A.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+z.opacity);f.appendChild(A)}function e(S,$,V,N,z,F,T){A=d(P++);A.setAttribute("d", +"M "+S.positionScreen.x+" "+S.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(D){i.r=p.r;i.g=p.g;i.b=p.b;a(T,z,i);n.r=F.color.r*i.r;n.g=F.color.g*i.g;n.b=F.color.b*i.b;n.updateStyleString()}else n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){o= +1-F.__2near/(F.__farPlusNear-z.z*F.__farMinusNear);n.setRGB(o,o,o)}else F instanceof THREE.MeshNormalMaterial&&n.setRGB(g(z.normalWorld.x),g(z.normalWorld.y),g(z.normalWorld.z));F.wireframe?A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):A.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+F.opacity);f.appendChild(A)} +function d(S){if(v[S]==null){v[S]=document.createElementNS("http://www.w3.org/2000/svg","path");W==0&&v[S].setAttribute("shape-rendering","crispEdges");return v[S]}return v[S]}function g(S){return S<0?Math.min((1+S)*0.5,0.5):0.5+Math.min(S*0.5,0.5)}var l=null,h=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,y,s,q,x,B,J=new THREE.Rectangle,H=new THREE.Rectangle,D=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),p=new THREE.Color(0),k=new THREE.Color(0), +w=new THREE.Color(0),o,m=new THREE.Vector3,v=[],L=[],C=[],A,P,I,M,W=1;this.domElement=f;this.autoClear=true;this.setQuality=function(S){switch(S){case "high":W=1;break;case "low":W=0}};this.setSize=function(S,$){j=S;c=$;t=j/2;y=c/2;f.setAttribute("viewBox",-t+" "+-y+" "+j+" "+c);f.setAttribute("width",j);f.setAttribute("height",c);J.set(-t,-y,t,y)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(S,$){var V,N,z,F,T,r,u,E;this.autoClear&&this.clear(); +l=h.projectScene(S,$);M=I=P=0;if(D=S.lights.length>0){u=S.lights;p.setRGB(0,0,0);k.setRGB(0,0,0);w.setRGB(0,0,0);V=0;for(N=u.length;V0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(k,h("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +i));c.attachShader(k,h("vertex",w+p));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};return k}function e(i,p){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_CUBE_MAP, +i.image.__webGLTextureCube)}}function d(i,p){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(i.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,p){var k,w,o;k=0;for(w=p.length;k=0&&c.enableVertexAttribArray(i.attributes[o])}}function h(i,p){var k;if(i=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")k=c.createShader(c.VERTEX_SHADER); +c.shaderSource(k,p);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function f(i){switch(i){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; +case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var j=document.createElement("canvas"),c,t,y,s=new THREE.Matrix4,q,x=new Float32Array(16),B=new Float32Array(16),J=new Float32Array(16),H=new Float32Array(9),D=new Float32Array(16);a=function(i,p){if(i){var k,w,o,m=pointLights=maxDirLights=maxPointLights=0;k=0;for(w=i.lights.length;k= 0.0 )": +"",p?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",p?"pointDiffuse += mColor * pointDiffuseWeight;":"",p?"pointSpecular += mSpecular * pointSpecularWeight;":"",p?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",p?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -k=b(v,k);c.useProgram(k);g(k,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&g(k,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&g(k,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(k.uniforms.enableMap,0);c.uniform1i(k.uniforms.tMap,0);c.uniform1i(k.uniforms.enableCubeMap,0);c.uniform1i(k.uniforms.tCube,1);c.uniform1i(k.uniforms.mixEnvMap,0);c.uniform1i(k.uniforms.useRefract,0);l(k,["position","normal","uv"]);return k}(a.directional,a.point);this.setSize=function(i,o){j.width=i;j.height=o;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,o){var k,v,n,m,z,G=[], -L=[],x=[];m=[];z=[];c.uniform1i(i.uniforms.enableLighting,o.length);k=0;for(v=o.length;k0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),c.STATIC_DRAW);H.__webGLFaceCount=R.length;H.__webGLLineCount=D.length}};this.renderBuffer=function(i,o,k,v){var n,m,z,G,L,x,J,R,D;if(k instanceof THREE.MeshShaderMaterial){if(!k.program){k.program=b(k.fragment_shader,k.vertex_shader);J=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in k.uniforms)J.push(D);g(k.program,J);l(k.program,["position","normal","uv","tangent"])}D= -k.program}else D=y;if(D!=t){c.useProgram(D);t=D}D==y&&this.setupLights(D,o);this.loadCamera(D,i);this.loadMatrices(D);if(k instanceof THREE.MeshShaderMaterial){z=k.wireframe;G=k.wireframe_linewidth;i=D;o=k.uniforms;var V;for(n in o){R=o[n].type;J=o[n].value;V=i.uniforms[n];if(R=="i")c.uniform1i(V,J);else if(R=="f")c.uniform1f(V,J);else if(R=="v3")c.uniform3f(V,J.x,J.y,J.z);else if(R=="c")c.uniform3f(V,J.r,J.g,J.b);else if(R=="t"){c.uniform1i(V,J);if(R=o[n].texture)R.image instanceof Array&&R.image.length== -6?e(R,J):d(R,J)}}}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshBasicMaterial){n=k.color;m=k.opacity;z=k.wireframe;G=k.wireframe_linewidth;L=k.map;x=k.env_map;o=k.combine==THREE.MixOperation;i=k.reflectivity;R=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;J=k.refraction_ratio;c.uniform4f(D.uniforms.mColor,n.r*m,n.g*m,n.b*m,m);c.uniform1i(D.uniforms.mixEnvMap,o);c.uniform1f(D.uniforms.mReflectivity,i);c.uniform1i(D.uniforms.useRefract, -R);c.uniform1f(D.uniforms.mRefractionRatio,J)}if(k instanceof THREE.MeshNormalMaterial){m=k.opacity;c.uniform1f(D.uniforms.mOpacity,m);c.uniform1i(D.uniforms.material,4)}else if(k instanceof THREE.MeshDepthMaterial){m=k.opacity;z=k.wireframe;G=k.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,m);c.uniform1f(D.uniforms.m2Near,k.__2near);c.uniform1f(D.uniforms.mFarPlusNear,k.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,k.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(k instanceof -THREE.MeshPhongMaterial){n=k.ambient;i=k.specular;k=k.shininess;c.uniform4f(D.uniforms.mAmbient,n.r,n.g,n.b,m);c.uniform4f(D.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(D.uniforms.mShininess,k);c.uniform1i(D.uniforms.material,2)}else if(k instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(k instanceof THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,0);else if(k instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);x=k.env_map}if(L){d(L,0);c.uniform1i(D.uniforms.tMap, -0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(x){e(x,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);m=D.attributes;c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer); -c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0)}if(m.uv>=0)if(v.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.enableVertexAttribArray(m.uv);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(m.uv);if(z){c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);c.drawElements(c.LINES,v.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,v.__webGLFaceCount,c.UNSIGNED_SHORT, -0)}};this.renderPass=function(i,o,k,v,n,m){var z,G,L,x,J;L=0;for(x=k.material.length;L=0;k--){v=i.__webGLObjects[k].object;o==v&&i.__webGLObjects.splice(k,1)}};this.setupMatrices=function(i,o){i.autoUpdateMatrix&&i.updateMatrix();s.multiply(o.matrix,i.matrix);B.set(s.flatten());r=THREE.Matrix4.makeInvert3x3(s).transpose();F.set(r.m);A.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix, -false,w);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,B);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,N);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,F);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,A)};this.loadCamera=function(i,o){c.uniform3f(i.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, -c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,o){if(i){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +k=b(w,k);c.useProgram(k);g(k,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&g(k,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&g(k,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(k.uniforms.enableMap,0);c.uniform1i(k.uniforms.tMap,0);c.uniform1i(k.uniforms.enableCubeMap,0);c.uniform1i(k.uniforms.tCube,1);c.uniform1i(k.uniforms.mixEnvMap,0);c.uniform1i(k.uniforms.useRefract,0);l(k,["position","normal","uv"]);return k}(a.directional,a.point);this.setSize=function(i,p){j.width=i;j.height=p;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,p){var k,w,o,m,v,L=[], +C=[],A=[];m=[];v=[];c.uniform1i(i.uniforms.enableLighting,p.length);k=0;for(w=p.length;k0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);z.__webGLFaceCount=I.length;z.__webGLLineCount=M.length}};this.renderBuffer=function(i,p,k,w){var o,m,v,L,C,A,P,I,M;if(k instanceof THREE.MeshShaderMaterial){if(!k.program){k.program=b(k.fragment_shader,k.vertex_shader);P=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(M in k.uniforms)P.push(M);g(k.program,P);l(k.program,["position","normal","uv","tangent"])}M= +k.program}else M=y;if(M!=t){c.useProgram(M);t=M}M==y&&this.setupLights(M,p);this.loadCamera(M,i);this.loadMatrices(M);if(k instanceof THREE.MeshShaderMaterial){v=k.wireframe;L=k.wireframe_linewidth;i=M;p=k.uniforms;var W;for(o in p){I=p[o].type;P=p[o].value;W=i.uniforms[o];if(I=="i")c.uniform1i(W,P);else if(I=="f")c.uniform1f(W,P);else if(I=="v3")c.uniform3f(W,P.x,P.y,P.z);else if(I=="c")c.uniform3f(W,P.r,P.g,P.b);else if(I=="t"){c.uniform1i(W,P);if(I=p[o].texture)I.image instanceof Array&&I.image.length== +6?e(I,P):d(I,P)}}}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshBasicMaterial){o=k.color;m=k.opacity;v=k.wireframe;L=k.wireframe_linewidth;C=k.map;A=k.env_map;p=k.combine==THREE.MixOperation;i=k.reflectivity;I=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;P=k.refraction_ratio;c.uniform4f(M.uniforms.mColor,o.r*m,o.g*m,o.b*m,m);c.uniform1i(M.uniforms.mixEnvMap,p);c.uniform1f(M.uniforms.mReflectivity,i);c.uniform1i(M.uniforms.useRefract, +I);c.uniform1f(M.uniforms.mRefractionRatio,P)}if(k instanceof THREE.MeshNormalMaterial){m=k.opacity;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1i(M.uniforms.material,4)}else if(k instanceof THREE.MeshDepthMaterial){m=k.opacity;v=k.wireframe;L=k.wireframe_linewidth;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1f(M.uniforms.m2Near,k.__2near);c.uniform1f(M.uniforms.mFarPlusNear,k.__farPlusNear);c.uniform1f(M.uniforms.mFarMinusNear,k.__farMinusNear);c.uniform1i(M.uniforms.material,3)}else if(k instanceof +THREE.MeshPhongMaterial){o=k.ambient;i=k.specular;k=k.shininess;c.uniform4f(M.uniforms.mAmbient,o.r,o.g,o.b,m);c.uniform4f(M.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(M.uniforms.mShininess,k);c.uniform1i(M.uniforms.material,2)}else if(k instanceof THREE.MeshLambertMaterial)c.uniform1i(M.uniforms.material,1);else if(k instanceof THREE.MeshBasicMaterial)c.uniform1i(M.uniforms.material,0);else if(k instanceof THREE.MeshCubeMaterial){c.uniform1i(M.uniforms.material,5);A=k.env_map}if(C){d(C,0);c.uniform1i(M.uniforms.tMap, +0);c.uniform1i(M.uniforms.enableMap,1)}else c.uniform1i(M.uniforms.enableMap,0);if(A){e(A,1);c.uniform1i(M.uniforms.tCube,1);c.uniform1i(M.uniforms.enableCubeMap,1)}else c.uniform1i(M.uniforms.enableCubeMap,0);m=M.attributes;c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer); +c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0)}if(m.uv>=0)if(w.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.enableVertexAttribArray(m.uv);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(m.uv);if(v){c.lineWidth(L);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);c.drawElements(c.LINES,w.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,w.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(i,p,k,w,o,m){var v,L,C,A,P;C=0;for(A=k.material.length;C=0;k--){w=i.__webGLObjects[k].object;p==w&&i.__webGLObjects.splice(k,1)}};this.setupMatrices=function(i,p){i.autoUpdateMatrix&&i.updateMatrix();s.multiply(p.matrix,i.matrix);B.set(s.flatten());q=THREE.Matrix4.makeInvert3x3(s).transpose();H.set(q.m);D.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix, +false,x);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,B);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,H);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,D)};this.loadCamera=function(i,p){c.uniform3f(i.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, +c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,p){if(i){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};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.Vertex;this.v2=new THREE.Vertex;this.material=null}; -var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,l=a.vertices,h=g.vertices,f=a.faces,j=g.faces,c=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var t=0,y=h.length;t= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, -basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"}}},Cube=function(a,b,e,d,g,l,h,f){function j(B,N,F,A,p,i,o,k){var v,n=d||1,m=g||1,z=n+1,G=m+1,L=p/2,x=i/2;p=p/n;i=i/m;var J=c.vertices.length;if(B=="x"&&N=="y"||B=="y"&&N=="x")v="z";else if(B=="x"&&N=="z"||B=="z"&&N=="x")v="y";else if(B=="z"&&N=="y"||B=="y"&&N=="z")v="x";for(iy=0;iy0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,f,s)))-1);c.push(t)}b.push(c)}var r,w;a=b.length;for(e=0;e0)for(d=0;d1){y=this.vertices[l].position.clone(); -r=this.vertices[f].position.clone();w=this.vertices[j].position.clone();y.normalize();r.normalize();w.normalize();this.faces.push(new THREE.Face3(l,f,j,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([c,s,B])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,l=Math.max(3,b||8),h=Math.max(2,e||6);b=[];for(e=0;e0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,f,s)))-1);c.push(t)}b.push(c)}var q,x;a=b.length;for(e=0;e0)for(d=0;d1){y=this.vertices[l].position.clone(); +q=this.vertices[f].position.clone();x=this.vertices[j].position.clone();y.normalize();q.normalize();x.normalize();this.faces.push(new THREE.Face3(l,f,j,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,s,B])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML= b},loadAsciiOld:function(a,b){var e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(l){THREE.Loader.prototype.loadAjaxBuffers(l.data.buffers, l.data.materials,b,e,g)};a.onerror=function(l){alert("worker.onerror: "+l.message+"\n"+l.data);l.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,g){var l=new XMLHttpRequest,h=d+"/"+a,f=0;l.onreadystatechange=function(){if(l.readyState==4)l.status==200||l.status==0?THREE.Loader.prototype.createBinModel(l.responseText,e,d,b):alert("Couldn't load ["+h+"] ["+l.status+"]");else if(l.readyState==3){if(g){if(f==0)f=l.getResponseHeader("Content-Length");g({total:f,loaded:l.responseText.length})}}else if(l.readyState== -2)f=l.getResponseHeader("Content-Length")};l.open("GET",h,true);l.overrideMimeType("text/plain; charset=x-user-defined");l.setRequestHeader("Content-Type","text/plain");l.send(null)},createBinModel:function(a,b,e,d){var g=function(l){function h(q,u){var E=t(q,u),M=t(q,u+1),X=t(q,u+2),Y=t(q,u+3),ea=(Y<<1&255|X>>7)-127;E=(X&127)<<16|M<<8|E;if(E==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ea)}function f(q,u){var E=t(q,u),M=t(q,u+1),X=t(q,u+2);return(t(q,u+3)<<24)+(X<<16)+ -(M<<8)+E}function j(q,u){var E=t(q,u);return(t(q,u+1)<<8)+E}function c(q,u){var E=t(q,u);return E>127?E-256:E}function t(q,u){return q.charCodeAt(u)&255}function y(q){var u,E,M;u=f(a,q);E=f(a,q+k);M=f(a,q+v);q=j(a,q+n);THREE.Loader.prototype.f3(F,u,E,M,q)}function s(q){var u,E,M,X,Y,ea;u=f(a,q);E=f(a,q+k);M=f(a,q+v);X=j(a,q+n);Y=f(a,q+m);ea=f(a,q+z);q=f(a,q+G);THREE.Loader.prototype.f3n(F,i,u,E,M,X,Y,ea,q)}function r(q){var u,E,M,X;u=f(a,q);E=f(a,q+L);M=f(a,q+x);X=f(a,q+J);q=j(a,q+R);THREE.Loader.prototype.f4(F, -u,E,M,X,q)}function w(q){var u,E,M,X,Y,ea,ma,oa;u=f(a,q);E=f(a,q+L);M=f(a,q+x);X=f(a,q+J);Y=j(a,q+R);ea=f(a,q+D);ma=f(a,q+V);oa=f(a,q+T);q=f(a,q+$);THREE.Loader.prototype.f4n(F,i,u,E,M,X,Y,ea,ma,oa,q)}function B(q){var u,E;u=f(a,q);E=f(a,q+W);q=f(a,q+O);THREE.Loader.prototype.uv3(F,o[u*2],o[u*2+1],o[E*2],o[E*2+1],o[q*2],o[q*2+1])}function N(q){var u,E,M;u=f(a,q);E=f(a,q+H);M=f(a,q+C);q=f(a,q+S);THREE.Loader.prototype.uv4(F,o[u*2],o[u*2+1],o[E*2],o[E*2+1],o[M*2],o[M*2+1],o[q*2],o[q*2+1])}var F=this, -A=0,p,i=[],o=[],k,v,n,m,z,G,L,x,J,R,D,V,T,$,W,O,H,C,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,d,l);p={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:f(a,A+16),nnormals:f(a,A+16+4),nuvs:f(a,A+16+8),ntri_flat:f(a,A+16+12),ntri_smooth:f(a,A+16+16),ntri_flat_uv:f(a, -A+16+20),ntri_smooth_uv:f(a,A+16+24),nquad_flat:f(a,A+16+28),nquad_smooth:f(a,A+16+32),nquad_flat_uv:f(a,A+16+36),nquad_smooth_uv:f(a,A+16+40)};A+=p.header_bytes;k=p.vertex_index_bytes;v=p.vertex_index_bytes*2;n=p.vertex_index_bytes*3;m=p.vertex_index_bytes*3+p.material_index_bytes;z=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;G=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;L=p.vertex_index_bytes;x=p.vertex_index_bytes*2;J=p.vertex_index_bytes*3;R=p.vertex_index_bytes* -4;D=p.vertex_index_bytes*4+p.material_index_bytes;V=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;T=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*2;$=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;W=p.uv_index_bytes;O=p.uv_index_bytes*2;H=p.uv_index_bytes;C=p.uv_index_bytes*2;S=p.uv_index_bytes*3;A+=function(q){var u,E,M,X=p.vertex_coordinate_bytes*3,Y=q+p.nvertices*X;for(q=q;q>7)-127;E=(X&127)<<16|O<<8|E;if(E==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ea)}function f(r,u){var E=t(r,u),O=t(r,u+1),X=t(r,u+2);return(t(r,u+3)<<24)+(X<<16)+ +(O<<8)+E}function j(r,u){var E=t(r,u);return(t(r,u+1)<<8)+E}function c(r,u){var E=t(r,u);return E>127?E-256:E}function t(r,u){return r.charCodeAt(u)&255}function y(r){var u,E,O;u=f(a,r);E=f(a,r+k);O=f(a,r+w);r=j(a,r+o);THREE.Loader.prototype.f3(H,u,E,O,r)}function s(r){var u,E,O,X,Y,ea;u=f(a,r);E=f(a,r+k);O=f(a,r+w);X=j(a,r+o);Y=f(a,r+m);ea=f(a,r+v);r=f(a,r+L);THREE.Loader.prototype.f3n(H,i,u,E,O,X,Y,ea,r)}function q(r){var u,E,O,X;u=f(a,r);E=f(a,r+C);O=f(a,r+A);X=f(a,r+P);r=j(a,r+I);THREE.Loader.prototype.f4(H, +u,E,O,X,r)}function x(r){var u,E,O,X,Y,ea,ma,oa;u=f(a,r);E=f(a,r+C);O=f(a,r+A);X=f(a,r+P);Y=j(a,r+I);ea=f(a,r+M);ma=f(a,r+W);oa=f(a,r+S);r=f(a,r+$);THREE.Loader.prototype.f4n(H,i,u,E,O,X,Y,ea,ma,oa,r)}function B(r){var u,E;u=f(a,r);E=f(a,r+V);r=f(a,r+N);THREE.Loader.prototype.uv3(H,p[u*2],p[u*2+1],p[E*2],p[E*2+1],p[r*2],p[r*2+1])}function J(r){var u,E,O;u=f(a,r);E=f(a,r+z);O=f(a,r+F);r=f(a,r+T);THREE.Loader.prototype.uv4(H,p[u*2],p[u*2+1],p[E*2],p[E*2+1],p[O*2],p[O*2+1],p[r*2],p[r*2+1])}var H=this, +D=0,n,i=[],p=[],k,w,o,m,v,L,C,A,P,I,M,W,S,$,V,N,z,F,T;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,d,l);n={signature:a.substr(D,8),header_bytes:t(a,D+8),vertex_coordinate_bytes:t(a,D+9),normal_coordinate_bytes:t(a,D+10),uv_coordinate_bytes:t(a,D+11),vertex_index_bytes:t(a,D+12),normal_index_bytes:t(a,D+13),uv_index_bytes:t(a,D+14),material_index_bytes:t(a,D+15),nvertices:f(a,D+16),nnormals:f(a,D+16+4),nuvs:f(a,D+16+8),ntri_flat:f(a,D+16+12),ntri_smooth:f(a,D+16+16),ntri_flat_uv:f(a, +D+16+20),ntri_smooth_uv:f(a,D+16+24),nquad_flat:f(a,D+16+28),nquad_smooth:f(a,D+16+32),nquad_flat_uv:f(a,D+16+36),nquad_smooth_uv:f(a,D+16+40)};D+=n.header_bytes;k=n.vertex_index_bytes;w=n.vertex_index_bytes*2;o=n.vertex_index_bytes*3;m=n.vertex_index_bytes*3+n.material_index_bytes;v=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;C=n.vertex_index_bytes;A=n.vertex_index_bytes*2;P=n.vertex_index_bytes*3;I=n.vertex_index_bytes* +4;M=n.vertex_index_bytes*4+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;V=n.uv_index_bytes;N=n.uv_index_bytes*2;z=n.uv_index_bytes;F=n.uv_index_bytes*2;T=n.uv_index_bytes*3;D+=function(r){var u,E,O,X=n.vertex_coordinate_bytes*3,Y=r+n.nvertices*X;for(r=r;r