diff --git a/build/Three.js b/build/Three.js index 154052f8..555c80a6 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,70 +1,70 @@ // Three.js r32 - 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,e){this.r=a;this.g=b;this.b=e;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)+")"},clone:function(){return new THREE.Color(this.hex)},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,e){this.x=a||0;this.y=b||0;this.z=e||0}; -THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;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,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= -a.z;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,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+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= +THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; +THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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,c,e){this.x=a||0;this.y=c||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-e*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= +a.z;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 c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+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,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1}; -THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;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,f=a.objects,g=[];a=0;for(b=f.length;a0&&T>0&&m+T<1}var e,f,g,j,q,c,k,n,D,E, -z,C=a.geometry,S=C.vertices,V=[];e=0;for(f=C.faces.length;ek?f:k;g=g>n? -g:n}a()};this.add3Points=function(k,n,D,E,z,C){if(c){c=false;b=kD?k>z?k:z:D>z?D:z;g=n>E?n>C?n:C:E>C?E:C}else{b=kD?k>z?k>f?k:f:z>f?z:f:D>z?D>f?D:f:z>f?z:f;g=n>E?n>C?n>g?n:g:C>g?C:g:E>C?E>g?E:g:C>g?C:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();e=k.getTop();f=k.getRight();g=k.getBottom()}else{b=bk.getRight()?f:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;f+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f=0&&Math.min(g,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){c=true;g=f=e=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+j+", height: "+q+" )"}};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,f,g,j,q,c,k,n,D,E,z,C,S,V){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=j||1;this.n23=q||0;this.n24=c||0;this.n31=k||0;this.n32=n||0;this.n33=D||1;this.n34=E||0;this.n41=z||0;this.n42=C||0;this.n43=S||0;this.n44=V||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,f,g,j,q,c,k,n,D,E,z,C,S,V){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=q;this.n24=c;this.n31=k;this.n32=n;this.n33=D;this.n34=E;this.n41=z;this.n42=C;this.n43=S;this.n44=V;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 f=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();f.cross(e,j).normalize();g.cross(j,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x; -this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*f+this.n24* -g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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,f=a.n12,g=a.n13,j=a.n14,q=a.n21,c=a.n22,k=a.n23,n=a.n24,D=a.n31,E=a.n32, -z=a.n33,C=a.n34,S=a.n41,V=a.n42,T=a.n43,s=a.n44,R=b.n11,d=b.n12,h=b.n13,m=b.n14,o=b.n21,p=b.n22,v=b.n23,r=b.n24,l=b.n31,x=b.n32,t=b.n33,i=b.n34,u=b.n41,I=b.n42,A=b.n43,L=b.n44;this.n11=e*R+f*o+g*l+j*u;this.n12=e*d+f*p+g*x+j*I;this.n13=e*h+f*v+g*t+j*A;this.n14=e*m+f*r+g*i+j*L;this.n21=q*R+c*o+k*l+n*u;this.n22=q*d+c*p+k*x+n*I;this.n23=q*h+c*v+k*t+n*A;this.n24=q*m+c*r+k*i+n*L;this.n31=D*R+E*o+z*l+C*u;this.n32=D*d+E*p+z*x+C*I;this.n33=D*h+E*v+z*t+C*A;this.n34=D*m+E*r+z*i+C*L;this.n41=S*R+V*o+T*l+s*u; -this.n42=S*d+V*p+T*x+s*I;this.n43=S*h+V*v+T*t+s*A;this.n44=S*m+V*r+T*i+s*L;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,j=this.n21,q=this.n22,c=this.n23,k=this.n24,n=this.n31,D=this.n32,E=this.n33,z=this.n34,C=this.n41,S=this.n42,V=this.n43,T=this.n44,s=a.n11,R=a.n21,d=a.n31,h=a.n41,m=a.n12,o=a.n22,p=a.n32,v=a.n42,r=a.n13,l=a.n23,x=a.n33,t=a.n43,i=a.n14,u=a.n24,I=a.n34;a=a.n44;this.n11=b*s+e*R+f*d+g*h;this.n12=b*m+e*o+f*p+g*v;this.n13=b*r+e*l+f*x+g*t;this.n14= -b*i+e*u+f*I+g*a;this.n21=j*s+q*R+c*d+k*h;this.n22=j*m+q*o+c*p+k*v;this.n23=j*r+q*l+c*x+k*t;this.n24=j*i+q*u+c*I+k*a;this.n31=n*s+D*R+E*d+z*h;this.n32=n*m+D*o+E*p+z*v;this.n33=n*r+D*l+E*x+z*t;this.n34=n*i+D*u+E*I+z*a;this.n41=C*s+S*R+V*d+T*h;this.n42=C*m+S*o+V*p+T*v;this.n43=C*r+S*l+V*x+T*t;this.n44=C*i+S*u+V*I+T*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.Vector4=function(a,c,e,f){this.x=a||0;this.y=c||0;this.z=e||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,c,e,f){this.x=a;this.y=c;this.z=e;this.w=f;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; +THREE.Ray.prototype={intersectScene:function(a){var c,e,f=a.objects,g=[];a=0;for(c=f.length;a0&&T>0&&k+T<1}var e,f,g,j,q,b,l,o,D,E, +z,C=a.geometry,S=C.vertices,V=[];e=0;for(f=C.faces.length;el?f:l;g=g>o? +g:o}a()};this.add3Points=function(l,o,D,E,z,C){if(b){b=false;c=lD?l>z?l:z:D>z?D:z;g=o>E?o>C?o:C:E>C?E:C}else{c=lD?l>z?l>f?l:f:z>f?z:f:D>z?D>f?D:f:z>f?z:f;g=o>E?o>C?o>g?o:g:C>g?C:g:E>C?E>g?E:g:C>g?C:g}a()};this.addRectangle=function(l){if(b){b=false;c=l.getLeft();e=l.getTop();f=l.getRight();g=l.getBottom()}else{c=cl.getRight()?f:l.getRight();g=g>l.getBottom()?g:l.getBottom()}a()};this.inflate=function(l){c-=l;e-=l;f+=l;g+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();e=e>l.getTop()?e:l.getTop();f=f=0&&Math.min(g,l.getBottom())-Math.max(e,l.getTop())>=0};this.empty=function(){b=true;g=f=e=c=0;a()};this.isEmpty=function(){return b};this.toString= +function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+e+", bottom: "+g+", width: "+j+", height: "+q+" )"}};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,c,e,f,g,j,q,b,l,o,D,E,z,C,S,V){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=j||1;this.n23=q||0;this.n24=b||0;this.n31=l||0;this.n32=o||0;this.n33=D||1;this.n34=E||0;this.n41=z||0;this.n42=C||0;this.n43=S||0;this.n44=V||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,c,e,f,g,j,q,b,l,o,D,E,z,C,S,V){this.n11=a;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=q;this.n24=b;this.n31=l;this.n32=o;this.n33=D;this.n34=E;this.n41=z;this.n42=C;this.n43=S;this.n44=V;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,c,e){var f=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,c).normalize();f.cross(e,j).normalize();g.cross(j,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x; +this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,f=a.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*e+this.n23*f+this.n24* +g;a.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var e=a.n11,f=a.n12,g=a.n13,j=a.n14,q=a.n21,b=a.n22,l=a.n23,o=a.n24,D=a.n31,E=a.n32, +z=a.n33,C=a.n34,S=a.n41,V=a.n42,T=a.n43,r=a.n44,R=c.n11,d=c.n12,h=c.n13,k=c.n14,n=c.n21,s=c.n22,v=c.n23,p=c.n24,m=c.n31,w=c.n32,t=c.n33,i=c.n34,u=c.n41,I=c.n42,A=c.n43,L=c.n44;this.n11=e*R+f*n+g*m+j*u;this.n12=e*d+f*s+g*w+j*I;this.n13=e*h+f*v+g*t+j*A;this.n14=e*k+f*p+g*i+j*L;this.n21=q*R+b*n+l*m+o*u;this.n22=q*d+b*s+l*w+o*I;this.n23=q*h+b*v+l*t+o*A;this.n24=q*k+b*p+l*i+o*L;this.n31=D*R+E*n+z*m+C*u;this.n32=D*d+E*s+z*w+C*I;this.n33=D*h+E*v+z*t+C*A;this.n34=D*k+E*p+z*i+C*L;this.n41=S*R+V*n+T*m+r*u; +this.n42=S*d+V*s+T*w+r*I;this.n43=S*h+V*v+T*t+r*A;this.n44=S*k+V*p+T*i+r*L;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,f=this.n13,g=this.n14,j=this.n21,q=this.n22,b=this.n23,l=this.n24,o=this.n31,D=this.n32,E=this.n33,z=this.n34,C=this.n41,S=this.n42,V=this.n43,T=this.n44,r=a.n11,R=a.n21,d=a.n31,h=a.n41,k=a.n12,n=a.n22,s=a.n32,v=a.n42,p=a.n13,m=a.n23,w=a.n33,t=a.n43,i=a.n14,u=a.n24,I=a.n34;a=a.n44;this.n11=c*r+e*R+f*d+g*h;this.n12=c*k+e*n+f*s+g*v;this.n13=c*p+e*m+f*w+g*t;this.n14= +c*i+e*u+f*I+g*a;this.n21=j*r+q*R+b*d+l*h;this.n22=j*k+q*n+b*s+l*v;this.n23=j*p+q*m+b*w+l*t;this.n24=j*i+q*u+b*I+l*a;this.n31=o*r+D*R+E*d+z*h;this.n32=o*k+D*n+E*s+z*v;this.n33=o*p+D*m+E*w+z*t;this.n34=o*i+D*u+E*I+z*a;this.n41=C*r+S*R+V*d+T*h;this.n42=C*k+S*n+V*s+T*v;this.n43=C*p+S*m+V*w+T*t;this.n44=C*i+S*u+V*I+T*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,f){var g=b[e];b[e]=b[f]; -b[f]=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, -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,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f}; -THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f};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 e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),j=1-f,q=a.x,c=a.y,k=a.z;e.n11=j*q*q+f;e.n12=j*q*c-g*k;e.n13=j*q*k+g*c;e.n21=j*q*c+g*k;e.n22=j*c*c+f;e.n23=j*c*k-g*q;e.n31=j*q*k-g*c;e.n32=j*c*k+g*q;e.n33=j*k*k+f;return e}; -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 e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*q;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*n;a.m[8]=b*D;return a}; -THREE.Matrix4.makeFrustum=function(a,b,e,f,g,j){var q,c,k;q=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(j+g)/(j-g);g=-2*j*g/(j-g);q.n11=c;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=k;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=g;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)}; -THREE.Matrix4.makeOrtho=function(a,b,e,f,g,j){var q,c,k,n;q=new THREE.Matrix4;c=b-a;k=e-f;n=j-g;a=(b+a)/c;e=(e+f)/k;g=(j+g)/n;q.n11=2/c;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/k;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-g;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q}; -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,e,f,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,e,f,g,j){this.a=a;this.b=b;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};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}; +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(c,e,f){var g=c[e];c[e]=c[f]; +c[f]=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, +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,c,e){var f=new THREE.Matrix4;f.n14=a;f.n24=c;f.n34=e;return f}; +THREE.Matrix4.scaleMatrix=function(a,c,e){var f=new THREE.Matrix4;f.n11=a;f.n22=c;f.n33=e;return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4,f=Math.cos(c),g=Math.sin(c),j=1-f,q=a.x,b=a.y,l=a.z;e.n11=j*q*q+f;e.n12=j*q*b-g*l;e.n13=j*q*l+g*b;e.n21=j*q*b+g*l;e.n22=j*b*b+f;e.n23=j*b*l-g*q;e.n31=j*q*l-g*b;e.n32=j*b*l+g*q;e.n33=j*l*l+f;return e}; +THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],g=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],q=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],l=c[9]*c[4]-c[5]*c[8],o=-c[9]*c[0]+c[1]*c[8],D=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*j+c[2]*l;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*e;a.m[1]=c*f;a.m[2]=c*g;a.m[3]=c*j;a.m[4]=c*q;a.m[5]=c*b;a.m[6]=c*l;a.m[7]=c*o;a.m[8]=c*D;return a}; +THREE.Matrix4.makeFrustum=function(a,c,e,f,g,j){var q,b,l;q=new THREE.Matrix4;b=2*g/(c-a);l=2*g/(f-e);a=(c+a)/(c-a);e=(f+e)/(f-e);f=-(j+g)/(j-g);g=-2*j*g/(j-g);q.n11=b;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=g;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,e,f)}; +THREE.Matrix4.makeOrtho=function(a,c,e,f,g,j){var q,b,l,o;q=new THREE.Matrix4;b=c-a;l=e-f;o=j-g;a=(c+a)/b;e=(e+f)/l;g=(j+g)/o;q.n11=2/b;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/o;q.n34=-g;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q}; +THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,e,f,g){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,c,e,f,g,j){this.a=a;this.b=c;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a0){this.boundingBox={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 b=1,e=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b65535){n[c].counter+=1;k=n[c].hash+"_"+n[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:q,vertices:0}}this.geometryChunks[k].faces.push(f);this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+ +THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a0){this.boundingBox={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 c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c65535){o[b].counter+=1;l=o[b].hash+"_"+o[b].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); +THREE.Camera=function(a,c,e,f){this.fov=a;this.aspect=c;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={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.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; +THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||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.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={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};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false}; -THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; -THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.autoUpdateMatrix=false}; +THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; +THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";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;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -91,98 +91,103 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM 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}}; THREE.ParticleBasicMaterial.prototype={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}}; THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,e,f,g,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,c,e,f,g,j){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},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;var Uniforms={clone:function(a){var b,e,f,g={};for(b in a){g[b]={};for(e in a[b]){f=a[b][e];g[b][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var b,e,f,g={};for(b=0;b=0&&t>=0&&i>=0&&u>=0)return true;else if(x<0&&t<0||i<0&&u<0)return false;else{if(x<0)r=Math.max(r,x/(x-t));else if(t<0)l=Math.min(l,x/(x-t));if(i<0)r=Math.max(r,i/(i-u));else if(u<0)l=Math.min(l,i/(i-u));if(lx&&A.z0&&T.z<1){z=S[C]=S[C]||new THREE.RenderableParticle;z.x=T.x/T.w;z.y=T.y/T.w;z.z=T.z;z.rotation=K.rotation.z;z.scale.x=K.scale.x*Math.abs(z.x-(T.x+v.projectionMatrix.n11)/(T.w+v.projectionMatrix.n14)); -z.scale.y=K.scale.y*Math.abs(z.y-(T.y+v.projectionMatrix.n22)/(T.w+v.projectionMatrix.n24));z.materials=K.materials;l.push(z);C++}}}}r&&l.sort(a);return l};this.unprojectVector=function(p,v){var r=new THREE.Matrix4;r.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));r.multiplyVector3(p);return p}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(q,c){e=q;f=c;g=e/2;j=f/2};this.render=function(q,c){var k,n,D,E,z,C,S,V;a=b.projectScene(q,c);k=0;for(n=a.length;k0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}else if(Z instanceof THREE.PointLight){aa.sub(Z.position,W);aa.normalize();Z=Q.dot(aa)*ha;if(Z>0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}}}function Na(y,W,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);var B, -M,Z,da,ha,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){da=Q.map;ha=da.width>>1;ia=da.height>>1;M=W.scale.x*c;Z=W.scale.y*k;Q=M*ha;B=Z*ia;w.set(y.x-Q,y.y-B,y.x+Q,y.y+B);if(P.instersects(w)){n.save();n.translate(y.x,y.y);n.rotate(-W.rotation);n.scale(M,-Z);n.translate(-ha,-ia);n.drawImage(da,0,0);n.restore()}}}else if(Q instanceof THREE.ParticleCircleMaterial){if(F){X.r=$.r+Y.r+ga.r;X.g=$.g+Y.g+ga.g;X.b=$.b+Y.b+ga.b;l.r=Q.color.r*X.r;l.g=Q.color.g*X.g;l.b=Q.color.b*X.b;l.updateStyleString()}else l.__styleString= -Q.color.__styleString;Q=W.scale.x*c;B=W.scale.y*k;w.set(y.x-Q,y.y-B,y.x+Q,y.y+B);if(P.instersects(w)){M=l.__styleString;if(V!=M)n.fillStyle=V=M;n.save();n.translate(y.x,y.y);n.rotate(-W.rotation);n.scale(Q,B);n.beginPath();n.arc(0,0,1,0,fa,true);n.closePath();n.fill();n.restore()}}}}function Oa(y,W,Q,B){if(B.opacity!=0){a(B.opacity);b(B.blending);n.beginPath();n.moveTo(y.positionScreen.x,y.positionScreen.y);n.lineTo(W.positionScreen.x,W.positionScreen.y);n.closePath();if(B instanceof THREE.LineBasicMaterial){l.__styleString= -B.color.__styleString;y=B.linewidth;if(T!=y)n.lineWidth=T=y;y=l.__styleString;if(S!=y)n.strokeStyle=S=y;n.stroke();w.inflate(B.linewidth*2)}}}function Ia(y,W,Q,B,M,Z){if(M.opacity!=0){a(M.opacity);b(M.blending);h=y.positionScreen.x;m=y.positionScreen.y;o=W.positionScreen.x;p=W.positionScreen.y;v=Q.positionScreen.x;r=Q.positionScreen.y;n.beginPath();n.moveTo(h,m);n.lineTo(o,p);n.lineTo(v,r);n.lineTo(h,m);n.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof -THREE.UVMapping&&wa(h,m,o,p,v,r,M.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(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){y=qa.matrix;aa.copy(B.vertexNormalsWorld[0]);N=(aa.x*y.n11+aa.y*y.n12+aa.z*y.n13)*0.5+0.5;K=-(aa.x*y.n21+aa.y*y.n22+aa.z*y.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[1]);O=(aa.x*y.n11+aa.y*y.n12+aa.z*y.n13)*0.5+0.5;U=-(aa.x*y.n21+aa.y*y.n22+aa.z*y.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[2]); -J=(aa.x*y.n11+aa.y*y.n12+aa.z*y.n13)*0.5+0.5;G=-(aa.x*y.n21+aa.y*y.n22+aa.z*y.n23)*0.5+0.5;wa(h,m,o,p,v,r,M.env_map.image,N,K,O,U,J,G)}}else M.wireframe?Ba(M.color.__styleString,M.wireframe_linewidth):Ca(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&wa(h,m,o,p,v,r,M.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);b(THREE.SubtractiveBlending)}if(F)if(!M.wireframe&&M.shading==THREE.SmoothShading&& -B.vertexNormalsWorld.length==3){x.r=t.r=i.r=$.r;x.g=t.g=i.g=$.g;x.b=t.b=i.b=$.b;Aa(Z,B.v1.positionWorld,B.vertexNormalsWorld[0],x);Aa(Z,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa(Z,B.v3.positionWorld,B.vertexNormalsWorld[2],i);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5;u.b=(t.b+i.b)*0.5;L=Ja(x,t,i,u);wa(h,m,o,p,v,r,L,0,0,1,0,0,1)}else{X.r=$.r;X.g=$.g;X.b=$.b;Aa(Z,B.centroidWorld,B.normalWorld,X);l.r=M.color.r*X.r;l.g=M.color.g*X.g;l.b=M.color.b*X.b;l.updateStyleString();M.wireframe?Ba(l.__styleString, -M.wireframe_linewidth):Ca(l.__styleString)}else M.wireframe?Ba(M.color.__styleString,M.wireframe_linewidth):Ca(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){I=qa.near;A=qa.far;x.r=x.g=x.b=1-Ea(y.positionScreen.z,I,A);t.r=t.g=t.b=1-Ea(W.positionScreen.z,I,A);i.r=i.g=i.b=1-Ea(Q.positionScreen.z,I,A);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5;u.b=(t.b+i.b)*0.5;L=Ja(x,t,i,u);wa(h,m,o,p,v,r,L,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){l.r=Fa(B.normalWorld.x);l.g=Fa(B.normalWorld.y); -l.b=Fa(B.normalWorld.z);l.updateStyleString();M.wireframe?Ba(l.__styleString,M.wireframe_linewidth):Ca(l.__styleString)}}}function Ba(y,W){if(S!=y)n.strokeStyle=S=y;if(T!=W)n.lineWidth=T=W;n.stroke();w.inflate(W*2)}function Ca(y){if(V!=y)n.fillStyle=V=y;n.fill()}function wa(y,W,Q,B,M,Z,da,ha,ia,na,la,oa,xa){var sa,pa;sa=da.width-1;pa=da.height-1;ha*=sa;ia*=pa;na*=sa;la*=pa;oa*=sa;xa*=pa;Q-=y;B-=W;M-=y;Z-=W;na-=ha;la-=ia;oa-=ha;xa-=ia;pa=1/(na*xa-oa*la);sa=(xa*Q-la*M)*pa;la=(xa*B-la*Z)*pa;Q=(na*M- -oa*Q)*pa;B=(na*Z-oa*B)*pa;y=y-sa*ha-Q*ia;W=W-la*ha-B*ia;n.save();n.transform(sa,la,Q,B,y,W);n.clip();n.drawImage(da,0,0);n.restore()}function Ja(y,W,Q,B){var M=~~(y.r*255),Z=~~(y.g*255);y=~~(y.b*255);var da=~~(W.r*255),ha=~~(W.g*255);W=~~(W.b*255);var ia=~~(Q.r*255),na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(B.r*255),oa=~~(B.g*255);B=~~(B.b*255);ja[0]=M<0?0:M>255?255:M;ja[1]=Z<0?0:Z>255?255:Z;ja[2]=y<0?0:y>255?255:y;ja[4]=da<0?0:da>255?255:da;ja[5]=ha<0?0:ha>255?255:ha;ja[6]=W<0?0:W>255?255:W;ja[8]=ia< -0?0:ia>255?255:ia;ja[9]=na<0?0:na>255?255:na;ja[10]=Q<0?0:Q>255?255:Q;ja[12]=la<0?0:la>255?255:la;ja[13]=oa<0?0:oa>255?255:oa;ja[14]=B<0?0:B>255?255:B;ca.putImageData(ta,0,0);za.drawImage(ka,0,0);return ra}function Ea(y,W,Q){y=(y-W)/(Q-W);return y*y*(3-2*y)}function Fa(y){y=(y+1)*0.5;return y<0?0:y>1?1:y}function Ga(y,W){var Q=W.x-y.x,B=W.y-y.y,M=1/Math.sqrt(Q*Q+B*B);Q*=M;B*=M;W.x+=Q;W.y+=B;y.x-=Q;y.y-=B}var Da,Ka,ba,ma,va,Ha,La,ya;n.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();e=f.projectScene(ea, -qa,this.sortElements);(F=ea.lights.length>0)&&Ma(ea);Da=0;for(Ka=e.length;Da0){O.r+=G.color.r*P;O.g+=G.color.g*P;O.b+=G.color.b*P}}else if(G instanceof THREE.PointLight){r.sub(G.position,K.centroidWorld);r.normalize();P=K.normalWorld.dot(r)*G.intensity;if(P>0){O.r+=G.color.r*P;O.g+=G.color.g*P;O.b+=G.color.b*P}}}}function b(N,K,O,U,J,G){i=f(u++);i.setAttribute("d","M "+N.positionScreen.x+ -" "+N.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(R){h.r=m.r;h.g=m.g;h.b=m.b;a(G,U,h);d.r=J.color.r*h.r;d.g=J.color.g*h.g;d.b=J.color.b*h.b;d.updateStyleString()}else d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){v=1-J.__2near/(J.__farPlusNear-U.z*J.__farMinusNear); -d.setRGB(v,v,v)}else J instanceof THREE.MeshNormalMaterial&&d.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));J.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+J.opacity);c.appendChild(i)}function e(N,K,O,U,J,G,P){i=f(u++);i.setAttribute("d", -"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)d.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(R){h.r=m.r;h.g=m.g;h.b=m.b;a(P,J,h);d.r=G.color.r*h.r;d.g=G.color.g*h.g;d.b=G.color.b*h.b;d.updateStyleString()}else d.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){v= -1-G.__2near/(G.__farPlusNear-J.z*G.__farMinusNear);d.setRGB(v,v,v)}else G instanceof THREE.MeshNormalMaterial&&d.setRGB(g(J.normalWorld.x),g(J.normalWorld.y),g(J.normalWorld.z));G.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+G.opacity);c.appendChild(i)} -function f(N){if(l[N]==null){l[N]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&l[N].setAttribute("shape-rendering","crispEdges");return l[N]}return l[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var j=null,q=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,D,E,z,C,S,V,T=new THREE.Rectangle,s=new THREE.Rectangle,R=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),m=new THREE.Color(0),o=new THREE.Color(0), -p=new THREE.Color(0),v,r=new THREE.Vector3,l=[],x=[],t=[],i,u,I,A,L=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(N){switch(N){case "high":L=1;break;case "low":L=0}};this.setSize=function(N,K){k=N;n=K;D=k/2;E=n/2;c.setAttribute("viewBox",-D+" "+-E+" "+k+" "+n);c.setAttribute("width",k);c.setAttribute("height",n);T.set(-D,-E,D,E)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(N,K){var O,U, -J,G,P,H,w,F;this.autoClear&&this.clear();j=q.projectScene(N,K,this.sortElements);A=I=u=0;if(R=N.lights.length>0){w=N.lights;m.setRGB(0,0,0);o.setRGB(0,0,0);p.setRGB(0,0,0);O=0;for(U=w.length;O=0&&t>=0&&i>=0&&u>=0)return true;else if(w<0&&t<0||i<0&&u<0)return false;else{if(w<0)p=Math.max(p,w/(w-t));else if(t<0)m=Math.min(m,w/(w-t));if(i<0)p=Math.max(p,i/(i-u));else if(u<0)m=Math.min(m,i/(i-u));if(mw&&A.z0&&T.z<1){z=S[C]=S[C]||new THREE.RenderableParticle;z.x=T.x/T.w;z.y=T.y/T.w;z.z=T.z;z.rotation=K.rotation.z;z.scale.x=K.scale.x*Math.abs(z.x-(T.x+v.projectionMatrix.n11)/(T.w+v.projectionMatrix.n14)); +z.scale.y=K.scale.y*Math.abs(z.y-(T.y+v.projectionMatrix.n22)/(T.w+v.projectionMatrix.n24));z.materials=K.materials;m.push(z);C++}}}}p&&m.sort(a);return m};this.unprojectVector=function(s,v){var p=new THREE.Matrix4;p.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));p.multiplyVector3(s);return s}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(q,b){e=q;f=b;g=e/2;j=f/2};this.render=function(q,b){var l,o,D,E,z,C,S,V;a=c.projectScene(q,b);l=0;for(o=a.length;l0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}else if(Z instanceof THREE.PointLight){aa.sub(Z.position,W);aa.normalize();Z=Q.dot(aa)*ha;if(Z>0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}}}function Na(y,W,Q){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);var B, +M,Z,da,ha,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){da=Q.map;ha=da.width>>1;ia=da.height>>1;M=W.scale.x*b;Z=W.scale.y*l;Q=M*ha;B=Z*ia;x.set(y.x-Q,y.y-B,y.x+Q,y.y+B);if(P.instersects(x)){o.save();o.translate(y.x,y.y);o.rotate(-W.rotation);o.scale(M,-Z);o.translate(-ha,-ia);o.drawImage(da,0,0);o.restore()}}}else if(Q instanceof THREE.ParticleCircleMaterial){if(F){X.r=$.r+Y.r+ga.r;X.g=$.g+Y.g+ga.g;X.b=$.b+Y.b+ga.b;m.r=Q.color.r*X.r;m.g=Q.color.g*X.g;m.b=Q.color.b*X.b;m.updateStyleString()}else m.__styleString= +Q.color.__styleString;Q=W.scale.x*b;B=W.scale.y*l;x.set(y.x-Q,y.y-B,y.x+Q,y.y+B);if(P.instersects(x)){M=m.__styleString;if(V!=M)o.fillStyle=V=M;o.save();o.translate(y.x,y.y);o.rotate(-W.rotation);o.scale(Q,B);o.beginPath();o.arc(0,0,1,0,fa,true);o.closePath();o.fill();o.restore()}}}}function Oa(y,W,Q,B){if(B.opacity!=0){a(B.opacity);c(B.blending);o.beginPath();o.moveTo(y.positionScreen.x,y.positionScreen.y);o.lineTo(W.positionScreen.x,W.positionScreen.y);o.closePath();if(B instanceof THREE.LineBasicMaterial){m.__styleString= +B.color.__styleString;y=B.linewidth;if(T!=y)o.lineWidth=T=y;y=m.__styleString;if(S!=y)o.strokeStyle=S=y;o.stroke();x.inflate(B.linewidth*2)}}}function Ia(y,W,Q,B,M,Z){if(M.opacity!=0){a(M.opacity);c(M.blending);h=y.positionScreen.x;k=y.positionScreen.y;n=W.positionScreen.x;s=W.positionScreen.y;v=Q.positionScreen.x;p=Q.positionScreen.y;o.beginPath();o.moveTo(h,k);o.lineTo(n,s);o.lineTo(v,p);o.lineTo(h,k);o.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof +THREE.UVMapping&&wa(h,k,n,s,v,p,M.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(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){y=qa.matrix;aa.copy(B.vertexNormalsWorld[0]);N=(aa.x*y.n11+aa.y*y.n12+aa.z*y.n13)*0.5+0.5;K=-(aa.x*y.n21+aa.y*y.n22+aa.z*y.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[1]);O=(aa.x*y.n11+aa.y*y.n12+aa.z*y.n13)*0.5+0.5;U=-(aa.x*y.n21+aa.y*y.n22+aa.z*y.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[2]); +J=(aa.x*y.n11+aa.y*y.n12+aa.z*y.n13)*0.5+0.5;G=-(aa.x*y.n21+aa.y*y.n22+aa.z*y.n23)*0.5+0.5;wa(h,k,n,s,v,p,M.env_map.image,N,K,O,U,J,G)}}else M.wireframe?Ba(M.color.__styleString,M.wireframe_linewidth):Ca(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&wa(h,k,n,s,v,p,M.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);c(THREE.SubtractiveBlending)}if(F)if(!M.wireframe&&M.shading==THREE.SmoothShading&& +B.vertexNormalsWorld.length==3){w.r=t.r=i.r=$.r;w.g=t.g=i.g=$.g;w.b=t.b=i.b=$.b;Aa(Z,B.v1.positionWorld,B.vertexNormalsWorld[0],w);Aa(Z,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa(Z,B.v3.positionWorld,B.vertexNormalsWorld[2],i);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5;u.b=(t.b+i.b)*0.5;L=Ja(w,t,i,u);wa(h,k,n,s,v,p,L,0,0,1,0,0,1)}else{X.r=$.r;X.g=$.g;X.b=$.b;Aa(Z,B.centroidWorld,B.normalWorld,X);m.r=M.color.r*X.r;m.g=M.color.g*X.g;m.b=M.color.b*X.b;m.updateStyleString();M.wireframe?Ba(m.__styleString, +M.wireframe_linewidth):Ca(m.__styleString)}else M.wireframe?Ba(M.color.__styleString,M.wireframe_linewidth):Ca(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){I=qa.near;A=qa.far;w.r=w.g=w.b=1-Ea(y.positionScreen.z,I,A);t.r=t.g=t.b=1-Ea(W.positionScreen.z,I,A);i.r=i.g=i.b=1-Ea(Q.positionScreen.z,I,A);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5;u.b=(t.b+i.b)*0.5;L=Ja(w,t,i,u);wa(h,k,n,s,v,p,L,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){m.r=Fa(B.normalWorld.x);m.g=Fa(B.normalWorld.y); +m.b=Fa(B.normalWorld.z);m.updateStyleString();M.wireframe?Ba(m.__styleString,M.wireframe_linewidth):Ca(m.__styleString)}}}function Ba(y,W){if(S!=y)o.strokeStyle=S=y;if(T!=W)o.lineWidth=T=W;o.stroke();x.inflate(W*2)}function Ca(y){if(V!=y)o.fillStyle=V=y;o.fill()}function wa(y,W,Q,B,M,Z,da,ha,ia,na,la,oa,xa){var sa,pa;sa=da.width-1;pa=da.height-1;ha*=sa;ia*=pa;na*=sa;la*=pa;oa*=sa;xa*=pa;Q-=y;B-=W;M-=y;Z-=W;na-=ha;la-=ia;oa-=ha;xa-=ia;pa=1/(na*xa-oa*la);sa=(xa*Q-la*M)*pa;la=(xa*B-la*Z)*pa;Q=(na*M- +oa*Q)*pa;B=(na*Z-oa*B)*pa;y=y-sa*ha-Q*ia;W=W-la*ha-B*ia;o.save();o.transform(sa,la,Q,B,y,W);o.clip();o.drawImage(da,0,0);o.restore()}function Ja(y,W,Q,B){var M=~~(y.r*255),Z=~~(y.g*255);y=~~(y.b*255);var da=~~(W.r*255),ha=~~(W.g*255);W=~~(W.b*255);var ia=~~(Q.r*255),na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(B.r*255),oa=~~(B.g*255);B=~~(B.b*255);ja[0]=M<0?0:M>255?255:M;ja[1]=Z<0?0:Z>255?255:Z;ja[2]=y<0?0:y>255?255:y;ja[4]=da<0?0:da>255?255:da;ja[5]=ha<0?0:ha>255?255:ha;ja[6]=W<0?0:W>255?255:W;ja[8]=ia< +0?0:ia>255?255:ia;ja[9]=na<0?0:na>255?255:na;ja[10]=Q<0?0:Q>255?255:Q;ja[12]=la<0?0:la>255?255:la;ja[13]=oa<0?0:oa>255?255:oa;ja[14]=B<0?0:B>255?255:B;ca.putImageData(ta,0,0);za.drawImage(ka,0,0);return ra}function Ea(y,W,Q){y=(y-W)/(Q-W);return y*y*(3-2*y)}function Fa(y){y=(y+1)*0.5;return y<0?0:y>1?1:y}function Ga(y,W){var Q=W.x-y.x,B=W.y-y.y,M=1/Math.sqrt(Q*Q+B*B);Q*=M;B*=M;W.x+=Q;W.y+=B;y.x-=Q;y.y-=B}var Da,Ka,ba,ma,va,Ha,La,ya;o.setTransform(1,0,0,-1,b,l);this.autoClear&&this.clear();e=f.projectScene(ea, +qa,this.sortElements);(F=ea.lights.length>0)&&Ma(ea);Da=0;for(Ka=e.length;Da0){O.r+=G.color.r*P;O.g+=G.color.g*P;O.b+=G.color.b*P}}else if(G instanceof THREE.PointLight){p.sub(G.position,K.centroidWorld);p.normalize();P=K.normalWorld.dot(p)*G.intensity;if(P>0){O.r+=G.color.r*P;O.g+=G.color.g*P;O.b+=G.color.b*P}}}}function c(N,K,O,U,J,G){i=f(u++);i.setAttribute("d","M "+N.positionScreen.x+ +" "+N.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(R){h.r=k.r;h.g=k.g;h.b=k.b;a(G,U,h);d.r=J.color.r*h.r;d.g=J.color.g*h.g;d.b=J.color.b*h.b;d.updateStyleString()}else d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){v=1-J.__2near/(J.__farPlusNear-U.z*J.__farMinusNear); +d.setRGB(v,v,v)}else J instanceof THREE.MeshNormalMaterial&&d.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));J.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+J.opacity);b.appendChild(i)}function e(N,K,O,U,J,G,P){i=f(u++);i.setAttribute("d", +"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)d.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(R){h.r=k.r;h.g=k.g;h.b=k.b;a(P,J,h);d.r=G.color.r*h.r;d.g=G.color.g*h.g;d.b=G.color.b*h.b;d.updateStyleString()}else d.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){v= +1-G.__2near/(G.__farPlusNear-J.z*G.__farMinusNear);d.setRGB(v,v,v)}else G instanceof THREE.MeshNormalMaterial&&d.setRGB(g(J.normalWorld.x),g(J.normalWorld.y),g(J.normalWorld.z));G.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+G.opacity);b.appendChild(i)} +function f(N){if(m[N]==null){m[N]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&m[N].setAttribute("shape-rendering","crispEdges");return m[N]}return m[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var j=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,o,D,E,z,C,S,V,T=new THREE.Rectangle,r=new THREE.Rectangle,R=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),k=new THREE.Color(0),n=new THREE.Color(0), +s=new THREE.Color(0),v,p=new THREE.Vector3,m=[],w=[],t=[],i,u,I,A,L=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(N){switch(N){case "high":L=1;break;case "low":L=0}};this.setSize=function(N,K){l=N;o=K;D=l/2;E=o/2;b.setAttribute("viewBox",-D+" "+-E+" "+l+" "+o);b.setAttribute("width",l);b.setAttribute("height",o);T.set(-D,-E,D,E)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(N,K){var O,U, +J,G,P,H,x,F;this.autoClear&&this.clear();j=q.projectScene(N,K,this.sortElements);A=I=u=0;if(R=N.lights.length>0){x=N.lights;k.setRGB(0,0,0);n.setRGB(0,0,0);s.setRGB(0,0,0);O=0;for(U=x.length;O0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,X,m)}if(p){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ga,m);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,fa,m)}};this.setLineBuffers=function(d,h,m,o){var p,v,r=d.vertices,l=r.length,x=d.__vertexArray,t=d.__lineArray;if(m)for(m=0;m0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"","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(u, -g("fragment",I+l));c.attachShader(u,g("vertex",t+i));c.linkProgram(u);c.getProgramParameter(u,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(u,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");u.uniforms={};u.attributes={};o.program=u;l=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(r in o.uniforms)l.push(r);r=o.program;i=0;for(u=l.length;i=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer); -c.vertexAttribPointer(x.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(x.normal)}if(x.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);c.vertexAttribPointer(x.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(x.tangent)}if(x.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(x.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(x.uv)}else c.disableVertexAttribArray(x.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){x= -o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&v.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(x);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(o,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(d,h,m,o,p,v,r){var l,x,t,i,u;t=0;for(i= -o.materials.length;t=0;m--){o=d.__webGLObjects[m].object;h==o&&d.__webGLObjects.splice(m,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();n.multiply(h.matrix,d.matrix);z.set(n.flatten());D=THREE.Matrix4.makeInvert3x3(n).transpose();S.set(D.m);V.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,E);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,z);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,C); -c.uniformMatrix3fv(d.uniforms.normalMatrix,false,S);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,V)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(d){switch(d){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(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="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.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif", -envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif", -map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", +h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var k;if(d=="fragment")k=b.createShader(b.FRAGMENT_SHADER);else if(d=="vertex")k=b.createShader(b.VERTEX_SHADER);b.shaderSource(k,h);b.compileShader(k);if(!b.getShaderParameter(k,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(k));return null}return k}function j(d){switch(d){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT; +case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT; +case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var q=document.createElement("canvas"),b,l=null,o=new THREE.Matrix4,D,E=new Float32Array(16),z=new Float32Array(16),C=new Float32Array(16),S=new Float32Array(9),V= +new Float32Array(16),T=true,r=new THREE.Color(0),R=0;if(a){if(a.antialias!==undefined)T=a.antialias;a.clearColor!==undefined&&r.setHex(a.clearColor);if(a.clearAlpha!==undefined)R=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(d,h,k){try{b=q.getContext("experimental-webgl",{antialias:d})}catch(n){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK); +b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,k)})(T,r,R);this.context=b;this.setSize=function(d,h){q.width=d;q.height=h;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(d,h){var k=new THREE.Color(d);b.clearColor(k.r,k.g,k.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var k,n,s,v=0,p=0,m=0,w,t,i,u=[],I=[],A=[],L=[];k=0;for(n=h.length;k0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,X,k)}if(s){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ga,k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,k)}};this.setLineBuffers=function(d,h,k,n){var s,v,p=d.vertices,m=p.length,w=d.__vertexArray,t=d.__lineArray;if(k)for(k=0;k0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"","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");b.attachShader(u, +g("fragment",I+m));b.attachShader(u,g("vertex",t+i));b.linkProgram(u);b.getProgramParameter(u,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(u,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");u.uniforms={};u.attributes={};n.program=u;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(p in n.uniforms)m.push(p);p=n.program;i=0;for(u=m.length;i=0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLNormalBuffer); +b.vertexAttribPointer(w.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(w.normal)}if(w.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLTangentBuffer);b.vertexAttribPointer(w.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(w.tangent)}if(w.uv>=0)if(s.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLUVBuffer);b.vertexAttribPointer(w.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(w.uv)}else b.disableVertexAttribArray(w.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){w= +n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(w);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);b.drawElements(n,s.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,s.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,k,n,s,v,p){var m,w,t,i,u;t=0;for(i= +n.materials.length;t=0;k--){n=d.__webGLObjects[k].object;h==n&&d.__webGLObjects.splice(k,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();o.multiply(h.matrix,d.matrix);z.set(o.flatten());D=THREE.Matrix4.makeInvert3x3(o).transpose();S.set(D.m); +V.set(d.matrix.flatten())};this.loadMatrices=function(d){b.uniformMatrix4fv(d.uniforms.viewMatrix,false,E);b.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,z);b.uniformMatrix4fv(d.uniforms.projectionMatrix,false,C);b.uniformMatrix3fv(d.uniforms.normalMatrix,false,S);b.uniformMatrix4fv(d.uniforms.objectMatrix,false,V)};this.loadCamera=function(d,h){b.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD); +b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> +0}}; +THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", +map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 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, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv", diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index 30a5e927..7134cb60 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,70 +1,70 @@ // ThreeDebug.js r32 - 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,e){this.r=a;this.g=b;this.b=e;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)+")"},clone:function(){return new THREE.Color(this.hex)},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,e){this.x=a||0;this.y=b||0;this.z=e||0}; -THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;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,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= -a.z;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,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+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= +THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; +THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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,c,e){this.x=a||0;this.y=c||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-e*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= +a.z;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 c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+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,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1}; -THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;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,f=a.objects,g=[];a=0;for(b=f.length;a0&&T>0&&n+T<1}var e,f,g,j,q,c,k,l,D,E, -z,C=a.geometry,S=C.vertices,V=[];e=0;for(f=C.faces.length;ek?f:k;g=g>l? -g:l}a()};this.add3Points=function(k,l,D,E,z,C){if(c){c=false;b=kD?k>z?k:z:D>z?D:z;g=l>E?l>C?l:C:E>C?E:C}else{b=kD?k>z?k>f?k:f:z>f?z:f:D>z?D>f?D:f:z>f?z:f;g=l>E?l>C?l>g?l:g:C>g?C:g:E>C?E>g?E:g:C>g?C:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();e=k.getTop();f=k.getRight();g=k.getBottom()}else{b=bk.getRight()?f:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;f+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f=0&&Math.min(g,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){c=true;g=f=e=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+j+", height: "+q+" )"}};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,f,g,j,q,c,k,l,D,E,z,C,S,V){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=j||1;this.n23=q||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=D||1;this.n34=E||0;this.n41=z||0;this.n42=C||0;this.n43=S||0;this.n44=V||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,f,g,j,q,c,k,l,D,E,z,C,S,V){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=q;this.n24=c;this.n31=k;this.n32=l;this.n33=D;this.n34=E;this.n41=z;this.n42=C;this.n43=S;this.n44=V;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 f=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();f.cross(e,j).normalize();g.cross(j,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x; -this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*f+this.n24* -g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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,f=a.n12,g=a.n13,j=a.n14,q=a.n21,c=a.n22,k=a.n23,l=a.n24,D=a.n31,E=a.n32, -z=a.n33,C=a.n34,S=a.n41,V=a.n42,T=a.n43,s=a.n44,R=b.n11,d=b.n12,h=b.n13,n=b.n14,o=b.n21,p=b.n22,v=b.n23,r=b.n24,m=b.n31,y=b.n32,t=b.n33,i=b.n34,u=b.n41,I=b.n42,A=b.n43,L=b.n44;this.n11=e*R+f*o+g*m+j*u;this.n12=e*d+f*p+g*y+j*I;this.n13=e*h+f*v+g*t+j*A;this.n14=e*n+f*r+g*i+j*L;this.n21=q*R+c*o+k*m+l*u;this.n22=q*d+c*p+k*y+l*I;this.n23=q*h+c*v+k*t+l*A;this.n24=q*n+c*r+k*i+l*L;this.n31=D*R+E*o+z*m+C*u;this.n32=D*d+E*p+z*y+C*I;this.n33=D*h+E*v+z*t+C*A;this.n34=D*n+E*r+z*i+C*L;this.n41=S*R+V*o+T*m+s*u; -this.n42=S*d+V*p+T*y+s*I;this.n43=S*h+V*v+T*t+s*A;this.n44=S*n+V*r+T*i+s*L;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,j=this.n21,q=this.n22,c=this.n23,k=this.n24,l=this.n31,D=this.n32,E=this.n33,z=this.n34,C=this.n41,S=this.n42,V=this.n43,T=this.n44,s=a.n11,R=a.n21,d=a.n31,h=a.n41,n=a.n12,o=a.n22,p=a.n32,v=a.n42,r=a.n13,m=a.n23,y=a.n33,t=a.n43,i=a.n14,u=a.n24,I=a.n34;a=a.n44;this.n11=b*s+e*R+f*d+g*h;this.n12=b*n+e*o+f*p+g*v;this.n13=b*r+e*m+f*y+g*t;this.n14= -b*i+e*u+f*I+g*a;this.n21=j*s+q*R+c*d+k*h;this.n22=j*n+q*o+c*p+k*v;this.n23=j*r+q*m+c*y+k*t;this.n24=j*i+q*u+c*I+k*a;this.n31=l*s+D*R+E*d+z*h;this.n32=l*n+D*o+E*p+z*v;this.n33=l*r+D*m+E*y+z*t;this.n34=l*i+D*u+E*I+z*a;this.n41=C*s+S*R+V*d+T*h;this.n42=C*n+S*o+V*p+T*v;this.n43=C*r+S*m+V*y+T*t;this.n44=C*i+S*u+V*I+T*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.Vector4=function(a,c,e,f){this.x=a||0;this.y=c||0;this.z=e||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,c,e,f){this.x=a;this.y=c;this.z=e;this.w=f;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; +THREE.Ray.prototype={intersectScene:function(a){var c,e,f=a.objects,g=[];a=0;for(c=f.length;a0&&T>0&&k+T<1}var e,f,g,j,q,b,l,m,D,E, +z,C=a.geometry,S=C.vertices,V=[];e=0;for(f=C.faces.length;el?f:l;g=g>m? +g:m}a()};this.add3Points=function(l,m,D,E,z,C){if(b){b=false;c=lD?l>z?l:z:D>z?D:z;g=m>E?m>C?m:C:E>C?E:C}else{c=lD?l>z?l>f?l:f:z>f?z:f:D>z?D>f?D:f:z>f?z:f;g=m>E?m>C?m>g?m:g:C>g?C:g:E>C?E>g?E:g:C>g?C:g}a()};this.addRectangle=function(l){if(b){b=false;c=l.getLeft();e=l.getTop();f=l.getRight();g=l.getBottom()}else{c=cl.getRight()?f:l.getRight();g=g>l.getBottom()?g:l.getBottom()}a()};this.inflate=function(l){c-=l;e-=l;f+=l;g+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();e=e>l.getTop()?e:l.getTop();f=f=0&&Math.min(g,l.getBottom())-Math.max(e,l.getTop())>=0};this.empty=function(){b=true;g=f=e=c=0;a()};this.isEmpty=function(){return b};this.toString= +function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+e+", bottom: "+g+", width: "+j+", height: "+q+" )"}};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,c,e,f,g,j,q,b,l,m,D,E,z,C,S,V){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=j||1;this.n23=q||0;this.n24=b||0;this.n31=l||0;this.n32=m||0;this.n33=D||1;this.n34=E||0;this.n41=z||0;this.n42=C||0;this.n43=S||0;this.n44=V||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,c,e,f,g,j,q,b,l,m,D,E,z,C,S,V){this.n11=a;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=q;this.n24=b;this.n31=l;this.n32=m;this.n33=D;this.n34=E;this.n41=z;this.n42=C;this.n43=S;this.n44=V;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,c,e){var f=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,c).normalize();f.cross(e,j).normalize();g.cross(j,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x; +this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,f=a.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*e+this.n23*f+this.n24* +g;a.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var e=a.n11,f=a.n12,g=a.n13,j=a.n14,q=a.n21,b=a.n22,l=a.n23,m=a.n24,D=a.n31,E=a.n32, +z=a.n33,C=a.n34,S=a.n41,V=a.n42,T=a.n43,r=a.n44,R=c.n11,d=c.n12,h=c.n13,k=c.n14,o=c.n21,s=c.n22,v=c.n23,p=c.n24,n=c.n31,w=c.n32,t=c.n33,i=c.n34,u=c.n41,I=c.n42,A=c.n43,L=c.n44;this.n11=e*R+f*o+g*n+j*u;this.n12=e*d+f*s+g*w+j*I;this.n13=e*h+f*v+g*t+j*A;this.n14=e*k+f*p+g*i+j*L;this.n21=q*R+b*o+l*n+m*u;this.n22=q*d+b*s+l*w+m*I;this.n23=q*h+b*v+l*t+m*A;this.n24=q*k+b*p+l*i+m*L;this.n31=D*R+E*o+z*n+C*u;this.n32=D*d+E*s+z*w+C*I;this.n33=D*h+E*v+z*t+C*A;this.n34=D*k+E*p+z*i+C*L;this.n41=S*R+V*o+T*n+r*u; +this.n42=S*d+V*s+T*w+r*I;this.n43=S*h+V*v+T*t+r*A;this.n44=S*k+V*p+T*i+r*L;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,f=this.n13,g=this.n14,j=this.n21,q=this.n22,b=this.n23,l=this.n24,m=this.n31,D=this.n32,E=this.n33,z=this.n34,C=this.n41,S=this.n42,V=this.n43,T=this.n44,r=a.n11,R=a.n21,d=a.n31,h=a.n41,k=a.n12,o=a.n22,s=a.n32,v=a.n42,p=a.n13,n=a.n23,w=a.n33,t=a.n43,i=a.n14,u=a.n24,I=a.n34;a=a.n44;this.n11=c*r+e*R+f*d+g*h;this.n12=c*k+e*o+f*s+g*v;this.n13=c*p+e*n+f*w+g*t;this.n14= +c*i+e*u+f*I+g*a;this.n21=j*r+q*R+b*d+l*h;this.n22=j*k+q*o+b*s+l*v;this.n23=j*p+q*n+b*w+l*t;this.n24=j*i+q*u+b*I+l*a;this.n31=m*r+D*R+E*d+z*h;this.n32=m*k+D*o+E*s+z*v;this.n33=m*p+D*n+E*w+z*t;this.n34=m*i+D*u+E*I+z*a;this.n41=C*r+S*R+V*d+T*h;this.n42=C*k+S*o+V*s+T*v;this.n43=C*p+S*n+V*w+T*t;this.n44=C*i+S*u+V*I+T*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,f){var g=b[e];b[e]=b[f]; -b[f]=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, -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,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f}; -THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f};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 e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),j=1-f,q=a.x,c=a.y,k=a.z;e.n11=j*q*q+f;e.n12=j*q*c-g*k;e.n13=j*q*k+g*c;e.n21=j*q*c+g*k;e.n22=j*c*c+f;e.n23=j*c*k-g*q;e.n31=j*q*k-g*c;e.n32=j*c*k+g*q;e.n33=j*k*k+f;return e}; -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 e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*q;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*l;a.m[8]=b*D;return a}; -THREE.Matrix4.makeFrustum=function(a,b,e,f,g,j){var q,c,k;q=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(j+g)/(j-g);g=-2*j*g/(j-g);q.n11=c;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=k;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=g;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)}; -THREE.Matrix4.makeOrtho=function(a,b,e,f,g,j){var q,c,k,l;q=new THREE.Matrix4;c=b-a;k=e-f;l=j-g;a=(b+a)/c;e=(e+f)/k;g=(j+g)/l;q.n11=2/c;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/k;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/l;q.n34=-g;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q}; -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,e,f,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,e,f,g,j){this.a=a;this.b=b;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};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}; +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(c,e,f){var g=c[e];c[e]=c[f]; +c[f]=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, +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,c,e){var f=new THREE.Matrix4;f.n14=a;f.n24=c;f.n34=e;return f}; +THREE.Matrix4.scaleMatrix=function(a,c,e){var f=new THREE.Matrix4;f.n11=a;f.n22=c;f.n33=e;return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4,f=Math.cos(c),g=Math.sin(c),j=1-f,q=a.x,b=a.y,l=a.z;e.n11=j*q*q+f;e.n12=j*q*b-g*l;e.n13=j*q*l+g*b;e.n21=j*q*b+g*l;e.n22=j*b*b+f;e.n23=j*b*l-g*q;e.n31=j*q*l-g*b;e.n32=j*b*l+g*q;e.n33=j*l*l+f;return e}; +THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],g=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],q=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],l=c[9]*c[4]-c[5]*c[8],m=-c[9]*c[0]+c[1]*c[8],D=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*j+c[2]*l;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*e;a.m[1]=c*f;a.m[2]=c*g;a.m[3]=c*j;a.m[4]=c*q;a.m[5]=c*b;a.m[6]=c*l;a.m[7]=c*m;a.m[8]=c*D;return a}; +THREE.Matrix4.makeFrustum=function(a,c,e,f,g,j){var q,b,l;q=new THREE.Matrix4;b=2*g/(c-a);l=2*g/(f-e);a=(c+a)/(c-a);e=(f+e)/(f-e);f=-(j+g)/(j-g);g=-2*j*g/(j-g);q.n11=b;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=g;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,e,f)}; +THREE.Matrix4.makeOrtho=function(a,c,e,f,g,j){var q,b,l,m;q=new THREE.Matrix4;b=c-a;l=e-f;m=j-g;a=(c+a)/b;e=(e+f)/l;g=(j+g)/m;q.n11=2/b;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-g;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q}; +THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,e,f,g){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,c,e,f,g,j){this.a=a;this.b=c;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a0){this.boundingBox={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 b=1,e=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:q,vertices:0}}this.geometryChunks[k].faces.push(f);this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+ +THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a0){this.boundingBox={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 c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c65535){m[b].counter+=1;l=m[b].hash+"_"+m[b].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); +THREE.Camera=function(a,c,e,f){this.fov=a;this.aspect=c;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={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.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; +THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||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.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={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};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false}; -THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; -THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.autoUpdateMatrix=false}; +THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; +THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";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;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -91,99 +91,104 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM 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}}; THREE.ParticleBasicMaterial.prototype={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}}; THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,e,f,g,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,c,e,f,g,j){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},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;var Uniforms={clone:function(a){var b,e,f,g={};for(b in a){g[b]={};for(e in a[b]){f=a[b][e];g[b][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var b,e,f,g={};for(b=0;b=0&&t>=0&&i>=0&&u>=0)return true;else if(y<0&&t<0||i<0&&u<0)return false;else{if(y<0)r=Math.max(r,y/(y-t));else if(t<0)m=Math.min(m,y/(y-t));if(i<0)r=Math.max(r,i/(i-u));else if(u<0)m=Math.min(m,i/(i-u));if(my&&A.z0&&T.z<1){z=S[C]=S[C]||new THREE.RenderableParticle;z.x=T.x/T.w;z.y=T.y/T.w;z.z=T.z;z.rotation=K.rotation.z;z.scale.x=K.scale.x*Math.abs(z.x-(T.x+v.projectionMatrix.n11)/(T.w+v.projectionMatrix.n14)); -z.scale.y=K.scale.y*Math.abs(z.y-(T.y+v.projectionMatrix.n22)/(T.w+v.projectionMatrix.n24));z.materials=K.materials;m.push(z);C++}}}}r&&m.sort(a);return m};this.unprojectVector=function(p,v){var r=new THREE.Matrix4;r.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));r.multiplyVector3(p);return p}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(q,c){e=q;f=c;g=e/2;j=f/2};this.render=function(q,c){var k,l,D,E,z,C,S,V;a=b.projectScene(q,c);k=0;for(l=a.length;k0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}else if(Z instanceof THREE.PointLight){aa.sub(Z.position,W);aa.normalize();Z=Q.dot(aa)*ha;if(Z>0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}}}function Na(w,W,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);var B, -N,Z,da,ha,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){da=Q.map;ha=da.width>>1;ia=da.height>>1;N=W.scale.x*c;Z=W.scale.y*k;Q=N*ha;B=Z*ia;x.set(w.x-Q,w.y-B,w.x+Q,w.y+B);if(!M.instersects(x))return;l.save();l.translate(w.x,w.y);l.rotate(-W.rotation);l.scale(N,-Z);l.translate(-ha,-ia);l.drawImage(da,0,0);l.restore()}l.beginPath();l.moveTo(w.x-10,w.y);l.lineTo(w.x+10,w.y);l.moveTo(w.x,w.y-10);l.lineTo(w.x,w.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(Q instanceof -THREE.ParticleCircleMaterial){if(G){X.r=$.r+Y.r+ga.r;X.g=$.g+Y.g+ga.g;X.b=$.b+Y.b+ga.b;m.r=Q.color.r*X.r;m.g=Q.color.g*X.g;m.b=Q.color.b*X.b;m.updateStyleString()}else m.__styleString=Q.color.__styleString;Q=W.scale.x*c;B=W.scale.y*k;x.set(w.x-Q,w.y-B,w.x+Q,w.y+B);if(M.instersects(x)){N=m.__styleString;if(V!=N)l.fillStyle=V=N;l.save();l.translate(w.x,w.y);l.rotate(-W.rotation);l.scale(Q,B);l.beginPath();l.arc(0,0,1,0,fa,true);l.closePath();l.fill();l.restore()}}}}function Oa(w,W,Q,B){if(B.opacity!= -0){a(B.opacity);b(B.blending);l.beginPath();l.moveTo(w.positionScreen.x,w.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(B instanceof THREE.LineBasicMaterial){m.__styleString=B.color.__styleString;w=B.linewidth;if(T!=w)l.lineWidth=T=w;w=m.__styleString;if(S!=w)l.strokeStyle=S=w;l.stroke();x.inflate(B.linewidth*2)}}}function Ia(w,W,Q,B,N,Z){if(N.opacity!=0){a(N.opacity);b(N.blending);h=w.positionScreen.x;n=w.positionScreen.y;o=W.positionScreen.x;p=W.positionScreen.y; -v=Q.positionScreen.x;r=Q.positionScreen.y;l.beginPath();l.moveTo(h,n);l.lineTo(o,p);l.lineTo(v,r);l.lineTo(h,n);l.closePath();if(N instanceof THREE.MeshBasicMaterial)if(N.map)N.map.image.loaded&&N.map.mapping instanceof THREE.UVMapping&&wa(h,n,o,p,v,r,N.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(N.env_map){if(N.env_map.image.loaded)if(N.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=qa.matrix;aa.copy(B.vertexNormalsWorld[0]);O=(aa.x*w.n11+ -aa.y*w.n12+aa.z*w.n13)*0.5+0.5;K=-(aa.x*w.n21+aa.y*w.n22+aa.z*w.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[1]);P=(aa.x*w.n11+aa.y*w.n12+aa.z*w.n13)*0.5+0.5;U=-(aa.x*w.n21+aa.y*w.n22+aa.z*w.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[2]);J=(aa.x*w.n11+aa.y*w.n12+aa.z*w.n13)*0.5+0.5;H=-(aa.x*w.n21+aa.y*w.n22+aa.z*w.n23)*0.5+0.5;wa(h,n,o,p,v,r,N.env_map.image,O,K,P,U,J,H)}}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString);else if(N instanceof THREE.MeshLambertMaterial){if(N.map&& -!N.wireframe){N.map.mapping instanceof THREE.UVMapping&&wa(h,n,o,p,v,r,N.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);b(THREE.SubtractiveBlending)}if(G)if(!N.wireframe&&N.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){y.r=t.r=i.r=$.r;y.g=t.g=i.g=$.g;y.b=t.b=i.b=$.b;Aa(Z,B.v1.positionWorld,B.vertexNormalsWorld[0],y);Aa(Z,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa(Z,B.v3.positionWorld,B.vertexNormalsWorld[2],i);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5; -u.b=(t.b+i.b)*0.5;L=Ja(y,t,i,u);wa(h,n,o,p,v,r,L,0,0,1,0,0,1)}else{X.r=$.r;X.g=$.g;X.b=$.b;Aa(Z,B.centroidWorld,B.normalWorld,X);m.r=N.color.r*X.r;m.g=N.color.g*X.g;m.b=N.color.b*X.b;m.updateStyleString();N.wireframe?Ba(m.__styleString,N.wireframe_linewidth):Ca(m.__styleString)}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString)}else if(N instanceof THREE.MeshDepthMaterial){I=qa.near;A=qa.far;y.r=y.g=y.b=1-Ea(w.positionScreen.z,I,A);t.r=t.g=t.b=1-Ea(W.positionScreen.z, -I,A);i.r=i.g=i.b=1-Ea(Q.positionScreen.z,I,A);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5;u.b=(t.b+i.b)*0.5;L=Ja(y,t,i,u);wa(h,n,o,p,v,r,L,0,0,1,0,0,1)}else if(N instanceof THREE.MeshNormalMaterial){m.r=Fa(B.normalWorld.x);m.g=Fa(B.normalWorld.y);m.b=Fa(B.normalWorld.z);m.updateStyleString();N.wireframe?Ba(m.__styleString,N.wireframe_linewidth):Ca(m.__styleString)}}}function Ba(w,W){if(S!=w)l.strokeStyle=S=w;if(T!=W)l.lineWidth=T=W;l.stroke();x.inflate(W*2)}function Ca(w){if(V!=w)l.fillStyle=V=w;l.fill()} -function wa(w,W,Q,B,N,Z,da,ha,ia,na,la,oa,xa){var sa,pa;sa=da.width-1;pa=da.height-1;ha*=sa;ia*=pa;na*=sa;la*=pa;oa*=sa;xa*=pa;Q-=w;B-=W;N-=w;Z-=W;na-=ha;la-=ia;oa-=ha;xa-=ia;pa=1/(na*xa-oa*la);sa=(xa*Q-la*N)*pa;la=(xa*B-la*Z)*pa;Q=(na*N-oa*Q)*pa;B=(na*Z-oa*B)*pa;w=w-sa*ha-Q*ia;W=W-la*ha-B*ia;l.save();l.transform(sa,la,Q,B,w,W);l.clip();l.drawImage(da,0,0);l.restore()}function Ja(w,W,Q,B){var N=~~(w.r*255),Z=~~(w.g*255);w=~~(w.b*255);var da=~~(W.r*255),ha=~~(W.g*255);W=~~(W.b*255);var ia=~~(Q.r*255), -na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(B.r*255),oa=~~(B.g*255);B=~~(B.b*255);ja[0]=N<0?0:N>255?255:N;ja[1]=Z<0?0:Z>255?255:Z;ja[2]=w<0?0:w>255?255:w;ja[4]=da<0?0:da>255?255:da;ja[5]=ha<0?0:ha>255?255:ha;ja[6]=W<0?0:W>255?255:W;ja[8]=ia<0?0:ia>255?255:ia;ja[9]=na<0?0:na>255?255:na;ja[10]=Q<0?0:Q>255?255:Q;ja[12]=la<0?0:la>255?255:la;ja[13]=oa<0?0:oa>255?255:oa;ja[14]=B<0?0:B>255?255:B;ca.putImageData(ta,0,0);za.drawImage(ka,0,0);return ra}function Ea(w,W,Q){w=(w-W)/(Q-W);return w*w*(3-2*w)}function Fa(w){w= -(w+1)*0.5;return w<0?0:w>1?1:w}function Ga(w,W){var Q=W.x-w.x,B=W.y-w.y,N=1/Math.sqrt(Q*Q+B*B);Q*=N;B*=N;W.x+=Q;W.y+=B;w.x-=Q;w.y-=B}var Da,Ka,ba,ma,va,Ha,La,ya;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();e=f.projectScene(ea,qa,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(M.getX(),M.getY(),M.getWidth(),M.getHeight());(G=ea.lights.length>0)&&Ma(ea);Da=0;for(Ka=e.length;Da0){P.r+=H.color.r*M;P.g+=H.color.g*M;P.b+=H.color.b*M}}else if(H instanceof THREE.PointLight){r.sub(H.position,K.centroidWorld);r.normalize();M=K.normalWorld.dot(r)*H.intensity;if(M>0){P.r+=H.color.r*M;P.g+=H.color.g*M;P.b+=H.color.b*M}}}}function b(O,K,P,U,J,H){i=f(u++);i.setAttribute("d","M "+O.positionScreen.x+ -" "+O.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(R){h.r=n.r;h.g=n.g;h.b=n.b;a(H,U,h);d.r=J.color.r*h.r;d.g=J.color.g*h.g;d.b=J.color.b*h.b;d.updateStyleString()}else d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){v=1-J.__2near/(J.__farPlusNear-U.z*J.__farMinusNear); -d.setRGB(v,v,v)}else J instanceof THREE.MeshNormalMaterial&&d.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));J.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+J.opacity);c.appendChild(i)}function e(O,K,P,U,J,H,M){i=f(u++);i.setAttribute("d", -"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(R){h.r=n.r;h.g=n.g;h.b=n.b;a(M,J,h);d.r=H.color.r*h.r;d.g=H.color.g*h.g;d.b=H.color.b*h.b;d.updateStyleString()}else d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){v= -1-H.__2near/(H.__farPlusNear-J.z*H.__farMinusNear);d.setRGB(v,v,v)}else H instanceof THREE.MeshNormalMaterial&&d.setRGB(g(J.normalWorld.x),g(J.normalWorld.y),g(J.normalWorld.z));H.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+H.opacity);c.appendChild(i)} -function f(O){if(m[O]==null){m[O]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&m[O].setAttribute("shape-rendering","crispEdges");return m[O]}return m[O]}function g(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var j=null,q=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,D,E,z,C,S,V,T=new THREE.Rectangle,s=new THREE.Rectangle,R=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),n=new THREE.Color(0),o=new THREE.Color(0), -p=new THREE.Color(0),v,r=new THREE.Vector3,m=[],y=[],t=[],i,u,I,A,L=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(O){switch(O){case "high":L=1;break;case "low":L=0}};this.setSize=function(O,K){k=O;l=K;D=k/2;E=l/2;c.setAttribute("viewBox",-D+" "+-E+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);T.set(-D,-E,D,E)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(O,K){var P,U, -J,H,M,F,x,G;this.autoClear&&this.clear();j=q.projectScene(O,K,this.sortElements);A=I=u=0;if(R=O.lights.length>0){x=O.lights;n.setRGB(0,0,0);o.setRGB(0,0,0);p.setRGB(0,0,0);P=0;for(U=x.length;P=0&&t>=0&&i>=0&&u>=0)return true;else if(w<0&&t<0||i<0&&u<0)return false;else{if(w<0)p=Math.max(p,w/(w-t));else if(t<0)n=Math.min(n,w/(w-t));if(i<0)p=Math.max(p,i/(i-u));else if(u<0)n=Math.min(n,i/(i-u));if(nw&&A.z0&&T.z<1){z=S[C]=S[C]||new THREE.RenderableParticle;z.x=T.x/T.w;z.y=T.y/T.w;z.z=T.z;z.rotation=K.rotation.z;z.scale.x=K.scale.x*Math.abs(z.x-(T.x+v.projectionMatrix.n11)/(T.w+v.projectionMatrix.n14)); +z.scale.y=K.scale.y*Math.abs(z.y-(T.y+v.projectionMatrix.n22)/(T.w+v.projectionMatrix.n24));z.materials=K.materials;n.push(z);C++}}}}p&&n.sort(a);return n};this.unprojectVector=function(s,v){var p=new THREE.Matrix4;p.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));p.multiplyVector3(s);return s}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(q,b){e=q;f=b;g=e/2;j=f/2};this.render=function(q,b){var l,m,D,E,z,C,S,V;a=c.projectScene(q,b);l=0;for(m=a.length;l0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}else if(Z instanceof THREE.PointLight){aa.sub(Z.position,W);aa.normalize();Z=Q.dot(aa)*ha;if(Z>0){B.r+=da.r*Z;B.g+=da.g*Z;B.b+=da.b*Z}}}}function Na(x,W,Q){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);var B, +N,Z,da,ha,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){da=Q.map;ha=da.width>>1;ia=da.height>>1;N=W.scale.x*b;Z=W.scale.y*l;Q=N*ha;B=Z*ia;y.set(x.x-Q,x.y-B,x.x+Q,x.y+B);if(!M.instersects(y))return;m.save();m.translate(x.x,x.y);m.rotate(-W.rotation);m.scale(N,-Z);m.translate(-ha,-ia);m.drawImage(da,0,0);m.restore()}m.beginPath();m.moveTo(x.x-10,x.y);m.lineTo(x.x+10,x.y);m.moveTo(x.x,x.y-10);m.lineTo(x.x,x.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(Q instanceof +THREE.ParticleCircleMaterial){if(G){X.r=$.r+Y.r+ga.r;X.g=$.g+Y.g+ga.g;X.b=$.b+Y.b+ga.b;n.r=Q.color.r*X.r;n.g=Q.color.g*X.g;n.b=Q.color.b*X.b;n.updateStyleString()}else n.__styleString=Q.color.__styleString;Q=W.scale.x*b;B=W.scale.y*l;y.set(x.x-Q,x.y-B,x.x+Q,x.y+B);if(M.instersects(y)){N=n.__styleString;if(V!=N)m.fillStyle=V=N;m.save();m.translate(x.x,x.y);m.rotate(-W.rotation);m.scale(Q,B);m.beginPath();m.arc(0,0,1,0,fa,true);m.closePath();m.fill();m.restore()}}}}function Oa(x,W,Q,B){if(B.opacity!= +0){a(B.opacity);c(B.blending);m.beginPath();m.moveTo(x.positionScreen.x,x.positionScreen.y);m.lineTo(W.positionScreen.x,W.positionScreen.y);m.closePath();if(B instanceof THREE.LineBasicMaterial){n.__styleString=B.color.__styleString;x=B.linewidth;if(T!=x)m.lineWidth=T=x;x=n.__styleString;if(S!=x)m.strokeStyle=S=x;m.stroke();y.inflate(B.linewidth*2)}}}function Ia(x,W,Q,B,N,Z){if(N.opacity!=0){a(N.opacity);c(N.blending);h=x.positionScreen.x;k=x.positionScreen.y;o=W.positionScreen.x;s=W.positionScreen.y; +v=Q.positionScreen.x;p=Q.positionScreen.y;m.beginPath();m.moveTo(h,k);m.lineTo(o,s);m.lineTo(v,p);m.lineTo(h,k);m.closePath();if(N instanceof THREE.MeshBasicMaterial)if(N.map)N.map.image.loaded&&N.map.mapping instanceof THREE.UVMapping&&wa(h,k,o,s,v,p,N.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(N.env_map){if(N.env_map.image.loaded)if(N.env_map.mapping instanceof THREE.SphericalReflectionMapping){x=qa.matrix;aa.copy(B.vertexNormalsWorld[0]);O=(aa.x*x.n11+ +aa.y*x.n12+aa.z*x.n13)*0.5+0.5;K=-(aa.x*x.n21+aa.y*x.n22+aa.z*x.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[1]);P=(aa.x*x.n11+aa.y*x.n12+aa.z*x.n13)*0.5+0.5;U=-(aa.x*x.n21+aa.y*x.n22+aa.z*x.n23)*0.5+0.5;aa.copy(B.vertexNormalsWorld[2]);J=(aa.x*x.n11+aa.y*x.n12+aa.z*x.n13)*0.5+0.5;H=-(aa.x*x.n21+aa.y*x.n22+aa.z*x.n23)*0.5+0.5;wa(h,k,o,s,v,p,N.env_map.image,O,K,P,U,J,H)}}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString);else if(N instanceof THREE.MeshLambertMaterial){if(N.map&& +!N.wireframe){N.map.mapping instanceof THREE.UVMapping&&wa(h,k,o,s,v,p,N.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);c(THREE.SubtractiveBlending)}if(G)if(!N.wireframe&&N.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){w.r=t.r=i.r=$.r;w.g=t.g=i.g=$.g;w.b=t.b=i.b=$.b;Aa(Z,B.v1.positionWorld,B.vertexNormalsWorld[0],w);Aa(Z,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa(Z,B.v3.positionWorld,B.vertexNormalsWorld[2],i);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5; +u.b=(t.b+i.b)*0.5;L=Ja(w,t,i,u);wa(h,k,o,s,v,p,L,0,0,1,0,0,1)}else{X.r=$.r;X.g=$.g;X.b=$.b;Aa(Z,B.centroidWorld,B.normalWorld,X);n.r=N.color.r*X.r;n.g=N.color.g*X.g;n.b=N.color.b*X.b;n.updateStyleString();N.wireframe?Ba(n.__styleString,N.wireframe_linewidth):Ca(n.__styleString)}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString)}else if(N instanceof THREE.MeshDepthMaterial){I=qa.near;A=qa.far;w.r=w.g=w.b=1-Ea(x.positionScreen.z,I,A);t.r=t.g=t.b=1-Ea(W.positionScreen.z, +I,A);i.r=i.g=i.b=1-Ea(Q.positionScreen.z,I,A);u.r=(t.r+i.r)*0.5;u.g=(t.g+i.g)*0.5;u.b=(t.b+i.b)*0.5;L=Ja(w,t,i,u);wa(h,k,o,s,v,p,L,0,0,1,0,0,1)}else if(N instanceof THREE.MeshNormalMaterial){n.r=Fa(B.normalWorld.x);n.g=Fa(B.normalWorld.y);n.b=Fa(B.normalWorld.z);n.updateStyleString();N.wireframe?Ba(n.__styleString,N.wireframe_linewidth):Ca(n.__styleString)}}}function Ba(x,W){if(S!=x)m.strokeStyle=S=x;if(T!=W)m.lineWidth=T=W;m.stroke();y.inflate(W*2)}function Ca(x){if(V!=x)m.fillStyle=V=x;m.fill()} +function wa(x,W,Q,B,N,Z,da,ha,ia,na,la,oa,xa){var sa,pa;sa=da.width-1;pa=da.height-1;ha*=sa;ia*=pa;na*=sa;la*=pa;oa*=sa;xa*=pa;Q-=x;B-=W;N-=x;Z-=W;na-=ha;la-=ia;oa-=ha;xa-=ia;pa=1/(na*xa-oa*la);sa=(xa*Q-la*N)*pa;la=(xa*B-la*Z)*pa;Q=(na*N-oa*Q)*pa;B=(na*Z-oa*B)*pa;x=x-sa*ha-Q*ia;W=W-la*ha-B*ia;m.save();m.transform(sa,la,Q,B,x,W);m.clip();m.drawImage(da,0,0);m.restore()}function Ja(x,W,Q,B){var N=~~(x.r*255),Z=~~(x.g*255);x=~~(x.b*255);var da=~~(W.r*255),ha=~~(W.g*255);W=~~(W.b*255);var ia=~~(Q.r*255), +na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(B.r*255),oa=~~(B.g*255);B=~~(B.b*255);ja[0]=N<0?0:N>255?255:N;ja[1]=Z<0?0:Z>255?255:Z;ja[2]=x<0?0:x>255?255:x;ja[4]=da<0?0:da>255?255:da;ja[5]=ha<0?0:ha>255?255:ha;ja[6]=W<0?0:W>255?255:W;ja[8]=ia<0?0:ia>255?255:ia;ja[9]=na<0?0:na>255?255:na;ja[10]=Q<0?0:Q>255?255:Q;ja[12]=la<0?0:la>255?255:la;ja[13]=oa<0?0:oa>255?255:oa;ja[14]=B<0?0:B>255?255:B;ca.putImageData(ta,0,0);za.drawImage(ka,0,0);return ra}function Ea(x,W,Q){x=(x-W)/(Q-W);return x*x*(3-2*x)}function Fa(x){x= +(x+1)*0.5;return x<0?0:x>1?1:x}function Ga(x,W){var Q=W.x-x.x,B=W.y-x.y,N=1/Math.sqrt(Q*Q+B*B);Q*=N;B*=N;W.x+=Q;W.y+=B;x.x-=Q;x.y-=B}var Da,Ka,ba,ma,va,Ha,La,ya;m.setTransform(1,0,0,-1,b,l);this.autoClear&&this.clear();e=f.projectScene(ea,qa,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(M.getX(),M.getY(),M.getWidth(),M.getHeight());(G=ea.lights.length>0)&&Ma(ea);Da=0;for(Ka=e.length;Da0){P.r+=H.color.r*M;P.g+=H.color.g*M;P.b+=H.color.b*M}}else if(H instanceof THREE.PointLight){p.sub(H.position,K.centroidWorld);p.normalize();M=K.normalWorld.dot(p)*H.intensity;if(M>0){P.r+=H.color.r*M;P.g+=H.color.g*M;P.b+=H.color.b*M}}}}function c(O,K,P,U,J,H){i=f(u++);i.setAttribute("d","M "+O.positionScreen.x+ +" "+O.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(R){h.r=k.r;h.g=k.g;h.b=k.b;a(H,U,h);d.r=J.color.r*h.r;d.g=J.color.g*h.g;d.b=J.color.b*h.b;d.updateStyleString()}else d.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){v=1-J.__2near/(J.__farPlusNear-U.z*J.__farMinusNear); +d.setRGB(v,v,v)}else J instanceof THREE.MeshNormalMaterial&&d.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));J.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+J.opacity);b.appendChild(i)}function e(O,K,P,U,J,H,M){i=f(u++);i.setAttribute("d", +"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(R){h.r=k.r;h.g=k.g;h.b=k.b;a(M,J,h);d.r=H.color.r*h.r;d.g=H.color.g*h.g;d.b=H.color.b*h.b;d.updateStyleString()}else d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){v= +1-H.__2near/(H.__farPlusNear-J.z*H.__farMinusNear);d.setRGB(v,v,v)}else H instanceof THREE.MeshNormalMaterial&&d.setRGB(g(J.normalWorld.x),g(J.normalWorld.y),g(J.normalWorld.z));H.wireframe?i.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):i.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+H.opacity);b.appendChild(i)} +function f(O){if(n[O]==null){n[O]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&n[O].setAttribute("shape-rendering","crispEdges");return n[O]}return n[O]}function g(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var j=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,D,E,z,C,S,V,T=new THREE.Rectangle,r=new THREE.Rectangle,R=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),k=new THREE.Color(0),o=new THREE.Color(0), +s=new THREE.Color(0),v,p=new THREE.Vector3,n=[],w=[],t=[],i,u,I,A,L=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(O){switch(O){case "high":L=1;break;case "low":L=0}};this.setSize=function(O,K){l=O;m=K;D=l/2;E=m/2;b.setAttribute("viewBox",-D+" "+-E+" "+l+" "+m);b.setAttribute("width",l);b.setAttribute("height",m);T.set(-D,-E,D,E)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(O,K){var P,U, +J,H,M,F,y,G;this.autoClear&&this.clear();j=q.projectScene(O,K,this.sortElements);A=I=u=0;if(R=O.lights.length>0){y=O.lights;k.setRGB(0,0,0);o.setRGB(0,0,0);s.setRGB(0,0,0);P=0;for(U=y.length;P0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,X,n)}if(p){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ga,n);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,fa,n)}};this.setLineBuffers=function(d,h,n,o){var p,v,r=d.vertices,m=r.length,y=d.__vertexArray,t=d.__lineArray;if(n)for(n=0;n0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"","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(u, -g("fragment",I+m));c.attachShader(u,g("vertex",t+i));c.linkProgram(u);c.getProgramParameter(u,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(u,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");u.uniforms={};u.attributes={};o.program=u;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(r in o.uniforms)m.push(r);r=o.program;i=0;for(u=m.length;i=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer); -c.vertexAttribPointer(y.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(y.normal)}if(y.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);c.vertexAttribPointer(y.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(y.tangent)}if(y.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(y.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(y.uv)}else c.disableVertexAttribArray(y.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){y= -o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&v.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(y);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(o,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(d,h,n,o,p,v,r){var m,y,t,i,u;t=0;for(i= -o.materials.length;t=0;n--){o=d.__webGLObjects[n].object;h==o&&d.__webGLObjects.splice(n,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(h.matrix,d.matrix);z.set(l.flatten());D=THREE.Matrix4.makeInvert3x3(l).transpose();S.set(D.m);V.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,E);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,z);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,C); -c.uniformMatrix3fv(d.uniforms.normalMatrix,false,S);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,V)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(d){switch(d){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(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="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.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif", -envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif", -map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", +h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var k;if(d=="fragment")k=b.createShader(b.FRAGMENT_SHADER);else if(d=="vertex")k=b.createShader(b.VERTEX_SHADER);b.shaderSource(k,h);b.compileShader(k);if(!b.getShaderParameter(k,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(k));return null}return k}function j(d){switch(d){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT; +case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT; +case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var q=document.createElement("canvas"),b,l=null,m=new THREE.Matrix4,D,E=new Float32Array(16),z=new Float32Array(16),C=new Float32Array(16),S=new Float32Array(9),V= +new Float32Array(16),T=true,r=new THREE.Color(0),R=0;if(a){if(a.antialias!==undefined)T=a.antialias;a.clearColor!==undefined&&r.setHex(a.clearColor);if(a.clearAlpha!==undefined)R=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(d,h,k){try{b=q.getContext("experimental-webgl",{antialias:d})}catch(o){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK); +b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,k)})(T,r,R);this.context=b;this.setSize=function(d,h){q.width=d;q.height=h;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(d,h){var k=new THREE.Color(d);b.clearColor(k.r,k.g,k.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var k,o,s,v=0,p=0,n=0,w,t,i,u=[],I=[],A=[],L=[];k=0;for(o=h.length;k0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,X,k)}if(s){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ga,k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,k)}};this.setLineBuffers=function(d,h,k,o){var s,v,p=d.vertices,n=p.length,w=d.__vertexArray,t=d.__lineArray;if(k)for(k=0;k0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"","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");b.attachShader(u, +g("fragment",I+n));b.attachShader(u,g("vertex",t+i));b.linkProgram(u);b.getProgramParameter(u,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(u,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");u.uniforms={};u.attributes={};o.program=u;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(p in o.uniforms)n.push(p);p=o.program;i=0;for(u=n.length;i=0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLNormalBuffer); +b.vertexAttribPointer(w.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(w.normal)}if(w.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLTangentBuffer);b.vertexAttribPointer(w.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(w.tangent)}if(w.uv>=0)if(s.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLUVBuffer);b.vertexAttribPointer(w.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(w.uv)}else b.disableVertexAttribArray(w.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){w= +o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(w);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);b.drawElements(o,s.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,s.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,k,o,s,v,p){var n,w,t,i,u;t=0;for(i= +o.materials.length;t=0;k--){o=d.__webGLObjects[k].object;h==o&&d.__webGLObjects.splice(k,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();m.multiply(h.matrix,d.matrix);z.set(m.flatten());D=THREE.Matrix4.makeInvert3x3(m).transpose();S.set(D.m); +V.set(d.matrix.flatten())};this.loadMatrices=function(d){b.uniformMatrix4fv(d.uniforms.viewMatrix,false,E);b.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,z);b.uniformMatrix4fv(d.uniforms.projectionMatrix,false,C);b.uniformMatrix3fv(d.uniforms.normalMatrix,false,S);b.uniformMatrix4fv(d.uniforms.objectMatrix,false,V)};this.loadCamera=function(d,h){b.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD); +b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> +0}}; +THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", +map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 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, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv", diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 88adb6fe..02b3e791 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,21 +12,21 @@ THREE.Vector4=function(a,b,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1} THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;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,f=a.objects,g=[];a=0;for(b=f.length;a0&&L>0&&n+L<1}var e,f,g,h,j,c,i,l,u,C, -o,w=a.geometry,y=w.vertices,A=[];e=0;for(f=w.faces.length;ei?f:i;g=g>l? -g:l}a()};this.add3Points=function(i,l,u,C,o,w){if(c){c=false;b=iu?i>o?i:o:u>o?u:o;g=l>C?l>w?l:w:C>w?C:w}else{b=iu?i>o?i>f?i:f:o>f?o:f:u>o?u>f?u:f:o>f?o:f;g=l>C?l>w?l>g?l:g:w>g?w:g:C>w?C>g?C:g:w>g?w:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();e=i.getTop();f=i.getRight();g=i.getBottom()}else{b=b0&&L>0&&m+L<1}var e,f,g,h,j,c,i,l,u,D, +o,w=a.geometry,y=w.vertices,A=[];e=0;for(f=w.faces.length;ei?f:i;g=g>l? +g:l}a()};this.add3Points=function(i,l,u,D,o,w){if(c){c=false;b=iu?i>o?i:o:u>o?u:o;g=l>D?l>w?l:w:D>w?D:w}else{b=iu?i>o?i>f?i:f:o>f?o:f:u>o?u>f?u:f:o>f?o:f;g=l>D?l>w?l>g?l:g:w>g?w:g:D>w?D>g?D:g:w>g?w:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();e=i.getTop();f=i.getRight();g=i.getBottom()}else{b=bi.getRight()?f:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){b-=i;e-=i;f+=i;g+=i;a()};this.minSelf=function(i){b=b>i.getLeft()?b:i.getLeft();e=e>i.getTop()?e:i.getTop();f=f=0&&Math.min(g,i.getBottom())-Math.max(e,i.getTop())>=0};this.empty=function(){c=true;g=f=e=b=0;a()};this.isEmpty=function(){return c};this.toString= function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+h+", 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,e,f,g,h,j,c,i,l,u,C,o,w,y,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=l||0;this.n33=u||1;this.n34=C||0;this.n41=o||0;this.n42=w||0;this.n43=y||0;this.n44=A||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,f,g,h,j,c,i,l,u,C,o,w,y,A){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=l;this.n33=u;this.n34=C;this.n41=o;this.n42=w;this.n43=y;this.n44=A;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Matrix4=function(a,b,e,f,g,h,j,c,i,l,u,D,o,w,y,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=l||0;this.n33=u||1;this.n34=D||0;this.n41=o||0;this.n42=w||0;this.n43=y||0;this.n44=A||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,f,g,h,j,c,i,l,u,D,o,w,y,A){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=l;this.n33=u;this.n34=D;this.n41=o;this.n42=w;this.n43=y;this.n44=A;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 f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3;h.sub(a,b).normalize();f.cross(e,h).normalize();g.cross(h,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=h.x; this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*f+this.n24* -g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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,f=a.n12,g=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,l=a.n24,u=a.n31,C=a.n32, -o=a.n33,w=a.n34,y=a.n41,A=a.n42,L=a.n43,q=a.n44,G=b.n11,d=b.n12,k=b.n13,n=b.n14,t=b.n21,s=b.n22,x=b.n23,v=b.n24,p=b.n31,F=b.n32,z=b.n33,m=b.n34,B=b.n41,P=b.n42,J=b.n43,Q=b.n44;this.n11=e*G+f*t+g*p+h*B;this.n12=e*d+f*s+g*F+h*P;this.n13=e*k+f*x+g*z+h*J;this.n14=e*n+f*v+g*m+h*Q;this.n21=j*G+c*t+i*p+l*B;this.n22=j*d+c*s+i*F+l*P;this.n23=j*k+c*x+i*z+l*J;this.n24=j*n+c*v+i*m+l*Q;this.n31=u*G+C*t+o*p+w*B;this.n32=u*d+C*s+o*F+w*P;this.n33=u*k+C*x+o*z+w*J;this.n34=u*n+C*v+o*m+w*Q;this.n41=y*G+A*t+L*p+q*B; -this.n42=y*d+A*s+L*F+q*P;this.n43=y*k+A*x+L*z+q*J;this.n44=y*n+A*v+L*m+q*Q;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,l=this.n31,u=this.n32,C=this.n33,o=this.n34,w=this.n41,y=this.n42,A=this.n43,L=this.n44,q=a.n11,G=a.n21,d=a.n31,k=a.n41,n=a.n12,t=a.n22,s=a.n32,x=a.n42,v=a.n13,p=a.n23,F=a.n33,z=a.n43,m=a.n14,B=a.n24,P=a.n34;a=a.n44;this.n11=b*q+e*G+f*d+g*k;this.n12=b*n+e*t+f*s+g*x;this.n13=b*v+e*p+f*F+g*z;this.n14= -b*m+e*B+f*P+g*a;this.n21=h*q+j*G+c*d+i*k;this.n22=h*n+j*t+c*s+i*x;this.n23=h*v+j*p+c*F+i*z;this.n24=h*m+j*B+c*P+i*a;this.n31=l*q+u*G+C*d+o*k;this.n32=l*n+u*t+C*s+o*x;this.n33=l*v+u*p+C*F+o*z;this.n34=l*m+u*B+C*P+o*a;this.n41=w*q+y*G+A*d+L*k;this.n42=w*n+y*t+A*s+L*x;this.n43=w*v+y*p+A*F+L*z;this.n44=w*m+y*B+A*P+L*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*= +g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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,f=a.n12,g=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,l=a.n24,u=a.n31,D=a.n32, +o=a.n33,w=a.n34,y=a.n41,A=a.n42,L=a.n43,q=a.n44,G=b.n11,d=b.n12,k=b.n13,m=b.n14,s=b.n21,v=b.n22,x=b.n23,t=b.n24,p=b.n31,C=b.n32,z=b.n33,n=b.n34,B=b.n41,P=b.n42,J=b.n43,Q=b.n44;this.n11=e*G+f*s+g*p+h*B;this.n12=e*d+f*v+g*C+h*P;this.n13=e*k+f*x+g*z+h*J;this.n14=e*m+f*t+g*n+h*Q;this.n21=j*G+c*s+i*p+l*B;this.n22=j*d+c*v+i*C+l*P;this.n23=j*k+c*x+i*z+l*J;this.n24=j*m+c*t+i*n+l*Q;this.n31=u*G+D*s+o*p+w*B;this.n32=u*d+D*v+o*C+w*P;this.n33=u*k+D*x+o*z+w*J;this.n34=u*m+D*t+o*n+w*Q;this.n41=y*G+A*s+L*p+q*B; +this.n42=y*d+A*v+L*C+q*P;this.n43=y*k+A*x+L*z+q*J;this.n44=y*m+A*t+L*n+q*Q;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,l=this.n31,u=this.n32,D=this.n33,o=this.n34,w=this.n41,y=this.n42,A=this.n43,L=this.n44,q=a.n11,G=a.n21,d=a.n31,k=a.n41,m=a.n12,s=a.n22,v=a.n32,x=a.n42,t=a.n13,p=a.n23,C=a.n33,z=a.n43,n=a.n14,B=a.n24,P=a.n34;a=a.n44;this.n11=b*q+e*G+f*d+g*k;this.n12=b*m+e*s+f*v+g*x;this.n13=b*t+e*p+f*C+g*z;this.n14= +b*n+e*B+f*P+g*a;this.n21=h*q+j*G+c*d+i*k;this.n22=h*m+j*s+c*v+i*x;this.n23=h*t+j*p+c*C+i*z;this.n24=h*n+j*B+c*P+i*a;this.n31=l*q+u*G+D*d+o*k;this.n32=l*m+u*s+D*v+o*x;this.n33=l*t+u*p+D*C+o*z;this.n34=l*n+u*B+D*P+o*a;this.n41=w*q+y*G+A*d+L*k;this.n42=w*m+y*s+A*v+L*x;this.n43=w*t+y*p+A*C+L*z;this.n44=w*n+y*B+A*P+L*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,f){var g=b[e];b[e]=b[f]; b[f]=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, @@ -48,12 +48,12 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.f e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,e,f,g,h,j,c=new THREE.Vector3,i=new THREE.Vector3;f=0;for(g=this.vertices.length;f0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[f.d].normal.copy(f.vertexNormals[3])}}b=0;for(e=this.vertices.length;b0){this.boundingBox={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 b=1,e=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b65535){l[c].counter+=1;i=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(f);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); @@ -93,96 +93,101 @@ THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.Particle THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; THREE.Texture=function(a,b,e,f,g,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},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;var Uniforms={clone:function(a){var b,e,f,g={};for(b in a){g[b]={};for(e in a[b]){f=a[b][e];g[b][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var b,e,f,g={};for(b=0;b=0&&z>=0&&m>=0&&B>=0)return true;else if(F<0&&z<0||m<0&&B<0)return false;else{if(F<0)v=Math.max(v,F/(F-z));else if(z<0)p=Math.min(p,F/(F-z));if(m<0)v=Math.max(v,m/(m-B));else if(B<0)p=Math.min(p,m/(m-B));if(pF&&J.z=0&&z>=0&&n>=0&&B>=0)return true;else if(C<0&&z<0||n<0&&B<0)return false;else{if(C<0)t=Math.max(t,C/(C-z));else if(z<0)p=Math.min(p,C/(C-z));if(n<0)t=Math.max(t,n/(n-B));else if(B<0)p=Math.min(p,n/(n-B));if(pC&&J.z0&&L.z<1){o=y[w]=y[w]||new THREE.RenderableParticle;o.x=L.x/L.w;o.y=L.y/L.w;o.z=L.z;o.rotation=T.rotation.z;o.scale.x=T.scale.x*Math.abs(o.x-(L.x+x.projectionMatrix.n11)/(L.w+ -x.projectionMatrix.n14));o.scale.y=T.scale.y*Math.abs(o.y-(L.y+x.projectionMatrix.n22)/(L.w+x.projectionMatrix.n24));o.materials=T.materials;p.push(o);w++}}}}v&&p.sort(a);return p};this.unprojectVector=function(s,x){var v=new THREE.Matrix4;v.multiply(THREE.Matrix4.makeInvert(x.matrix),THREE.Matrix4.makeInvert(x.projectionMatrix));v.multiplyVector3(s);return s}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){e=j;f=c;g=e/2;h=f/2};this.render=function(j,c){var i,l,u,C,o,w,y,A;a=b.projectScene(j,c);i=0;for(l=a.length;i0&&L.z<1){o=y[w]=y[w]||new THREE.RenderableParticle;o.x=L.x/L.w;o.y=L.y/L.w;o.z=L.z;o.rotation=T.rotation.z;o.scale.x=T.scale.x*Math.abs(o.x-(L.x+x.projectionMatrix.n11)/(L.w+ +x.projectionMatrix.n14));o.scale.y=T.scale.y*Math.abs(o.y-(L.y+x.projectionMatrix.n22)/(L.w+x.projectionMatrix.n24));o.materials=T.materials;p.push(o);w++}}}}t&&p.sort(a);return p};this.unprojectVector=function(v,x){var t=new THREE.Matrix4;t.multiply(THREE.Matrix4.makeInvert(x.matrix),THREE.Matrix4.makeInvert(x.projectionMatrix));t.multiplyVector3(v);return v}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){e=j;f=c;g=e/2;h=f/2};this.render=function(j,c){var i,l,u,D,o,w,y,A;a=b.projectScene(j,c);i=0;for(l=a.length;i0){K.r+=ha.r*da;K.g+=ha.g*da;K.b+=ha.b*da}}else if(da instanceof THREE.PointLight){H.sub(da.position,ca);H.normalize();da=Z.dot(H)*ka;if(da>0){K.r+=ha.r*da;K.g+=ha.g*da;K.b+=ha.b*da}}}}function Na(I,ca,Z){if(Z.opacity!=0){a(Z.opacity);b(Z.blending);var K,W,da,ha,ka,la; -if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){ha=Z.map;ka=ha.width>>1;la=ha.height>>1;W=ca.scale.x*c;da=ca.scale.y*i;Z=W*ka;K=da*la;E.set(I.x-Z,I.y-K,I.x+Z,I.y+K);if(X.instersects(E)){l.save();l.translate(I.x,I.y);l.rotate(-ca.rotation);l.scale(W,-da);l.translate(-ka,-la);l.drawImage(ha,0,0);l.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(M){aa.r=ea.r+ba.r+r.r;aa.g=ea.g+ba.g+r.g;aa.b=ea.b+ba.b+r.b;p.r=Z.color.r*aa.r;p.g=Z.color.g*aa.g;p.b=Z.color.b*aa.b;p.updateStyleString()}else p.__styleString= -Z.color.__styleString;Z=ca.scale.x*c;K=ca.scale.y*i;E.set(I.x-Z,I.y-K,I.x+Z,I.y+K);if(X.instersects(E)){W=p.__styleString;if(A!=W)l.fillStyle=A=W;l.save();l.translate(I.x,I.y);l.rotate(-ca.rotation);l.scale(Z,K);l.beginPath();l.arc(0,0,1,0,D,true);l.closePath();l.fill();l.restore()}}}}function Oa(I,ca,Z,K){if(K.opacity!=0){a(K.opacity);b(K.blending);l.beginPath();l.moveTo(I.positionScreen.x,I.positionScreen.y);l.lineTo(ca.positionScreen.x,ca.positionScreen.y);l.closePath();if(K instanceof THREE.LineBasicMaterial){p.__styleString= -K.color.__styleString;I=K.linewidth;if(L!=I)l.lineWidth=L=I;I=p.__styleString;if(y!=I)l.strokeStyle=y=I;l.stroke();E.inflate(K.linewidth*2)}}}function Ia(I,ca,Z,K,W,da){if(W.opacity!=0){a(W.opacity);b(W.blending);k=I.positionScreen.x;n=I.positionScreen.y;t=ca.positionScreen.x;s=ca.positionScreen.y;x=Z.positionScreen.x;v=Z.positionScreen.y;l.beginPath();l.moveTo(k,n);l.lineTo(t,s);l.lineTo(x,v);l.lineTo(k,n);l.closePath();if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.image.loaded&&W.map.mapping instanceof -THREE.UVMapping&&xa(k,n,t,s,x,v,W.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(W.env_map){if(W.env_map.image.loaded)if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){I=sa.matrix;H.copy(K.vertexNormalsWorld[0]);U=(H.x*I.n11+H.y*I.n12+H.z*I.n13)*0.5+0.5;T=-(H.x*I.n21+H.y*I.n22+H.z*I.n23)*0.5+0.5;H.copy(K.vertexNormalsWorld[1]);V=(H.x*I.n11+H.y*I.n12+H.z*I.n13)*0.5+0.5;$=-(H.x*I.n21+H.y*I.n22+H.z*I.n23)*0.5+0.5;H.copy(K.vertexNormalsWorld[2]);S= -(H.x*I.n11+H.y*I.n12+H.z*I.n13)*0.5+0.5;O=-(H.x*I.n21+H.y*I.n22+H.z*I.n23)*0.5+0.5;xa(k,n,t,s,x,v,W.env_map.image,U,T,V,$,S,O)}}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){W.map.mapping instanceof THREE.UVMapping&&xa(k,n,t,s,x,v,W.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);b(THREE.SubtractiveBlending)}if(M)if(!W.wireframe&&W.shading==THREE.SmoothShading&& -K.vertexNormalsWorld.length==3){F.r=z.r=m.r=ea.r;F.g=z.g=m.g=ea.g;F.b=z.b=m.b=ea.b;Aa(da,K.v1.positionWorld,K.vertexNormalsWorld[0],F);Aa(da,K.v2.positionWorld,K.vertexNormalsWorld[1],z);Aa(da,K.v3.positionWorld,K.vertexNormalsWorld[2],m);B.r=(z.r+m.r)*0.5;B.g=(z.g+m.g)*0.5;B.b=(z.b+m.b)*0.5;Q=Ja(F,z,m,B);xa(k,n,t,s,x,v,Q,0,0,1,0,0,1)}else{aa.r=ea.r;aa.g=ea.g;aa.b=ea.b;Aa(da,K.centroidWorld,K.normalWorld,aa);p.r=W.color.r*aa.r;p.g=W.color.g*aa.g;p.b=W.color.b*aa.b;p.updateStyleString();W.wireframe? -Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){P=sa.near;J=sa.far;F.r=F.g=F.b=1-Ea(I.positionScreen.z,P,J);z.r=z.g=z.b=1-Ea(ca.positionScreen.z,P,J);m.r=m.g=m.b=1-Ea(Z.positionScreen.z,P,J);B.r=(z.r+m.r)*0.5;B.g=(z.g+m.g)*0.5;B.b=(z.b+m.b)*0.5;Q=Ja(F,z,m,B);xa(k,n,t,s,x,v,Q,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){p.r=Fa(K.normalWorld.x); -p.g=Fa(K.normalWorld.y);p.b=Fa(K.normalWorld.z);p.updateStyleString();W.wireframe?Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(I,ca){if(y!=I)l.strokeStyle=y=I;if(L!=ca)l.lineWidth=L=ca;l.stroke();E.inflate(ca*2)}function Ca(I){if(A!=I)l.fillStyle=A=I;l.fill()}function xa(I,ca,Z,K,W,da,ha,ka,la,pa,ma,qa,ya){var ua,ra;ua=ha.width-1;ra=ha.height-1;ka*=ua;la*=ra;pa*=ua;ma*=ra;qa*=ua;ya*=ra;Z-=I;K-=ca;W-=I;da-=ca;pa-=ka;ma-=la;qa-=ka;ya-=la;ra=1/(pa*ya-qa*ma);ua=(ya*Z-ma* +if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){ha=Z.map;ka=ha.width>>1;la=ha.height>>1;W=ca.scale.x*c;da=ca.scale.y*i;Z=W*ka;K=da*la;F.set(I.x-Z,I.y-K,I.x+Z,I.y+K);if(X.instersects(F)){l.save();l.translate(I.x,I.y);l.rotate(-ca.rotation);l.scale(W,-da);l.translate(-ka,-la);l.drawImage(ha,0,0);l.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(M){aa.r=ea.r+ba.r+r.r;aa.g=ea.g+ba.g+r.g;aa.b=ea.b+ba.b+r.b;p.r=Z.color.r*aa.r;p.g=Z.color.g*aa.g;p.b=Z.color.b*aa.b;p.updateStyleString()}else p.__styleString= +Z.color.__styleString;Z=ca.scale.x*c;K=ca.scale.y*i;F.set(I.x-Z,I.y-K,I.x+Z,I.y+K);if(X.instersects(F)){W=p.__styleString;if(A!=W)l.fillStyle=A=W;l.save();l.translate(I.x,I.y);l.rotate(-ca.rotation);l.scale(Z,K);l.beginPath();l.arc(0,0,1,0,E,true);l.closePath();l.fill();l.restore()}}}}function Oa(I,ca,Z,K){if(K.opacity!=0){a(K.opacity);b(K.blending);l.beginPath();l.moveTo(I.positionScreen.x,I.positionScreen.y);l.lineTo(ca.positionScreen.x,ca.positionScreen.y);l.closePath();if(K instanceof THREE.LineBasicMaterial){p.__styleString= +K.color.__styleString;I=K.linewidth;if(L!=I)l.lineWidth=L=I;I=p.__styleString;if(y!=I)l.strokeStyle=y=I;l.stroke();F.inflate(K.linewidth*2)}}}function Ia(I,ca,Z,K,W,da){if(W.opacity!=0){a(W.opacity);b(W.blending);k=I.positionScreen.x;m=I.positionScreen.y;s=ca.positionScreen.x;v=ca.positionScreen.y;x=Z.positionScreen.x;t=Z.positionScreen.y;l.beginPath();l.moveTo(k,m);l.lineTo(s,v);l.lineTo(x,t);l.lineTo(k,m);l.closePath();if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.image.loaded&&W.map.mapping instanceof +THREE.UVMapping&&xa(k,m,s,v,x,t,W.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(W.env_map){if(W.env_map.image.loaded)if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){I=sa.matrix;H.copy(K.vertexNormalsWorld[0]);U=(H.x*I.n11+H.y*I.n12+H.z*I.n13)*0.5+0.5;T=-(H.x*I.n21+H.y*I.n22+H.z*I.n23)*0.5+0.5;H.copy(K.vertexNormalsWorld[1]);V=(H.x*I.n11+H.y*I.n12+H.z*I.n13)*0.5+0.5;$=-(H.x*I.n21+H.y*I.n22+H.z*I.n23)*0.5+0.5;H.copy(K.vertexNormalsWorld[2]);S= +(H.x*I.n11+H.y*I.n12+H.z*I.n13)*0.5+0.5;O=-(H.x*I.n21+H.y*I.n22+H.z*I.n23)*0.5+0.5;xa(k,m,s,v,x,t,W.env_map.image,U,T,V,$,S,O)}}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){W.map.mapping instanceof THREE.UVMapping&&xa(k,m,s,v,x,t,W.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);b(THREE.SubtractiveBlending)}if(M)if(!W.wireframe&&W.shading==THREE.SmoothShading&& +K.vertexNormalsWorld.length==3){C.r=z.r=n.r=ea.r;C.g=z.g=n.g=ea.g;C.b=z.b=n.b=ea.b;Aa(da,K.v1.positionWorld,K.vertexNormalsWorld[0],C);Aa(da,K.v2.positionWorld,K.vertexNormalsWorld[1],z);Aa(da,K.v3.positionWorld,K.vertexNormalsWorld[2],n);B.r=(z.r+n.r)*0.5;B.g=(z.g+n.g)*0.5;B.b=(z.b+n.b)*0.5;Q=Ja(C,z,n,B);xa(k,m,s,v,x,t,Q,0,0,1,0,0,1)}else{aa.r=ea.r;aa.g=ea.g;aa.b=ea.b;Aa(da,K.centroidWorld,K.normalWorld,aa);p.r=W.color.r*aa.r;p.g=W.color.g*aa.g;p.b=W.color.b*aa.b;p.updateStyleString();W.wireframe? +Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){P=sa.near;J=sa.far;C.r=C.g=C.b=1-Ea(I.positionScreen.z,P,J);z.r=z.g=z.b=1-Ea(ca.positionScreen.z,P,J);n.r=n.g=n.b=1-Ea(Z.positionScreen.z,P,J);B.r=(z.r+n.r)*0.5;B.g=(z.g+n.g)*0.5;B.b=(z.b+n.b)*0.5;Q=Ja(C,z,n,B);xa(k,m,s,v,x,t,Q,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){p.r=Fa(K.normalWorld.x); +p.g=Fa(K.normalWorld.y);p.b=Fa(K.normalWorld.z);p.updateStyleString();W.wireframe?Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(I,ca){if(y!=I)l.strokeStyle=y=I;if(L!=ca)l.lineWidth=L=ca;l.stroke();F.inflate(ca*2)}function Ca(I){if(A!=I)l.fillStyle=A=I;l.fill()}function xa(I,ca,Z,K,W,da,ha,ka,la,pa,ma,qa,ya){var ua,ra;ua=ha.width-1;ra=ha.height-1;ka*=ua;la*=ra;pa*=ua;ma*=ra;qa*=ua;ya*=ra;Z-=I;K-=ca;W-=I;da-=ca;pa-=ka;ma-=la;qa-=ka;ya-=la;ra=1/(pa*ya-qa*ma);ua=(ya*Z-ma* W)*ra;ma=(ya*K-ma*da)*ra;Z=(pa*W-qa*Z)*ra;K=(pa*da-qa*K)*ra;I=I-ua*ka-Z*la;ca=ca-ma*ka-K*la;l.save();l.transform(ua,ma,Z,K,I,ca);l.clip();l.drawImage(ha,0,0);l.restore()}function Ja(I,ca,Z,K){var W=~~(I.r*255),da=~~(I.g*255);I=~~(I.b*255);var ha=~~(ca.r*255),ka=~~(ca.g*255);ca=~~(ca.b*255);var la=~~(Z.r*255),pa=~~(Z.g*255);Z=~~(Z.b*255);var ma=~~(K.r*255),qa=~~(K.g*255);K=~~(K.b*255);fa[0]=W<0?0:W>255?255:W;fa[1]=da<0?0:da>255?255:da;fa[2]=I<0?0:I>255?255:I;fa[4]=ha<0?0:ha>255?255:ha;fa[5]=ka<0?0: ka>255?255:ka;fa[6]=ca<0?0:ca>255?255:ca;fa[8]=la<0?0:la>255?255:la;fa[9]=pa<0?0:pa>255?255:pa;fa[10]=Z<0?0:Z>255?255:Z;fa[12]=ma<0?0:ma>255?255:ma;fa[13]=qa<0?0:qa>255?255:qa;fa[14]=K<0?0:K>255?255:K;Y.putImageData(ja,0,0);ta.drawImage(R,0,0);return na}function Ea(I,ca,Z){I=(I-ca)/(Z-ca);return I*I*(3-2*I)}function Fa(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function Ga(I,ca){var Z=ca.x-I.x,K=ca.y-I.y,W=1/Math.sqrt(Z*Z+K*K);Z*=W;K*=W;ca.x+=Z;ca.y+=K;I.x-=Z;I.y-=K}var Da,Ka,ga,oa,wa,Ha,La,za;l.setTransform(1, -0,0,-1,c,i);this.autoClear&&this.clear();e=f.projectScene(ia,sa,this.sortElements);(M=ia.lights.length>0)&&Ma(ia);Da=0;for(Ka=e.length;Da0){V.r+=O.color.r*X;V.g+=O.color.g*X;V.b+=O.color.b*X}}else if(O instanceof THREE.PointLight){v.sub(O.position,T.centroidWorld);v.normalize();X=T.normalWorld.dot(v)*O.intensity;if(X>0){V.r+=O.color.r*X;V.g+=O.color.g*X;V.b+=O.color.b*X}}}}function b(U,T,V,$,S,O){m=f(B++);m.setAttribute("d","M "+U.positionScreen.x+ -" "+U.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)d.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(G){k.r=n.r;k.g=n.g;k.b=n.b;a(O,$,k);d.r=S.color.r*k.r;d.g=S.color.g*k.g;d.b=S.color.b*k.b;d.updateStyleString()}else d.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){x=1-S.__2near/(S.__farPlusNear-$.z*S.__farMinusNear); -d.setRGB(x,x,x)}else S instanceof THREE.MeshNormalMaterial&&d.setRGB(g($.normalWorld.x),g($.normalWorld.y),g($.normalWorld.z));S.wireframe?m.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):m.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+S.opacity);c.appendChild(m)}function e(U,T,V,$,S,O,X){m=f(B++);m.setAttribute("d", -"M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+$.positionScreen.x+","+$.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)d.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(G){k.r=n.r;k.g=n.g;k.b=n.b;a(X,S,k);d.r=O.color.r*k.r;d.g=O.color.g*k.g;d.b=O.color.b*k.b;d.updateStyleString()}else d.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){x= -1-O.__2near/(O.__farPlusNear-S.z*O.__farMinusNear);d.setRGB(x,x,x)}else O instanceof THREE.MeshNormalMaterial&&d.setRGB(g(S.normalWorld.x),g(S.normalWorld.y),g(S.normalWorld.z));O.wireframe?m.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):m.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+O.opacity);c.appendChild(m)} -function f(U){if(p[U]==null){p[U]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&p[U].setAttribute("shape-rendering","crispEdges");return p[U]}return p[U]}function g(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,u,C,o,w,y,A,L=new THREE.Rectangle,q=new THREE.Rectangle,G=false,d=new THREE.Color(16777215),k=new THREE.Color(16777215),n=new THREE.Color(0),t=new THREE.Color(0), -s=new THREE.Color(0),x,v=new THREE.Vector3,p=[],F=[],z=[],m,B,P,J,Q=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(U,T){i=U;l=T;u=i/2;C=l/2;c.setAttribute("viewBox",-u+" "+-C+" "+i+" "+l);c.setAttribute("width",i);c.setAttribute("height",l);L.set(-u,-C,u,C)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(U,T){var V,$, -S,O,X,N,E,M;this.autoClear&&this.clear();h=j.projectScene(U,T,this.sortElements);J=P=B=0;if(G=U.lights.length>0){E=U.lights;n.setRGB(0,0,0);t.setRGB(0,0,0);s.setRGB(0,0,0);V=0;for($=E.length;V<$;V++){S=E[V];O=S.color;if(S instanceof THREE.AmbientLight){n.r+=O.r;n.g+=O.g;n.b+=O.b}else if(S instanceof THREE.DirectionalLight){t.r+=O.r;t.g+=O.g;t.b+=O.b}else if(S instanceof THREE.PointLight){s.r+=O.r;s.g+=O.g;s.b+=O.b}}}V=0;for($=h.length;V<$;V++){E=h[V];q.empty();if(E instanceof THREE.RenderableParticle){o= -E;o.x*=u;o.y*=-C;S=0;for(O=E.materials.length;S0)&&Ma(ia);Da=0;for(Ka=e.length;Da0){V.r+=O.color.r*X;V.g+=O.color.g*X;V.b+=O.color.b*X}}else if(O instanceof THREE.PointLight){t.sub(O.position,T.centroidWorld);t.normalize();X=T.normalWorld.dot(t)*O.intensity;if(X>0){V.r+=O.color.r*X;V.g+=O.color.g*X;V.b+=O.color.b*X}}}}function b(U,T,V,$,S,O){n=f(B++);n.setAttribute("d","M "+U.positionScreen.x+ +" "+U.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)d.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(G){k.r=m.r;k.g=m.g;k.b=m.b;a(O,$,k);d.r=S.color.r*k.r;d.g=S.color.g*k.g;d.b=S.color.b*k.b;d.updateStyleString()}else d.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){x=1-S.__2near/(S.__farPlusNear-$.z*S.__farMinusNear); +d.setRGB(x,x,x)}else S instanceof THREE.MeshNormalMaterial&&d.setRGB(g($.normalWorld.x),g($.normalWorld.y),g($.normalWorld.z));S.wireframe?n.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):n.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+S.opacity);c.appendChild(n)}function e(U,T,V,$,S,O,X){n=f(B++);n.setAttribute("d", +"M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+$.positionScreen.x+","+$.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)d.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(G){k.r=m.r;k.g=m.g;k.b=m.b;a(X,S,k);d.r=O.color.r*k.r;d.g=O.color.g*k.g;d.b=O.color.b*k.b;d.updateStyleString()}else d.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){x= +1-O.__2near/(O.__farPlusNear-S.z*O.__farMinusNear);d.setRGB(x,x,x)}else O instanceof THREE.MeshNormalMaterial&&d.setRGB(g(S.normalWorld.x),g(S.normalWorld.y),g(S.normalWorld.z));O.wireframe?n.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):n.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+O.opacity);c.appendChild(n)} +function f(U){if(p[U]==null){p[U]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&p[U].setAttribute("shape-rendering","crispEdges");return p[U]}return p[U]}function g(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,u,D,o,w,y,A,L=new THREE.Rectangle,q=new THREE.Rectangle,G=false,d=new THREE.Color(16777215),k=new THREE.Color(16777215),m=new THREE.Color(0),s=new THREE.Color(0), +v=new THREE.Color(0),x,t=new THREE.Vector3,p=[],C=[],z=[],n,B,P,J,Q=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(U,T){i=U;l=T;u=i/2;D=l/2;c.setAttribute("viewBox",-u+" "+-D+" "+i+" "+l);c.setAttribute("width",i);c.setAttribute("height",l);L.set(-u,-D,u,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(U,T){var V,$, +S,O,X,N,F,M;this.autoClear&&this.clear();h=j.projectScene(U,T,this.sortElements);J=P=B=0;if(G=U.lights.length>0){F=U.lights;m.setRGB(0,0,0);s.setRGB(0,0,0);v.setRGB(0,0,0);V=0;for($=F.length;V<$;V++){S=F[V];O=S.color;if(S instanceof THREE.AmbientLight){m.r+=O.r;m.g+=O.g;m.b+=O.b}else if(S instanceof THREE.DirectionalLight){s.r+=O.r;s.g+=O.g;s.b+=O.b}else if(S instanceof THREE.PointLight){v.r+=O.r;v.g+=O.g;v.b+=O.b}}}V=0;for($=h.length;V<$;V++){F=h[V];q.empty();if(F instanceof THREE.RenderableParticle){o= +F;o.x*=u;o.y*=-D;S=0;for(O=F.materials.length;S0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,aa,n)}if(s){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,r,n);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,D,n)}};this.setLineBuffers=function(d,k,n,t){var s,x,v=d.vertices,p=v.length,F=d.__vertexArray,z=d.__lineArray; -if(n)for(n=0;n0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,aa,m)}if(v){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,r,m);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,m)}};this.setLineBuffers=function(d,k,m,s){var v,x,t=d.vertices,p=t.length,C=d.__vertexArray,z=d.__lineArray; +if(m)for(m=0;m0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+z.maxDirLights,"#define MAX_POINT_LIGHTS "+z.maxPointLights,z.map?"#define USE_MAP":"",z.env_map?"#define USE_ENVMAP":"","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(B,g("fragment",P+p));c.attachShader(B,g("vertex",z+m));c.linkProgram(B);c.getProgramParameter(B,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(B,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");B.uniforms={};B.attributes={};t.program=B;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in t.uniforms)p.push(v);v=t.program;m=0;for(B=p.length;m=0){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLNormalBuffer); -c.vertexAttribPointer(F.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.normal)}if(F.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLTangentBuffer);c.vertexAttribPointer(F.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.tangent)}if(F.uv>=0)if(s.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLUVBuffer);c.vertexAttribPointer(F.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.uv)}else c.disableVertexAttribArray(F.uv);if(t.wireframe||t instanceof THREE.LineBasicMaterial){F= -t.wireframe_linewidth!==undefined?t.wireframe_linewidth:t.linewidth!==undefined?t.linewidth:1;t=t instanceof THREE.LineBasicMaterial&&x.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(F);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);c.drawElements(t,s.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,s.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,k,n,t,s,x,v){var p,F,z,m,B;z=0;for(m= -t.materials.length;z=0;n--){t=d.__webGLObjects[n].object;k==t&&d.__webGLObjects.splice(n,1)}};this.setupMatrices=function(d,k){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(k.matrix,d.matrix);o.set(l.flatten());u=THREE.Matrix4.makeInvert3x3(l).transpose();y.set(u.m);A.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,C);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,o);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,w); -c.uniformMatrix3fv(d.uniforms.normalMatrix,false,y);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,A)};this.loadCamera=function(d,k){c.uniform3f(d.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(d){switch(d){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(d,k){if(d){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="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.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif", -envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif", -map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", +h(k.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(k.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(k.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,k.__webGLTexture)}}}C=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.vertexAttribPointer(C.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.position);if(C.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer); +c.vertexAttribPointer(C.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.normal)}if(C.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);c.vertexAttribPointer(C.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.tangent)}if(C.uv>=0)if(v.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.vertexAttribPointer(C.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.uv)}else c.disableVertexAttribArray(C.uv);if(s.wireframe||s instanceof THREE.LineBasicMaterial){C= +s.wireframe_linewidth!==undefined?s.wireframe_linewidth:s.linewidth!==undefined?s.linewidth:1;s=s instanceof THREE.LineBasicMaterial&&x.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);c.drawElements(s,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(d,k,m,s,v,x,t){var p,C,z,n,B;z=0;for(n= +s.materials.length;z=0;m--){s=d.__webGLObjects[m].object;k==s&&d.__webGLObjects.splice(m,1)}};this.setupMatrices=function(d,k){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(k.matrix,d.matrix);o.set(l.flatten());u=THREE.Matrix4.makeInvert3x3(l).transpose();y.set(u.m); +A.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,o);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,w);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,y);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,A)};this.loadCamera=function(d,k){c.uniform3f(d.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(d){switch(d){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(d,k){if(d){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="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.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", +map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 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, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv", @@ -196,8 +201,8 @@ shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform "gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;", THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};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.faceMaterials=this.meshMaterials=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.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; -var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,f=a.vertices.length,g=e?b.geometry:b,h=a.vertices,j=g.vertices,c=a.faces,i=g.faces,l=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var u=0,C=j.length;u= 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( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\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 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;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\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:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", -fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,e,f,g,h,j,c){function i(A,L,q,G,d,k,n,t){var s,x,v=f||1,p=g||1,F=v+1,z=p+1,m=d/2,B=k/2;d=d/v;var P=k/p,J=l.vertices.length;if(A=="x"&&L=="y"||A=="y"&&L=="x")s="z";else if(A=="x"&&L=="z"||A=="z"&&L=="x")s="y";else if(A=="z"&&L=="y"||A=="y"&&L=="z")s="x";for(x=0;x0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,c,o)))-1);l.push(u)}b.push(l)}var w,y,A;g=b.length;for(e=0;e0)for(f=0;f1){w=this.vertices[j].position.clone(); -y=this.vertices[i].position.clone();A=this.vertices[l].position.clone();w.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,i,l,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([u,C,L])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,e){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,b||8),j=Math.max(2,e||6);b=[];for(e=0;e0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(D,c,o)))-1);l.push(u)}b.push(l)}var w,y,A;g=b.length;for(e=0;e0)for(f=0;f1){w=this.vertices[j].position.clone(); +y=this.vertices[i].position.clone();A=this.vertices[l].position.clone();w.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,i,l,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([u,D,L])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};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){var b=a.model,e=a.callback,f=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,e,f)};b.postMessage(a)},loadBinary:function(a){var b=a.model,e=a.callback,f=a.texture_path?a.texture_path: THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,e,g,f,h)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,e,f,g,h){var j=new XMLHttpRequest,c=f+"/"+a,i=0; j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,e,g,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(h){if(i==0)i=j.getResponseHeader("Content-Length");h({total:i,loaded:j.responseText.length})}}else if(j.readyState==2)i=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)}, -createBinModel:function(a,b,e,f){var g=function(h){function j(r,D){var H=u(r,D),R=u(r,D+1),Y=u(r,D+2),ja=u(r,D+3),fa=(ja<<1&255|Y>>7)-127;H=(Y&127)<<16|R<<8|H;if(H==0&&fa==-127)return 0;return(1-2*(ja>>7))*(1+H*Math.pow(2,-23))*Math.pow(2,fa)}function c(r,D){var H=u(r,D),R=u(r,D+1),Y=u(r,D+2);return(u(r,D+3)<<24)+(Y<<16)+(R<<8)+H}function i(r,D){var H=u(r,D);return(u(r,D+1)<<8)+H}function l(r,D){var H=u(r,D);return H>127?H-256:H}function u(r,D){return r.charCodeAt(D)&255}function C(r){var D,H,R;D= -c(a,r);H=c(a,r+t);R=c(a,r+s);r=i(a,r+x);THREE.Loader.prototype.f3(q,D,H,R,r)}function o(r){var D,H,R,Y,ja,fa;D=c(a,r);H=c(a,r+t);R=c(a,r+s);Y=i(a,r+x);ja=c(a,r+v);fa=c(a,r+p);r=c(a,r+F);THREE.Loader.prototype.f3n(q,k,D,H,R,Y,ja,fa,r)}function w(r){var D,H,R,Y;D=c(a,r);H=c(a,r+z);R=c(a,r+m);Y=c(a,r+B);r=i(a,r+P);THREE.Loader.prototype.f4(q,D,H,R,Y,r)}function y(r){var D,H,R,Y,ja,fa,na,ta;D=c(a,r);H=c(a,r+z);R=c(a,r+m);Y=c(a,r+B);ja=i(a,r+P);fa=c(a,r+J);na=c(a,r+Q);ta=c(a,r+U);r=c(a,r+T);THREE.Loader.prototype.f4n(q, -k,D,H,R,Y,ja,fa,na,ta,r)}function A(r){var D,H;D=c(a,r);H=c(a,r+V);r=c(a,r+$);THREE.Loader.prototype.uv3(q,n[D*2],n[D*2+1],n[H*2],n[H*2+1],n[r*2],n[r*2+1])}function L(r){var D,H,R;D=c(a,r);H=c(a,r+S);R=c(a,r+O);r=c(a,r+X);THREE.Loader.prototype.uv4(q,n[D*2],n[D*2+1],n[H*2],n[H*2+1],n[R*2],n[R*2+1],n[r*2],n[r*2+1])}var q=this,G=0,d,k=[],n=[],t,s,x,v,p,F,z,m,B,P,J,Q,U,T,V,$,S,O,X,N,E,M,aa,ea,ba;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(q,f,h);d={signature:a.substr(G,8),header_bytes:u(a, +createBinModel:function(a,b,e,f){var g=function(h){function j(r,E){var H=u(r,E),R=u(r,E+1),Y=u(r,E+2),ja=u(r,E+3),fa=(ja<<1&255|Y>>7)-127;H=(Y&127)<<16|R<<8|H;if(H==0&&fa==-127)return 0;return(1-2*(ja>>7))*(1+H*Math.pow(2,-23))*Math.pow(2,fa)}function c(r,E){var H=u(r,E),R=u(r,E+1),Y=u(r,E+2);return(u(r,E+3)<<24)+(Y<<16)+(R<<8)+H}function i(r,E){var H=u(r,E);return(u(r,E+1)<<8)+H}function l(r,E){var H=u(r,E);return H>127?H-256:H}function u(r,E){return r.charCodeAt(E)&255}function D(r){var E,H,R;E= +c(a,r);H=c(a,r+s);R=c(a,r+v);r=i(a,r+x);THREE.Loader.prototype.f3(q,E,H,R,r)}function o(r){var E,H,R,Y,ja,fa;E=c(a,r);H=c(a,r+s);R=c(a,r+v);Y=i(a,r+x);ja=c(a,r+t);fa=c(a,r+p);r=c(a,r+C);THREE.Loader.prototype.f3n(q,k,E,H,R,Y,ja,fa,r)}function w(r){var E,H,R,Y;E=c(a,r);H=c(a,r+z);R=c(a,r+n);Y=c(a,r+B);r=i(a,r+P);THREE.Loader.prototype.f4(q,E,H,R,Y,r)}function y(r){var E,H,R,Y,ja,fa,na,ta;E=c(a,r);H=c(a,r+z);R=c(a,r+n);Y=c(a,r+B);ja=i(a,r+P);fa=c(a,r+J);na=c(a,r+Q);ta=c(a,r+U);r=c(a,r+T);THREE.Loader.prototype.f4n(q, +k,E,H,R,Y,ja,fa,na,ta,r)}function A(r){var E,H;E=c(a,r);H=c(a,r+V);r=c(a,r+$);THREE.Loader.prototype.uv3(q,m[E*2],m[E*2+1],m[H*2],m[H*2+1],m[r*2],m[r*2+1])}function L(r){var E,H,R;E=c(a,r);H=c(a,r+S);R=c(a,r+O);r=c(a,r+X);THREE.Loader.prototype.uv4(q,m[E*2],m[E*2+1],m[H*2],m[H*2+1],m[R*2],m[R*2+1],m[r*2],m[r*2+1])}var q=this,G=0,d,k=[],m=[],s,v,x,t,p,C,z,n,B,P,J,Q,U,T,V,$,S,O,X,N,F,M,aa,ea,ba;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(q,f,h);d={signature:a.substr(G,8),header_bytes:u(a, G+8),vertex_coordinate_bytes:u(a,G+9),normal_coordinate_bytes:u(a,G+10),uv_coordinate_bytes:u(a,G+11),vertex_index_bytes:u(a,G+12),normal_index_bytes:u(a,G+13),uv_index_bytes:u(a,G+14),material_index_bytes:u(a,G+15),nvertices:c(a,G+16),nnormals:c(a,G+16+4),nuvs:c(a,G+16+8),ntri_flat:c(a,G+16+12),ntri_smooth:c(a,G+16+16),ntri_flat_uv:c(a,G+16+20),ntri_smooth_uv:c(a,G+16+24),nquad_flat:c(a,G+16+28),nquad_smooth:c(a,G+16+32),nquad_flat_uv:c(a,G+16+36),nquad_smooth_uv:c(a,G+16+40)};G+=d.header_bytes; -t=d.vertex_index_bytes;s=d.vertex_index_bytes*2;x=d.vertex_index_bytes*3;v=d.vertex_index_bytes*3+d.material_index_bytes;p=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes;F=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes*2;z=d.vertex_index_bytes;m=d.vertex_index_bytes*2;B=d.vertex_index_bytes*3;P=d.vertex_index_bytes*4;J=d.vertex_index_bytes*4+d.material_index_bytes;Q=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes;U=d.vertex_index_bytes*4+ -d.material_index_bytes+d.normal_index_bytes*2;T=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*3;V=d.uv_index_bytes;$=d.uv_index_bytes*2;S=d.uv_index_bytes;O=d.uv_index_bytes*2;X=d.uv_index_bytes*3;h=d.vertex_index_bytes*3+d.material_index_bytes;ba=d.vertex_index_bytes*4+d.material_index_bytes;N=d.ntri_flat*h;E=d.ntri_smooth*(h+d.normal_index_bytes*3);M=d.ntri_flat_uv*(h+d.uv_index_bytes*3);aa=d.ntri_smooth_uv*(h+d.normal_index_bytes*3+d.uv_index_bytes*3);ea=d.nquad_flat*ba;h= -d.nquad_smooth*(ba+d.normal_index_bytes*4);ba=d.nquad_flat_uv*(ba+d.uv_index_bytes*4);G+=function(r){var D,H,R,Y=d.vertex_coordinate_bytes*3,ja=r+d.nvertices*Y;for(r=r;r' + @@ -42,13 +43,35 @@ THREE.Texture.prototype = { THREE.MultiplyOperation = 0; THREE.MixOperation = 1; +// Wrapping modes + THREE.RepeatWrapping = 0; THREE.ClampToEdgeWrapping = 1; THREE.MirroredRepeatWrapping = 2; +// Filters + THREE.NearestFilter = 3; THREE.NearestMipMapNearestFilter = 4; THREE.NearestMipMapLinearFilter = 5; THREE.LinearFilter = 6; THREE.LinearMipMapNearestFilter = 7; THREE.LinearMipMapLinearFilter = 8; + +// Types + +THREE.ByteType = 9; +THREE.UnsignedByteType = 10; +THREE.ShortType = 11; +THREE.UnsignedShortType = 12; +THREE.IntType = 13; +THREE.UnsignedIntType = 14; +THREE.FloatType = 15; + +// Formats + +THREE.AlphaFormat = 16; +THREE.RGBFormat = 17; +THREE.RGBAFormat = 18; +THREE.LuminanceFormat = 19; +THREE.LuminanceAlphaFormat = 20; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 6d1e172f..a242dc24 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -2,6 +2,7 @@ * @author supereggbert / http://www.paulbrunt.co.uk/ * @author mrdoob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ + * @author szimek / https://github.com/szimek/ */ THREE.WebGLRenderer = function ( parameters ) { @@ -48,6 +49,8 @@ THREE.WebGLRenderer = function ( parameters ) { initGL( antialias, clearColor, clearAlpha ); + this.context = _gl; + //alert( dumpObject( getGLParams() ) ); this.setSize = function ( width, height ) { @@ -839,7 +842,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( material.wireframe || material instanceof THREE.LineBasicMaterial ) { linewidth = material.wireframe_linewidth !== undefined ? material.wireframe_linewidth : - material.linewidth !== undefined ? material.linewidth : 1; + material.linewidth !== undefined ? material.linewidth : 1; primitives = material instanceof THREE.LineBasicMaterial && object.type == THREE.LineStrip ? _gl.LINE_STRIP : _gl.LINES; @@ -897,7 +900,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.render = function( scene, camera ) { + this.render = function( scene, camera, renderTarget ) { var o, ol, webGLObject, object, buffer, lights = scene.lights, @@ -905,10 +908,16 @@ THREE.WebGLRenderer = function ( parameters ) { this.initWebGLObjects( scene ); + if ( renderTarget ) { + + setRenderTarget( renderTarget ); + + } + if ( this.autoClear ) { - + this.clear(); - + } camera.autoUpdateMatrix && camera.updateMatrix(); @@ -965,8 +974,16 @@ THREE.WebGLRenderer = function ( parameters ) { } - }; + // Generate mipmap if we're using any kind of mipmap filtering + + if ( renderTarget && renderTarget.min_filter !== THREE.NearestFilter && renderTarget.min_filter !== THREE.LinearFilter ) { + updateRenderTargetMipmap( renderTarget ); + + } + + }; + this.initWebGLObjects = function( scene ) { function add_buffer( objmap, id, buffer, object ) { @@ -1435,6 +1452,57 @@ THREE.WebGLRenderer = function ( parameters ) { }; + function setRenderTarget( renderTexture ) { + + var framebuffer; + + if ( renderTexture && !renderTexture.__webGLFramebuffer ) { + + renderTexture.__webGLFramebuffer = _gl.createFramebuffer(); + renderTexture.__webGLRenderbuffer = _gl.createRenderbuffer(); + renderTexture.__webGLTexture = _gl.createTexture(); + + // Setup renderbuffer + + _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webGLRenderbuffer ); + _gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height ); + + // Setup texture + + _gl.bindTexture( _gl.TEXTURE_2D, renderTexture.__webGLTexture ); + _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( renderTexture.wrap_s ) ); + _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( renderTexture.wrap_t ) ); + _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( renderTexture.mag_filter ) ); + _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( renderTexture.min_filter ) ); + _gl.texImage2D( _gl.TEXTURE_2D, 0, paramThreeToGL( renderTexture.format ), renderTexture.width, renderTexture.height, 0, paramThreeToGL( renderTexture.format ), paramThreeToGL( renderTexture.type ), null ); + + // Setup framebuffer + + _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTexture.__webGLFramebuffer ); + _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, renderTexture.__webGLTexture, 0 ); + _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webGLRenderbuffer ); + + // Release everything + + _gl.bindTexture( _gl.TEXTURE_2D, null ); + _gl.bindRenderbuffer( _gl.RENDERBUFFER, null ); + _gl.bindFramebuffer( _gl.FRAMEBUFFER, null); + + } + + framebuffer = renderTexture ? renderTexture.__webGLFramebuffer : null; + _gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); + + }; + + function updateRenderTargetMipmap( renderTarget ) { + + _gl.bindTexture( _gl.TEXTURE_2D, renderTarget.__webGLTexture ); + _gl.generateMipmap( _gl.TEXTURE_2D ); + _gl.bindTexture( _gl.TEXTURE_2D, null ); + + }; + function cacheUniformLocations( program, identifiers ) { var i, l, id; @@ -1505,6 +1573,20 @@ THREE.WebGLRenderer = function ( parameters ) { case THREE.LinearMipMapNearestFilter: return _gl.LINEAR_MIPMAP_NEAREST; break; case THREE.LinearMipMapLinearFilter: return _gl.LINEAR_MIPMAP_LINEAR; break; + case THREE.ByteType: return _gl.BYTE; break; + case THREE.UnsignedByteType: return _gl.UNSIGNED_BYTE; break; + case THREE.ShortType: return _gl.SHORT; break; + case THREE.UnsignedShortType: return _gl.UNSIGNED_SHORT; break; + case THREE.IntType: return _gl.INT; break; + case THREE.UnsignedShortType: return _gl.UNSIGNED_INT; break; + case THREE.FloatType: return _gl.FLOAT; break; + + case THREE.AlphaFormat: return _gl.ALPHA; break; + case THREE.RGBFormat: return _gl.RGB; break; + case THREE.RGBAFormat: return _gl.RGBA; break; + case THREE.LuminanceFormat: return _gl.LUMINANCE; break; + case THREE.LuminanceAlphaFormat: return _gl.LUMINANCE_ALPHA; break; + } return 0; @@ -2138,7 +2220,7 @@ THREE.ShaderLib = { uniforms: Uniforms.merge( [ THREE.UniformsLib[ "common" ], THREE.UniformsLib[ "lights" ], - { "ambient" : { type: "c", value: new THREE.Color( 0x050505 ) }, + { "ambient" : { type: "c", value: new THREE.Color( 0x050505 ) }, "specular" : { type: "c", value: new THREE.Color( 0x111111 ) }, "shininess": { type: "f", value: 30 } } diff --git a/utils/build.py b/utils/build.py index 21fc1ace..b92eae61 100644 --- a/utils/build.py +++ b/utils/build.py @@ -49,6 +49,7 @@ COMMON_FILES = [ 'materials/ParticleCircleMaterial.js', 'materials/ParticleDOMMaterial.js', 'materials/Texture.js', +'materials/RenderTarget.js', 'materials/Uniforms.js', 'materials/mappings/CubeReflectionMapping.js', 'materials/mappings/CubeRefractionMapping.js', @@ -238,6 +239,7 @@ WEBGL_FILES = [ 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', 'materials/Texture.js', +'materials/RenderTarget.js', 'materials/Uniforms.js', 'materials/mappings/CubeReflectionMapping.js', 'materials/mappings/CubeRefractionMapping.js',