Transplanted simple hierarchy system from WebGLRenderer2 into WebGLRenderer.

Work in progress.

As with static objects, faster with OpenGL (34 -> 38 fps) and slower with ANGLE (30 -> 27 fps).
This commit is contained in:
alteredq
2011-02-15 04:22:37 +01:00
parent 04cae71659
commit df513e044c
6 changed files with 811 additions and 730 deletions
+159 -158
View File
@@ -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,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var f,k,l,p,q,m;if(e==0)f=k=l=0;else{p=Math.floor(a*6);q=a*6-p;a=e*(1-c);m=e*(1-c*q);c=e*(1-c*(1-q));switch(p){case 1:f=m;k=e;l=a;break;case 2:f=a;k=e;l=c;break;case 3:f=a;k=m;l=e;break;case 4:f=c;k=a;l=e;break;case 5:f=e;k=a;l=m;break;case 6:case 0:f=e;k=c;l=a}}this.r=f;this.g=k;this.b=l;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;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)},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,d){this.x=a||0;this.y=c||0;this.z=d||0};
THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;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,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+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,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;
THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;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,k=[];a=0;for(c=f.length;a<c;a++){e=f[a];if(e instanceof THREE.Mesh)k=k.concat(this.intersectObject(e))}k.sort(function(l,p){return l.distance-p.distance});return k},intersectObject:function(a){function c(I,s,R,E){E=E.clone().subSelf(s);R=R.clone().subSelf(s);var J=I.clone().subSelf(s);I=E.dot(E);s=E.dot(R);E=E.dot(J);var O=R.dot(R);R=R.dot(J);J=1/(I*O-s*s);O=(O*E-s*R)*J;I=(I*R-s*E)*J;return O>0&&I>0&&O+I<1}var e,f,k,l,p,q,m,o,C,B,
u,x=a.geometry,b=x.vertices,H=[];e=0;for(f=x.faces.length;e<f;e++){k=x.faces[e];B=this.origin.clone();u=this.direction.clone();l=a.matrix.multiplyVector3(b[k.a].position.clone());p=a.matrix.multiplyVector3(b[k.b].position.clone());q=a.matrix.multiplyVector3(b[k.c].position.clone());m=k instanceof THREE.Face4?a.matrix.multiplyVector3(b[k.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(k.normal.clone());C=u.dot(o);if(C<0){o=o.dot((new THREE.Vector3).sub(l,B))/C;B=B.addSelf(u.multiplyScalar(o));
if(k instanceof THREE.Face3){if(c(B,l,p,q)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}else if(k instanceof THREE.Face4)if(c(B,l,p,m)||c(B,p,q,m)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}}return H}};
THREE.Rectangle=function(){function a(){l=f-c;p=k-e}var c,e,f,k,l,p,q=true;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return l};this.getHeight=function(){return p};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return k};this.set=function(m,o,C,B){q=false;c=m;e=o;f=C;k=B;a()};this.addPoint=function(m,o){if(q){q=false;c=m;e=o;f=m;k=o}else{c=c<m?c:m;e=e<o?e:o;f=f>m?f:m;k=k>o?
k:o}a()};this.add3Points=function(m,o,C,B,u,x){if(q){q=false;c=m<C?m<u?m:u:C<u?C:u;e=o<B?o<x?o:x:B<x?B:x;f=m>C?m>u?m:u:C>u?C:u;k=o>B?o>x?o:x:B>x?B:x}else{c=m<C?m<u?m<c?m:c:u<c?u:c:C<u?C<c?C:c:u<c?u:c;e=o<B?o<x?o<e?o:e:x<e?x:e:B<x?B<e?B:e:x<e?x:e;f=m>C?m>u?m>f?m:f:u>f?u:f:C>u?C>f?C:f:u>f?u:f;k=o>B?o>x?o>k?o:k:x>k?x:k:B>x?B>k?B:k:x>k?x:k}a()};this.addRectangle=function(m){if(q){q=false;c=m.getLeft();e=m.getTop();f=m.getRight();k=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();e=e<m.getTop()?e:m.getTop();
f=f>m.getRight()?f:m.getRight();k=k>m.getBottom()?k:m.getBottom()}a()};this.inflate=function(m){c-=m;e-=m;f+=m;k+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();e=e>m.getTop()?e:m.getTop();f=f<m.getRight()?f:m.getRight();k=k<m.getBottom()?k:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(k,m.getBottom())-Math.max(e,m.getTop())>=0};this.empty=function(){q=true;k=f=e=c=0;a()};this.isEmpty=function(){return q};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+e+", bottom: "+k+", width: "+l+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
THREE.Matrix4=function(a,c,e,f,k,l,p,q,m,o,C,B,u,x,b,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=f||0;this.n21=k||0;this.n22=l||1;this.n23=p||0;this.n24=q||0;this.n31=m||0;this.n32=o||0;this.n33=C||1;this.n34=B||0;this.n41=u||0;this.n42=x||0;this.n43=b||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
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,k,l,p,q,m,o,C,B,u,x,b,H){this.n11=a;this.n12=c;this.n13=e;this.n14=f;this.n21=k;this.n22=l;this.n23=p;this.n24=q;this.n31=m;this.n32=o;this.n33=C;this.n34=B;this.n41=u;this.n42=x;this.n43=b;this.n44=H;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=THREE.Matrix4.__tmpVec1,k=THREE.Matrix4.__tmpVec2,l=THREE.Matrix4.__tmpVec3;l.sub(a,c).normalize();f.cross(e,l).normalize();k.cross(l,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=k.x;this.n22=k.y;this.n23=k.z;this.n24=-k.dot(a);
this.n31=l.x;this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,f=a.z,k=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)*k;a.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*k;a.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*k;return a},multiplyVector4:function(a){var c=a.x,e=a.y,f=a.z,k=a.w;a.x=this.n11*c+this.n12*e+this.n13*f+this.n14*k;a.y=this.n21*c+this.n22*e+this.n23*
f+this.n24*k;a.z=this.n31*c+this.n32*e+this.n33*f+this.n34*k;a.w=this.n41*c+this.n42*e+this.n43*f+this.n44*k;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,k=a.n13,l=a.n14,p=a.n21,q=a.n22,m=a.n23,o=a.n24,C=a.n31,
B=a.n32,u=a.n33,x=a.n34,b=a.n41,H=a.n42,I=a.n43,s=a.n44,R=c.n11,E=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,K=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43,n=c.n44;this.n11=e*R+f*Y+k*M+l*i;this.n12=e*E+f*P+k*U+l*j;this.n13=e*J+f*K+k*d+l*g;this.n14=e*O+f*V+k*h+l*n;this.n21=p*R+q*Y+m*M+o*i;this.n22=p*E+q*P+m*U+o*j;this.n23=p*J+q*K+m*d+o*g;this.n24=p*O+q*V+m*h+o*n;this.n31=C*R+B*Y+u*M+x*i;this.n32=C*E+B*P+u*U+x*j;this.n33=C*J+B*K+u*d+x*g;this.n34=C*O+B*V+u*h+x*n;this.n41=b*R+H*Y+
I*M+s*i;this.n42=b*E+H*P+I*U+s*j;this.n43=b*J+H*K+I*d+s*g;this.n44=b*O+H*V+I*h+s*n;return this},multiplyToArray:function(a,c,e){var f=a.n11,k=a.n12,l=a.n13,p=a.n14,q=a.n21,m=a.n22,o=a.n23,C=a.n24,B=a.n31,u=a.n32,x=a.n33,b=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var R=c.n11,E=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,K=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43;c=c.n44;this.n11=f*R+k*Y+l*M+p*i;this.n12=f*E+k*P+l*U+p*j;this.n13=f*J+k*K+l*d+p*g;this.n14=f*O+k*V+l*h+p*c;this.n21=
q*R+m*Y+o*M+C*i;this.n22=q*E+m*P+o*U+C*j;this.n23=q*J+m*K+o*d+C*g;this.n24=q*O+m*V+o*h+C*c;this.n31=B*R+u*Y+x*M+b*i;this.n32=B*E+u*P+x*U+b*j;this.n33=B*J+u*K+x*d+b*g;this.n34=B*O+u*V+x*h+b*c;this.n41=H*R+I*Y+s*M+a*i;this.n42=H*E+I*P+s*U+a*j;this.n43=H*J+I*K+s*d+a*g;this.n44=H*O+I*V+s*h+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;
e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,f=this.n13,k=this.n14,l=this.n21,p=this.n22,q=this.n23,m=this.n24,o=this.n31,C=this.n32,B=this.n33,u=this.n34,x=this.n41,b=this.n42,H=this.n43,I=this.n44,s=a.n11,R=a.n21,E=a.n31,J=a.n41,O=a.n12,Y=a.n22,P=a.n32,K=a.n42,V=a.n13,M=a.n23,U=a.n33,d=a.n43,h=a.n14,i=a.n24,j=a.n34;a=a.n44;this.n11=c*s+e*R+f*E+k*J;this.n12=c*O+e*Y+f*P+k*K;this.n13=c*V+e*M+f*U+k*d;this.n14=c*h+e*i+f*j+k*a;this.n21=l*s+p*R+q*E+m*J;this.n22=l*O+p*
Y+q*P+m*K;this.n23=l*V+p*M+q*U+m*d;this.n24=l*h+p*i+q*j+m*a;this.n31=o*s+C*R+B*E+u*J;this.n32=o*O+C*Y+B*P+u*K;this.n33=o*V+C*M+B*U+u*d;this.n34=o*h+C*i+B*j+u*a;this.n41=x*s+b*R+H*E+I*J;this.n42=x*O+b*Y+H*P+I*K;this.n43=x*V+b*M+H*U+I*d;this.n44=x*h+b*i+H*j+I*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(){var a=this.n11,c=this.n12,e=this.n13,f=this.n14,k=this.n21,l=this.n22,p=this.n23,q=this.n24,m=this.n31,o=this.n32,C=this.n33,B=this.n34,u=this.n41,x=this.n42,b=this.n43,H=this.n44;return f*p*o*u-e*q*o*u-f*l*C*u+c*q*C*u+e*l*B*u-c*p*B*u-f*p*m*x+e*q*m*x+f*k*C*x-a*q*C*x-e*k*B*x+a*p*B*x+f*l*m*b-c*q*m*b-f*k*o*b+a*q*o*b+c*k*B*b-a*l*B*b-e*l*m*H+c*p*m*H+e*k*o*H-a*p*o*H-c*k*C*H+a*l*C*H},transpose:function(){function a(c,e,f){var k=c[e];c[e]=c[f];c[f]=k}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=
this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1,0,0,a,0,1,0,c,0,0,1,e,0,0,0,
1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),f=Math.sin(c),k=1-e,l=a.x,p=a.y,q=a.z,
m=k*l,o=k*p;this.set(m*l+e,m*p-f*q,m*q+f*p,0,m*p+f*q,o*p+e,o*q-f*l,0,m*q-f*p,o*q+f*l,k*q*q+e,0,0,0,0,1);return this},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.setTranslation(a,c,e);return f};
THREE.Matrix4.scaleMatrix=function(a,c,e){var f=new THREE.Matrix4;f.setScale(a,c,e);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,f=a.n13,k=a.n14,l=a.n21,p=a.n22,q=a.n23,m=a.n24,o=a.n31,C=a.n32,B=a.n33,u=a.n34,x=a.n41,b=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=q*u*b-m*B*b+m*C*H-p*u*H-q*C*I+p*B*I;s.n12=k*B*b-f*u*b-k*C*H+e*u*H+f*C*I-e*B*I;s.n13=f*m*b-k*q*b+k*p*H-e*m*H-f*p*I+e*q*I;s.n14=k*q*C-f*m*C-k*p*B+e*m*B+f*p*u-e*q*u;s.n21=m*B*x-q*u*x-m*o*H+l*u*H+q*o*I-l*B*I;s.n22=f*u*x-k*B*x+k*o*H-c*u*H-f*o*I+c*B*I;s.n23=k*q*x-f*m*x-k*l*H+c*m*H+f*l*I-c*q*I;s.n24=f*m*o-k*q*o+
k*l*B-c*m*B-f*l*u+c*q*u;s.n31=p*u*x-m*C*x+m*o*b-l*u*b-p*o*I+l*C*I;s.n32=k*C*x-e*u*x-k*o*b+c*u*b+e*o*I-c*C*I;s.n33=f*m*x-k*p*x+k*l*b-c*m*b-e*l*I+c*p*I;s.n34=k*p*o-e*m*o-k*l*C+c*m*C+e*l*u-c*p*u;s.n41=q*C*x-p*B*x-q*o*b+l*B*b+p*o*H-l*C*H;s.n42=e*B*x-f*C*x+f*o*b-c*B*b-e*o*H+c*C*H;s.n43=f*p*x-e*q*x-f*l*b+c*q*b+e*l*H-c*p*H;s.n44=e*q*o-f*p*o+f*l*C-c*q*C-e*l*B+c*p*B;s.multiplyScalar(1/a.determinant());return s};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,f=a.n33*a.n22-a.n32*a.n23,k=-a.n33*a.n21+a.n31*a.n23,l=a.n32*a.n21-a.n31*a.n22,p=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,C=-a.n23*a.n11+a.n21*a.n13,B=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*p+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*f;e[1]=a*k;e[2]=a*l;e[3]=a*p;e[4]=a*q;e[5]=a*m;e[6]=a*o;e[7]=a*C;e[8]=a*B;return c};
THREE.Matrix4.makeFrustum=function(a,c,e,f,k,l){var p,q,m;p=new THREE.Matrix4;q=2*k/(c-a);m=2*k/(f-e);a=(c+a)/(c-a);e=(f+e)/(f-e);f=-(l+k)/(l-k);k=-2*l*k/(l-k);p.n11=q;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=m;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=k;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,c,e,f){var k;a=e*Math.tan(a*Math.PI/360);k=-a;return THREE.Matrix4.makeFrustum(k*c,a*c,k,a,e,f)};
THREE.Matrix4.makeOrtho=function(a,c,e,f,k,l){var p,q,m,o;p=new THREE.Matrix4;q=c-a;m=e-f;o=l-k;a=(c+a)/q;e=(e+f)/m;k=(l+k)/o;p.n11=2/q;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/m;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/o;p.n34=-k;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function c(I,s,O,C){C=C.clone().subSelf(s);O=O.clone().subSelf(s);var b=I.clone().subSelf(s);I=C.dot(C);s=C.dot(O);C=C.dot(b);var R=O.dot(O);O=O.dot(b);b=1/(I*R-s*s);R=(R*C-s*O)*b;I=(I*O-s*C)*b;return R>0&&I>0&&R+I<1}var d,f,j,k,q,o,l,n,z,y,
v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;d<f;d++){j=x.faces[d];y=this.origin.clone();v=this.direction.clone();k=a.matrix.multiplyVector3(F[j.a].position.clone());q=a.matrix.multiplyVector3(F[j.b].position.clone());o=a.matrix.multiplyVector3(F[j.c].position.clone());l=j instanceof THREE.Face4?a.matrix.multiplyVector3(F[j.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(j.normal.clone());z=v.dot(n);if(z<0){n=n.dot((new THREE.Vector3).sub(k,y))/z;y=y.addSelf(v.multiplyScalar(n));
if(j instanceof THREE.Face3){if(c(y,k,q,o)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}else if(j instanceof THREE.Face4)if(c(y,k,q,l)||c(y,q,o,l)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}}return H}};
THREE.Rectangle=function(){function a(){k=f-c;q=j-d}var c,d,f,j,k,q,o=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(l,n,z,y){o=false;c=l;d=n;f=z;j=y;a()};this.addPoint=function(l,n){if(o){o=false;c=l;d=n;f=l;j=n}else{c=c<l?c:l;d=d<n?d:n;f=f>l?f:l;j=j>n?
j:n}a()};this.add3Points=function(l,n,z,y,v,x){if(o){o=false;c=l<z?l<v?l:v:z<v?z:v;d=n<y?n<x?n:x:y<x?y:x;f=l>z?l>v?l:v:z>v?z:v;j=n>y?n>x?n:x:y>x?y:x}else{c=l<z?l<v?l<c?l:c:v<c?v:c:z<v?z<c?z:c:v<c?v:c;d=n<y?n<x?n<d?n:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=n>y?n>x?n>j?n:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
f=f>l.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();j=j<l.getBottom()?j:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,n,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=n||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
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,d,f,j,k,q,o,l,n,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=n;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;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,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;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 d=a.n11,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,n=a.n24,z=a.n31,
y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+n*K;this.n22=q*C+o*Q+l*U+n*ca;this.n23=q*b+o*J+l*M+n*N;this.n24=q*R+o*X+l*D+n*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41=
F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,n=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q*
c;this.n21=o*O+l*$+n*G+z*K;this.n22=o*C+l*Q+n*U+z*ca;this.n23=o*b+l*J+n*M+z*N;this.n24=o*R+l*X+n*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;
d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,n=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l*
b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=n*s+z*O+y*C+v*b;this.n32=n*R+z*$+y*Q+v*J;this.n33=n*X+z*G+y*U+v*M;this.n34=n*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*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(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,n=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*n*v-d*o*n*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*n*F+a*o*n*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*n*H-a*q*n*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}a(this,"n21","n12");
a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;
a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,
0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y,
o=a.z,l=j*k,n=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,n*q+d,n*o-f*k,0,l*o-f*q,n*o+f*k,j*o*o+d,0,0,0,0,1);return this},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,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};
THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,n=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*n*H+k*v*H+o*n*I-k*y*I;s.n22=f*v*x-j*y*x+j*n*H-c*v*H-f*n*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*n-j*o*n+
j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*n*F-k*v*F-q*n*I+k*z*I;s.n32=j*z*x-d*v*x-j*n*F+c*v*F+d*n*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*n-d*l*n-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*n*F+k*y*F+q*n*H-k*z*H;s.n42=d*y*x-f*z*x+f*n*F-c*y*F-d*n*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*n-f*q*n+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*n;d[7]=a*z;d[8]=a*y;return c};
THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)};
THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,n;q=new THREE.Matrix4;o=c-a;l=d-f;n=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/n;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
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,k){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=k instanceof Array?k:[k]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,e,f,k,l){this.a=a;this.b=c;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=k instanceof THREE.Vector3?k:new THREE.Vector3;this.vertexNormals=k instanceof Array?k:[];this.materials=l instanceof Array?l:[l]};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.Face3=function(a,c,d,f,j){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,e,f,k,l,p,q=new THREE.Vector3,m=new THREE.Vector3;f=0;for(k=this.vertices.length;f<k;f++){l=this.vertices[f];l.normal.set(0,0,0)}f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];if(a&&l.vertexNormals.length){q.set(0,0,0);c=0;for(e=l.normal.length;c<e;c++)q.addSelf(l.vertexNormals[c]);q.divideScalar(3)}else{c=this.vertices[l.a];e=this.vertices[l.b];p=this.vertices[l.c];q.sub(p.position,
e.position);m.sub(c.position,e.position);q.crossSelf(m)}q.isZero()||q.normalize();l.normal.copy(q)}},computeVertexNormals:function(){var a,c,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(h,i,j,g,n,z,r){l=h.vertices[i].position;p=h.vertices[j].position;q=h.vertices[g].position;m=k[n];o=k[z];C=k[r];B=p.x-l.x;u=q.x-l.x;x=p.y-l.y;b=q.y-l.y;
H=p.z-l.z;I=q.z-l.z;s=o.u-m.u;R=C.u-m.u;E=o.v-m.v;J=C.v-m.v;O=1/(s*J-R*E);K.set((J*B-E*u)*O,(J*x-E*b)*O,(J*H-E*I)*O);V.set((s*u-R*B)*O,(s*b-R*x)*O,(s*I-R*H)*O);Y[i].addSelf(K);Y[j].addSelf(K);Y[g].addSelf(K);P[i].addSelf(V);P[j].addSelf(V);P[g].addSelf(V)}var c,e,f,k,l,p,q,m,o,C,B,u,x,b,H,I,s,R,E,J,O,Y=[],P=[],K=new THREE.Vector3,V=new THREE.Vector3,M=new THREE.Vector3,U=new THREE.Vector3,d=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++){Y[c]=new THREE.Vector3;P[c]=new THREE.Vector3}c=0;
for(e=this.faces.length;c<e;c++){f=this.faces[c];k=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(e=this.vertices.length;c<e;c++){d.copy(this.vertices[c].normal);f=Y[c];M.copy(f);M.subSelf(d.multiplyScalar(d.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(P[c]);f=f<0?-1:1;this.vertices[c].tangent.set(M.x,M.y,M.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){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;c<e;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else 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;c<e;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(C){var B=[];c=0;for(e=C.length;c<e;c++)C[c]==undefined?B.push("undefined"):B.push(C[c].toString());return B.join("_")}var c,e,f,k,l,p,q,m,o={};f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];
p=l.materials;q=a(p);if(o[q]==undefined)o[q]={hash:q,counter:0};m=o[q].hash+"_"+o[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0};l=l instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+l>65535){o[q].counter+=1;m=o[q].hash+"_"+o[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0}}this.geometryChunks[m].faces.push(f);this.geometryChunks[m].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+
THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,j,k,q,o=new THREE.Vector3,l=new THREE.Vector3;f=0;for(j=this.vertices.length;f<j;f++){k=this.vertices[f];k.normal.set(0,0,0)}f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];if(a&&k.vertexNormals.length){o.set(0,0,0);c=0;for(d=k.normal.length;c<d;c++)o.addSelf(k.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[k.a];d=this.vertices[k.b];q=this.vertices[k.c];o.sub(q.position,
d.position);l.sub(c.position,d.position);o.crossSelf(l)}o.isZero()||o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(D,K,ca,N,aa,e,i){k=D.vertices[K].position;q=D.vertices[ca].position;o=D.vertices[N].position;l=j[aa];n=j[e];z=j[i];y=q.x-k.x;v=o.x-k.x;x=q.y-k.y;F=o.y-
k.y;H=q.z-k.z;I=o.z-k.z;s=n.u-l.u;O=z.u-l.u;C=n.v-l.v;b=z.v-l.v;R=1/(s*b-O*C);J.set((b*y-C*v)*R,(b*x-C*F)*R,(b*H-C*I)*R);X.set((s*v-O*y)*R,(s*F-O*x)*R,(s*I-O*H)*R);$[K].addSelf(J);$[ca].addSelf(J);$[N].addSelf(J);Q[K].addSelf(X);Q[ca].addSelf(X);Q[N].addSelf(X)}var c,d,f,j,k,q,o,l,n,z,y,v,x,F,H,I,s,O,C,b,R,$=[],Q=[],J=new THREE.Vector3,X=new THREE.Vector3,G=new THREE.Vector3,U=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){$[c]=new THREE.Vector3;Q[c]=new THREE.Vector3}c=
0;for(d=this.faces.length;c<d;c++){f=this.faces[c];j=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){M.copy(this.vertices[c].normal);f=$[c];G.copy(f);G.subSelf(M.multiplyScalar(M.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(Q[c]);f=f<0?-1:1;this.vertices[c].tangent.set(G.x,G.y,G.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){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,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else 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,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,j,k,q,o,l,n={};f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];
q=k.materials;o=a(q);if(n[o]==undefined)n[o]={hash:o,counter:0};l=n[o].hash+"_"+n[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){n[o].counter+=1;l=n[o].hash+"_"+n[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
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.tmpVec=new THREE.Vector3;this.translateX=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;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.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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,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.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};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.sortParticles=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.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.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x,
d.y,d.z))}};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.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d: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.BillboardBlending=3;
THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
@@ -96,115 +96,116 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
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 (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,f,k,l){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=k!==undefined?k:THREE.LinearFilter;this.min_filter=l!==undefined?l:THREE.LinearMipMapLinearFilter};
THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k: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 (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,c,e){this.width=a;this.height=c;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,e,f,k={};for(c in a){k[c]={};for(e in a[c]){f=a[c][e];k[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return k},merge:function(a){var c,e,f,k={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(e in f)k[e]=f[e]}return k}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)j[d]=f[d]}return j}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(P,K){return K.z-P.z}function c(P,K){var V=0,M=1,U=P.z+P.w,d=K.z+K.w,h=-P.z+P.w,i=-K.z+K.w;if(U>=0&&d>=0&&h>=0&&i>=0)return true;else if(U<0&&d<0||h<0&&i<0)return false;else{if(U<0)V=Math.max(V,U/(U-d));else if(d<0)M=Math.min(M,U/(U-d));if(h<0)V=Math.max(V,h/(h-i));else if(i<0)M=Math.min(M,h/(h-i));if(M<V)return false;else{P.lerpSelf(K,V);K.lerpSelf(P,1-M);return true}}}var e,f,k=[],l,p,q,m=[],o,C,B=[],u,x,b=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
R=new THREE.Matrix4,E=[],J=new THREE.Vector4,O=new THREE.Vector4,Y;this.projectObjects=function(P,K,V){var M=[],U,d;f=0;s.multiply(K.projectionMatrix,K.matrix);E[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);E[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);E[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);E[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);E[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);E[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);K=0;for(U=E.length;K<U;K++){d=E[K];d.divideScalar(Math.sqrt(d.x*d.x+d.y*d.y+d.z*d.z))}U=P.objects;P=0;for(K=U.length;P<K;P++){d=U[P];var h;if(!(h=!d.visible)){if(h=d instanceof THREE.Mesh){a:{h=void 0;for(var i=d.position,j=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,Math.max(d.scale.y,d.scale.z)),g=0;g<6;g++){h=E[g].x*i.x+E[g].y*i.y+E[g].z*i.z+E[g].w;if(h<=j){h=false;break a}}h=true}h=!h}h=h}if(!h){e=
k[f]=k[f]||new THREE.RenderableObject;H.copy(d.position);s.multiplyVector3(H);e.object=d;e.z=H.z;M.push(e);f++}}V&&M.sort(a);return M};this.projectScene=function(P,K,V){var M=[],U=K.near,d=K.far,h,i,j,g,n,z,r,t,v,w,y,L,F,A,N,T;q=C=x=0;K.autoUpdateMatrix&&K.updateMatrix();s.multiply(K.projectionMatrix,K.matrix);z=this.projectObjects(P,K,true);P=0;for(h=z.length;P<h;P++){r=z[P].object;if(r.visible){r.autoUpdateMatrix&&r.updateMatrix();t=r.matrix;v=r.rotationMatrix;w=r.materials;y=r.overdraw;if(r instanceof
THREE.Mesh){L=r.geometry;F=L.vertices;i=0;for(j=F.length;i<j;i++){A=F[i];A.positionWorld.copy(A.position);t.multiplyVector3(A.positionWorld);g=A.positionScreen;g.copy(A.positionWorld);s.multiplyVector4(g);g.x/=g.w;g.y/=g.w;A.__visible=g.z>U&&g.z<d}L=L.faces;i=0;for(j=L.length;i<j;i++){A=L[i];if(A instanceof THREE.Face3){g=F[A.a];n=F[A.b];N=F[A.c];if(g.__visible&&n.__visible&&N.__visible)if(r.doubleSided||r.flipSided!=(N.positionScreen.x-g.positionScreen.x)*(n.positionScreen.y-g.positionScreen.y)-
(N.positionScreen.y-g.positionScreen.y)*(n.positionScreen.x-g.positionScreen.x)<0){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(n.positionWorld);l.v3.positionWorld.copy(N.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(n.positionScreen);l.v3.positionScreen.copy(N.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);
l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);N=A.vertexNormals;Y=l.vertexNormalsWorld;g=0;for(n=N.length;g<n;g++){T=Y[g]=Y[g]||new THREE.Vector3;T.copy(N[g]);v.multiplyVector3(T)}l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][2]}M.push(l);q++}}else if(A instanceof THREE.Face4){g=F[A.a];n=F[A.b];N=F[A.c];T=F[A.d];if(g.__visible&&
n.__visible&&N.__visible&&T.__visible)if(r.doubleSided||r.flipSided!=((T.positionScreen.x-g.positionScreen.x)*(n.positionScreen.y-g.positionScreen.y)-(T.positionScreen.y-g.positionScreen.y)*(n.positionScreen.x-g.positionScreen.x)<0||(n.positionScreen.x-N.positionScreen.x)*(T.positionScreen.y-N.positionScreen.y)-(n.positionScreen.y-N.positionScreen.y)*(T.positionScreen.x-N.positionScreen.x)<0)){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(n.positionWorld);
l.v3.positionWorld.copy(T.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(n.positionScreen);l.v3.positionScreen.copy(T.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];
l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][3]}M.push(l);q++;p=m[q]=m[q]||new THREE.RenderableFace3;p.v1.positionWorld.copy(n.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(T.positionWorld);p.v1.positionScreen.copy(n.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(T.positionScreen);p.normalWorld.copy(l.normalWorld);p.centroidWorld.copy(l.centroidWorld);p.centroidScreen.copy(l.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
w;p.faceMaterials=A.materials;p.overdraw=y;if(r.geometry.uvs[i]){p.uvs[0]=r.geometry.uvs[i][1];p.uvs[1]=r.geometry.uvs[i][2];p.uvs[2]=r.geometry.uvs[i][3]}M.push(p);q++}}}}else if(r instanceof THREE.Line){R.multiply(s,t);F=r.geometry.vertices;A=F[0];A.positionScreen.copy(A.position);R.multiplyVector4(A.positionScreen);i=1;for(j=F.length;i<j;i++){g=F[i];g.positionScreen.copy(g.position);R.multiplyVector4(g.positionScreen);n=F[i-1];J.copy(g.positionScreen);O.copy(n.positionScreen);if(c(J,O)){J.multiplyScalar(1/
J.w);O.multiplyScalar(1/O.w);o=B[C]=B[C]||new THREE.RenderableLine;o.v1.positionScreen.copy(J);o.v2.positionScreen.copy(O);o.z=Math.max(J.z,O.z);o.materials=r.materials;M.push(o);C++}}}else if(r instanceof THREE.Particle){I.set(r.position.x,r.position.y,r.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){u=b[x]=b[x]||new THREE.RenderableParticle;u.x=I.x/I.w;u.y=I.y/I.w;u.z=I.z;u.rotation=r.rotation.z;u.scale.x=r.scale.x*Math.abs(u.x-(I.x+K.projectionMatrix.n11)/(I.w+K.projectionMatrix.n14));
u.scale.y=r.scale.y*Math.abs(u.y-(I.y+K.projectionMatrix.n22)/(I.w+K.projectionMatrix.n24));u.materials=r.materials;M.push(u);x++}}}}V&&M.sort(a);return M};this.unprojectVector=function(P,K){var V=THREE.Matrix4.makeInvert(K.matrix);V.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));V.multiplyVector3(P);return P}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,f,k,l;this.domElement=document.createElement("div");this.setSize=function(p,q){e=p;f=q;k=e/2;l=f/2};this.render=function(p,q){var m,o,C,B,u,x,b,H;a=c.projectScene(p,q);m=0;for(o=a.length;m<o;m++){u=a[m];if(u instanceof THREE.RenderableParticle){b=u.x*k+k;H=u.y*l+l;C=0;for(B=u.material.length;C<B;C++){x=u.material[C];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=b+"px";x.style.top=H+"px"}}}}}};
THREE.CanvasRenderer=function(){function a($){if(u!=$)o.globalAlpha=u=$}function c($){if(x!=$){switch($){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}x=$}}var e=null,f=new THREE.Projector,k=document.createElement("canvas"),l,p,q,m,o=k.getContext("2d"),C=new THREE.Color(0),B=0,u=1,x=0,b=null,H=null,I=1,s,R,E,J,O,Y,P,K,V,M=new THREE.Color,
U=new THREE.Color,d=new THREE.Color,h=new THREE.Color,i=new THREE.Color,j,g,n,z,r,t,v,w,y,L=new THREE.Rectangle,F=new THREE.Rectangle,A=new THREE.Rectangle,N=false,T=new THREE.Color,ca=new THREE.Color,ga=new THREE.Color,Z=new THREE.Color,ka=Math.PI*2,W=new THREE.Vector3,da,sa,va,ea,aa,fa,la=16;da=document.createElement("canvas");da.width=da.height=2;sa=da.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);va=sa.getImageData(0,0,2,2);ea=va.data;aa=document.createElement("canvas");aa.width=
aa.height=la;fa=aa.getContext("2d");fa.translate(-la/2,-la/2);fa.scale(la,la);la--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function($,qa){l=$;p=qa;q=l/2;m=p/2;k.width=l;k.height=p;L.set(-q,-m,q,m);u=1;x=0;H=b=null;I=1};this.setClearColor=function($,qa){C=$;B=qa;F.set(-q,-m,q,m);o.setTransform(1,0,0,-1,q,m);this.clear()};this.setClearColorHex=function($,qa){C.setHex($);B=qa;F.set(-q,-m,q,m);o.setTransform(1,0,0,-1,q,m);this.clear()};this.clear=function(){o.setTransform(1,
0,0,-1,q,m);if(!F.isEmpty()){F.inflate(1);F.minSelf(L);if(C.hex==0&&B==0)o.clearRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());else{c(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*255)+","+B+")";o.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight())}F.empty()}};this.render=function($,qa){function na(D){var X,S,G,Q=D.lights;ca.setRGB(0,0,0);ga.setRGB(0,0,0);Z.setRGB(0,0,0);D=0;for(X=Q.length;D<X;D++){S=Q[D];G=S.color;if(S instanceof
THREE.AmbientLight){ca.r+=G.r;ca.g+=G.g;ca.b+=G.b}else if(S instanceof THREE.DirectionalLight){ga.r+=G.r;ga.g+=G.g;ga.b+=G.b}else if(S instanceof THREE.PointLight){Z.r+=G.r;Z.g+=G.g;Z.b+=G.b}}}function za(D,X,S,G){var Q,ba,ia,ma,oa=D.lights;D=0;for(Q=oa.length;D<Q;D++){ba=oa[D];ia=ba.color;ma=ba.intensity;if(ba instanceof THREE.DirectionalLight){ba=S.dot(ba.position)*ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}else if(ba instanceof THREE.PointLight){W.sub(ba.position,X);W.normalize();ba=S.dot(W)*
ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}}}function Fa(D,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);var G,Q,ba,ia,ma,oa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){ia=S.map.image;ma=ia.width>>1;oa=ia.height>>1;Q=X.scale.x*q;ba=X.scale.y*m;S=Q*ma;G=ba*oa;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(L.instersects(A)){o.save();o.translate(D.x,D.y);o.rotate(-X.rotation);o.scale(Q,-ba);o.translate(-ma,-oa);o.drawImage(ia,0,0);o.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(N){T.r=
ca.r+ga.r+Z.r;T.g=ca.g+ga.g+Z.g;T.b=ca.b+ga.b+Z.b;M.r=S.color.r*T.r;M.g=S.color.g*T.g;M.b=S.color.b*T.b;M.updateStyleString()}else M.__styleString=S.color.__styleString;S=X.scale.x*q;G=X.scale.y*m;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(L.instersects(A)){Q=M.__styleString;if(H!=Q)o.fillStyle=H=Q;o.save();o.translate(D.x,D.y);o.rotate(-X.rotation);o.scale(S,G);o.beginPath();o.arc(0,0,1,0,ka,true);o.closePath();o.fill();o.restore()}}}}function Aa(D,X,S,G){if(G.opacity!=0){a(G.opacity);c(G.blending);o.beginPath();
o.moveTo(D.positionScreen.x,D.positionScreen.y);o.lineTo(X.positionScreen.x,X.positionScreen.y);o.closePath();if(G instanceof THREE.LineBasicMaterial){M.__styleString=G.color.__styleString;D=G.linewidth;if(I!=D)o.lineWidth=I=D;D=M.__styleString;if(b!=D)o.strokeStyle=b=D;o.stroke();A.inflate(G.linewidth*2)}}}function Da(D,X,S,G,Q,ba){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);J=D.positionScreen.x;O=D.positionScreen.y;Y=X.positionScreen.x;P=X.positionScreen.y;K=S.positionScreen.x;V=S.positionScreen.y;
o.beginPath();o.moveTo(J,O);o.lineTo(Y,P);o.lineTo(K,V);o.lineTo(J,O);o.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&ja(J,O,Y,P,K,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){D=qa.matrix;W.copy(G.vertexNormalsWorld[0]);z=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;r=-(W.x*D.n21+W.y*
D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[1]);t=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;v=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[2]);w=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;y=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;ja(J,O,Y,P,K,V,Q.env_map.image,z,r,t,v,w,y)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&
ja(J,O,Y,P,K,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);c(THREE.SubtractiveBlending)}if(N)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==3){U.r=d.r=h.r=ca.r;U.g=d.g=h.g=ca.g;U.b=d.b=h.b=ca.b;za(ba,G.v1.positionWorld,G.vertexNormalsWorld[0],U);za(ba,G.v2.positionWorld,G.vertexNormalsWorld[1],d);za(ba,G.v3.positionWorld,G.vertexNormalsWorld[2],h);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;n=Ga(U,d,h,i);ja(J,O,Y,P,K,V,n,
0,0,1,0,0,1)}else{T.r=ca.r;T.g=ca.g;T.b=ca.b;za(ba,G.centroidWorld,G.normalWorld,T);M.r=Q.color.r*T.r;M.g=Q.color.g*T.g;M.b=Q.color.b*T.b;M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){j=qa.near;g=qa.far;U.r=U.g=U.b=1-Ha(D.positionScreen.z,j,g);d.r=d.g=d.b=1-Ha(X.positionScreen.z,j,g);h.r=h.g=h.b=1-Ha(S.positionScreen.z,
j,g);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;n=Ga(U,d,h,i);ja(J,O,Y,P,K,V,n,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Ia(G.normalWorld.x);M.g=Ia(G.normalWorld.y);M.b=Ia(G.normalWorld.z);M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}}}function Ba(D,X){if(b!=D)o.strokeStyle=b=D;if(I!=X)o.lineWidth=I=X;o.stroke();A.inflate(X*2)}function Ca(D){if(H!=D)o.fillStyle=H=D;o.fill()}function ja(D,X,S,G,Q,ba,ia,ma,oa,wa,ra,
xa,Ja){var ta,ya;ta=ia.width-1;ya=ia.height-1;ma*=ta;oa*=ya;wa*=ta;ra*=ya;xa*=ta;Ja*=ya;S-=D;G-=X;Q-=D;ba-=X;wa-=ma;ra-=oa;xa-=ma;Ja-=oa;ta=wa*Ja-xa*ra;if(ta!=0){ya=1/ta;ta=(Ja*S-ra*Q)*ya;ra=(Ja*G-ra*ba)*ya;S=(wa*Q-xa*S)*ya;G=(wa*ba-xa*G)*ya;D=D-ta*ma-S*oa;X=X-ra*ma-G*oa;o.save();o.transform(ta,ra,S,G,D,X);o.clip();o.drawImage(ia,0,0);o.restore()}}function Ga(D,X,S,G){var Q=~~(D.r*255),ba=~~(D.g*255);D=~~(D.b*255);var ia=~~(X.r*255),ma=~~(X.g*255);X=~~(X.b*255);var oa=~~(S.r*255),wa=~~(S.g*255);S=
~~(S.b*255);var ra=~~(G.r*255),xa=~~(G.g*255);G=~~(G.b*255);ea[0]=Q<0?0:Q>255?255:Q;ea[1]=ba<0?0:ba>255?255:ba;ea[2]=D<0?0:D>255?255:D;ea[4]=ia<0?0:ia>255?255:ia;ea[5]=ma<0?0:ma>255?255:ma;ea[6]=X<0?0:X>255?255:X;ea[8]=oa<0?0:oa>255?255:oa;ea[9]=wa<0?0:wa>255?255:wa;ea[10]=S<0?0:S>255?255:S;ea[12]=ra<0?0:ra>255?255:ra;ea[13]=xa<0?0:xa>255?255:xa;ea[14]=G<0?0:G>255?255:G;sa.putImageData(va,0,0);fa.drawImage(da,0,0);return aa}function Ha(D,X,S){D=(D-X)/(S-X);return D*D*(3-2*D)}function Ia(D){D=(D+1)*
0.5;return D<0?0:D>1?1:D}function Ka(D,X){var S=X.x-D.x,G=X.y-D.y,Q=1/Math.sqrt(S*S+G*G);S*=Q;G*=Q;X.x+=S;X.y+=G;D.x-=S;D.y-=G}var pa,Na,ha,ua,Ea,Ma,Oa,La;this.autoClear?this.clear():o.setTransform(1,0,0,-1,q,m);e=f.projectScene($,qa,this.sortElements);(N=$.lights.length>0)&&na($);pa=0;for(Na=e.length;pa<Na;pa++){ha=e[pa];A.empty();if(ha instanceof THREE.RenderableParticle){s=ha;s.x*=q;s.y*=m;ua=0;for(Ea=ha.materials.length;ua<Ea;ua++)Fa(s,ha,ha.materials[ua],$)}else if(ha instanceof THREE.RenderableLine){s=
ha.v1;R=ha.v2;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;A.addPoint(s.positionScreen.x,s.positionScreen.y);A.addPoint(R.positionScreen.x,R.positionScreen.y);if(L.instersects(A)){ua=0;for(Ea=ha.materials.length;ua<Ea;)Aa(s,R,ha,ha.materials[ua++],$)}}else if(ha instanceof THREE.RenderableFace3){s=ha.v1;R=ha.v2;E=ha.v3;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;E.positionScreen.x*=q;E.positionScreen.y*=m;if(ha.overdraw){Ka(s.positionScreen,
R.positionScreen);Ka(R.positionScreen,E.positionScreen);Ka(E.positionScreen,s.positionScreen)}A.add3Points(s.positionScreen.x,s.positionScreen.y,R.positionScreen.x,R.positionScreen.y,E.positionScreen.x,E.positionScreen.y);if(L.instersects(A)){ua=0;for(Ea=ha.meshMaterials.length;ua<Ea;){La=ha.meshMaterials[ua++];if(La instanceof THREE.MeshFaceMaterial){Ma=0;for(Oa=ha.faceMaterials.length;Ma<Oa;)(La=ha.faceMaterials[Ma++])&&Da(s,R,E,ha,La,$)}else Da(s,R,E,ha,La,$)}}}F.addRectangle(A)}o.setTransform(1,
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(Q,J){return J.z-Q.z}function c(Q,J){var X=0,G=1,U=Q.z+Q.w,M=J.z+J.w,D=-Q.z+Q.w,K=-J.z+J.w;if(U>=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(G<X)return false;else{Q.lerpSelf(J,X);J.lerpSelf(Q,1-G);return true}}}var d,f,j=[],k,q,o,l=[],n,z,y=[],v,x,F=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
O=new THREE.Matrix4,C=[],b=new THREE.Vector4,R=new THREE.Vector4,$;this.projectObjects=function(Q,J,X){var G=[],U,M;f=0;s.multiply(J.projectionMatrix,J.matrix);C[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);C[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);C[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);C[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);C[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);C[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);J=0;for(U=C.length;J<U;J++){M=C[J];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}U=Q.objects;Q=0;for(J=U.length;Q<J;Q++){M=U[Q];var D;if(!(D=!M.visible)){if(D=M instanceof THREE.Mesh){a:{D=void 0;for(var K=M.position,ca=-M.geometry.boundingSphere.radius*Math.max(M.scale.x,Math.max(M.scale.y,M.scale.z)),N=0;N<6;N++){D=C[N].x*K.x+C[N].y*K.y+C[N].z*K.z+C[N].w;if(D<=ca){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
j[f]=j[f]||new THREE.RenderableObject;H.copy(M.position);s.multiplyVector3(H);d.object=M;d.z=H.z;G.push(d);f++}}X&&G.sort(a);return G};this.projectScene=function(Q,J,X){var G=[],U=J.near,M=J.far,D,K,ca,N,aa,e,i,m,h,g,t,w,u,r,p,B;o=z=x=0;J.autoUpdateMatrix&&J.updateMatrix();s.multiply(J.projectionMatrix,J.matrix);e=this.projectObjects(Q,J,true);Q=0;for(D=e.length;Q<D;Q++){i=e[Q].object;if(i.visible){i.autoUpdateMatrix&&i.updateMatrix();m=i.matrix;h=i.rotationMatrix;g=i.materials;t=i.overdraw;if(i instanceof
THREE.Mesh){w=i.geometry;u=w.vertices;K=0;for(ca=u.length;K<ca;K++){r=u[K];r.positionWorld.copy(r.position);m.multiplyVector3(r.positionWorld);N=r.positionScreen;N.copy(r.positionWorld);s.multiplyVector4(N);N.x/=N.w;N.y/=N.w;r.__visible=N.z>U&&N.z<M}w=w.faces;K=0;for(ca=w.length;K<ca;K++){r=w[K];if(r instanceof THREE.Face3){N=u[r.a];aa=u[r.b];p=u[r.c];if(N.__visible&&aa.__visible&&p.__visible)if(i.doubleSided||i.flipSided!=(p.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-
(p.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);k.v3.positionWorld.copy(p.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(p.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);m.multiplyVector3(k.centroidWorld);
k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);p=r.vertexNormals;$=k.vertexNormalsWorld;N=0;for(aa=p.length;N<aa;N++){B=$[N]=$[N]||new THREE.Vector3;B.copy(p[N]);h.multiplyVector3(B)}k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][2]}G.push(k);o++}}else if(r instanceof THREE.Face4){N=u[r.a];aa=u[r.b];p=u[r.c];B=u[r.d];if(N.__visible&&
aa.__visible&&p.__visible&&B.__visible)if(i.doubleSided||i.flipSided!=((B.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-(B.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0||(aa.positionScreen.x-p.positionScreen.x)*(B.positionScreen.y-p.positionScreen.y)-(aa.positionScreen.y-p.positionScreen.y)*(B.positionScreen.x-p.positionScreen.x)<0)){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);
k.v3.positionWorld.copy(B.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(B.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);m.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];
k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][3]}G.push(k);o++;q=l[o]=l[o]||new THREE.RenderableFace3;q.v1.positionWorld.copy(aa.positionWorld);q.v2.positionWorld.copy(p.positionWorld);q.v3.positionWorld.copy(B.positionWorld);q.v1.positionScreen.copy(aa.positionScreen);q.v2.positionScreen.copy(p.positionScreen);q.v3.positionScreen.copy(B.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
q.meshMaterials=g;q.faceMaterials=r.materials;q.overdraw=t;if(i.geometry.uvs[K]){q.uvs[0]=i.geometry.uvs[K][1];q.uvs[1]=i.geometry.uvs[K][2];q.uvs[2]=i.geometry.uvs[K][3]}G.push(q);o++}}}}else if(i instanceof THREE.Line){O.multiply(s,m);u=i.geometry.vertices;r=u[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);K=1;for(ca=u.length;K<ca;K++){N=u[K];N.positionScreen.copy(N.position);O.multiplyVector4(N.positionScreen);aa=u[K-1];b.copy(N.positionScreen);R.copy(aa.positionScreen);
if(c(b,R)){b.multiplyScalar(1/b.w);R.multiplyScalar(1/R.w);n=y[z]=y[z]||new THREE.RenderableLine;n.v1.positionScreen.copy(b);n.v2.positionScreen.copy(R);n.z=Math.max(b.z,R.z);n.materials=i.materials;G.push(n);z++}}}else if(i instanceof THREE.Particle){I.set(i.position.x,i.position.y,i.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/
(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,n,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(n=a.length;l<n;l++){v=a[l];if(v instanceof THREE.RenderableParticle){F=v.x*j+j;H=v.y*k+k;z=0;for(y=v.material.length;z<y;z++){x=v.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(W){if(v!=W)n.globalAlpha=v=W}function c(W){if(x!=W){switch(W){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}x=W}}var d=null,f=new THREE.Projector,j=document.createElement("canvas"),k,q,o,l,n=j.getContext("2d"),z=new THREE.Color(0),y=0,v=1,x=0,F=null,H=null,I=1,s,O,C,b,R,$,Q,J,X,G=new THREE.Color,
U=new THREE.Color,M=new THREE.Color,D=new THREE.Color,K=new THREE.Color,ca,N,aa,e,i,m,h,g,t,w=new THREE.Rectangle,u=new THREE.Rectangle,r=new THREE.Rectangle,p=false,B=new THREE.Color,V=new THREE.Color,da=new THREE.Color,ea=new THREE.Color,ia=Math.PI*2,S=new THREE.Vector3,Y,pa,P,ka,oa,wa,fa=16;Y=document.createElement("canvas");Y.width=Y.height=2;pa=Y.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);P=pa.getImageData(0,0,2,2);ka=P.data;oa=document.createElement("canvas");oa.width=
oa.height=fa;wa=oa.getContext("2d");wa.translate(-fa/2,-fa/2);wa.scale(fa,fa);fa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(W,ba){k=W;q=ba;o=k/2;l=q/2;j.width=k;j.height=q;w.set(-o,-l,o,l);v=1;x=0;H=F=null;I=1};this.setClearColor=function(W,ba){z=W;y=ba;u.set(-o,-l,o,l);n.setTransform(1,0,0,-1,o,l);this.clear()};this.setClearColorHex=function(W,ba){z.setHex(W);y=ba;u.set(-o,-l,o,l);n.setTransform(1,0,0,-1,o,l);this.clear()};this.clear=function(){n.setTransform(1,
0,0,-1,o,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(w);if(z.hex==0&&y==0)n.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";n.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(W,ba){function Ca(A){var Z,T,E,L=A.lights;V.setRGB(0,0,0);da.setRGB(0,0,0);ea.setRGB(0,0,0);A=0;for(Z=L.length;A<Z;A++){T=L[A];E=T.color;if(T instanceof
THREE.AmbientLight){V.r+=E.r;V.g+=E.g;V.b+=E.b}else if(T instanceof THREE.DirectionalLight){da.r+=E.r;da.g+=E.g;da.b+=E.b}else if(T instanceof THREE.PointLight){ea.r+=E.r;ea.g+=E.g;ea.b+=E.b}}}function qa(A,Z,T,E){var L,ha,ra,xa,za=A.lights;A=0;for(L=za.length;A<L;A++){ha=za[A];ra=ha.color;xa=ha.intensity;if(ha instanceof THREE.DirectionalLight){ha=T.dot(ha.position)*xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)*
xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){n.save();n.translate(A.x,A.y);n.rotate(-Z.rotation);n.scale(L,-ha);n.translate(-xa,-za);n.drawImage(ra,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r=
V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)n.fillStyle=H=L;n.save();n.translate(A.x,A.y);n.rotate(-Z.rotation);n.scale(T,E);n.beginPath();n.arc(0,0,1,0,ia,true);n.closePath();n.fill();n.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);n.beginPath();
n.moveTo(A.positionScreen.x,A.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y);n.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)n.lineWidth=I=A;A=G.__styleString;if(F!=A)n.strokeStyle=F=A;n.stroke();r.inflate(E.linewidth*2)}}}function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y;
n.beginPath();n.moveTo(b,R);n.lineTo($,Q);n.lineTo(J,X);n.lineTo(b,R);n.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y*
A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);m=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,m,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&
ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M);qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,
0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca=ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z,
ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)n.strokeStyle=F=A;if(I!=Z)n.lineWidth=I=Z;n.stroke();r.inflate(Z*2)}function va(A){if(H!=A)n.fillStyle=H=A;n.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga,
Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;n.save();n.transform(Ea,Ba,T,E,A,Z);n.clip();n.drawImage(ra,0,0);n.restore()}}function ma(A,Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255);
T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E>255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)*
0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);(p=W.lights.length>0)&&Ca(W);ua=0;for(Ma=d.length;ua<Ma;ua++){ja=d[ua];r.empty();if(ja instanceof THREE.RenderableParticle){s=ja;s.x*=o;s.y*=l;ya=0;for(Fa=ja.materials.length;ya<Fa;ya++)la(s,ja,ja.materials[ya],W)}else if(ja instanceof THREE.RenderableLine){s=
ja.v1;O=ja.v2;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;r.addPoint(s.positionScreen.x,s.positionScreen.y);r.addPoint(O.positionScreen.x,O.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.materials.length;ya<Fa;)na(s,O,ja,ja.materials[ya++],W)}}else if(ja instanceof THREE.RenderableFace3){s=ja.v1;O=ja.v2;C=ja.v3;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;C.positionScreen.x*=o;C.positionScreen.y*=l;if(ja.overdraw){La(s.positionScreen,
O.positionScreen);La(O.positionScreen,C.positionScreen);La(C.positionScreen,s.positionScreen)}r.add3Points(s.positionScreen.x,s.positionScreen.y,O.positionScreen.x,O.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.meshMaterials.length;ya<Fa;){sa=ja.meshMaterials[ya++];if(sa instanceof THREE.MeshFaceMaterial){Ka=0;for(Na=ja.faceMaterials.length;Ka<Na;)(sa=ja.faceMaterials[Ka++])&&Ja(s,O,C,ja,sa,W)}else Ja(s,O,C,ja,sa,W)}}}u.addRectangle(r)}n.setTransform(1,
0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(z,r,t){var v,w,y,L;v=0;for(w=z.lights.length;v<w;v++){y=z.lights[v];if(y instanceof THREE.DirectionalLight){L=r.normalWorld.dot(y.position)*y.intensity;if(L>0){t.r+=y.color.r*L;t.g+=y.color.g*L;t.b+=y.color.b*L}}else if(y instanceof THREE.PointLight){V.sub(y.position,r.centroidWorld);V.normalize();L=r.normalWorld.dot(V)*y.intensity;if(L>0){t.r+=y.color.r*L;t.g+=y.color.g*L;t.b+=y.color.b*L}}}}function c(z,r,t,v,w,y){h=f(i++);h.setAttribute("d","M "+z.positionScreen.x+
" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(y,v,J);E.r=w.color.r*J.r;E.g=w.color.g*J.g;E.b=w.color.b*J.b;E.updateStyleString()}else E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){K=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear);
E.setRGB(K,K,K)}else w instanceof THREE.MeshNormalMaterial&&E.setRGB(k(v.normalWorld.x),k(v.normalWorld.y),k(v.normalWorld.z));w.wireframe?h.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):h.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+w.opacity);q.appendChild(h)}function e(z,r,t,v,w,y,L){h=f(i++);h.setAttribute("d",
"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(L,w,J);E.r=y.color.r*J.r;E.g=y.color.g*J.g;E.b=y.color.b*J.b;E.updateStyleString()}else E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){K=
1-y.__2near/(y.__farPlusNear-w.z*y.__farMinusNear);E.setRGB(K,K,K)}else y instanceof THREE.MeshNormalMaterial&&E.setRGB(k(w.normalWorld.x),k(w.normalWorld.y),k(w.normalWorld.z));y.wireframe?h.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):h.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+y.opacity);q.appendChild(h)}
function f(z){if(M[z]==null){M[z]=document.createElementNS("http://www.w3.org/2000/svg","path");n==0&&M[z].setAttribute("shape-rendering","crispEdges");return M[z]}return M[z]}function k(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var l=null,p=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,o,C,B,u,x,b,H,I=new THREE.Rectangle,s=new THREE.Rectangle,R=false,E=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0),Y=new THREE.Color(0),
P=new THREE.Color(0),K,V=new THREE.Vector3,M=[],U=[],d=[],h,i,j,g,n=1;this.domElement=q;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":n=1;break;case "low":n=0}};this.setSize=function(z,r){m=z;o=r;C=m/2;B=o/2;q.setAttribute("viewBox",-C+" "+-B+" "+m+" "+o);q.setAttribute("width",m);q.setAttribute("height",o);I.set(-C,-B,C,B)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(z,r){var t,v,
w,y,L,F,A,N;this.autoClear&&this.clear();l=p.projectScene(z,r,this.sortElements);g=j=i=0;if(R=z.lights.length>0){A=z.lights;O.setRGB(0,0,0);Y.setRGB(0,0,0);P.setRGB(0,0,0);t=0;for(v=A.length;t<v;t++){w=A[t];y=w.color;if(w instanceof THREE.AmbientLight){O.r+=y.r;O.g+=y.g;O.b+=y.b}else if(w instanceof THREE.DirectionalLight){Y.r+=y.r;Y.g+=y.g;Y.b+=y.b}else if(w instanceof THREE.PointLight){P.r+=y.r;P.g+=y.g;P.b+=y.b}}}t=0;for(v=l.length;t<v;t++){A=l[t];s.empty();if(A instanceof THREE.RenderableParticle){u=
A;u.x*=C;u.y*=-B;w=0;for(y=A.materials.length;w<y;w++)if(N=A.materials[w]){L=u;F=A;N=N;var T=j++;if(U[T]==null){U[T]=document.createElementNS("http://www.w3.org/2000/svg","circle");n==0&&U[T].setAttribute("shape-rendering","crispEdges")}h=U[T];h.setAttribute("cx",L.x);h.setAttribute("cy",L.y);h.setAttribute("r",F.scale.x*C);if(N instanceof THREE.ParticleCircleMaterial){if(R){J.r=O.r+Y.r+P.r;J.g=O.g+Y.g+P.g;J.b=O.b+Y.b+P.b;E.r=N.color.r*J.r;E.g=N.color.g*J.g;E.b=N.color.b*J.b;E.updateStyleString()}else E=
N.color;h.setAttribute("style","fill: "+E.__styleString)}q.appendChild(h)}}else if(A instanceof THREE.RenderableLine){u=A.v1;x=A.v2;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.materials.length;w<y;)if(N=A.materials[w++]){L=u;F=x;N=N;T=g++;if(d[T]==null){d[T]=document.createElementNS("http://www.w3.org/2000/svg","line");n==
0&&d[T].setAttribute("shape-rendering","crispEdges")}h=d[T];h.setAttribute("x1",L.positionScreen.x);h.setAttribute("y1",L.positionScreen.y);h.setAttribute("x2",F.positionScreen.x);h.setAttribute("y2",F.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){E.__styleString=N.color.__styleString;h.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);q.appendChild(h)}}}}else if(A instanceof
THREE.RenderableFace3){u=A.v1;x=A.v2;b=A.v3;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){L=0;for(F=A.faceMaterials.length;L<F;)(N=A.faceMaterials[L++])&&
c(u,x,b,A,N,z)}else N&&c(u,x,b,A,N,z)}}}else if(A instanceof THREE.RenderableFace4){u=A.v1;x=A.v2;b=A.v3;H=A.v4;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;H.positionScreen.x*=C;H.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){w=
0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){L=0;for(F=A.faceMaterials.length;L<F;)(N=A.faceMaterials[L++])&&e(u,x,b,H,A,N,z)}else N&&e(u,x,b,H,A,N,z)}}}}}};
THREE.WebGLRenderer=function(a){function c(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function e(d,h){if(!d.__webGLVertexBuffer)d.__webGLVertexBuffer=b.createBuffer();if(!d.__webGLNormalBuffer)d.__webGLNormalBuffer=b.createBuffer();if(d.hasPos){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.position);b.vertexAttribPointer(h.attributes.position,
3,b.FLOAT,false,0,0)}if(d.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,d.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.normal);b.vertexAttribPointer(h.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,d.count);d.count=0}function f(d){if(s!=d.doubleSided){d.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);s=d.doubleSided}if(R!=d.flipSided){d.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);R=d.flipSided}}function k(d){J[0].set(d.n41-
d.n11,d.n42-d.n12,d.n43-d.n13,d.n44-d.n14);J[1].set(d.n41+d.n11,d.n42+d.n12,d.n43+d.n13,d.n44+d.n14);J[2].set(d.n41+d.n21,d.n42+d.n22,d.n43+d.n23,d.n44+d.n24);J[3].set(d.n41-d.n21,d.n42-d.n22,d.n43-d.n23,d.n44-d.n24);J[4].set(d.n41-d.n31,d.n42-d.n32,d.n43-d.n33,d.n44-d.n34);J[5].set(d.n41+d.n31,d.n42+d.n32,d.n43+d.n33,d.n44+d.n34);var h;for(d=0;d<5;d++){h=J[d];h.divideScalar(Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z))}}function l(d){for(var h=d.matrix,i=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,
Math.max(d.scale.y,d.scale.z)),j=0;j<6;j++){d=J[j].x*h.n14+J[j].y*h.n24+J[j].z*h.n34+J[j].w;if(d<=i)return false}return true}function p(d,h){d.list[d.count]=h;d.count+=1}function q(d){var h,i,j=d.object,g=d.opaque,n=d.transparent;n.count=0;d=g.count=0;for(h=j.materials.length;d<h;d++){i=j.materials[d];i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?p(n,i):p(g,i)}}function m(d){var h,i,j,g,n=d.object,z=d.buffer,r=d.opaque,t=d.transparent;t.count=0;d=r.count=0;for(j=n.materials.length;d<j;d++){h=
n.materials[d];if(h instanceof THREE.MeshFaceMaterial){h=0;for(i=z.materials.length;h<i;h++)if(g=z.materials[h])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}else{g=h;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}}}function o(d){if(d!=E){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}E=d}}function C(d,h){if(d&&!d.__webGLFramebuffer){d.__webGLFramebuffer=b.createFramebuffer();d.__webGLRenderbuffer=b.createRenderbuffer();d.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,d.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,d.width,d.height);b.bindTexture(b.TEXTURE_2D,d.__webGLTexture);b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_WRAP_S,u(d.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(d.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(d.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(d.min_filter));b.texImage2D(b.TEXTURE_2D,0,u(d.format),d.width,d.height,0,u(d.format),u(d.type),null);b.bindFramebuffer(b.FRAMEBUFFER,d.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,d.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,
b.RENDERBUFFER,d.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var i,j,g;if(d){i=d.__webGLFramebuffer;j=d.width;g=d.height}else{i=null;j=x.width;g=x.height}if(i!=I){b.bindFramebuffer(b.FRAMEBUFFER,i);b.viewport(0,0,j,g);h&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);I=i}}function B(d,h){var i;if(d=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(d=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,
h);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function u(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 x=document.createElement("canvas"),b,H=null,I=null,s=null,R=null,E=null,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Matrix4,Y=new Float32Array(16),P=new Float32Array(16),K=new THREE.Vector4,V=true,M=new THREE.Color(0),U=0;if(a){if(a.antialias!==undefined)V=a.antialias;a.clearColor!==undefined&&M.setHex(a.clearColor);
if(a.clearAlpha!==undefined)U=a.clearAlpha}this.domElement=x;this.autoClear=true;(function(d,h,i){try{b=x.getContext("experimental-webgl",{antialias:d})}catch(j){console.log(j)}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,i);_cullEnabled=true})(V,
M,U);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(d,h){x.width=d;x.height=h;b.viewport(0,0,x.width,x.height)};this.setClearColorHex=function(d,h){var i=new THREE.Color(d);b.clearColor(i.r,i.g,i.b,h)};this.setClearColor=function(d,h){b.clearColor(d.r,d.g,d.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var i,j,g,n=0,z=0,r=0,t,v,w,y=
this.lights,L=y.directional.colors,F=y.directional.positions,A=y.point.colors,N=y.point.positions,T=0,ca=0;i=g=g=0;for(j=h.length;i<j;i++){g=h[i];t=g.color;v=g.position;w=g.intensity;if(g instanceof THREE.AmbientLight){n+=t.r;z+=t.g;r+=t.b}else if(g instanceof THREE.DirectionalLight){g=T*3;L[g]=t.r*w;L[g+1]=t.g*w;L[g+2]=t.b*w;F[g]=v.x;F[g+1]=v.y;F[g+2]=v.z;T+=1}else if(g instanceof THREE.PointLight){g=ca*3;A[g]=t.r*w;A[g+1]=t.g*w;A[g+2]=t.b*w;N[g]=v.x;N[g+1]=v.y;N[g+2]=v.z;ca+=1}}for(i=T*3;i<L.length;i++)L[i]=
0;for(i=ca*3;i<A.length;i++)A[i]=0;y.point.length=ca;y.directional.length=T;y.ambient[0]=n;y.ambient[1]=z;y.ambient[2]=r};this.createParticleBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLNormalBuffer=b.createBuffer();d.__webGLTangentBuffer=b.createBuffer();
d.__webGLColorBuffer=b.createBuffer();d.__webGLUVBuffer=b.createBuffer();d.__webGLUV2Buffer=b.createBuffer();d.__webGLFaceBuffer=b.createBuffer();d.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__webGLLineCount=h};this.initParticleBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__sortArray=[];d.__webGLParticleCount=
h};this.initMeshBuffers=function(d,h){var i,j,g=0,n=0,z=0,r=h.geometry.faces,t=d.faces;i=0;for(j=t.length;i<j;i++){fi=t[i];face=r[fi];if(face instanceof THREE.Face3){g+=3;n+=1;z+=3}else if(face instanceof THREE.Face4){g+=4;n+=2;z+=4}}d.__vertexArray=new Float32Array(g*3);d.__normalArray=new Float32Array(g*3);d.__tangentArray=new Float32Array(g*4);d.__colorArray=new Float32Array(g*3);d.__uvArray=new Float32Array(g*2);d.__uv2Array=new Float32Array(g*2);d.__faceArray=new Uint16Array(n*3);d.__lineArray=
new Uint16Array(z*2);g=false;i=0;for(j=h.materials.length;i<j;i++){r=h.materials[i];if(r instanceof THREE.MeshFaceMaterial){r=0;for(t=d.materials.length;r<t;r++)if(d.materials[r]&&d.materials[r].shading!=undefined&&d.materials[r].shading==THREE.SmoothShading){g=true;break}}else if(r&&r.shading!=undefined&&r.shading==THREE.SmoothShading){g=true;break}if(g)break}d.__needsSmoothNormals=g;d.__webGLFaceCount=n*3;d.__webGLLineCount=z*2};this.setMeshBuffers=function(d,h,i){var j,g,n,z,r,t,v,w,y,L,F=0,A=
0,N=0,T=0,ca=0,ga=0,Z=0,ka=0,W=0,da=d.__vertexArray,sa=d.__uvArray,va=d.__uv2Array,ea=d.__normalArray,aa=d.__tangentArray,fa=d.__colorArray,la=d.__faceArray,$=d.__lineArray,qa=d.__needsSmoothNormals,na=h.geometry,za=na.__dirtyVertices,Fa=na.__dirtyElements,Aa=na.__dirtyUvs,Da=na.__dirtyNormals,Ba=na.__dirtyTangents,Ca=na.__dirtyColors,ja=na.vertices,Ga=d.faces,Ha=na.faces,Ia=na.uvs,Ka=na.uvs2,pa=na.colors;h=0;for(j=Ga.length;h<j;h++){g=Ga[h];n=Ha[g];t=Ia[g];g=Ka[g];z=n.vertexNormals;r=n.normal;if(n instanceof
THREE.Face3){if(za){v=ja[n.a].position;w=ja[n.b].position;y=ja[n.c].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;A+=9}if(Ca&&pa.length){v=pa[n.a];w=pa[n.b];y=pa[n.c];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;W+=9}if(Ba&&na.hasTangents){v=ja[n.a].tangent;w=ja[n.b].tangent;y=ja[n.c].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=
w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;Z+=12}if(Da)if(z.length==3&&qa)for(n=0;n<3;n++){r=z[n];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(n=0;n<3;n++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(n=0;n<3;n++){z=t[n];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(n=0;n<3;n++){t=g[n];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=F;la[ca+1]=F+1;la[ca+2]=F+2;ca+=3;$[ka]=F;$[ka+1]=F+1;$[ka+2]=F;$[ka+3]=F+2;$[ka+4]=F+1;$[ka+5]=F+2;ka+=6;F+=3}}else if(n instanceof THREE.Face4){if(za){v=
ja[n.a].position;w=ja[n.b].position;y=ja[n.c].position;L=ja[n.d].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;da[A+9]=L.x;da[A+10]=L.y;da[A+11]=L.z;A+=12}if(Ca&&pa.length){v=pa[n.a];w=pa[n.b];y=pa[n.c];L=pa[n.d];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;fa[W+9]=L.r;fa[W+10]=L.g;fa[W+11]=L.b;W+=12}if(Ba&&na.hasTangents){v=ja[n.a].tangent;w=ja[n.b].tangent;y=ja[n.c].tangent;
n=ja[n.d].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;aa[Z+12]=n.x;aa[Z+13]=n.y;aa[Z+14]=n.z;aa[Z+15]=n.w;Z+=16}if(Da)if(z.length==4&&qa)for(n=0;n<4;n++){r=z[n];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(n=0;n<4;n++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(n=0;n<4;n++){z=t[n];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(n=0;n<4;n++){t=g[n];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=
F;la[ca+1]=F+1;la[ca+2]=F+2;la[ca+3]=F;la[ca+4]=F+2;la[ca+5]=F+3;ca+=6;$[ka]=F;$[ka+1]=F+1;$[ka+2]=F;$[ka+3]=F+3;$[ka+4]=F+1;$[ka+5]=F+2;$[ka+6]=F+2;$[ka+7]=F+3;ka+=8;F+=4}}}if(za){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,da,i)}if(Ca&&pa.length){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,fa,i)}if(Da){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ea,i)}if(Ba&&na.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,
d.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,aa,i)}if(Aa&&N>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,sa,i)}if(Aa&&T>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,va,i)}if(Fa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,la,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,$,i)}};this.setLineBuffers=function(d,h){var i,j,g,n=d.vertices,
z=d.colors,r=n.length,t=z.length,v=d.__vertexArray,w=d.__colorArray,y=d.__dirtyColors;if(d.__dirtyVertices){for(i=0;i<r;i++){j=n[i].position;g=i*3;v[g]=j.x;v[g+1]=j.y;v[g+2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,h)}if(y){for(i=0;i<t;i++){color=z[i];g=i*3;w[g]=color.r;w[g+1]=color.g;w[g+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}};this.setParticleBuffers=function(d,h,i){var j,g,n,z=d.vertices,r=z.length,
t=d.colors,v=t.length,w=d.__vertexArray,y=d.__colorArray,L=d.__sortArray,F=d.__dirtyVertices,A=d.__dirtyColors;if(i.sortParticles){O.multiplySelf(i.matrix);for(j=0;j<r;j++){g=z[j].position;K.copy(g);O.multiplyVector3(K);L[j]=[K.z,j]}L.sort(function(N,T){return T[0]-N[0]});for(j=0;j<r;j++){g=z[L[j][1]].position;n=j*3;w[n]=g.x;w[n+1]=g.y;w[n+2]=g.z}for(j=0;j<v;j++){n=j*3;color=t[L[j][1]];y[n]=color.r;y[n+1]=color.g;y[n+2]=color.b}}else{if(F)for(j=0;j<r;j++){g=z[j].position;n=j*3;w[n]=g.x;w[n+1]=g.y;
w[n+2]=g.z}if(A)for(j=0;j<v;j++){color=t[j];n=j*3;y[n]=color.r;y[n+1]=color.g;y[n+2]=color.b}}if(F||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}if(A||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,y,h)}};this.initMaterial=function(d,h,i){var j,g;if(d instanceof THREE.MeshDepthMaterial)c(d,THREE.ShaderLib.depth);else if(d instanceof THREE.MeshNormalMaterial)c(d,THREE.ShaderLib.normal);else if(d instanceof
THREE.MeshBasicMaterial)c(d,THREE.ShaderLib.basic);else if(d instanceof THREE.MeshLambertMaterial)c(d,THREE.ShaderLib.lambert);else if(d instanceof THREE.MeshPhongMaterial)c(d,THREE.ShaderLib.phong);else if(d instanceof THREE.LineBasicMaterial)c(d,THREE.ShaderLib.basic);else d instanceof THREE.ParticleBasicMaterial&&c(d,THREE.ShaderLib.particle_basic);var n,z,r,t;g=r=t=0;for(n=h.length;g<n;g++){z=h[g];z instanceof THREE.DirectionalLight&&r++;z instanceof THREE.PointLight&&t++}if(t+r<=4){h=r;t=t}else{h=
Math.ceil(4*r/(t+r));t=4-h}g={directional:h,point:t};t=d.fragment_shader;h=d.vertex_shader;n={fog:i,map:d.map,env_map:d.env_map,light_map:d.light_map,vertex_colors:d.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};i=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.env_map?
"#define USE_ENVMAP":"",n.light_map?"#define USE_LIGHTMAP":"",n.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");n=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.map?"#define USE_MAP":"",n.env_map?"#define USE_ENVMAP":"",n.light_map?"#define USE_LIGHTMAP":"",n.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
b.attachShader(i,B("fragment",g+t));b.attachShader(i,B("vertex",n+h));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};d.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in d.uniforms)i.push(j);j=d.program;t=0;for(h=i.length;t<h;t++){g=i[t];j.uniforms[g]=b.getUniformLocation(j,
g)}d=d.program;j=["position","normal","uv","uv2","tangent","color"];i=0;for(t=j.length;i<t;i++){h=j[i];d.attributes[h]=b.getAttribLocation(d,h)}};this.setProgram=function(d,h,i,j,g){j.program||this.initMaterial(j,h,i);var n=j.program,z=n.uniforms,r=j.uniforms;if(n!=H){b.useProgram(n);H=n;b.uniformMatrix4fv(z.projectionMatrix,false,Y)}if(i&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof
THREE.ParticleBasicMaterial)){r.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){r.fogNear.value=i.near;r.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)r.fogDensity.value=i.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(n,h);h=this.lights;r.enableLighting.value=h.directional.length+h.point.length;r.ambientLightColor.value=h.ambient;r.directionalLightColor.value=h.directional.colors;r.directionalLightDirection.value=h.directional.positions;
r.pointLightColor.value=h.point.colors;r.pointLightPosition.value=h.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.map.texture=j.map;r.light_map.texture=j.light_map;r.env_map.texture=j.env_map;r.reflectivity.value=j.reflectivity;r.refraction_ratio.value=j.refraction_ratio;r.combine.value=j.combine;r.useRefract.value=
j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){r.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.size.value=j.size;r.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){r.ambient.value.setRGB(j.ambient.r,j.ambient.g,
j.ambient.b);r.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);r.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){r.mNear.value=d.near;r.mFar.value=d.far;r.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)r.opacity.value=j.opacity;var t,v,w;for(t in r)if(w=n.uniforms[t]){i=r[t];v=i.type;h=i.value;if(v=="i")b.uniform1i(w,h);else if(v=="f")b.uniform1f(w,h);else if(v=="fv1")b.uniform1fv(w,h);else if(v=="fv")b.uniform3fv(w,h);else if(v=="v2")b.uniform2f(w,
h.x,h.y);else if(v=="v3")b.uniform3f(w,h.x,h.y,h.z);else if(v=="c")b.uniform3f(w,h.r,h.g,h.b);else if(v=="t"){b.uniform1i(w,h);if(i=i.texture)if(i.image instanceof Array&&i.image.length==6){i=i;h=h;if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(v=0;v<6;++v)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image[v]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}else{i=i;h=h;if(!i.__webGLTexture&&
i.image.loaded){i.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,u(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(i.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
h);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture)}}}b.uniformMatrix4fv(z.modelViewMatrix,false,g._modelViewMatrixArray);b.uniformMatrix3fv(z.normalMatrix,false,g._normalMatrixArray);if(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)b.uniform3f(z.cameraPosition,d.position.x,d.position.y,d.position.z);if(j instanceof THREE.MeshShaderMaterial||j.env_map)b.uniformMatrix4fv(z.objectMatrix,false,g._objectMatrixArray);if(j instanceof THREE.MeshPhongMaterial||j instanceof
THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(z.viewMatrix,false,P);return n};this.renderBuffer=function(d,h,i,j,g,n){d=this.setProgram(d,h,i,j,n).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=
0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=
0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(n instanceof THREE.Mesh)if(j.wireframe){b.lineWidth(j.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,
0)}else if(n instanceof THREE.Line){n=n.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(j.linewidth);b.drawArrays(n,0,g.__webGLLineCount)}else n instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(d,h,i,j){var g,n,z,r,t,v,w,y=d.lights,L=d.fog;h.autoUpdateMatrix&&h.updateMatrix();h.matrix.flattenToArray(P);h.projectionMatrix.flattenToArray(Y);O.multiply(h.projectionMatrix,h.matrix);k(O);this.initWebGLObjects(d,h);C(i,j!==undefined?j:true);this.autoClear&&
this.clear();r=d.__webGLObjects.length;for(j=0;j<r;j++){g=d.__webGLObjects[j];v=g.object;if(v.visible&&(!(v instanceof THREE.Mesh)||l(v))){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,h);m(g);g.render=true}else g.render=false}t=d.__webGLObjectsImmediate.length;for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,
h);q(g)}}o(THREE.NormalBlending);for(j=0;j<r;j++){g=d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(h,y,L,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);n=this.setProgram(h,y,L,material,v);v.render(function(F){e(F,n)})}}}for(j=0;j<r;j++){g=
d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];o(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(h,y,L,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];o(material.blending);this.setDepthTest(material.depth_test);n=this.setProgram(h,y,L,material,v);v.render(function(F){e(F,n)})}}}if(i&&i.min_filter!==
THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d,h){function i(y,L,F,A){if(y[L]==undefined){d.__webGLObjects.push({buffer:F,object:A,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[L]=1}}function j(y,L,F){if(y[L]==undefined){d.__webGLObjectsImmediate.push({object:F,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[L]=1}}var g,n,
z,r,t,v,w;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}g=0;for(n=d.objects.length;g<n;g++){z=d.objects[g];t=z.geometry;if(d.__webGLObjectsMap[z.id]==undefined){d.__webGLObjectsMap[z.id]={};z._modelViewMatrix=new THREE.Matrix4;z._normalMatrixArray=new Float32Array(9);z._modelViewMatrixArray=new Float32Array(16);z._objectMatrixArray=new Float32Array(16);z.matrix.flattenToArray(z._objectMatrixArray)}w=d.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(r in t.geometryChunks){v=
t.geometryChunks[r];if(!v.__webGLVertexBuffer){this.createMeshBuffers(v);this.initMeshBuffers(v,z);t.__dirtyVertices=true;t.__dirtyElements=true;t.__dirtyUvs=true;t.__dirtyNormals=true;t.__dirtyTangents=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyElements||t.__dirtyUvs||t.__dirtyNormals||t.__dirtyColors||t.__dirtyTangents)this.setMeshBuffers(v,z,b.DYNAMIC_DRAW);i(w,r,v,z)}t.__dirtyVertices=false;t.__dirtyElements=false;t.__dirtyUvs=false;t.__dirtyNormals=false;t.__dirtyTangents=false;
t.__dirtyColors=false}else if(z instanceof THREE.Line){if(!t.__webGLVertexBuffer){this.createLineBuffers(t);this.initLineBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyColors)this.setLineBuffers(t,b.DYNAMIC_DRAW);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else if(z instanceof THREE.ParticleSystem){if(!t.__webGLVertexBuffer){this.createParticleBuffers(t);this.initParticleBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||
t.__dirtyColors||z.sortParticles)this.setParticleBuffers(t,b.DYNAMIC_DRAW,z,h);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else z instanceof THREE.MarchingCubes&&j(w,0,z)}};this.removeObject=function(d,h){var i,j;for(i=d.__webGLObjects.length-1;i>=0;i--){j=d.__webGLObjects[i].object;h==j&&d.__webGLObjects.splice(i,1)}};this.setupMatrices=function(d,h){d._modelViewMatrix.multiplyToArray(h.matrix,d.matrix,d._modelViewMatrixArray);d._normalMatrix=THREE.Matrix4.makeInvert3x3(d._modelViewMatrix).transposeIntoArray(d._normalMatrixArray)};
this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};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.SVGRenderer=function(){function a(e,i,m){var h,g,t,w;h=0;for(g=e.lights.length;h<g;h++){t=e.lights[h];if(t instanceof THREE.DirectionalLight){w=i.normalWorld.dot(t.position)*t.intensity;if(w>0){m.r+=t.color.r*w;m.g+=t.color.g*w;m.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){m.r+=t.color.r*w;m.g+=t.color.g*w;m.b+=t.color.b*w}}}}function c(e,i,m,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+
" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear);
C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,m,h,g,t,w){D=f(K++);D.setAttribute("d",
"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J=
1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)}
function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0),
Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;n=i;z=l/2;y=n/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+n);o.setAttribute("width",l);o.setAttribute("height",n);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var m,
h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);m=0;for(h=r.length;m<h;m++){g=r[m];t=g.color;if(g instanceof THREE.AmbientLight){R.r+=t.r;R.g+=t.g;R.b+=t.b}else if(g instanceof THREE.DirectionalLight){$.r+=t.r;$.g+=t.g;$.b+=t.b}else if(g instanceof THREE.PointLight){Q.r+=t.r;Q.g+=t.g;Q.b+=t.b}}}m=0;for(h=k.length;m<h;m++){r=k[m];s.empty();if(r instanceof THREE.RenderableParticle){v=
r;v.x*=z;v.y*=-y;g=0;for(t=r.materials.length;g<t;g++)if(p=r.materials[g]){w=v;u=r;p=p;var B=ca++;if(U[B]==null){U[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");aa==0&&U[B].setAttribute("shape-rendering","crispEdges")}D=U[B];D.setAttribute("cx",w.x);D.setAttribute("cy",w.y);D.setAttribute("r",u.scale.x*z);if(p instanceof THREE.ParticleCircleMaterial){if(O){b.r=R.r+$.r+Q.r;b.g=R.g+$.g+Q.g;b.b=R.b+$.b+Q.b;C.r=p.color.r*b.r;C.g=p.color.g*b.g;C.b=p.color.b*b.b;C.updateStyleString()}else C=
p.color;D.setAttribute("style","fill: "+C.__styleString)}o.appendChild(D)}}else if(r instanceof THREE.RenderableLine){v=r.v1;x=r.v2;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.materials.length;g<t;)if(p=r.materials[g++]){w=v;u=x;p=p;B=N++;if(M[B]==null){M[B]=document.createElementNS("http://www.w3.org/2000/svg","line");aa==
0&&M[B].setAttribute("shape-rendering","crispEdges")}D=M[B];D.setAttribute("x1",w.positionScreen.x);D.setAttribute("y1",w.positionScreen.y);D.setAttribute("x2",u.positionScreen.x);D.setAttribute("y2",u.positionScreen.y);if(p instanceof THREE.LineBasicMaterial){C.__styleString=p.color.__styleString;D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+p.linewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.linecap+"; stroke-linejoin: "+p.linejoin);o.appendChild(D)}}}}else if(r instanceof
THREE.RenderableFace3){v=r.v1;x=r.v2;F=r.v3;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&
c(v,x,F,r,p,e)}else p&&c(v,x,F,r,p,e)}}}else if(r instanceof THREE.RenderableFace4){v=r.v1;x=r.v2;F=r.v3;H=r.v4;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){g=
0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&d(v,x,F,H,r,p,e)}else p&&d(v,x,F,H,r,p,e)}}}}}};
THREE.WebGLRenderer=function(a){function c(e,i,m){var h,g,t,w=e.vertices,u=w.length,r=e.colors,p=r.length,B=e.__vertexArray,V=e.__colorArray,da=e.__sortArray,ea=e.__dirtyVertices,ia=e.__dirtyColors;if(m.sortParticles){U.multiplySelf(m.matrixWorld);for(h=0;h<u;h++){g=w[h].position;K.copy(g);U.multiplyVector3(K);da[h]=[K.z,h]}da.sort(function(S,Y){return Y[0]-S[0]});for(h=0;h<u;h++){g=w[da[h][1]].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}for(h=0;h<p;h++){t=h*3;color=r[da[h][1]];V[t]=color.r;V[t+
1]=color.g;V[t+2]=color.b}}else{if(ea)for(h=0;h<u;h++){g=w[h].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}if(ia)for(h=0;h<p;h++){color=r[h];t=h*3;V[t]=color.r;V[t+1]=color.g;V[t+2]=color.b}}if(ea||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,i)}if(ia||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,V,i)}}function d(e,i){e.fragment_shader=i.fragment_shader;e.vertex_shader=i.vertex_shader;e.uniforms=
Uniforms.clone(i.uniforms)}function f(e,i){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.position);b.vertexAttribPointer(i.attributes.position,3,b.FLOAT,false,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.normal);b.vertexAttribPointer(i.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function j(e){if(Q!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);Q=e.doubleSided}if(J!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);J=e.flipSided}}function k(e){G[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);G[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+
e.n14);G[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);G[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);G[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);G[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var i;for(e=0;e<5;e++){i=G[e];i.divideScalar(Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z))}}function q(e){for(var i=e.matrix,m=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=G[h].x*i.n14+G[h].y*i.n24+G[h].z*i.n34+G[h].w;
if(e<=m)return false}return true}function o(e,i){e.list[e.count]=i;e.count+=1}function l(e){var i,m,h=e.object,g=e.opaque,t=e.transparent;t.count=0;e=g.count=0;for(i=h.materials.length;e<i;e++){m=h.materials[e];m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?o(t,m):o(g,m)}}function n(e){var i,m,h,g,t=e.object,w=e.buffer,u=e.opaque,r=e.transparent;r.count=0;e=u.count=0;for(h=t.materials.length;e<h;e++){i=t.materials[e];if(i instanceof THREE.MeshFaceMaterial){i=0;for(m=w.materials.length;i<
m;i++)if(g=w.materials[i])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}else{g=i;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}}}function z(e){var i,m,h,g=e.children;i=0;for(m=g.length;i<m;i++){h=g[i];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(e.matrixWorld,h.matrix);z(h)}}function y(e,i){var m,h,g=i.children;m=0;for(h=g.length;m<h;m++){child=g[m];v(e,child,false);y(e,child)}}function v(e,i,m){var h,g,t;g=i.geometry;if(e.__webGLObjectsMap[i.id]==
undefined){e.__webGLObjectsMap[i.id]={};i._modelViewMatrix=new THREE.Matrix4;i._normalMatrixArray=new Float32Array(9);i._modelViewMatrixArray=new Float32Array(16);i._objectMatrixArray=new Float32Array(16);i.matrix.flattenToArray(i._objectMatrixArray)}t=e.__webGLObjectsMap[i.id];objlist=e.__webGLObjects;if(i instanceof THREE.Mesh){for(h in g.geometryChunks){e=g.geometryChunks[h];if(!e.__webGLVertexBuffer){var w=e;w.__webGLVertexBuffer=b.createBuffer();w.__webGLNormalBuffer=b.createBuffer();w.__webGLTangentBuffer=
b.createBuffer();w.__webGLColorBuffer=b.createBuffer();w.__webGLUVBuffer=b.createBuffer();w.__webGLUV2Buffer=b.createBuffer();w.__webGLFaceBuffer=b.createBuffer();w.__webGLLineBuffer=b.createBuffer();w=e;var u=i,r=void 0,p=void 0,B=0,V=0,da=0,ea=u.geometry.faces,ia=w.faces;r=0;for(p=ia.length;r<p;r++){fi=ia[r];face=ea[fi];if(face instanceof THREE.Face3){B+=3;V+=1;da+=3}else if(face instanceof THREE.Face4){B+=4;V+=2;da+=4}}w.__vertexArray=new Float32Array(B*3);w.__normalArray=new Float32Array(B*3);
w.__tangentArray=new Float32Array(B*4);w.__colorArray=new Float32Array(B*3);w.__uvArray=new Float32Array(B*2);w.__uv2Array=new Float32Array(B*2);w.__faceArray=new Uint16Array(V*3);w.__lineArray=new Uint16Array(da*2);p=r=w;u=u;B=void 0;ea=void 0;var S=void 0,Y=void 0;S=void 0;ia=false;B=0;for(ea=u.materials.length;B<ea;B++){S=u.materials[B];if(S instanceof THREE.MeshFaceMaterial){S=0;for(Y=p.materials.length;S<Y;S++)if(p.materials[S]&&p.materials[S].shading!=undefined&&p.materials[S].shading==THREE.SmoothShading){ia=
true;break}}else if(S&&S.shading!=undefined&&S.shading==THREE.SmoothShading){ia=true;break}if(ia)break}r.__needsSmoothNormals=ia;w.__webGLFaceCount=V*3;w.__webGLLineCount=da*2;g.__dirtyVertices=true;g.__dirtyElements=true;g.__dirtyUvs=true;g.__dirtyNormals=true;g.__dirtyTangents=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyElements||g.__dirtyUvs||g.__dirtyNormals||g.__dirtyColors||g.__dirtyTangents){w=e;V=b.DYNAMIC_DRAW;da=void 0;r=void 0;var pa=void 0,P=void 0,ka=void 0,oa=void 0,wa=
void 0;pa=void 0;var fa=void 0,W=void 0,ba=void 0,Ca=void 0;fa=void 0;W=void 0;ba=void 0;P=void 0;fa=void 0;W=void 0;ba=void 0;Ca=void 0;P=void 0;oa=void 0;ka=void 0;wa=void 0;var qa=Y=S=ia=ea=B=u=p=0,la=0,na=w.__vertexArray,Ja=w.__uvArray,Da=w.__uv2Array,va=w.__normalArray,ga=w.__tangentArray,ma=w.__colorArray,Aa=w.__faceArray,ta=w.__lineArray,La=w.__needsSmoothNormals,ua=i.geometry,Ma=ua.__dirtyVertices,ja=ua.__dirtyElements,ya=ua.__dirtyUvs,Fa=ua.__dirtyNormals,Ka=ua.__dirtyTangents,Na=ua.__dirtyColors,
sa=ua.vertices,A=w.faces,Z=ua.faces,T=ua.uvs,E=ua.uvs2,L=ua.colors;da=0;for(r=A.length;da<r;da++){pa=A[da];P=Z[pa];wa=T[pa];pa=E[pa];ka=P.vertexNormals;oa=P.normal;if(P instanceof THREE.Face3){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;u+=9}if(Na&&L.length){fa=L[P.a];W=L[P.b];ba=L[P.c];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;
ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;la+=9}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;Y+=12}if(Fa)if(ka.length==3&&La)for(P=0;P<3;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<3;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<3;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;
B+=2}if(ya&&pa)for(P=0;P<3;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;ia+=3;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+2;ta[qa+4]=p+1;ta[qa+5]=p+2;qa+=6;p+=3}}else if(P instanceof THREE.Face4){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;Ca=sa[P.d].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;na[u+9]=Ca.x;na[u+10]=Ca.y;na[u+11]=Ca.z;u+=12}if(Na&&L.length){fa=
L[P.a];W=L[P.b];ba=L[P.c];Ca=L[P.d];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;ma[la+9]=Ca.r;ma[la+10]=Ca.g;ma[la+11]=Ca.b;la+=12}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;P=sa[P.d].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;ga[Y+12]=P.x;ga[Y+13]=P.y;ga[Y+14]=P.z;ga[Y+
15]=P.w;Y+=16}if(Fa)if(ka.length==4&&La)for(P=0;P<4;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<4;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<4;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;B+=2}if(ya&&pa)for(P=0;P<4;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;Aa[ia+3]=p;Aa[ia+4]=p+2;Aa[ia+5]=p+3;ia+=6;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+3;ta[qa+4]=p+1;ta[qa+5]=p+2;ta[qa+6]=p+2;ta[qa+7]=p+3;qa+=8;p+=4}}}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,
w.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,V)}if(Na&&L.length){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ma,V)}if(Fa){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,va,V)}if(Ka&&ua.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ga,V)}if(ya&&B>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer);
b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,m)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=
b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r<B;r++){p=u[r].position;e=r*3;ea[e]=p.x;ea[e+1]=p.y;ea[e+2]=p.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
ea,h)}if(ia){for(r=0;r<V;r++){color=w[r];e=r*3;da[e]=color.r;da[e+1]=color.g;da[e+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,da,h)}}x(objlist,t,0,g,i,m);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.ParticleSystem){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__sortArray=
[];g.__webGLParticleCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors||i.sortParticles)c(g,b.DYNAMIC_DRAW,i,camera);x(objlist,t,0,g,i,m);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.MarchingCubes)if(t[0]==undefined){e.__webGLObjectsImmediate.push({object:i,opaque:{list:[],count:0},transparent:{list:[],count:0},root:m});t[0]=1}}function x(e,i,m,h,g,t){if(i[m]==undefined){e.push({buffer:h,object:g,opaque:{list:[],count:0},transparent:{list:[],
count:0},root:t});i[m]=1}}function F(e,i){e._modelViewMatrix.multiplyToArray(i.matrix,e.matrixWorld,e._modelViewMatrixArray);e._normalMatrix=THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function H(e){if(e!=X){switch(e){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}X=e}}function I(e,i){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(e.wrap_s));b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_WRAP_T,O(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,O(e.format),e.width,e.height,0,O(e.format),O(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var m,h,g;if(e){m=e.__webGLFramebuffer;h=e.width;g=e.height}else{m=null;h=C.width;g=C.height}if(m!=$){b.bindFramebuffer(b.FRAMEBUFFER,m);b.viewport(0,0,h,g);i&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);$=m}}function s(e,i){var m;if(e=="fragment")m=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")m=b.createShader(b.VERTEX_SHADER);b.shaderSource(m,i);b.compileShader(m);if(!b.getShaderParameter(m,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(m));
return null}return m}function O(e){switch(e){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 C=document.createElement("canvas"),b,R=null,$=null,Q=null,J=null,X=null,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],U=new THREE.Matrix4,M=new Float32Array(16),D=new Float32Array(16),K=new THREE.Vector4,ca=true,N=new THREE.Color(0),aa=0;if(a){if(a.antialias!==undefined)ca=a.antialias;a.clearColor!==undefined&&N.setHex(a.clearColor);if(a.clearAlpha!==undefined)aa=a.clearAlpha}this.domElement=C;this.autoClear=true;(function(e,i,
m){try{b=C.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}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(i.r,i.g,i.b,m);_cullEnabled=true})(ca,N,aa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},
point:{length:0,colors:[],positions:[]}};this.setSize=function(e,i){C.width=e;C.height=i;b.viewport(0,0,C.width,C.height)};this.setClearColorHex=function(e,i){var m=new THREE.Color(e);b.clearColor(m.r,m.g,m.b,i)};this.setClearColor=function(e,i){b.clearColor(e.r,e.g,e.b,i)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,i){var m,h,g,t=0,w=0,u=0,r,p,B,V=this.lights,da=V.directional.colors,ea=V.directional.positions,ia=V.point.colors,S=V.point.positions,
Y=0,pa=0;m=g=g=0;for(h=i.length;m<h;m++){g=i[m];r=g.color;p=g.position;B=g.intensity;if(g instanceof THREE.AmbientLight){t+=r.r;w+=r.g;u+=r.b}else if(g instanceof THREE.DirectionalLight){g=Y*3;da[g]=r.r*B;da[g+1]=r.g*B;da[g+2]=r.b*B;ea[g]=p.x;ea[g+1]=p.y;ea[g+2]=p.z;Y+=1}else if(g instanceof THREE.PointLight){g=pa*3;ia[g]=r.r*B;ia[g+1]=r.g*B;ia[g+2]=r.b*B;S[g]=p.x;S[g+1]=p.y;S[g+2]=p.z;pa+=1}}for(m=Y*3;m<da.length;m++)da[m]=0;for(m=pa*3;m<ia.length;m++)ia[m]=0;V.point.length=pa;V.directional.length=
Y;V.ambient[0]=t;V.ambient[1]=w;V.ambient[2]=u};this.initMaterial=function(e,i,m){var h,g;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);
else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var t,w,u,r;g=u=r=0;for(t=i.length;g<t;g++){w=i[g];w instanceof THREE.DirectionalLight&&u++;w instanceof THREE.PointLight&&r++}if(r+u<=4){i=u;r=r}else{i=Math.ceil(4*u/(r+u));r=4-i}g={directional:i,point:r};r=e.fragment_shader;i=e.vertex_shader;t={fog:m,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};m=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
"#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#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":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(m,s("fragment",g+r));b.attachShader(m,
s("vertex",t+i));b.linkProgram(m);b.getProgramParameter(m,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(m,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");m.uniforms={};m.attributes={};e.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)m.push(h);h=e.program;r=0;for(i=m.length;r<i;r++){g=m[r];h.uniforms[g]=b.getUniformLocation(h,g)}e=e.program;h=["position","normal",
"uv","uv2","tangent","color"];m=0;for(r=h.length;m<r;m++){i=h[m];e.attributes[i]=b.getAttribLocation(e,i)}};this.setProgram=function(e,i,m,h,g){h.program||this.initMaterial(h,i,m);var t=h.program,w=t.uniforms,u=h.uniforms;if(t!=R){b.useProgram(t);R=t;b.uniformMatrix4fv(w.projectionMatrix,false,M)}if(m&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){u.fogColor.value.setHex(m.color.hex);
if(m instanceof THREE.Fog){u.fogNear.value=m.near;u.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)u.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(t,i);i=this.lights;u.enableLighting.value=i.directional.length+i.point.length;u.ambientLightColor.value=i.ambient;u.directionalLightColor.value=i.directional.colors;u.directionalLightDirection.value=i.directional.positions;u.pointLightColor.value=i.point.colors;u.pointLightPosition.value=
i.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.map.texture=h.map;u.light_map.texture=h.light_map;u.env_map.texture=h.env_map;u.reflectivity.value=h.reflectivity;u.refraction_ratio.value=h.refraction_ratio;u.combine.value=h.combine;u.useRefract.value=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof
THREE.LineBasicMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.size.value=h.size;u.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(h.ambient.r,h.ambient.g,h.ambient.b);u.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);
u.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){u.mNear.value=e.near;u.mFar.value=e.far;u.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)u.opacity.value=h.opacity;var r,p,B;for(r in u)if(B=t.uniforms[r]){m=u[r];p=m.type;i=m.value;if(p=="i")b.uniform1i(B,i);else if(p=="f")b.uniform1f(B,i);else if(p=="fv1")b.uniform1fv(B,i);else if(p=="fv")b.uniform3fv(B,i);else if(p=="v2")b.uniform2f(B,i.x,i.y);else if(p=="v3")b.uniform3f(B,i.x,i.y,i.z);else if(p==
"c")b.uniform3f(B,i.r,i.g,i.b);else if(p=="t"){b.uniform1i(B,i);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){m=m;i=i;if(m.image.length==6){if(!m.image.__webGLTextureCube&&!m.image.__cubeMapInitialized&&m.image.loadCount==6){m.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(p=0;p<6;++p)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);m.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{m=m;i=i;if(!m.__webGLTexture&&m.image.loaded){m.__webGLTexture=b.createTexture();
b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,m.__webGLTexture)}}}b.uniformMatrix4fv(w.modelViewMatrix,
false,g._modelViewMatrixArray);b.uniformMatrix3fv(w.normalMatrix,false,g._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(w.cameraPosition,e.position.x,e.position.y,e.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(w.objectMatrix,false,g._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(w.viewMatrix,
false,D);return t};this.renderBuffer=function(e,i,m,h,g,t){e=this.setProgram(e,i,m,h,t).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.position);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,
false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,
2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);
b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,m,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(m,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h<u;h++){g=e.__webGLObjects[h];p=g.object;if(p.visible){if(g.root){p.autoUpdateMatrix&&
p.updateMatrix();p.matrixWorld.copy(p.matrix);z(p)}if(!(p instanceof THREE.Mesh)||q(p)){p.matrixWorld.flattenToArray(p._objectMatrixArray);F(p,i);n(g);g.render=true}else g.render=false}else g.render=false}r=e.__webGLObjectsImmediate.length;for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){if(p.autoUpdateMatrix){p.updateMatrix();p.matrixWorld.copy(p.matrix);p.matrixWorld.flattenToArray(p._objectMatrixArray)}F(p,i);l(g)}}H(THREE.NormalBlending);for(h=0;h<u;h++){g=e.__webGLObjects[h];
if(g.render){p=g.object;B=g.buffer;w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}for(h=0;h<u;h++){g=e.__webGLObjects[h];if(g.render){p=g.object;B=g.buffer;w=g.transparent;
j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.transparent;j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}if(m&&m.min_filter!==THREE.NearestFilter&&m.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,
m.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e){var i,m,h;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}i=0;for(m=e.objects.length;i<m;i++){h=e.objects[i];v(e,h,true);y(e,h)}};this.removeObject=function(e,i){var m,h;for(m=e.__webGLObjects.length-1;m>=0;m--){h=e.__webGLObjects[m].object;i==h&&e.__webGLObjects.splice(m,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};
this.setFaceCulling=function(e,i){if(e){!i||i=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="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, gl_FragColor.w ), 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
+160 -159
View File
@@ -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,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var f,k,l,p,q,m;if(e==0)f=k=l=0;else{p=Math.floor(a*6);q=a*6-p;a=e*(1-c);m=e*(1-c*q);c=e*(1-c*(1-q));switch(p){case 1:f=m;k=e;l=a;break;case 2:f=a;k=e;l=c;break;case 3:f=a;k=m;l=e;break;case 4:f=c;k=a;l=e;break;case 5:f=e;k=a;l=m;break;case 6:case 0:f=e;k=c;l=a}}this.r=f;this.g=k;this.b=l;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;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)},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,d){this.x=a||0;this.y=c||0;this.z=d||0};
THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;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,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+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,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;
THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;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,k=[];a=0;for(c=f.length;a<c;a++){e=f[a];if(e instanceof THREE.Mesh)k=k.concat(this.intersectObject(e))}k.sort(function(l,p){return l.distance-p.distance});return k},intersectObject:function(a){function c(I,s,R,F){F=F.clone().subSelf(s);R=R.clone().subSelf(s);var J=I.clone().subSelf(s);I=F.dot(F);s=F.dot(R);F=F.dot(J);var O=R.dot(R);R=R.dot(J);J=1/(I*O-s*s);O=(O*F-s*R)*J;I=(I*R-s*F)*J;return O>0&&I>0&&O+I<1}var e,f,k,l,p,q,m,n,C,B,
u,x=a.geometry,b=x.vertices,H=[];e=0;for(f=x.faces.length;e<f;e++){k=x.faces[e];B=this.origin.clone();u=this.direction.clone();l=a.matrix.multiplyVector3(b[k.a].position.clone());p=a.matrix.multiplyVector3(b[k.b].position.clone());q=a.matrix.multiplyVector3(b[k.c].position.clone());m=k instanceof THREE.Face4?a.matrix.multiplyVector3(b[k.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(k.normal.clone());C=u.dot(n);if(C<0){n=n.dot((new THREE.Vector3).sub(l,B))/C;B=B.addSelf(u.multiplyScalar(n));
if(k instanceof THREE.Face3){if(c(B,l,p,q)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}else if(k instanceof THREE.Face4)if(c(B,l,p,m)||c(B,p,q,m)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}}return H}};
THREE.Rectangle=function(){function a(){l=f-c;p=k-e}var c,e,f,k,l,p,q=true;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return l};this.getHeight=function(){return p};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return k};this.set=function(m,n,C,B){q=false;c=m;e=n;f=C;k=B;a()};this.addPoint=function(m,n){if(q){q=false;c=m;e=n;f=m;k=n}else{c=c<m?c:m;e=e<n?e:n;f=f>m?f:m;k=k>n?
k:n}a()};this.add3Points=function(m,n,C,B,u,x){if(q){q=false;c=m<C?m<u?m:u:C<u?C:u;e=n<B?n<x?n:x:B<x?B:x;f=m>C?m>u?m:u:C>u?C:u;k=n>B?n>x?n:x:B>x?B:x}else{c=m<C?m<u?m<c?m:c:u<c?u:c:C<u?C<c?C:c:u<c?u:c;e=n<B?n<x?n<e?n:e:x<e?x:e:B<x?B<e?B:e:x<e?x:e;f=m>C?m>u?m>f?m:f:u>f?u:f:C>u?C>f?C:f:u>f?u:f;k=n>B?n>x?n>k?n:k:x>k?x:k:B>x?B>k?B:k:x>k?x:k}a()};this.addRectangle=function(m){if(q){q=false;c=m.getLeft();e=m.getTop();f=m.getRight();k=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();e=e<m.getTop()?e:m.getTop();
f=f>m.getRight()?f:m.getRight();k=k>m.getBottom()?k:m.getBottom()}a()};this.inflate=function(m){c-=m;e-=m;f+=m;k+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();e=e>m.getTop()?e:m.getTop();f=f<m.getRight()?f:m.getRight();k=k<m.getBottom()?k:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(k,m.getBottom())-Math.max(e,m.getTop())>=0};this.empty=function(){q=true;k=f=e=c=0;a()};this.isEmpty=function(){return q};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+e+", bottom: "+k+", width: "+l+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
THREE.Matrix4=function(a,c,e,f,k,l,p,q,m,n,C,B,u,x,b,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=f||0;this.n21=k||0;this.n22=l||1;this.n23=p||0;this.n24=q||0;this.n31=m||0;this.n32=n||0;this.n33=C||1;this.n34=B||0;this.n41=u||0;this.n42=x||0;this.n43=b||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
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,k,l,p,q,m,n,C,B,u,x,b,H){this.n11=a;this.n12=c;this.n13=e;this.n14=f;this.n21=k;this.n22=l;this.n23=p;this.n24=q;this.n31=m;this.n32=n;this.n33=C;this.n34=B;this.n41=u;this.n42=x;this.n43=b;this.n44=H;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=THREE.Matrix4.__tmpVec1,k=THREE.Matrix4.__tmpVec2,l=THREE.Matrix4.__tmpVec3;l.sub(a,c).normalize();f.cross(e,l).normalize();k.cross(l,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=k.x;this.n22=k.y;this.n23=k.z;this.n24=-k.dot(a);
this.n31=l.x;this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,f=a.z,k=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)*k;a.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*k;a.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*k;return a},multiplyVector4:function(a){var c=a.x,e=a.y,f=a.z,k=a.w;a.x=this.n11*c+this.n12*e+this.n13*f+this.n14*k;a.y=this.n21*c+this.n22*e+this.n23*
f+this.n24*k;a.z=this.n31*c+this.n32*e+this.n33*f+this.n34*k;a.w=this.n41*c+this.n42*e+this.n43*f+this.n44*k;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,k=a.n13,l=a.n14,p=a.n21,q=a.n22,m=a.n23,n=a.n24,C=a.n31,
B=a.n32,u=a.n33,x=a.n34,b=a.n41,H=a.n42,I=a.n43,s=a.n44,R=c.n11,F=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,L=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43,o=c.n44;this.n11=e*R+f*Y+k*M+l*i;this.n12=e*F+f*P+k*U+l*j;this.n13=e*J+f*L+k*d+l*g;this.n14=e*O+f*V+k*h+l*o;this.n21=p*R+q*Y+m*M+n*i;this.n22=p*F+q*P+m*U+n*j;this.n23=p*J+q*L+m*d+n*g;this.n24=p*O+q*V+m*h+n*o;this.n31=C*R+B*Y+u*M+x*i;this.n32=C*F+B*P+u*U+x*j;this.n33=C*J+B*L+u*d+x*g;this.n34=C*O+B*V+u*h+x*o;this.n41=b*R+H*Y+
I*M+s*i;this.n42=b*F+H*P+I*U+s*j;this.n43=b*J+H*L+I*d+s*g;this.n44=b*O+H*V+I*h+s*o;return this},multiplyToArray:function(a,c,e){var f=a.n11,k=a.n12,l=a.n13,p=a.n14,q=a.n21,m=a.n22,n=a.n23,C=a.n24,B=a.n31,u=a.n32,x=a.n33,b=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var R=c.n11,F=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,L=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43;c=c.n44;this.n11=f*R+k*Y+l*M+p*i;this.n12=f*F+k*P+l*U+p*j;this.n13=f*J+k*L+l*d+p*g;this.n14=f*O+k*V+l*h+p*c;this.n21=
q*R+m*Y+n*M+C*i;this.n22=q*F+m*P+n*U+C*j;this.n23=q*J+m*L+n*d+C*g;this.n24=q*O+m*V+n*h+C*c;this.n31=B*R+u*Y+x*M+b*i;this.n32=B*F+u*P+x*U+b*j;this.n33=B*J+u*L+x*d+b*g;this.n34=B*O+u*V+x*h+b*c;this.n41=H*R+I*Y+s*M+a*i;this.n42=H*F+I*P+s*U+a*j;this.n43=H*J+I*L+s*d+a*g;this.n44=H*O+I*V+s*h+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;
e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,f=this.n13,k=this.n14,l=this.n21,p=this.n22,q=this.n23,m=this.n24,n=this.n31,C=this.n32,B=this.n33,u=this.n34,x=this.n41,b=this.n42,H=this.n43,I=this.n44,s=a.n11,R=a.n21,F=a.n31,J=a.n41,O=a.n12,Y=a.n22,P=a.n32,L=a.n42,V=a.n13,M=a.n23,U=a.n33,d=a.n43,h=a.n14,i=a.n24,j=a.n34;a=a.n44;this.n11=c*s+e*R+f*F+k*J;this.n12=c*O+e*Y+f*P+k*L;this.n13=c*V+e*M+f*U+k*d;this.n14=c*h+e*i+f*j+k*a;this.n21=l*s+p*R+q*F+m*J;this.n22=l*O+p*
Y+q*P+m*L;this.n23=l*V+p*M+q*U+m*d;this.n24=l*h+p*i+q*j+m*a;this.n31=n*s+C*R+B*F+u*J;this.n32=n*O+C*Y+B*P+u*L;this.n33=n*V+C*M+B*U+u*d;this.n34=n*h+C*i+B*j+u*a;this.n41=x*s+b*R+H*F+I*J;this.n42=x*O+b*Y+H*P+I*L;this.n43=x*V+b*M+H*U+I*d;this.n44=x*h+b*i+H*j+I*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(){var a=this.n11,c=this.n12,e=this.n13,f=this.n14,k=this.n21,l=this.n22,p=this.n23,q=this.n24,m=this.n31,n=this.n32,C=this.n33,B=this.n34,u=this.n41,x=this.n42,b=this.n43,H=this.n44;return f*p*n*u-e*q*n*u-f*l*C*u+c*q*C*u+e*l*B*u-c*p*B*u-f*p*m*x+e*q*m*x+f*k*C*x-a*q*C*x-e*k*B*x+a*p*B*x+f*l*m*b-c*q*m*b-f*k*n*b+a*q*n*b+c*k*B*b-a*l*B*b-e*l*m*H+c*p*m*H+e*k*n*H-a*p*n*H-c*k*C*H+a*l*C*H},transpose:function(){function a(c,e,f){var k=c[e];c[e]=c[f];c[f]=k}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=
this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1,0,0,a,0,1,0,c,0,0,1,e,0,0,0,
1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),f=Math.sin(c),k=1-e,l=a.x,p=a.y,q=a.z,
m=k*l,n=k*p;this.set(m*l+e,m*p-f*q,m*q+f*p,0,m*p+f*q,n*p+e,n*q-f*l,0,m*q-f*p,n*q+f*l,k*q*q+e,0,0,0,0,1);return this},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.setTranslation(a,c,e);return f};
THREE.Matrix4.scaleMatrix=function(a,c,e){var f=new THREE.Matrix4;f.setScale(a,c,e);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,f=a.n13,k=a.n14,l=a.n21,p=a.n22,q=a.n23,m=a.n24,n=a.n31,C=a.n32,B=a.n33,u=a.n34,x=a.n41,b=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=q*u*b-m*B*b+m*C*H-p*u*H-q*C*I+p*B*I;s.n12=k*B*b-f*u*b-k*C*H+e*u*H+f*C*I-e*B*I;s.n13=f*m*b-k*q*b+k*p*H-e*m*H-f*p*I+e*q*I;s.n14=k*q*C-f*m*C-k*p*B+e*m*B+f*p*u-e*q*u;s.n21=m*B*x-q*u*x-m*n*H+l*u*H+q*n*I-l*B*I;s.n22=f*u*x-k*B*x+k*n*H-c*u*H-f*n*I+c*B*I;s.n23=k*q*x-f*m*x-k*l*H+c*m*H+f*l*I-c*q*I;s.n24=f*m*n-k*q*n+
k*l*B-c*m*B-f*l*u+c*q*u;s.n31=p*u*x-m*C*x+m*n*b-l*u*b-p*n*I+l*C*I;s.n32=k*C*x-e*u*x-k*n*b+c*u*b+e*n*I-c*C*I;s.n33=f*m*x-k*p*x+k*l*b-c*m*b-e*l*I+c*p*I;s.n34=k*p*n-e*m*n-k*l*C+c*m*C+e*l*u-c*p*u;s.n41=q*C*x-p*B*x-q*n*b+l*B*b+p*n*H-l*C*H;s.n42=e*B*x-f*C*x+f*n*b-c*B*b-e*n*H+c*C*H;s.n43=f*p*x-e*q*x-f*l*b+c*q*b+e*l*H-c*p*H;s.n44=e*q*n-f*p*n+f*l*C-c*q*C-e*l*B+c*p*B;s.multiplyScalar(1/a.determinant());return s};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,f=a.n33*a.n22-a.n32*a.n23,k=-a.n33*a.n21+a.n31*a.n23,l=a.n32*a.n21-a.n31*a.n22,p=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,C=-a.n23*a.n11+a.n21*a.n13,B=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*p+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*f;e[1]=a*k;e[2]=a*l;e[3]=a*p;e[4]=a*q;e[5]=a*m;e[6]=a*n;e[7]=a*C;e[8]=a*B;return c};
THREE.Matrix4.makeFrustum=function(a,c,e,f,k,l){var p,q,m;p=new THREE.Matrix4;q=2*k/(c-a);m=2*k/(f-e);a=(c+a)/(c-a);e=(f+e)/(f-e);f=-(l+k)/(l-k);k=-2*l*k/(l-k);p.n11=q;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=m;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=k;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,c,e,f){var k;a=e*Math.tan(a*Math.PI/360);k=-a;return THREE.Matrix4.makeFrustum(k*c,a*c,k,a,e,f)};
THREE.Matrix4.makeOrtho=function(a,c,e,f,k,l){var p,q,m,n;p=new THREE.Matrix4;q=c-a;m=e-f;n=l-k;a=(c+a)/q;e=(e+f)/m;k=(l+k)/n;p.n11=2/q;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/m;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/n;p.n34=-k;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function c(I,s,O,C){C=C.clone().subSelf(s);O=O.clone().subSelf(s);var b=I.clone().subSelf(s);I=C.dot(C);s=C.dot(O);C=C.dot(b);var R=O.dot(O);O=O.dot(b);b=1/(I*R-s*s);R=(R*C-s*O)*b;I=(I*O-s*C)*b;return R>0&&I>0&&R+I<1}var d,f,j,k,q,o,l,m,z,y,
v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;d<f;d++){j=x.faces[d];y=this.origin.clone();v=this.direction.clone();k=a.matrix.multiplyVector3(F[j.a].position.clone());q=a.matrix.multiplyVector3(F[j.b].position.clone());o=a.matrix.multiplyVector3(F[j.c].position.clone());l=j instanceof THREE.Face4?a.matrix.multiplyVector3(F[j.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(j.normal.clone());z=v.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(k,y))/z;y=y.addSelf(v.multiplyScalar(m));
if(j instanceof THREE.Face3){if(c(y,k,q,o)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}else if(j instanceof THREE.Face4)if(c(y,k,q,l)||c(y,q,o,l)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}}return H}};
THREE.Rectangle=function(){function a(){k=f-c;q=j-d}var c,d,f,j,k,q,o=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(l,m,z,y){o=false;c=l;d=m;f=z;j=y;a()};this.addPoint=function(l,m){if(o){o=false;c=l;d=m;f=l;j=m}else{c=c<l?c:l;d=d<m?d:m;f=f>l?f:l;j=j>m?
j:m}a()};this.add3Points=function(l,m,z,y,v,x){if(o){o=false;c=l<z?l<v?l:v:z<v?z:v;d=m<y?m<x?m:x:y<x?y:x;f=l>z?l>v?l:v:z>v?z:v;j=m>y?m>x?m:x:y>x?y:x}else{c=l<z?l<v?l<c?l:c:v<c?v:c:z<v?z<c?z:c:v<c?v:c;d=m<y?m<x?m<d?m:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=m>y?m>x?m>j?m:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
f=f>l.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();j=j<l.getBottom()?j:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
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,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;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,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;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 d=a.n11,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,m=a.n24,z=a.n31,
y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+m*K;this.n22=q*C+o*Q+l*U+m*ca;this.n23=q*b+o*J+l*M+m*N;this.n24=q*R+o*X+l*D+m*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41=
F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,m=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q*
c;this.n21=o*O+l*$+m*G+z*K;this.n22=o*C+l*Q+m*U+z*ca;this.n23=o*b+l*J+m*M+z*N;this.n24=o*R+l*X+m*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;
d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l*
b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=m*s+z*O+y*C+v*b;this.n32=m*R+z*$+y*Q+v*J;this.n33=m*X+z*G+y*U+v*M;this.n34=m*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*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(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*m*v-d*o*m*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*m*F+a*o*m*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*m*H-a*q*m*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}a(this,"n21","n12");
a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;
a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,
0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y,
o=a.z,l=j*k,m=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,m*q+d,m*o-f*k,0,l*o-f*q,m*o+f*k,j*o*o+d,0,0,0,0,1);return this},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,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};
THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*m*H+k*v*H+o*m*I-k*y*I;s.n22=f*v*x-j*y*x+j*m*H-c*v*H-f*m*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*m-j*o*m+
j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*m*F-k*v*F-q*m*I+k*z*I;s.n32=j*z*x-d*v*x-j*m*F+c*v*F+d*m*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*m-d*l*m-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*m*F+k*y*F+q*m*H-k*z*H;s.n42=d*y*x-f*z*x+f*m*F-c*y*F-d*m*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*m-f*q*m+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*m;d[7]=a*z;d[8]=a*y;return c};
THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)};
THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,m;q=new THREE.Matrix4;o=c-a;l=d-f;m=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/m;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
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,k){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=k instanceof Array?k:[k]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,e,f,k,l){this.a=a;this.b=c;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=k instanceof THREE.Vector3?k:new THREE.Vector3;this.vertexNormals=k instanceof Array?k:[];this.materials=l instanceof Array?l:[l]};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.Face3=function(a,c,d,f,j){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,e,f,k,l,p,q=new THREE.Vector3,m=new THREE.Vector3;f=0;for(k=this.vertices.length;f<k;f++){l=this.vertices[f];l.normal.set(0,0,0)}f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];if(a&&l.vertexNormals.length){q.set(0,0,0);c=0;for(e=l.normal.length;c<e;c++)q.addSelf(l.vertexNormals[c]);q.divideScalar(3)}else{c=this.vertices[l.a];e=this.vertices[l.b];p=this.vertices[l.c];q.sub(p.position,
e.position);m.sub(c.position,e.position);q.crossSelf(m)}q.isZero()||q.normalize();l.normal.copy(q)}},computeVertexNormals:function(){var a,c,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(h,i,j,g,o,z,r){l=h.vertices[i].position;p=h.vertices[j].position;q=h.vertices[g].position;m=k[o];n=k[z];C=k[r];B=p.x-l.x;u=q.x-l.x;x=p.y-l.y;b=q.y-l.y;
H=p.z-l.z;I=q.z-l.z;s=n.u-m.u;R=C.u-m.u;F=n.v-m.v;J=C.v-m.v;O=1/(s*J-R*F);L.set((J*B-F*u)*O,(J*x-F*b)*O,(J*H-F*I)*O);V.set((s*u-R*B)*O,(s*b-R*x)*O,(s*I-R*H)*O);Y[i].addSelf(L);Y[j].addSelf(L);Y[g].addSelf(L);P[i].addSelf(V);P[j].addSelf(V);P[g].addSelf(V)}var c,e,f,k,l,p,q,m,n,C,B,u,x,b,H,I,s,R,F,J,O,Y=[],P=[],L=new THREE.Vector3,V=new THREE.Vector3,M=new THREE.Vector3,U=new THREE.Vector3,d=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++){Y[c]=new THREE.Vector3;P[c]=new THREE.Vector3}c=0;
for(e=this.faces.length;c<e;c++){f=this.faces[c];k=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(e=this.vertices.length;c<e;c++){d.copy(this.vertices[c].normal);f=Y[c];M.copy(f);M.subSelf(d.multiplyScalar(d.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(P[c]);f=f<0?-1:1;this.vertices[c].tangent.set(M.x,M.y,M.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){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;c<e;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else 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;c<e;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(C){var B=[];c=0;for(e=C.length;c<e;c++)C[c]==undefined?B.push("undefined"):B.push(C[c].toString());return B.join("_")}var c,e,f,k,l,p,q,m,n={};f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];
p=l.materials;q=a(p);if(n[q]==undefined)n[q]={hash:q,counter:0};m=n[q].hash+"_"+n[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0};l=l instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+l>65535){n[q].counter+=1;m=n[q].hash+"_"+n[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0}}this.geometryChunks[m].faces.push(f);this.geometryChunks[m].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+
THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,j,k,q,o=new THREE.Vector3,l=new THREE.Vector3;f=0;for(j=this.vertices.length;f<j;f++){k=this.vertices[f];k.normal.set(0,0,0)}f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];if(a&&k.vertexNormals.length){o.set(0,0,0);c=0;for(d=k.normal.length;c<d;c++)o.addSelf(k.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[k.a];d=this.vertices[k.b];q=this.vertices[k.c];o.sub(q.position,
d.position);l.sub(c.position,d.position);o.crossSelf(l)}o.isZero()||o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(D,K,ca,N,aa,e,i){k=D.vertices[K].position;q=D.vertices[ca].position;o=D.vertices[N].position;l=j[aa];m=j[e];z=j[i];y=q.x-k.x;v=o.x-k.x;x=q.y-k.y;F=o.y-
k.y;H=q.z-k.z;I=o.z-k.z;s=m.u-l.u;O=z.u-l.u;C=m.v-l.v;b=z.v-l.v;R=1/(s*b-O*C);J.set((b*y-C*v)*R,(b*x-C*F)*R,(b*H-C*I)*R);X.set((s*v-O*y)*R,(s*F-O*x)*R,(s*I-O*H)*R);$[K].addSelf(J);$[ca].addSelf(J);$[N].addSelf(J);Q[K].addSelf(X);Q[ca].addSelf(X);Q[N].addSelf(X)}var c,d,f,j,k,q,o,l,m,z,y,v,x,F,H,I,s,O,C,b,R,$=[],Q=[],J=new THREE.Vector3,X=new THREE.Vector3,G=new THREE.Vector3,U=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){$[c]=new THREE.Vector3;Q[c]=new THREE.Vector3}c=
0;for(d=this.faces.length;c<d;c++){f=this.faces[c];j=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){M.copy(this.vertices[c].normal);f=$[c];G.copy(f);G.subSelf(M.multiplyScalar(M.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(Q[c]);f=f<0?-1:1;this.vertices[c].tangent.set(G.x,G.y,G.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){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,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else 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,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,j,k,q,o,l,m={};f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];
q=k.materials;o=a(q);if(m[o]==undefined)m[o]={hash:o,counter:0};l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){m[o].counter+=1;l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
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.tmpVec=new THREE.Vector3;this.translateX=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;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.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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,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.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};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.sortParticles=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.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.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x,
d.y,d.z))}};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.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d: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.BillboardBlending=3;
THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
@@ -96,115 +96,116 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
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 (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,f,k,l){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=k!==undefined?k:THREE.LinearFilter;this.min_filter=l!==undefined?l:THREE.LinearMipMapLinearFilter};
THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k: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 (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,c,e){this.width=a;this.height=c;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,e,f,k={};for(c in a){k[c]={};for(e in a[c]){f=a[c][e];k[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return k},merge:function(a){var c,e,f,k={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(e in f)k[e]=f[e]}return k}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)j[d]=f[d]}return j}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(P,L){return L.z-P.z}function c(P,L){var V=0,M=1,U=P.z+P.w,d=L.z+L.w,h=-P.z+P.w,i=-L.z+L.w;if(U>=0&&d>=0&&h>=0&&i>=0)return true;else if(U<0&&d<0||h<0&&i<0)return false;else{if(U<0)V=Math.max(V,U/(U-d));else if(d<0)M=Math.min(M,U/(U-d));if(h<0)V=Math.max(V,h/(h-i));else if(i<0)M=Math.min(M,h/(h-i));if(M<V)return false;else{P.lerpSelf(L,V);L.lerpSelf(P,1-M);return true}}}var e,f,k=[],l,p,q,m=[],n,C,B=[],u,x,b=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
R=new THREE.Matrix4,F=[],J=new THREE.Vector4,O=new THREE.Vector4,Y;this.projectObjects=function(P,L,V){var M=[],U,d;f=0;s.multiply(L.projectionMatrix,L.matrix);F[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);F[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);F[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);F[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);F[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);F[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);L=0;for(U=F.length;L<U;L++){d=F[L];d.divideScalar(Math.sqrt(d.x*d.x+d.y*d.y+d.z*d.z))}U=P.objects;P=0;for(L=U.length;P<L;P++){d=U[P];var h;if(!(h=!d.visible)){if(h=d instanceof THREE.Mesh){a:{h=void 0;for(var i=d.position,j=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,Math.max(d.scale.y,d.scale.z)),g=0;g<6;g++){h=F[g].x*i.x+F[g].y*i.y+F[g].z*i.z+F[g].w;if(h<=j){h=false;break a}}h=true}h=!h}h=h}if(!h){e=
k[f]=k[f]||new THREE.RenderableObject;H.copy(d.position);s.multiplyVector3(H);e.object=d;e.z=H.z;M.push(e);f++}}V&&M.sort(a);return M};this.projectScene=function(P,L,V){var M=[],U=L.near,d=L.far,h,i,j,g,o,z,r,t,v,w,y,K,E,A,N,T;q=C=x=0;L.autoUpdateMatrix&&L.updateMatrix();s.multiply(L.projectionMatrix,L.matrix);z=this.projectObjects(P,L,true);P=0;for(h=z.length;P<h;P++){r=z[P].object;if(r.visible){r.autoUpdateMatrix&&r.updateMatrix();t=r.matrix;v=r.rotationMatrix;w=r.materials;y=r.overdraw;if(r instanceof
THREE.Mesh){K=r.geometry;E=K.vertices;i=0;for(j=E.length;i<j;i++){A=E[i];A.positionWorld.copy(A.position);t.multiplyVector3(A.positionWorld);g=A.positionScreen;g.copy(A.positionWorld);s.multiplyVector4(g);g.x/=g.w;g.y/=g.w;A.__visible=g.z>U&&g.z<d}K=K.faces;i=0;for(j=K.length;i<j;i++){A=K[i];if(A instanceof THREE.Face3){g=E[A.a];o=E[A.b];N=E[A.c];if(g.__visible&&o.__visible&&N.__visible)if(r.doubleSided||r.flipSided!=(N.positionScreen.x-g.positionScreen.x)*(o.positionScreen.y-g.positionScreen.y)-
(N.positionScreen.y-g.positionScreen.y)*(o.positionScreen.x-g.positionScreen.x)<0){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(o.positionWorld);l.v3.positionWorld.copy(N.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(o.positionScreen);l.v3.positionScreen.copy(N.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);
l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);N=A.vertexNormals;Y=l.vertexNormalsWorld;g=0;for(o=N.length;g<o;g++){T=Y[g]=Y[g]||new THREE.Vector3;T.copy(N[g]);v.multiplyVector3(T)}l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][2]}M.push(l);q++}}else if(A instanceof THREE.Face4){g=E[A.a];o=E[A.b];N=E[A.c];T=E[A.d];if(g.__visible&&
o.__visible&&N.__visible&&T.__visible)if(r.doubleSided||r.flipSided!=((T.positionScreen.x-g.positionScreen.x)*(o.positionScreen.y-g.positionScreen.y)-(T.positionScreen.y-g.positionScreen.y)*(o.positionScreen.x-g.positionScreen.x)<0||(o.positionScreen.x-N.positionScreen.x)*(T.positionScreen.y-N.positionScreen.y)-(o.positionScreen.y-N.positionScreen.y)*(T.positionScreen.x-N.positionScreen.x)<0)){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(o.positionWorld);
l.v3.positionWorld.copy(T.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(o.positionScreen);l.v3.positionScreen.copy(T.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];
l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][3]}M.push(l);q++;p=m[q]=m[q]||new THREE.RenderableFace3;p.v1.positionWorld.copy(o.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(T.positionWorld);p.v1.positionScreen.copy(o.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(T.positionScreen);p.normalWorld.copy(l.normalWorld);p.centroidWorld.copy(l.centroidWorld);p.centroidScreen.copy(l.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
w;p.faceMaterials=A.materials;p.overdraw=y;if(r.geometry.uvs[i]){p.uvs[0]=r.geometry.uvs[i][1];p.uvs[1]=r.geometry.uvs[i][2];p.uvs[2]=r.geometry.uvs[i][3]}M.push(p);q++}}}}else if(r instanceof THREE.Line){R.multiply(s,t);E=r.geometry.vertices;A=E[0];A.positionScreen.copy(A.position);R.multiplyVector4(A.positionScreen);i=1;for(j=E.length;i<j;i++){g=E[i];g.positionScreen.copy(g.position);R.multiplyVector4(g.positionScreen);o=E[i-1];J.copy(g.positionScreen);O.copy(o.positionScreen);if(c(J,O)){J.multiplyScalar(1/
J.w);O.multiplyScalar(1/O.w);n=B[C]=B[C]||new THREE.RenderableLine;n.v1.positionScreen.copy(J);n.v2.positionScreen.copy(O);n.z=Math.max(J.z,O.z);n.materials=r.materials;M.push(n);C++}}}else if(r instanceof THREE.Particle){I.set(r.position.x,r.position.y,r.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){u=b[x]=b[x]||new THREE.RenderableParticle;u.x=I.x/I.w;u.y=I.y/I.w;u.z=I.z;u.rotation=r.rotation.z;u.scale.x=r.scale.x*Math.abs(u.x-(I.x+L.projectionMatrix.n11)/(I.w+L.projectionMatrix.n14));
u.scale.y=r.scale.y*Math.abs(u.y-(I.y+L.projectionMatrix.n22)/(I.w+L.projectionMatrix.n24));u.materials=r.materials;M.push(u);x++}}}}V&&M.sort(a);return M};this.unprojectVector=function(P,L){var V=THREE.Matrix4.makeInvert(L.matrix);V.multiplySelf(THREE.Matrix4.makeInvert(L.projectionMatrix));V.multiplyVector3(P);return P}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,f,k,l;this.domElement=document.createElement("div");this.setSize=function(p,q){e=p;f=q;k=e/2;l=f/2};this.render=function(p,q){var m,n,C,B,u,x,b,H;a=c.projectScene(p,q);m=0;for(n=a.length;m<n;m++){u=a[m];if(u instanceof THREE.RenderableParticle){b=u.x*k+k;H=u.y*l+l;C=0;for(B=u.material.length;C<B;C++){x=u.material[C];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=b+"px";x.style.top=H+"px"}}}}}};
THREE.CanvasRenderer=function(){function a($){if(u!=$)n.globalAlpha=u=$}function c($){if(x!=$){switch($){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}x=$}}var e=null,f=new THREE.Projector,k=document.createElement("canvas"),l,p,q,m,n=k.getContext("2d"),C=new THREE.Color(0),B=0,u=1,x=0,b=null,H=null,I=1,s,R,F,J,O,Y,P,L,V,M=new THREE.Color,
U=new THREE.Color,d=new THREE.Color,h=new THREE.Color,i=new THREE.Color,j,g,o,z,r,t,v,w,y,K=new THREE.Rectangle,E=new THREE.Rectangle,A=new THREE.Rectangle,N=false,T=new THREE.Color,ca=new THREE.Color,ga=new THREE.Color,Z=new THREE.Color,ka=Math.PI*2,W=new THREE.Vector3,da,sa,va,ea,aa,fa,la=16;da=document.createElement("canvas");da.width=da.height=2;sa=da.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);va=sa.getImageData(0,0,2,2);ea=va.data;aa=document.createElement("canvas");aa.width=
aa.height=la;fa=aa.getContext("2d");fa.translate(-la/2,-la/2);fa.scale(la,la);la--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function($,qa){l=$;p=qa;q=l/2;m=p/2;k.width=l;k.height=p;K.set(-q,-m,q,m);u=1;x=0;H=b=null;I=1};this.setClearColor=function($,qa){C=$;B=qa;E.set(-q,-m,q,m);n.setTransform(1,0,0,-1,q,m);this.clear()};this.setClearColorHex=function($,qa){C.setHex($);B=qa;E.set(-q,-m,q,m);n.setTransform(1,0,0,-1,q,m);this.clear()};this.clear=function(){n.setTransform(1,
0,0,-1,q,m);if(!E.isEmpty()){E.inflate(1);E.minSelf(K);if(C.hex==0&&B==0)n.clearRect(E.getX(),E.getY(),E.getWidth(),E.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*255)+","+B+")";n.fillRect(E.getX(),E.getY(),E.getWidth(),E.getHeight())}E.empty()}};this.render=function($,qa){function na(D){var X,S,G,Q=D.lights;ca.setRGB(0,0,0);ga.setRGB(0,0,0);Z.setRGB(0,0,0);D=0;for(X=Q.length;D<X;D++){S=Q[D];G=S.color;if(S instanceof
THREE.AmbientLight){ca.r+=G.r;ca.g+=G.g;ca.b+=G.b}else if(S instanceof THREE.DirectionalLight){ga.r+=G.r;ga.g+=G.g;ga.b+=G.b}else if(S instanceof THREE.PointLight){Z.r+=G.r;Z.g+=G.g;Z.b+=G.b}}}function za(D,X,S,G){var Q,ba,ia,ma,oa=D.lights;D=0;for(Q=oa.length;D<Q;D++){ba=oa[D];ia=ba.color;ma=ba.intensity;if(ba instanceof THREE.DirectionalLight){ba=S.dot(ba.position)*ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}else if(ba instanceof THREE.PointLight){W.sub(ba.position,X);W.normalize();ba=S.dot(W)*
ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}}}function Fa(D,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);var G,Q,ba,ia,ma,oa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){ia=S.map.image;ma=ia.width>>1;oa=ia.height>>1;Q=X.scale.x*q;ba=X.scale.y*m;S=Q*ma;G=ba*oa;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(!K.instersects(A))return;n.save();n.translate(D.x,D.y);n.rotate(-X.rotation);n.scale(Q,-ba);n.translate(-ma,-oa);n.drawImage(ia,0,0);n.restore()}n.beginPath();n.moveTo(D.x-
10,D.y);n.lineTo(D.x+10,D.y);n.moveTo(D.x,D.y-10);n.lineTo(D.x,D.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(N){T.r=ca.r+ga.r+Z.r;T.g=ca.g+ga.g+Z.g;T.b=ca.b+ga.b+Z.b;M.r=S.color.r*T.r;M.g=S.color.g*T.g;M.b=S.color.b*T.b;M.updateStyleString()}else M.__styleString=S.color.__styleString;S=X.scale.x*q;G=X.scale.y*m;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(K.instersects(A)){Q=M.__styleString;if(H!=Q)n.fillStyle=H=Q;n.save();n.translate(D.x,
D.y);n.rotate(-X.rotation);n.scale(S,G);n.beginPath();n.arc(0,0,1,0,ka,true);n.closePath();n.fill();n.restore()}}}}function Aa(D,X,S,G){if(G.opacity!=0){a(G.opacity);c(G.blending);n.beginPath();n.moveTo(D.positionScreen.x,D.positionScreen.y);n.lineTo(X.positionScreen.x,X.positionScreen.y);n.closePath();if(G instanceof THREE.LineBasicMaterial){M.__styleString=G.color.__styleString;D=G.linewidth;if(I!=D)n.lineWidth=I=D;D=M.__styleString;if(b!=D)n.strokeStyle=b=D;n.stroke();A.inflate(G.linewidth*2)}}}
function Da(D,X,S,G,Q,ba){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);J=D.positionScreen.x;O=D.positionScreen.y;Y=X.positionScreen.x;P=X.positionScreen.y;L=S.positionScreen.x;V=S.positionScreen.y;n.beginPath();n.moveTo(J,O);n.lineTo(Y,P);n.lineTo(L,V);n.lineTo(J,O);n.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&ja(J,O,Y,P,L,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
THREE.SphericalReflectionMapping){D=qa.matrix;W.copy(G.vertexNormalsWorld[0]);z=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;r=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[1]);t=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;v=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[2]);w=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;y=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;ja(J,O,Y,P,L,V,Q.env_map.image,z,r,t,v,w,y)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):
Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&ja(J,O,Y,P,L,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);c(THREE.SubtractiveBlending)}if(N)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==3){U.r=d.r=h.r=ca.r;U.g=d.g=h.g=ca.g;U.b=d.b=h.b=ca.b;za(ba,G.v1.positionWorld,G.vertexNormalsWorld[0],U);za(ba,G.v2.positionWorld,G.vertexNormalsWorld[1],
d);za(ba,G.v3.positionWorld,G.vertexNormalsWorld[2],h);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;o=Ga(U,d,h,i);ja(J,O,Y,P,L,V,o,0,0,1,0,0,1)}else{T.r=ca.r;T.g=ca.g;T.b=ca.b;za(ba,G.centroidWorld,G.normalWorld,T);M.r=Q.color.r*T.r;M.g=Q.color.g*T.g;M.b=Q.color.b*T.b;M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){j=
qa.near;g=qa.far;U.r=U.g=U.b=1-Ha(D.positionScreen.z,j,g);d.r=d.g=d.b=1-Ha(X.positionScreen.z,j,g);h.r=h.g=h.b=1-Ha(S.positionScreen.z,j,g);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;o=Ga(U,d,h,i);ja(J,O,Y,P,L,V,o,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Ia(G.normalWorld.x);M.g=Ia(G.normalWorld.y);M.b=Ia(G.normalWorld.z);M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}}}function Ba(D,X){if(b!=D)n.strokeStyle=b=D;if(I!=
X)n.lineWidth=I=X;n.stroke();A.inflate(X*2)}function Ca(D){if(H!=D)n.fillStyle=H=D;n.fill()}function ja(D,X,S,G,Q,ba,ia,ma,oa,wa,ra,xa,Ja){var ta,ya;ta=ia.width-1;ya=ia.height-1;ma*=ta;oa*=ya;wa*=ta;ra*=ya;xa*=ta;Ja*=ya;S-=D;G-=X;Q-=D;ba-=X;wa-=ma;ra-=oa;xa-=ma;Ja-=oa;ta=wa*Ja-xa*ra;if(ta!=0){ya=1/ta;ta=(Ja*S-ra*Q)*ya;ra=(Ja*G-ra*ba)*ya;S=(wa*Q-xa*S)*ya;G=(wa*ba-xa*G)*ya;D=D-ta*ma-S*oa;X=X-ra*ma-G*oa;n.save();n.transform(ta,ra,S,G,D,X);n.clip();n.drawImage(ia,0,0);n.restore()}}function Ga(D,X,S,G){var Q=
~~(D.r*255),ba=~~(D.g*255);D=~~(D.b*255);var ia=~~(X.r*255),ma=~~(X.g*255);X=~~(X.b*255);var oa=~~(S.r*255),wa=~~(S.g*255);S=~~(S.b*255);var ra=~~(G.r*255),xa=~~(G.g*255);G=~~(G.b*255);ea[0]=Q<0?0:Q>255?255:Q;ea[1]=ba<0?0:ba>255?255:ba;ea[2]=D<0?0:D>255?255:D;ea[4]=ia<0?0:ia>255?255:ia;ea[5]=ma<0?0:ma>255?255:ma;ea[6]=X<0?0:X>255?255:X;ea[8]=oa<0?0:oa>255?255:oa;ea[9]=wa<0?0:wa>255?255:wa;ea[10]=S<0?0:S>255?255:S;ea[12]=ra<0?0:ra>255?255:ra;ea[13]=xa<0?0:xa>255?255:xa;ea[14]=G<0?0:G>255?255:G;sa.putImageData(va,
0,0);fa.drawImage(da,0,0);return aa}function Ha(D,X,S){D=(D-X)/(S-X);return D*D*(3-2*D)}function Ia(D){D=(D+1)*0.5;return D<0?0:D>1?1:D}function Ka(D,X){var S=X.x-D.x,G=X.y-D.y,Q=1/Math.sqrt(S*S+G*G);S*=Q;G*=Q;X.x+=S;X.y+=G;D.x-=S;D.y-=G}var pa,Na,ha,ua,Ea,Ma,Oa,La;this.autoClear?this.clear():n.setTransform(1,0,0,-1,q,m);e=f.projectScene($,qa,this.sortElements);n.fillStyle="rgba( 0, 255, 255, 0.5 )";n.fillRect(K.getX(),K.getY(),K.getWidth(),K.getHeight());(N=$.lights.length>0)&&na($);pa=0;for(Na=
e.length;pa<Na;pa++){ha=e[pa];A.empty();if(ha instanceof THREE.RenderableParticle){s=ha;s.x*=q;s.y*=m;ua=0;for(Ea=ha.materials.length;ua<Ea;ua++)Fa(s,ha,ha.materials[ua],$)}else if(ha instanceof THREE.RenderableLine){s=ha.v1;R=ha.v2;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;A.addPoint(s.positionScreen.x,s.positionScreen.y);A.addPoint(R.positionScreen.x,R.positionScreen.y);if(K.instersects(A)){ua=0;for(Ea=ha.materials.length;ua<Ea;)Aa(s,R,ha,ha.materials[ua++],
$)}}else if(ha instanceof THREE.RenderableFace3){s=ha.v1;R=ha.v2;F=ha.v3;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;F.positionScreen.x*=q;F.positionScreen.y*=m;if(ha.overdraw){Ka(s.positionScreen,R.positionScreen);Ka(R.positionScreen,F.positionScreen);Ka(F.positionScreen,s.positionScreen)}A.add3Points(s.positionScreen.x,s.positionScreen.y,R.positionScreen.x,R.positionScreen.y,F.positionScreen.x,F.positionScreen.y);if(K.instersects(A)){ua=0;for(Ea=ha.meshMaterials.length;ua<
Ea;){La=ha.meshMaterials[ua++];if(La instanceof THREE.MeshFaceMaterial){Ma=0;for(Oa=ha.faceMaterials.length;Ma<Oa;)(La=ha.faceMaterials[Ma++])&&Da(s,R,F,ha,La,$)}else Da(s,R,F,ha,La,$)}}}E.addRectangle(A)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(E.getX(),E.getY(),E.getWidth(),E.getHeight());n.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(z,r,t){var v,w,y,K;v=0;for(w=z.lights.length;v<w;v++){y=z.lights[v];if(y instanceof THREE.DirectionalLight){K=r.normalWorld.dot(y.position)*y.intensity;if(K>0){t.r+=y.color.r*K;t.g+=y.color.g*K;t.b+=y.color.b*K}}else if(y instanceof THREE.PointLight){V.sub(y.position,r.centroidWorld);V.normalize();K=r.normalWorld.dot(V)*y.intensity;if(K>0){t.r+=y.color.r*K;t.g+=y.color.g*K;t.b+=y.color.b*K}}}}function c(z,r,t,v,w,y){h=f(i++);h.setAttribute("d","M "+z.positionScreen.x+
" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(y,v,J);F.r=w.color.r*J.r;F.g=w.color.g*J.g;F.b=w.color.b*J.b;F.updateStyleString()}else F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){L=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear);
F.setRGB(L,L,L)}else w instanceof THREE.MeshNormalMaterial&&F.setRGB(k(v.normalWorld.x),k(v.normalWorld.y),k(v.normalWorld.z));w.wireframe?h.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):h.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+w.opacity);q.appendChild(h)}function e(z,r,t,v,w,y,K){h=f(i++);h.setAttribute("d",
"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)F.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(K,w,J);F.r=y.color.r*J.r;F.g=y.color.g*J.g;F.b=y.color.b*J.b;F.updateStyleString()}else F.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){L=
1-y.__2near/(y.__farPlusNear-w.z*y.__farMinusNear);F.setRGB(L,L,L)}else y instanceof THREE.MeshNormalMaterial&&F.setRGB(k(w.normalWorld.x),k(w.normalWorld.y),k(w.normalWorld.z));y.wireframe?h.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):h.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+y.opacity);q.appendChild(h)}
function f(z){if(M[z]==null){M[z]=document.createElementNS("http://www.w3.org/2000/svg","path");o==0&&M[z].setAttribute("shape-rendering","crispEdges");return M[z]}return M[z]}function k(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var l=null,p=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,C,B,u,x,b,H,I=new THREE.Rectangle,s=new THREE.Rectangle,R=false,F=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0),Y=new THREE.Color(0),
P=new THREE.Color(0),L,V=new THREE.Vector3,M=[],U=[],d=[],h,i,j,g,o=1;this.domElement=q;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":o=1;break;case "low":o=0}};this.setSize=function(z,r){m=z;n=r;C=m/2;B=n/2;q.setAttribute("viewBox",-C+" "+-B+" "+m+" "+n);q.setAttribute("width",m);q.setAttribute("height",n);I.set(-C,-B,C,B)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(z,r){var t,v,
w,y,K,E,A,N;this.autoClear&&this.clear();l=p.projectScene(z,r,this.sortElements);g=j=i=0;if(R=z.lights.length>0){A=z.lights;O.setRGB(0,0,0);Y.setRGB(0,0,0);P.setRGB(0,0,0);t=0;for(v=A.length;t<v;t++){w=A[t];y=w.color;if(w instanceof THREE.AmbientLight){O.r+=y.r;O.g+=y.g;O.b+=y.b}else if(w instanceof THREE.DirectionalLight){Y.r+=y.r;Y.g+=y.g;Y.b+=y.b}else if(w instanceof THREE.PointLight){P.r+=y.r;P.g+=y.g;P.b+=y.b}}}t=0;for(v=l.length;t<v;t++){A=l[t];s.empty();if(A instanceof THREE.RenderableParticle){u=
A;u.x*=C;u.y*=-B;w=0;for(y=A.materials.length;w<y;w++)if(N=A.materials[w]){K=u;E=A;N=N;var T=j++;if(U[T]==null){U[T]=document.createElementNS("http://www.w3.org/2000/svg","circle");o==0&&U[T].setAttribute("shape-rendering","crispEdges")}h=U[T];h.setAttribute("cx",K.x);h.setAttribute("cy",K.y);h.setAttribute("r",E.scale.x*C);if(N instanceof THREE.ParticleCircleMaterial){if(R){J.r=O.r+Y.r+P.r;J.g=O.g+Y.g+P.g;J.b=O.b+Y.b+P.b;F.r=N.color.r*J.r;F.g=N.color.g*J.g;F.b=N.color.b*J.b;F.updateStyleString()}else F=
N.color;h.setAttribute("style","fill: "+F.__styleString)}q.appendChild(h)}}else if(A instanceof THREE.RenderableLine){u=A.v1;x=A.v2;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.materials.length;w<y;)if(N=A.materials[w++]){K=u;E=x;N=N;T=g++;if(d[T]==null){d[T]=document.createElementNS("http://www.w3.org/2000/svg","line");o==
0&&d[T].setAttribute("shape-rendering","crispEdges")}h=d[T];h.setAttribute("x1",K.positionScreen.x);h.setAttribute("y1",K.positionScreen.y);h.setAttribute("x2",E.positionScreen.x);h.setAttribute("y2",E.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){F.__styleString=N.color.__styleString;h.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);q.appendChild(h)}}}}else if(A instanceof
THREE.RenderableFace3){u=A.v1;x=A.v2;b=A.v3;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){K=0;for(E=A.faceMaterials.length;K<E;)(N=A.faceMaterials[K++])&&
c(u,x,b,A,N,z)}else N&&c(u,x,b,A,N,z)}}}else if(A instanceof THREE.RenderableFace4){u=A.v1;x=A.v2;b=A.v3;H=A.v4;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;H.positionScreen.x*=C;H.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){w=
0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){K=0;for(E=A.faceMaterials.length;K<E;)(N=A.faceMaterials[K++])&&e(u,x,b,H,A,N,z)}else N&&e(u,x,b,H,A,N,z)}}}}}};
THREE.WebGLRenderer=function(a){function c(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function e(d,h){if(!d.__webGLVertexBuffer)d.__webGLVertexBuffer=b.createBuffer();if(!d.__webGLNormalBuffer)d.__webGLNormalBuffer=b.createBuffer();if(d.hasPos){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.position);b.vertexAttribPointer(h.attributes.position,
3,b.FLOAT,false,0,0)}if(d.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,d.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.normal);b.vertexAttribPointer(h.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,d.count);d.count=0}function f(d){if(s!=d.doubleSided){d.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);s=d.doubleSided}if(R!=d.flipSided){d.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);R=d.flipSided}}function k(d){J[0].set(d.n41-
d.n11,d.n42-d.n12,d.n43-d.n13,d.n44-d.n14);J[1].set(d.n41+d.n11,d.n42+d.n12,d.n43+d.n13,d.n44+d.n14);J[2].set(d.n41+d.n21,d.n42+d.n22,d.n43+d.n23,d.n44+d.n24);J[3].set(d.n41-d.n21,d.n42-d.n22,d.n43-d.n23,d.n44-d.n24);J[4].set(d.n41-d.n31,d.n42-d.n32,d.n43-d.n33,d.n44-d.n34);J[5].set(d.n41+d.n31,d.n42+d.n32,d.n43+d.n33,d.n44+d.n34);var h;for(d=0;d<5;d++){h=J[d];h.divideScalar(Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z))}}function l(d){for(var h=d.matrix,i=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,
Math.max(d.scale.y,d.scale.z)),j=0;j<6;j++){d=J[j].x*h.n14+J[j].y*h.n24+J[j].z*h.n34+J[j].w;if(d<=i)return false}return true}function p(d,h){d.list[d.count]=h;d.count+=1}function q(d){var h,i,j=d.object,g=d.opaque,o=d.transparent;o.count=0;d=g.count=0;for(h=j.materials.length;d<h;d++){i=j.materials[d];i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?p(o,i):p(g,i)}}function m(d){var h,i,j,g,o=d.object,z=d.buffer,r=d.opaque,t=d.transparent;t.count=0;d=r.count=0;for(j=o.materials.length;d<j;d++){h=
o.materials[d];if(h instanceof THREE.MeshFaceMaterial){h=0;for(i=z.materials.length;h<i;h++)if(g=z.materials[h])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}else{g=h;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}}}function n(d){if(d!=F){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}F=d}}function C(d,h){if(d&&!d.__webGLFramebuffer){d.__webGLFramebuffer=b.createFramebuffer();d.__webGLRenderbuffer=b.createRenderbuffer();d.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,d.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,d.width,d.height);b.bindTexture(b.TEXTURE_2D,d.__webGLTexture);b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_WRAP_S,u(d.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(d.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(d.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(d.min_filter));b.texImage2D(b.TEXTURE_2D,0,u(d.format),d.width,d.height,0,u(d.format),u(d.type),null);b.bindFramebuffer(b.FRAMEBUFFER,d.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,d.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,
b.RENDERBUFFER,d.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var i,j,g;if(d){i=d.__webGLFramebuffer;j=d.width;g=d.height}else{i=null;j=x.width;g=x.height}if(i!=I){b.bindFramebuffer(b.FRAMEBUFFER,i);b.viewport(0,0,j,g);h&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);I=i}}function B(d,h){var i;if(d=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(d=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,
h);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function u(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 x=document.createElement("canvas"),b,H=null,I=null,s=null,R=null,F=null,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Matrix4,Y=new Float32Array(16),P=new Float32Array(16),L=new THREE.Vector4,V=true,M=new THREE.Color(0),U=0;if(a){if(a.antialias!==undefined)V=a.antialias;a.clearColor!==undefined&&M.setHex(a.clearColor);
if(a.clearAlpha!==undefined)U=a.clearAlpha}this.domElement=x;this.autoClear=true;(function(d,h,i){try{b=x.getContext("experimental-webgl",{antialias:d})}catch(j){console.log(j)}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,i);_cullEnabled=true})(V,
M,U);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(d,h){x.width=d;x.height=h;b.viewport(0,0,x.width,x.height)};this.setClearColorHex=function(d,h){var i=new THREE.Color(d);b.clearColor(i.r,i.g,i.b,h)};this.setClearColor=function(d,h){b.clearColor(d.r,d.g,d.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var i,j,g,o=0,z=0,r=0,t,v,w,y=
this.lights,K=y.directional.colors,E=y.directional.positions,A=y.point.colors,N=y.point.positions,T=0,ca=0;i=g=g=0;for(j=h.length;i<j;i++){g=h[i];t=g.color;v=g.position;w=g.intensity;if(g instanceof THREE.AmbientLight){o+=t.r;z+=t.g;r+=t.b}else if(g instanceof THREE.DirectionalLight){g=T*3;K[g]=t.r*w;K[g+1]=t.g*w;K[g+2]=t.b*w;E[g]=v.x;E[g+1]=v.y;E[g+2]=v.z;T+=1}else if(g instanceof THREE.PointLight){g=ca*3;A[g]=t.r*w;A[g+1]=t.g*w;A[g+2]=t.b*w;N[g]=v.x;N[g+1]=v.y;N[g+2]=v.z;ca+=1}}for(i=T*3;i<K.length;i++)K[i]=
0;for(i=ca*3;i<A.length;i++)A[i]=0;y.point.length=ca;y.directional.length=T;y.ambient[0]=o;y.ambient[1]=z;y.ambient[2]=r};this.createParticleBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLNormalBuffer=b.createBuffer();d.__webGLTangentBuffer=b.createBuffer();
d.__webGLColorBuffer=b.createBuffer();d.__webGLUVBuffer=b.createBuffer();d.__webGLUV2Buffer=b.createBuffer();d.__webGLFaceBuffer=b.createBuffer();d.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__webGLLineCount=h};this.initParticleBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__sortArray=[];d.__webGLParticleCount=
h};this.initMeshBuffers=function(d,h){var i,j,g=0,o=0,z=0,r=h.geometry.faces,t=d.faces;i=0;for(j=t.length;i<j;i++){fi=t[i];face=r[fi];if(face instanceof THREE.Face3){g+=3;o+=1;z+=3}else if(face instanceof THREE.Face4){g+=4;o+=2;z+=4}}d.__vertexArray=new Float32Array(g*3);d.__normalArray=new Float32Array(g*3);d.__tangentArray=new Float32Array(g*4);d.__colorArray=new Float32Array(g*3);d.__uvArray=new Float32Array(g*2);d.__uv2Array=new Float32Array(g*2);d.__faceArray=new Uint16Array(o*3);d.__lineArray=
new Uint16Array(z*2);g=false;i=0;for(j=h.materials.length;i<j;i++){r=h.materials[i];if(r instanceof THREE.MeshFaceMaterial){r=0;for(t=d.materials.length;r<t;r++)if(d.materials[r]&&d.materials[r].shading!=undefined&&d.materials[r].shading==THREE.SmoothShading){g=true;break}}else if(r&&r.shading!=undefined&&r.shading==THREE.SmoothShading){g=true;break}if(g)break}d.__needsSmoothNormals=g;d.__webGLFaceCount=o*3;d.__webGLLineCount=z*2};this.setMeshBuffers=function(d,h,i){var j,g,o,z,r,t,v,w,y,K,E=0,A=
0,N=0,T=0,ca=0,ga=0,Z=0,ka=0,W=0,da=d.__vertexArray,sa=d.__uvArray,va=d.__uv2Array,ea=d.__normalArray,aa=d.__tangentArray,fa=d.__colorArray,la=d.__faceArray,$=d.__lineArray,qa=d.__needsSmoothNormals,na=h.geometry,za=na.__dirtyVertices,Fa=na.__dirtyElements,Aa=na.__dirtyUvs,Da=na.__dirtyNormals,Ba=na.__dirtyTangents,Ca=na.__dirtyColors,ja=na.vertices,Ga=d.faces,Ha=na.faces,Ia=na.uvs,Ka=na.uvs2,pa=na.colors;h=0;for(j=Ga.length;h<j;h++){g=Ga[h];o=Ha[g];t=Ia[g];g=Ka[g];z=o.vertexNormals;r=o.normal;if(o instanceof
THREE.Face3){if(za){v=ja[o.a].position;w=ja[o.b].position;y=ja[o.c].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;A+=9}if(Ca&&pa.length){v=pa[o.a];w=pa[o.b];y=pa[o.c];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;W+=9}if(Ba&&na.hasTangents){v=ja[o.a].tangent;w=ja[o.b].tangent;y=ja[o.c].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=
w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;Z+=12}if(Da)if(z.length==3&&qa)for(o=0;o<3;o++){r=z[o];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(o=0;o<3;o++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(o=0;o<3;o++){z=t[o];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(o=0;o<3;o++){t=g[o];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=E;la[ca+1]=E+1;la[ca+2]=E+2;ca+=3;$[ka]=E;$[ka+1]=E+1;$[ka+2]=E;$[ka+3]=E+2;$[ka+4]=E+1;$[ka+5]=E+2;ka+=6;E+=3}}else if(o instanceof THREE.Face4){if(za){v=
ja[o.a].position;w=ja[o.b].position;y=ja[o.c].position;K=ja[o.d].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;da[A+9]=K.x;da[A+10]=K.y;da[A+11]=K.z;A+=12}if(Ca&&pa.length){v=pa[o.a];w=pa[o.b];y=pa[o.c];K=pa[o.d];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;fa[W+9]=K.r;fa[W+10]=K.g;fa[W+11]=K.b;W+=12}if(Ba&&na.hasTangents){v=ja[o.a].tangent;w=ja[o.b].tangent;y=ja[o.c].tangent;
o=ja[o.d].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;aa[Z+12]=o.x;aa[Z+13]=o.y;aa[Z+14]=o.z;aa[Z+15]=o.w;Z+=16}if(Da)if(z.length==4&&qa)for(o=0;o<4;o++){r=z[o];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(o=0;o<4;o++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(o=0;o<4;o++){z=t[o];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(o=0;o<4;o++){t=g[o];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=
E;la[ca+1]=E+1;la[ca+2]=E+2;la[ca+3]=E;la[ca+4]=E+2;la[ca+5]=E+3;ca+=6;$[ka]=E;$[ka+1]=E+1;$[ka+2]=E;$[ka+3]=E+3;$[ka+4]=E+1;$[ka+5]=E+2;$[ka+6]=E+2;$[ka+7]=E+3;ka+=8;E+=4}}}if(za){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,da,i)}if(Ca&&pa.length){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,fa,i)}if(Da){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ea,i)}if(Ba&&na.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,
d.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,aa,i)}if(Aa&&N>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,sa,i)}if(Aa&&T>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,va,i)}if(Fa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,la,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,$,i)}};this.setLineBuffers=function(d,h){var i,j,g,o=d.vertices,
z=d.colors,r=o.length,t=z.length,v=d.__vertexArray,w=d.__colorArray,y=d.__dirtyColors;if(d.__dirtyVertices){for(i=0;i<r;i++){j=o[i].position;g=i*3;v[g]=j.x;v[g+1]=j.y;v[g+2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,h)}if(y){for(i=0;i<t;i++){color=z[i];g=i*3;w[g]=color.r;w[g+1]=color.g;w[g+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}};this.setParticleBuffers=function(d,h,i){var j,g,o,z=d.vertices,r=z.length,
t=d.colors,v=t.length,w=d.__vertexArray,y=d.__colorArray,K=d.__sortArray,E=d.__dirtyVertices,A=d.__dirtyColors;if(i.sortParticles){O.multiplySelf(i.matrix);for(j=0;j<r;j++){g=z[j].position;L.copy(g);O.multiplyVector3(L);K[j]=[L.z,j]}K.sort(function(N,T){return T[0]-N[0]});for(j=0;j<r;j++){g=z[K[j][1]].position;o=j*3;w[o]=g.x;w[o+1]=g.y;w[o+2]=g.z}for(j=0;j<v;j++){o=j*3;color=t[K[j][1]];y[o]=color.r;y[o+1]=color.g;y[o+2]=color.b}}else{if(E)for(j=0;j<r;j++){g=z[j].position;o=j*3;w[o]=g.x;w[o+1]=g.y;
w[o+2]=g.z}if(A)for(j=0;j<v;j++){color=t[j];o=j*3;y[o]=color.r;y[o+1]=color.g;y[o+2]=color.b}}if(E||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}if(A||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,y,h)}};this.initMaterial=function(d,h,i){var j,g;if(d instanceof THREE.MeshDepthMaterial)c(d,THREE.ShaderLib.depth);else if(d instanceof THREE.MeshNormalMaterial)c(d,THREE.ShaderLib.normal);else if(d instanceof
THREE.MeshBasicMaterial)c(d,THREE.ShaderLib.basic);else if(d instanceof THREE.MeshLambertMaterial)c(d,THREE.ShaderLib.lambert);else if(d instanceof THREE.MeshPhongMaterial)c(d,THREE.ShaderLib.phong);else if(d instanceof THREE.LineBasicMaterial)c(d,THREE.ShaderLib.basic);else d instanceof THREE.ParticleBasicMaterial&&c(d,THREE.ShaderLib.particle_basic);var o,z,r,t;g=r=t=0;for(o=h.length;g<o;g++){z=h[g];z instanceof THREE.DirectionalLight&&r++;z instanceof THREE.PointLight&&t++}if(t+r<=4){h=r;t=t}else{h=
Math.ceil(4*r/(t+r));t=4-h}g={directional:h,point:t};t=d.fragment_shader;h=d.vertex_shader;o={fog:i,map:d.map,env_map:d.env_map,light_map:d.light_map,vertex_colors:d.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};i=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+o.maxDirLights,"#define MAX_POINT_LIGHTS "+o.maxPointLights,o.fog?"#define USE_FOG":"",o.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.env_map?
"#define USE_ENVMAP":"",o.light_map?"#define USE_LIGHTMAP":"",o.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");o=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+o.maxDirLights,"#define MAX_POINT_LIGHTS "+o.maxPointLights,o.map?"#define USE_MAP":"",o.env_map?"#define USE_ENVMAP":"",o.light_map?"#define USE_LIGHTMAP":"",o.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
b.attachShader(i,B("fragment",g+t));b.attachShader(i,B("vertex",o+h));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};d.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in d.uniforms)i.push(j);j=d.program;t=0;for(h=i.length;t<h;t++){g=i[t];j.uniforms[g]=b.getUniformLocation(j,
g)}d=d.program;j=["position","normal","uv","uv2","tangent","color"];i=0;for(t=j.length;i<t;i++){h=j[i];d.attributes[h]=b.getAttribLocation(d,h)}};this.setProgram=function(d,h,i,j,g){j.program||this.initMaterial(j,h,i);var o=j.program,z=o.uniforms,r=j.uniforms;if(o!=H){b.useProgram(o);H=o;b.uniformMatrix4fv(z.projectionMatrix,false,Y)}if(i&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof
THREE.ParticleBasicMaterial)){r.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){r.fogNear.value=i.near;r.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)r.fogDensity.value=i.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(o,h);h=this.lights;r.enableLighting.value=h.directional.length+h.point.length;r.ambientLightColor.value=h.ambient;r.directionalLightColor.value=h.directional.colors;r.directionalLightDirection.value=h.directional.positions;
r.pointLightColor.value=h.point.colors;r.pointLightPosition.value=h.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.map.texture=j.map;r.light_map.texture=j.light_map;r.env_map.texture=j.env_map;r.reflectivity.value=j.reflectivity;r.refraction_ratio.value=j.refraction_ratio;r.combine.value=j.combine;r.useRefract.value=
j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){r.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.size.value=j.size;r.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){r.ambient.value.setRGB(j.ambient.r,j.ambient.g,
j.ambient.b);r.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);r.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){r.mNear.value=d.near;r.mFar.value=d.far;r.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)r.opacity.value=j.opacity;var t,v,w;for(t in r)if(w=o.uniforms[t]){i=r[t];v=i.type;h=i.value;if(v=="i")b.uniform1i(w,h);else if(v=="f")b.uniform1f(w,h);else if(v=="fv1")b.uniform1fv(w,h);else if(v=="fv")b.uniform3fv(w,h);else if(v=="v2")b.uniform2f(w,
h.x,h.y);else if(v=="v3")b.uniform3f(w,h.x,h.y,h.z);else if(v=="c")b.uniform3f(w,h.r,h.g,h.b);else if(v=="t"){b.uniform1i(w,h);if(i=i.texture)if(i.image instanceof Array&&i.image.length==6){i=i;h=h;if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(v=0;v<6;++v)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image[v]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}else{i=i;h=h;if(!i.__webGLTexture&&
i.image.loaded){i.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,u(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(i.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
h);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture)}}}b.uniformMatrix4fv(z.modelViewMatrix,false,g._modelViewMatrixArray);b.uniformMatrix3fv(z.normalMatrix,false,g._normalMatrixArray);if(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)b.uniform3f(z.cameraPosition,d.position.x,d.position.y,d.position.z);if(j instanceof THREE.MeshShaderMaterial||j.env_map)b.uniformMatrix4fv(z.objectMatrix,false,g._objectMatrixArray);if(j instanceof THREE.MeshPhongMaterial||j instanceof
THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(z.viewMatrix,false,P);return o};this.renderBuffer=function(d,h,i,j,g,o){d=this.setProgram(d,h,i,j,o).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=
0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=
0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(o instanceof THREE.Mesh)if(j.wireframe){b.lineWidth(j.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,
0)}else if(o instanceof THREE.Line){o=o.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(j.linewidth);b.drawArrays(o,0,g.__webGLLineCount)}else o instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(d,h,i,j){var g,o,z,r,t,v,w,y=d.lights,K=d.fog;h.autoUpdateMatrix&&h.updateMatrix();h.matrix.flattenToArray(P);h.projectionMatrix.flattenToArray(Y);O.multiply(h.projectionMatrix,h.matrix);k(O);this.initWebGLObjects(d,h);C(i,j!==undefined?j:true);this.autoClear&&
this.clear();r=d.__webGLObjects.length;for(j=0;j<r;j++){g=d.__webGLObjects[j];v=g.object;if(v.visible&&(!(v instanceof THREE.Mesh)||l(v))){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,h);m(g);g.render=true}else g.render=false}t=d.__webGLObjectsImmediate.length;for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,
h);q(g)}}n(THREE.NormalBlending);for(j=0;j<r;j++){g=d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(h,y,K,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);o=this.setProgram(h,y,K,material,v);v.render(function(E){e(E,o)})}}}for(j=0;j<r;j++){g=
d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];n(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(h,y,K,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];n(material.blending);this.setDepthTest(material.depth_test);o=this.setProgram(h,y,K,material,v);v.render(function(E){e(E,o)})}}}if(i&&i.min_filter!==
THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d,h){function i(y,K,E,A){if(y[K]==undefined){d.__webGLObjects.push({buffer:E,object:A,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[K]=1}}function j(y,K,E){if(y[K]==undefined){d.__webGLObjectsImmediate.push({object:E,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[K]=1}}var g,o,
z,r,t,v,w;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}g=0;for(o=d.objects.length;g<o;g++){z=d.objects[g];t=z.geometry;if(d.__webGLObjectsMap[z.id]==undefined){d.__webGLObjectsMap[z.id]={};z._modelViewMatrix=new THREE.Matrix4;z._normalMatrixArray=new Float32Array(9);z._modelViewMatrixArray=new Float32Array(16);z._objectMatrixArray=new Float32Array(16);z.matrix.flattenToArray(z._objectMatrixArray)}w=d.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(r in t.geometryChunks){v=
t.geometryChunks[r];if(!v.__webGLVertexBuffer){this.createMeshBuffers(v);this.initMeshBuffers(v,z);t.__dirtyVertices=true;t.__dirtyElements=true;t.__dirtyUvs=true;t.__dirtyNormals=true;t.__dirtyTangents=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyElements||t.__dirtyUvs||t.__dirtyNormals||t.__dirtyColors||t.__dirtyTangents)this.setMeshBuffers(v,z,b.DYNAMIC_DRAW);i(w,r,v,z)}t.__dirtyVertices=false;t.__dirtyElements=false;t.__dirtyUvs=false;t.__dirtyNormals=false;t.__dirtyTangents=false;
t.__dirtyColors=false}else if(z instanceof THREE.Line){if(!t.__webGLVertexBuffer){this.createLineBuffers(t);this.initLineBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyColors)this.setLineBuffers(t,b.DYNAMIC_DRAW);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else if(z instanceof THREE.ParticleSystem){if(!t.__webGLVertexBuffer){this.createParticleBuffers(t);this.initParticleBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||
t.__dirtyColors||z.sortParticles)this.setParticleBuffers(t,b.DYNAMIC_DRAW,z,h);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else z instanceof THREE.MarchingCubes&&j(w,0,z)}};this.removeObject=function(d,h){var i,j;for(i=d.__webGLObjects.length-1;i>=0;i--){j=d.__webGLObjects[i].object;h==j&&d.__webGLObjects.splice(i,1)}};this.setupMatrices=function(d,h){d._modelViewMatrix.multiplyToArray(h.matrix,d.matrix,d._modelViewMatrixArray);d._normalMatrix=THREE.Matrix4.makeInvert3x3(d._modelViewMatrix).transposeIntoArray(d._normalMatrixArray)};
this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};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.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(Q,J){return J.z-Q.z}function c(Q,J){var X=0,G=1,U=Q.z+Q.w,M=J.z+J.w,D=-Q.z+Q.w,K=-J.z+J.w;if(U>=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(G<X)return false;else{Q.lerpSelf(J,X);J.lerpSelf(Q,1-G);return true}}}var d,f,j=[],k,q,o,l=[],m,z,y=[],v,x,F=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
O=new THREE.Matrix4,C=[],b=new THREE.Vector4,R=new THREE.Vector4,$;this.projectObjects=function(Q,J,X){var G=[],U,M;f=0;s.multiply(J.projectionMatrix,J.matrix);C[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);C[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);C[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);C[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);C[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);C[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);J=0;for(U=C.length;J<U;J++){M=C[J];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}U=Q.objects;Q=0;for(J=U.length;Q<J;Q++){M=U[Q];var D;if(!(D=!M.visible)){if(D=M instanceof THREE.Mesh){a:{D=void 0;for(var K=M.position,ca=-M.geometry.boundingSphere.radius*Math.max(M.scale.x,Math.max(M.scale.y,M.scale.z)),N=0;N<6;N++){D=C[N].x*K.x+C[N].y*K.y+C[N].z*K.z+C[N].w;if(D<=ca){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
j[f]=j[f]||new THREE.RenderableObject;H.copy(M.position);s.multiplyVector3(H);d.object=M;d.z=H.z;G.push(d);f++}}X&&G.sort(a);return G};this.projectScene=function(Q,J,X){var G=[],U=J.near,M=J.far,D,K,ca,N,aa,e,i,n,h,g,t,w,u,r,p,B;o=z=x=0;J.autoUpdateMatrix&&J.updateMatrix();s.multiply(J.projectionMatrix,J.matrix);e=this.projectObjects(Q,J,true);Q=0;for(D=e.length;Q<D;Q++){i=e[Q].object;if(i.visible){i.autoUpdateMatrix&&i.updateMatrix();n=i.matrix;h=i.rotationMatrix;g=i.materials;t=i.overdraw;if(i instanceof
THREE.Mesh){w=i.geometry;u=w.vertices;K=0;for(ca=u.length;K<ca;K++){r=u[K];r.positionWorld.copy(r.position);n.multiplyVector3(r.positionWorld);N=r.positionScreen;N.copy(r.positionWorld);s.multiplyVector4(N);N.x/=N.w;N.y/=N.w;r.__visible=N.z>U&&N.z<M}w=w.faces;K=0;for(ca=w.length;K<ca;K++){r=w[K];if(r instanceof THREE.Face3){N=u[r.a];aa=u[r.b];p=u[r.c];if(N.__visible&&aa.__visible&&p.__visible)if(i.doubleSided||i.flipSided!=(p.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-
(p.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);k.v3.positionWorld.copy(p.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(p.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);n.multiplyVector3(k.centroidWorld);
k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);p=r.vertexNormals;$=k.vertexNormalsWorld;N=0;for(aa=p.length;N<aa;N++){B=$[N]=$[N]||new THREE.Vector3;B.copy(p[N]);h.multiplyVector3(B)}k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][2]}G.push(k);o++}}else if(r instanceof THREE.Face4){N=u[r.a];aa=u[r.b];p=u[r.c];B=u[r.d];if(N.__visible&&
aa.__visible&&p.__visible&&B.__visible)if(i.doubleSided||i.flipSided!=((B.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-(B.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0||(aa.positionScreen.x-p.positionScreen.x)*(B.positionScreen.y-p.positionScreen.y)-(aa.positionScreen.y-p.positionScreen.y)*(B.positionScreen.x-p.positionScreen.x)<0)){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);
k.v3.positionWorld.copy(B.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(B.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);n.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];
k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][3]}G.push(k);o++;q=l[o]=l[o]||new THREE.RenderableFace3;q.v1.positionWorld.copy(aa.positionWorld);q.v2.positionWorld.copy(p.positionWorld);q.v3.positionWorld.copy(B.positionWorld);q.v1.positionScreen.copy(aa.positionScreen);q.v2.positionScreen.copy(p.positionScreen);q.v3.positionScreen.copy(B.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
q.meshMaterials=g;q.faceMaterials=r.materials;q.overdraw=t;if(i.geometry.uvs[K]){q.uvs[0]=i.geometry.uvs[K][1];q.uvs[1]=i.geometry.uvs[K][2];q.uvs[2]=i.geometry.uvs[K][3]}G.push(q);o++}}}}else if(i instanceof THREE.Line){O.multiply(s,n);u=i.geometry.vertices;r=u[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);K=1;for(ca=u.length;K<ca;K++){N=u[K];N.positionScreen.copy(N.position);O.multiplyVector4(N.positionScreen);aa=u[K-1];b.copy(N.positionScreen);R.copy(aa.positionScreen);
if(c(b,R)){b.multiplyScalar(1/b.w);R.multiplyScalar(1/R.w);m=y[z]=y[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(b);m.v2.positionScreen.copy(R);m.z=Math.max(b.z,R.z);m.materials=i.materials;G.push(m);z++}}}else if(i instanceof THREE.Particle){I.set(i.position.x,i.position.y,i.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/
(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,m,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(m=a.length;l<m;l++){v=a[l];if(v instanceof THREE.RenderableParticle){F=v.x*j+j;H=v.y*k+k;z=0;for(y=v.material.length;z<y;z++){x=v.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(W){if(v!=W)m.globalAlpha=v=W}function c(W){if(x!=W){switch(W){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=W}}var d=null,f=new THREE.Projector,j=document.createElement("canvas"),k,q,o,l,m=j.getContext("2d"),z=new THREE.Color(0),y=0,v=1,x=0,F=null,H=null,I=1,s,O,C,b,R,$,Q,J,X,G=new THREE.Color,
U=new THREE.Color,M=new THREE.Color,D=new THREE.Color,K=new THREE.Color,ca,N,aa,e,i,n,h,g,t,w=new THREE.Rectangle,u=new THREE.Rectangle,r=new THREE.Rectangle,p=false,B=new THREE.Color,V=new THREE.Color,da=new THREE.Color,ea=new THREE.Color,ia=Math.PI*2,S=new THREE.Vector3,Y,pa,P,ka,oa,wa,fa=16;Y=document.createElement("canvas");Y.width=Y.height=2;pa=Y.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);P=pa.getImageData(0,0,2,2);ka=P.data;oa=document.createElement("canvas");oa.width=
oa.height=fa;wa=oa.getContext("2d");wa.translate(-fa/2,-fa/2);wa.scale(fa,fa);fa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(W,ba){k=W;q=ba;o=k/2;l=q/2;j.width=k;j.height=q;w.set(-o,-l,o,l);v=1;x=0;H=F=null;I=1};this.setClearColor=function(W,ba){z=W;y=ba;u.set(-o,-l,o,l);m.setTransform(1,0,0,-1,o,l);this.clear()};this.setClearColorHex=function(W,ba){z.setHex(W);y=ba;u.set(-o,-l,o,l);m.setTransform(1,0,0,-1,o,l);this.clear()};this.clear=function(){m.setTransform(1,
0,0,-1,o,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(w);if(z.hex==0&&y==0)m.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";m.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(W,ba){function Ca(A){var Z,T,E,L=A.lights;V.setRGB(0,0,0);da.setRGB(0,0,0);ea.setRGB(0,0,0);A=0;for(Z=L.length;A<Z;A++){T=L[A];E=T.color;if(T instanceof
THREE.AmbientLight){V.r+=E.r;V.g+=E.g;V.b+=E.b}else if(T instanceof THREE.DirectionalLight){da.r+=E.r;da.g+=E.g;da.b+=E.b}else if(T instanceof THREE.PointLight){ea.r+=E.r;ea.g+=E.g;ea.b+=E.b}}}function qa(A,Z,T,E){var L,ha,ra,xa,za=A.lights;A=0;for(L=za.length;A<L;A++){ha=za[A];ra=ha.color;xa=ha.intensity;if(ha instanceof THREE.DirectionalLight){ha=T.dot(ha.position)*xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)*
xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(!w.instersects(r))return;m.save();m.translate(A.x,A.y);m.rotate(-Z.rotation);m.scale(L,-ha);m.translate(-xa,-za);m.drawImage(ra,0,0);m.restore()}m.beginPath();m.moveTo(A.x-
10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r=V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)m.fillStyle=H=L;m.save();m.translate(A.x,
A.y);m.rotate(-Z.rotation);m.scale(T,E);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(Z.positionScreen.x,Z.positionScreen.y);m.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)m.lineWidth=I=A;A=G.__styleString;if(F!=A)m.strokeStyle=F=A;m.stroke();r.inflate(E.linewidth*2)}}}
function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y;m.beginPath();m.moveTo(b,R);m.lineTo($,Q);m.lineTo(J,X);m.lineTo(b,R);m.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof
THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);n=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,n,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):
va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M);
qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca=
ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z,ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)m.strokeStyle=F=
A;if(I!=Z)m.lineWidth=I=Z;m.stroke();r.inflate(Z*2)}function va(A){if(H!=A)m.fillStyle=H=A;m.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga,Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;m.save();m.transform(Ea,Ba,T,E,A,Z);m.clip();m.drawImage(ra,0,0);m.restore()}}function ma(A,
Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255);T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E>
255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());(p=W.lights.length>
0)&&Ca(W);ua=0;for(Ma=d.length;ua<Ma;ua++){ja=d[ua];r.empty();if(ja instanceof THREE.RenderableParticle){s=ja;s.x*=o;s.y*=l;ya=0;for(Fa=ja.materials.length;ya<Fa;ya++)la(s,ja,ja.materials[ya],W)}else if(ja instanceof THREE.RenderableLine){s=ja.v1;O=ja.v2;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;r.addPoint(s.positionScreen.x,s.positionScreen.y);r.addPoint(O.positionScreen.x,O.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.materials.length;ya<Fa;)na(s,
O,ja,ja.materials[ya++],W)}}else if(ja instanceof THREE.RenderableFace3){s=ja.v1;O=ja.v2;C=ja.v3;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;C.positionScreen.x*=o;C.positionScreen.y*=l;if(ja.overdraw){La(s.positionScreen,O.positionScreen);La(O.positionScreen,C.positionScreen);La(C.positionScreen,s.positionScreen)}r.add3Points(s.positionScreen.x,s.positionScreen.y,O.positionScreen.x,O.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if(w.instersects(r)){ya=
0;for(Fa=ja.meshMaterials.length;ya<Fa;){sa=ja.meshMaterials[ya++];if(sa instanceof THREE.MeshFaceMaterial){Ka=0;for(Na=ja.faceMaterials.length;Ka<Na;)(sa=ja.faceMaterials[Ka++])&&Ja(s,O,C,ja,sa,W)}else Ja(s,O,C,ja,sa,W)}}}u.addRectangle(r)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(e,i,n){var h,g,t,w;h=0;for(g=e.lights.length;h<g;h++){t=e.lights[h];if(t instanceof THREE.DirectionalLight){w=i.normalWorld.dot(t.position)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}}}function c(e,i,n,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+
" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear);
C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,n,h,g,t,w){D=f(K++);D.setAttribute("d",
"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J=
1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)}
function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0),
Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;m=i;z=l/2;y=m/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);o.setAttribute("width",l);o.setAttribute("height",m);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var n,
h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);n=0;for(h=r.length;n<h;n++){g=r[n];t=g.color;if(g instanceof THREE.AmbientLight){R.r+=t.r;R.g+=t.g;R.b+=t.b}else if(g instanceof THREE.DirectionalLight){$.r+=t.r;$.g+=t.g;$.b+=t.b}else if(g instanceof THREE.PointLight){Q.r+=t.r;Q.g+=t.g;Q.b+=t.b}}}n=0;for(h=k.length;n<h;n++){r=k[n];s.empty();if(r instanceof THREE.RenderableParticle){v=
r;v.x*=z;v.y*=-y;g=0;for(t=r.materials.length;g<t;g++)if(p=r.materials[g]){w=v;u=r;p=p;var B=ca++;if(U[B]==null){U[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");aa==0&&U[B].setAttribute("shape-rendering","crispEdges")}D=U[B];D.setAttribute("cx",w.x);D.setAttribute("cy",w.y);D.setAttribute("r",u.scale.x*z);if(p instanceof THREE.ParticleCircleMaterial){if(O){b.r=R.r+$.r+Q.r;b.g=R.g+$.g+Q.g;b.b=R.b+$.b+Q.b;C.r=p.color.r*b.r;C.g=p.color.g*b.g;C.b=p.color.b*b.b;C.updateStyleString()}else C=
p.color;D.setAttribute("style","fill: "+C.__styleString)}o.appendChild(D)}}else if(r instanceof THREE.RenderableLine){v=r.v1;x=r.v2;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.materials.length;g<t;)if(p=r.materials[g++]){w=v;u=x;p=p;B=N++;if(M[B]==null){M[B]=document.createElementNS("http://www.w3.org/2000/svg","line");aa==
0&&M[B].setAttribute("shape-rendering","crispEdges")}D=M[B];D.setAttribute("x1",w.positionScreen.x);D.setAttribute("y1",w.positionScreen.y);D.setAttribute("x2",u.positionScreen.x);D.setAttribute("y2",u.positionScreen.y);if(p instanceof THREE.LineBasicMaterial){C.__styleString=p.color.__styleString;D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+p.linewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.linecap+"; stroke-linejoin: "+p.linejoin);o.appendChild(D)}}}}else if(r instanceof
THREE.RenderableFace3){v=r.v1;x=r.v2;F=r.v3;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&
c(v,x,F,r,p,e)}else p&&c(v,x,F,r,p,e)}}}else if(r instanceof THREE.RenderableFace4){v=r.v1;x=r.v2;F=r.v3;H=r.v4;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){g=
0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&d(v,x,F,H,r,p,e)}else p&&d(v,x,F,H,r,p,e)}}}}}};
THREE.WebGLRenderer=function(a){function c(e,i,n){var h,g,t,w=e.vertices,u=w.length,r=e.colors,p=r.length,B=e.__vertexArray,V=e.__colorArray,da=e.__sortArray,ea=e.__dirtyVertices,ia=e.__dirtyColors;if(n.sortParticles){U.multiplySelf(n.matrixWorld);for(h=0;h<u;h++){g=w[h].position;K.copy(g);U.multiplyVector3(K);da[h]=[K.z,h]}da.sort(function(S,Y){return Y[0]-S[0]});for(h=0;h<u;h++){g=w[da[h][1]].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}for(h=0;h<p;h++){t=h*3;color=r[da[h][1]];V[t]=color.r;V[t+
1]=color.g;V[t+2]=color.b}}else{if(ea)for(h=0;h<u;h++){g=w[h].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}if(ia)for(h=0;h<p;h++){color=r[h];t=h*3;V[t]=color.r;V[t+1]=color.g;V[t+2]=color.b}}if(ea||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,i)}if(ia||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,V,i)}}function d(e,i){e.fragment_shader=i.fragment_shader;e.vertex_shader=i.vertex_shader;e.uniforms=
Uniforms.clone(i.uniforms)}function f(e,i){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.position);b.vertexAttribPointer(i.attributes.position,3,b.FLOAT,false,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.normal);b.vertexAttribPointer(i.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function j(e){if(Q!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);Q=e.doubleSided}if(J!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);J=e.flipSided}}function k(e){G[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);G[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+
e.n14);G[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);G[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);G[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);G[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var i;for(e=0;e<5;e++){i=G[e];i.divideScalar(Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z))}}function q(e){for(var i=e.matrix,n=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=G[h].x*i.n14+G[h].y*i.n24+G[h].z*i.n34+G[h].w;
if(e<=n)return false}return true}function o(e,i){e.list[e.count]=i;e.count+=1}function l(e){var i,n,h=e.object,g=e.opaque,t=e.transparent;t.count=0;e=g.count=0;for(i=h.materials.length;e<i;e++){n=h.materials[e];n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?o(t,n):o(g,n)}}function m(e){var i,n,h,g,t=e.object,w=e.buffer,u=e.opaque,r=e.transparent;r.count=0;e=u.count=0;for(h=t.materials.length;e<h;e++){i=t.materials[e];if(i instanceof THREE.MeshFaceMaterial){i=0;for(n=w.materials.length;i<
n;i++)if(g=w.materials[i])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}else{g=i;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}}}function z(e){var i,n,h,g=e.children;i=0;for(n=g.length;i<n;i++){h=g[i];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(e.matrixWorld,h.matrix);z(h)}}function y(e,i){var n,h,g=i.children;n=0;for(h=g.length;n<h;n++){child=g[n];v(e,child,false);y(e,child)}}function v(e,i,n){var h,g,t;g=i.geometry;if(e.__webGLObjectsMap[i.id]==
undefined){e.__webGLObjectsMap[i.id]={};i._modelViewMatrix=new THREE.Matrix4;i._normalMatrixArray=new Float32Array(9);i._modelViewMatrixArray=new Float32Array(16);i._objectMatrixArray=new Float32Array(16);i.matrix.flattenToArray(i._objectMatrixArray)}t=e.__webGLObjectsMap[i.id];objlist=e.__webGLObjects;if(i instanceof THREE.Mesh){for(h in g.geometryChunks){e=g.geometryChunks[h];if(!e.__webGLVertexBuffer){var w=e;w.__webGLVertexBuffer=b.createBuffer();w.__webGLNormalBuffer=b.createBuffer();w.__webGLTangentBuffer=
b.createBuffer();w.__webGLColorBuffer=b.createBuffer();w.__webGLUVBuffer=b.createBuffer();w.__webGLUV2Buffer=b.createBuffer();w.__webGLFaceBuffer=b.createBuffer();w.__webGLLineBuffer=b.createBuffer();w=e;var u=i,r=void 0,p=void 0,B=0,V=0,da=0,ea=u.geometry.faces,ia=w.faces;r=0;for(p=ia.length;r<p;r++){fi=ia[r];face=ea[fi];if(face instanceof THREE.Face3){B+=3;V+=1;da+=3}else if(face instanceof THREE.Face4){B+=4;V+=2;da+=4}}w.__vertexArray=new Float32Array(B*3);w.__normalArray=new Float32Array(B*3);
w.__tangentArray=new Float32Array(B*4);w.__colorArray=new Float32Array(B*3);w.__uvArray=new Float32Array(B*2);w.__uv2Array=new Float32Array(B*2);w.__faceArray=new Uint16Array(V*3);w.__lineArray=new Uint16Array(da*2);p=r=w;u=u;B=void 0;ea=void 0;var S=void 0,Y=void 0;S=void 0;ia=false;B=0;for(ea=u.materials.length;B<ea;B++){S=u.materials[B];if(S instanceof THREE.MeshFaceMaterial){S=0;for(Y=p.materials.length;S<Y;S++)if(p.materials[S]&&p.materials[S].shading!=undefined&&p.materials[S].shading==THREE.SmoothShading){ia=
true;break}}else if(S&&S.shading!=undefined&&S.shading==THREE.SmoothShading){ia=true;break}if(ia)break}r.__needsSmoothNormals=ia;w.__webGLFaceCount=V*3;w.__webGLLineCount=da*2;g.__dirtyVertices=true;g.__dirtyElements=true;g.__dirtyUvs=true;g.__dirtyNormals=true;g.__dirtyTangents=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyElements||g.__dirtyUvs||g.__dirtyNormals||g.__dirtyColors||g.__dirtyTangents){w=e;V=b.DYNAMIC_DRAW;da=void 0;r=void 0;var pa=void 0,P=void 0,ka=void 0,oa=void 0,wa=
void 0;pa=void 0;var fa=void 0,W=void 0,ba=void 0,Ca=void 0;fa=void 0;W=void 0;ba=void 0;P=void 0;fa=void 0;W=void 0;ba=void 0;Ca=void 0;P=void 0;oa=void 0;ka=void 0;wa=void 0;var qa=Y=S=ia=ea=B=u=p=0,la=0,na=w.__vertexArray,Ja=w.__uvArray,Da=w.__uv2Array,va=w.__normalArray,ga=w.__tangentArray,ma=w.__colorArray,Aa=w.__faceArray,ta=w.__lineArray,La=w.__needsSmoothNormals,ua=i.geometry,Ma=ua.__dirtyVertices,ja=ua.__dirtyElements,ya=ua.__dirtyUvs,Fa=ua.__dirtyNormals,Ka=ua.__dirtyTangents,Na=ua.__dirtyColors,
sa=ua.vertices,A=w.faces,Z=ua.faces,T=ua.uvs,E=ua.uvs2,L=ua.colors;da=0;for(r=A.length;da<r;da++){pa=A[da];P=Z[pa];wa=T[pa];pa=E[pa];ka=P.vertexNormals;oa=P.normal;if(P instanceof THREE.Face3){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;u+=9}if(Na&&L.length){fa=L[P.a];W=L[P.b];ba=L[P.c];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;
ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;la+=9}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;Y+=12}if(Fa)if(ka.length==3&&La)for(P=0;P<3;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<3;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<3;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;
B+=2}if(ya&&pa)for(P=0;P<3;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;ia+=3;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+2;ta[qa+4]=p+1;ta[qa+5]=p+2;qa+=6;p+=3}}else if(P instanceof THREE.Face4){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;Ca=sa[P.d].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;na[u+9]=Ca.x;na[u+10]=Ca.y;na[u+11]=Ca.z;u+=12}if(Na&&L.length){fa=
L[P.a];W=L[P.b];ba=L[P.c];Ca=L[P.d];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;ma[la+9]=Ca.r;ma[la+10]=Ca.g;ma[la+11]=Ca.b;la+=12}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;P=sa[P.d].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;ga[Y+12]=P.x;ga[Y+13]=P.y;ga[Y+14]=P.z;ga[Y+
15]=P.w;Y+=16}if(Fa)if(ka.length==4&&La)for(P=0;P<4;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<4;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<4;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;B+=2}if(ya&&pa)for(P=0;P<4;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;Aa[ia+3]=p;Aa[ia+4]=p+2;Aa[ia+5]=p+3;ia+=6;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+3;ta[qa+4]=p+1;ta[qa+5]=p+2;ta[qa+6]=p+2;ta[qa+7]=p+3;qa+=8;p+=4}}}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,
w.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,V)}if(Na&&L.length){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ma,V)}if(Fa){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,va,V)}if(Ka&&ua.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ga,V)}if(ya&&B>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer);
b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,n)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=
b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r<B;r++){p=u[r].position;e=r*3;ea[e]=p.x;ea[e+1]=p.y;ea[e+2]=p.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
ea,h)}if(ia){for(r=0;r<V;r++){color=w[r];e=r*3;da[e]=color.r;da[e+1]=color.g;da[e+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,da,h)}}x(objlist,t,0,g,i,n);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.ParticleSystem){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__sortArray=
[];g.__webGLParticleCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors||i.sortParticles)c(g,b.DYNAMIC_DRAW,i,camera);x(objlist,t,0,g,i,n);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.MarchingCubes)if(t[0]==undefined){e.__webGLObjectsImmediate.push({object:i,opaque:{list:[],count:0},transparent:{list:[],count:0},root:n});t[0]=1}}function x(e,i,n,h,g,t){if(i[n]==undefined){e.push({buffer:h,object:g,opaque:{list:[],count:0},transparent:{list:[],
count:0},root:t});i[n]=1}}function F(e,i){e._modelViewMatrix.multiplyToArray(i.matrix,e.matrixWorld,e._modelViewMatrixArray);e._normalMatrix=THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function H(e){if(e!=X){switch(e){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}X=e}}function I(e,i){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(e.wrap_s));b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_WRAP_T,O(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,O(e.format),e.width,e.height,0,O(e.format),O(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var n,h,g;if(e){n=e.__webGLFramebuffer;h=e.width;g=e.height}else{n=null;h=C.width;g=C.height}if(n!=$){b.bindFramebuffer(b.FRAMEBUFFER,n);b.viewport(0,0,h,g);i&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);$=n}}function s(e,i){var n;if(e=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,i);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));
return null}return n}function O(e){switch(e){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 C=document.createElement("canvas"),b,R=null,$=null,Q=null,J=null,X=null,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],U=new THREE.Matrix4,M=new Float32Array(16),D=new Float32Array(16),K=new THREE.Vector4,ca=true,N=new THREE.Color(0),aa=0;if(a){if(a.antialias!==undefined)ca=a.antialias;a.clearColor!==undefined&&N.setHex(a.clearColor);if(a.clearAlpha!==undefined)aa=a.clearAlpha}this.domElement=C;this.autoClear=true;(function(e,i,
n){try{b=C.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}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(i.r,i.g,i.b,n);_cullEnabled=true})(ca,N,aa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},
point:{length:0,colors:[],positions:[]}};this.setSize=function(e,i){C.width=e;C.height=i;b.viewport(0,0,C.width,C.height)};this.setClearColorHex=function(e,i){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,i)};this.setClearColor=function(e,i){b.clearColor(e.r,e.g,e.b,i)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,i){var n,h,g,t=0,w=0,u=0,r,p,B,V=this.lights,da=V.directional.colors,ea=V.directional.positions,ia=V.point.colors,S=V.point.positions,
Y=0,pa=0;n=g=g=0;for(h=i.length;n<h;n++){g=i[n];r=g.color;p=g.position;B=g.intensity;if(g instanceof THREE.AmbientLight){t+=r.r;w+=r.g;u+=r.b}else if(g instanceof THREE.DirectionalLight){g=Y*3;da[g]=r.r*B;da[g+1]=r.g*B;da[g+2]=r.b*B;ea[g]=p.x;ea[g+1]=p.y;ea[g+2]=p.z;Y+=1}else if(g instanceof THREE.PointLight){g=pa*3;ia[g]=r.r*B;ia[g+1]=r.g*B;ia[g+2]=r.b*B;S[g]=p.x;S[g+1]=p.y;S[g+2]=p.z;pa+=1}}for(n=Y*3;n<da.length;n++)da[n]=0;for(n=pa*3;n<ia.length;n++)ia[n]=0;V.point.length=pa;V.directional.length=
Y;V.ambient[0]=t;V.ambient[1]=w;V.ambient[2]=u};this.initMaterial=function(e,i,n){var h,g;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);
else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var t,w,u,r;g=u=r=0;for(t=i.length;g<t;g++){w=i[g];w instanceof THREE.DirectionalLight&&u++;w instanceof THREE.PointLight&&r++}if(r+u<=4){i=u;r=r}else{i=Math.ceil(4*u/(r+u));r=4-i}g={directional:i,point:r};r=e.fragment_shader;i=e.vertex_shader;t={fog:n,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};n=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
"#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#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":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,s("fragment",g+r));b.attachShader(n,
s("vertex",t+i));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};e.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)n.push(h);h=e.program;r=0;for(i=n.length;r<i;r++){g=n[r];h.uniforms[g]=b.getUniformLocation(h,g)}e=e.program;h=["position","normal",
"uv","uv2","tangent","color"];n=0;for(r=h.length;n<r;n++){i=h[n];e.attributes[i]=b.getAttribLocation(e,i)}};this.setProgram=function(e,i,n,h,g){h.program||this.initMaterial(h,i,n);var t=h.program,w=t.uniforms,u=h.uniforms;if(t!=R){b.useProgram(t);R=t;b.uniformMatrix4fv(w.projectionMatrix,false,M)}if(n&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){u.fogColor.value.setHex(n.color.hex);
if(n instanceof THREE.Fog){u.fogNear.value=n.near;u.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)u.fogDensity.value=n.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(t,i);i=this.lights;u.enableLighting.value=i.directional.length+i.point.length;u.ambientLightColor.value=i.ambient;u.directionalLightColor.value=i.directional.colors;u.directionalLightDirection.value=i.directional.positions;u.pointLightColor.value=i.point.colors;u.pointLightPosition.value=
i.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.map.texture=h.map;u.light_map.texture=h.light_map;u.env_map.texture=h.env_map;u.reflectivity.value=h.reflectivity;u.refraction_ratio.value=h.refraction_ratio;u.combine.value=h.combine;u.useRefract.value=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof
THREE.LineBasicMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.size.value=h.size;u.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(h.ambient.r,h.ambient.g,h.ambient.b);u.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);
u.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){u.mNear.value=e.near;u.mFar.value=e.far;u.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)u.opacity.value=h.opacity;var r,p,B;for(r in u)if(B=t.uniforms[r]){n=u[r];p=n.type;i=n.value;if(p=="i")b.uniform1i(B,i);else if(p=="f")b.uniform1f(B,i);else if(p=="fv1")b.uniform1fv(B,i);else if(p=="fv")b.uniform3fv(B,i);else if(p=="v2")b.uniform2f(B,i.x,i.y);else if(p=="v3")b.uniform3f(B,i.x,i.y,i.z);else if(p==
"c")b.uniform3f(B,i.r,i.g,i.b);else if(p=="t"){b.uniform1i(B,i);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;i=i;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(p=0;p<6;++p)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;i=i;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=b.createTexture();
b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(n.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture)}}}b.uniformMatrix4fv(w.modelViewMatrix,
false,g._modelViewMatrixArray);b.uniformMatrix3fv(w.normalMatrix,false,g._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(w.cameraPosition,e.position.x,e.position.y,e.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(w.objectMatrix,false,g._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(w.viewMatrix,
false,D);return t};this.renderBuffer=function(e,i,n,h,g,t){e=this.setProgram(e,i,n,h,t).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.position);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,
false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,
2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);
b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,n,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(n,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h<u;h++){g=e.__webGLObjects[h];p=g.object;if(p.visible){if(g.root){p.autoUpdateMatrix&&
p.updateMatrix();p.matrixWorld.copy(p.matrix);z(p)}if(!(p instanceof THREE.Mesh)||q(p)){p.matrixWorld.flattenToArray(p._objectMatrixArray);F(p,i);m(g);g.render=true}else g.render=false}else g.render=false}r=e.__webGLObjectsImmediate.length;for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){if(p.autoUpdateMatrix){p.updateMatrix();p.matrixWorld.copy(p.matrix);p.matrixWorld.flattenToArray(p._objectMatrixArray)}F(p,i);l(g)}}H(THREE.NormalBlending);for(h=0;h<u;h++){g=e.__webGLObjects[h];
if(g.render){p=g.object;B=g.buffer;w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}for(h=0;h<u;h++){g=e.__webGLObjects[h];if(g.render){p=g.object;B=g.buffer;w=g.transparent;
j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.transparent;j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,
n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e){var i,n,h;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}i=0;for(n=e.objects.length;i<n;i++){h=e.objects[i];v(e,h,true);y(e,h)}};this.removeObject=function(e,i){var n,h;for(n=e.__webGLObjects.length-1;n>=0;n--){h=e.__webGLObjects[n].object;i==h&&e.__webGLObjects.splice(n,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};
this.setFaceCulling=function(e,i){if(e){!i||i=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="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, gl_FragColor.w ), 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
+218 -217
View File
@@ -1,6 +1,6 @@
// ThreeExtras.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,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,h,f,j,l,k;if(c==0)e=h=f=0;else{j=Math.floor(a*6);l=a*6-j;a=c*(1-b);k=c*(1-b*l);b=c*(1-b*(1-l));switch(j){case 1:e=k;h=c;f=a;break;case 2:e=a;h=c;f=b;break;case 3:e=a;h=k;f=c;break;case 4:e=b;h=a;f=c;break;case 5:e=c;h=a;f=k;break;case 6:case 0:e=c;h=b;f=a}}this.r=e;this.g=h;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,f,h,k,j;if(c==0)e=g=f=0;else{h=Math.floor(a*6);k=a*6-h;a=c*(1-b);j=c*(1-b*k);b=c*(1-b*(1-k));switch(h){case 1:e=j;g=c;f=a;break;case 2:e=a;g=c;f=b;break;case 3:e=a;g=j;f=c;break;case 4:e=b;g=a;f=c;break;case 5:e=c;g=a;f=j;break;case 6:case 0:e=c;g=b;f=a}}this.r=e;this.g=g;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(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*
@@ -13,57 +13,57 @@ THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1}
THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;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,c,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){c=e[a];if(c instanceof THREE.Mesh)h=h.concat(this.intersectObject(c))}h.sort(function(f,j){return f.distance-j.distance});return h},intersectObject:function(a){function b(E,w,F,u){u=u.clone().subSelf(w);F=F.clone().subSelf(w);var I=E.clone().subSelf(w);E=u.dot(u);w=u.dot(F);u=u.dot(I);var Q=F.dot(F);F=F.dot(I);I=1/(E*Q-w*w);Q=(Q*u-w*F)*I;E=(E*F-w*u)*I;return Q>0&&E>0&&Q+E<1}var c,e,h,f,j,l,k,m,p,y,
t,o=a.geometry,d=o.vertices,A=[];c=0;for(e=o.faces.length;c<e;c++){h=o.faces[c];y=this.origin.clone();t=this.direction.clone();f=a.matrix.multiplyVector3(d[h.a].position.clone());j=a.matrix.multiplyVector3(d[h.b].position.clone());l=a.matrix.multiplyVector3(d[h.c].position.clone());k=h instanceof THREE.Face4?a.matrix.multiplyVector3(d[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());p=t.dot(m);if(p<0){m=m.dot((new THREE.Vector3).sub(f,y))/p;y=y.addSelf(t.multiplyScalar(m));
if(h instanceof THREE.Face3){if(b(y,f,j,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};A.push(h)}}else if(h instanceof THREE.Face4)if(b(y,f,j,k)||b(y,j,l,k)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};A.push(h)}}}return A}};
THREE.Rectangle=function(){function a(){f=e-b;j=h-c}var b,c,e,h,f,j,l=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(k,m,p,y){l=false;b=k;c=m;e=p;h=y;a()};this.addPoint=function(k,m){if(l){l=false;b=k;c=m;e=k;h=m}else{b=b<k?b:k;c=c<m?c:m;e=e>k?e:k;h=h>m?
h:m}a()};this.add3Points=function(k,m,p,y,t,o){if(l){l=false;b=k<p?k<t?k:t:p<t?p:t;c=m<y?m<o?m:o:y<o?y:o;e=k>p?k>t?k:t:p>t?p:t;h=m>y?m>o?m:o:y>o?y:o}else{b=k<p?k<t?k<b?k:b:t<b?t:b:p<t?p<b?p:b:t<b?t:b;c=m<y?m<o?m<c?m:c:o<c?o:c:y<o?y<c?y:c:o<c?o:c;e=k>p?k>t?k>e?k:e:t>e?t:e:p>t?p>e?p:e:t>e?t:e;h=m>y?m>o?m>h?m:h:o>h?o:h:y>o?y>h?y:h:o>h?o:h}a()};this.addRectangle=function(k){if(l){l=false;b=k.getLeft();c=k.getTop();e=k.getRight();h=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();
e=e>k.getRight()?e:k.getRight();h=h>k.getBottom()?h:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;h+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();h=h<k.getBottom()?h:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(h,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){l=true;h=e=c=b=0;a()};this.isEmpty=function(){return l};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+h+", width: "+f+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,e,h,f,j,l,k,m,p,y,t,o,d,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=h||0;this.n22=f||1;this.n23=j||0;this.n24=l||0;this.n31=k||0;this.n32=m||0;this.n33=p||1;this.n34=y||0;this.n41=t||0;this.n42=o||0;this.n43=d||0;this.n44=A||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
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,c,e,h,f,j,l,k,m,p,y,t,o,d,A){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=h;this.n22=f;this.n23=j;this.n24=l;this.n31=k;this.n32=m;this.n33=p;this.n34=y;this.n41=t;this.n42=o;this.n43=d;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,c){var e=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();h.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,h=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*c+this.n23*
e+this.n24*h;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,h=a.n13,f=a.n14,j=a.n21,l=a.n22,k=a.n23,m=a.n24,p=a.n31,
y=a.n32,t=a.n33,o=a.n34,d=a.n41,A=a.n42,E=a.n43,w=a.n44,F=b.n11,u=b.n12,I=b.n13,Q=b.n14,$=b.n21,N=b.n22,K=b.n23,W=b.n24,R=b.n31,X=b.n32,g=b.n33,n=b.n34,v=b.n41,x=b.n42,q=b.n43,z=b.n44;this.n11=c*F+e*$+h*R+f*v;this.n12=c*u+e*N+h*X+f*x;this.n13=c*I+e*K+h*g+f*q;this.n14=c*Q+e*W+h*n+f*z;this.n21=j*F+l*$+k*R+m*v;this.n22=j*u+l*N+k*X+m*x;this.n23=j*I+l*K+k*g+m*q;this.n24=j*Q+l*W+k*n+m*z;this.n31=p*F+y*$+t*R+o*v;this.n32=p*u+y*N+t*X+o*x;this.n33=p*I+y*K+t*g+o*q;this.n34=p*Q+y*W+t*n+o*z;this.n41=d*F+A*$+
E*R+w*v;this.n42=d*u+A*N+E*X+w*x;this.n43=d*I+A*K+E*g+w*q;this.n44=d*Q+A*W+E*n+w*z;return this},multiplyToArray:function(a,b,c){var e=a.n11,h=a.n12,f=a.n13,j=a.n14,l=a.n21,k=a.n22,m=a.n23,p=a.n24,y=a.n31,t=a.n32,o=a.n33,d=a.n34,A=a.n41,E=a.n42,w=a.n43;a=a.n44;var F=b.n11,u=b.n12,I=b.n13,Q=b.n14,$=b.n21,N=b.n22,K=b.n23,W=b.n24,R=b.n31,X=b.n32,g=b.n33,n=b.n34,v=b.n41,x=b.n42,q=b.n43;b=b.n44;this.n11=e*F+h*$+f*R+j*v;this.n12=e*u+h*N+f*X+j*x;this.n13=e*I+h*K+f*g+j*q;this.n14=e*Q+h*W+f*n+j*b;this.n21=
l*F+k*$+m*R+p*v;this.n22=l*u+k*N+m*X+p*x;this.n23=l*I+k*K+m*g+p*q;this.n24=l*Q+k*W+m*n+p*b;this.n31=y*F+t*$+o*R+d*v;this.n32=y*u+t*N+o*X+d*x;this.n33=y*I+t*K+o*g+d*q;this.n34=y*Q+t*W+o*n+d*b;this.n41=A*F+E*$+w*R+a*v;this.n42=A*u+E*N+w*X+a*x;this.n43=A*I+E*K+w*g+a*q;this.n44=A*Q+E*W+w*n+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;
c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,h=this.n14,f=this.n21,j=this.n22,l=this.n23,k=this.n24,m=this.n31,p=this.n32,y=this.n33,t=this.n34,o=this.n41,d=this.n42,A=this.n43,E=this.n44,w=a.n11,F=a.n21,u=a.n31,I=a.n41,Q=a.n12,$=a.n22,N=a.n32,K=a.n42,W=a.n13,R=a.n23,X=a.n33,g=a.n43,n=a.n14,v=a.n24,x=a.n34;a=a.n44;this.n11=b*w+c*F+e*u+h*I;this.n12=b*Q+c*$+e*N+h*K;this.n13=b*W+c*R+e*X+h*g;this.n14=b*n+c*v+e*x+h*a;this.n21=f*w+j*F+l*u+k*I;this.n22=f*Q+j*
$+l*N+k*K;this.n23=f*W+j*R+l*X+k*g;this.n24=f*n+j*v+l*x+k*a;this.n31=m*w+p*F+y*u+t*I;this.n32=m*Q+p*$+y*N+t*K;this.n33=m*W+p*R+y*X+t*g;this.n34=m*n+p*v+y*x+t*a;this.n41=o*w+d*F+A*u+E*I;this.n42=o*Q+d*$+A*N+E*K;this.n43=o*W+d*R+A*X+E*g;this.n44=o*n+d*v+A*x+E*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(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,h=this.n21,f=this.n22,j=this.n23,l=this.n24,k=this.n31,m=this.n32,p=this.n33,y=this.n34,t=this.n41,o=this.n42,d=this.n43,A=this.n44;return e*j*m*t-c*l*m*t-e*f*p*t+b*l*p*t+c*f*y*t-b*j*y*t-e*j*k*o+c*l*k*o+e*h*p*o-a*l*p*o-c*h*y*o+a*j*y*o+e*f*k*d-b*l*k*d-e*h*m*d+a*l*m*d+b*h*y*d-a*f*y*d-c*f*k*A+b*j*k*A+c*h*m*A-a*j*m*A-b*h*p*A+a*f*p*A},transpose:function(){function a(b,c,e){var h=b[c];b[c]=b[e];b[e]=h}a(this,"n21","n12");a(this,"n31",
"n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=
this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,
1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),h=1-c,f=a.x,j=a.y,l=a.z,
k=h*f,m=h*j;this.set(k*f+c,k*j-e*l,k*l+e*j,0,k*j+e*l,m*j+c,m*l-e*f,0,k*l-e*j,m*l+e*f,h*l*l+c,0,0,0,0,1);return this},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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];if(c instanceof THREE.Mesh)g=g.concat(this.intersectObject(c))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function b(H,w,E,o){o=o.clone().subSelf(w);E=E.clone().subSelf(w);var d=H.clone().subSelf(w);H=o.dot(o);w=o.dot(E);o=o.dot(d);var P=E.dot(E);E=E.dot(d);d=1/(H*P-w*w);P=(P*o-w*E)*d;H=(H*E-w*o)*d;return P>0&&H>0&&P+H<1}var c,e,g,f,h,k,j,m,p,x,
t,q=a.geometry,y=q.vertices,z=[];c=0;for(e=q.faces.length;c<e;c++){g=q.faces[c];x=this.origin.clone();t=this.direction.clone();f=a.matrix.multiplyVector3(y[g.a].position.clone());h=a.matrix.multiplyVector3(y[g.b].position.clone());k=a.matrix.multiplyVector3(y[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(y[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());p=t.dot(m);if(p<0){m=m.dot((new THREE.Vector3).sub(f,x))/p;x=x.addSelf(t.multiplyScalar(m));
if(g instanceof THREE.Face3){if(b(x,f,h,k)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};z.push(g)}}else if(g instanceof THREE.Face4)if(b(x,f,h,j)||b(x,h,k,j)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};z.push(g)}}}return z}};
THREE.Rectangle=function(){function a(){f=e-b;h=g-c}var b,c,e,g,f,h,k=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,m,p,x){k=false;b=j;c=m;e=p;g=x;a()};this.addPoint=function(j,m){if(k){k=false;b=j;c=m;e=j;g=m}else{b=b<j?b:j;c=c<m?c:m;e=e>j?e:j;g=g>m?
g:m}a()};this.add3Points=function(j,m,p,x,t,q){if(k){k=false;b=j<p?j<t?j:t:p<t?p:t;c=m<x?m<q?m:q:x<q?x:q;e=j>p?j>t?j:t:p>t?p:t;g=m>x?m>q?m:q:x>q?x:q}else{b=j<p?j<t?j<b?j:b:t<b?t:b:p<t?p<b?p:b:t<b?t:b;c=m<x?m<q?m<c?m:c:q<c?q:c:x<q?x<c?x:c:q<c?q:c;e=j>p?j>t?j>e?j:e:t>e?t:e:p>t?p>e?p:e:t>e?t:e;g=m>x?m>q?m>g?m:g:q>g?q:g:x>q?x>g?x:g:q>g?q:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();
e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=p||1;this.n34=x||0;this.n41=t||0;this.n42=q||0;this.n43=y||0;this.n44=z||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
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,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=p;this.n34=x;this.n41=t;this.n42=q;this.n43=y;this.n44=z;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,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*
e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+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 c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,p=a.n31,
x=a.n32,t=a.n33,q=a.n34,y=a.n41,z=a.n42,H=a.n43,w=a.n44,E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43,ea=b.n44;this.n11=c*E+e*aa+g*O+f*X;this.n12=c*o+e*N+g*Y+f*ha;this.n13=c*d+e*M+g*W+f*Z;this.n14=c*P+e*U+g*J+f*ea;this.n21=h*E+k*aa+j*O+m*X;this.n22=h*o+k*N+j*Y+m*ha;this.n23=h*d+k*M+j*W+m*Z;this.n24=h*P+k*U+j*J+m*ea;this.n31=p*E+x*aa+t*O+q*X;this.n32=p*o+x*N+t*Y+q*ha;this.n33=p*d+x*M+t*W+q*Z;this.n34=p*P+x*U+t*J+q*ea;this.n41=
y*E+z*aa+H*O+w*X;this.n42=y*o+z*N+H*Y+w*ha;this.n43=y*d+z*M+H*W+w*Z;this.n44=y*P+z*U+H*J+w*ea;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,p=a.n24,x=a.n31,t=a.n32,q=a.n33,y=a.n34,z=a.n41,H=a.n42,w=a.n43;a=a.n44;var E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43;b=b.n44;this.n11=e*E+g*aa+f*O+h*X;this.n12=e*o+g*N+f*Y+h*ha;this.n13=e*d+g*M+f*W+h*Z;this.n14=e*P+g*U+f*
J+h*b;this.n21=k*E+j*aa+m*O+p*X;this.n22=k*o+j*N+m*Y+p*ha;this.n23=k*d+j*M+m*W+p*Z;this.n24=k*P+j*U+m*J+p*b;this.n31=x*E+t*aa+q*O+y*X;this.n32=x*o+t*N+q*Y+y*ha;this.n33=x*d+t*M+q*W+y*Z;this.n34=x*P+t*U+q*J+y*b;this.n41=z*E+H*aa+w*O+a*X;this.n42=z*o+H*N+w*Y+a*ha;this.n43=z*d+H*M+w*W+a*Z;this.n44=z*P+H*U+w*J+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=
this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,p=this.n32,x=this.n33,t=this.n34,q=this.n41,y=this.n42,z=this.n43,H=this.n44,w=a.n11,E=a.n21,o=a.n31,d=a.n41,P=a.n12,aa=a.n22,N=a.n32,M=a.n42,U=a.n13,O=a.n23,Y=a.n33,W=a.n43,J=a.n14,X=a.n24,ha=a.n34;a=a.n44;this.n11=b*w+c*E+e*o+g*d;this.n12=b*P+c*aa+e*N+g*M;this.n13=b*U+c*O+e*Y+g*W;this.n14=b*J+c*X+e*ha+g*a;this.n21=f*w+
h*E+k*o+j*d;this.n22=f*P+h*aa+k*N+j*M;this.n23=f*U+h*O+k*Y+j*W;this.n24=f*J+h*X+k*ha+j*a;this.n31=m*w+p*E+x*o+t*d;this.n32=m*P+p*aa+x*N+t*M;this.n33=m*U+p*O+x*Y+t*W;this.n34=m*J+p*X+x*ha+t*a;this.n41=q*w+y*E+z*o+H*d;this.n42=q*P+y*aa+z*N+H*M;this.n43=q*U+y*O+z*Y+H*W;this.n44=q*J+y*X+z*ha+H*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(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,p=this.n33,x=this.n34,t=this.n41,q=this.n42,y=this.n43,z=this.n44;return e*h*m*t-c*k*m*t-e*f*p*t+b*k*p*t+c*f*x*t-b*h*x*t-e*h*j*q+c*k*j*q+e*g*p*q-a*k*p*q-c*g*x*q+a*h*x*q+e*f*j*y-b*k*j*y-e*g*m*y+a*k*m*y+b*g*x*y-a*f*x*y-c*f*j*z+b*h*j*z+c*g*m*z-a*h*m*z-b*g*p*z+a*f*p*z},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=
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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,
0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),
g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,0,0,0,0,1);return this},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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,h=a.n14,f=a.n21,j=a.n22,l=a.n23,k=a.n24,m=a.n31,p=a.n32,y=a.n33,t=a.n34,o=a.n41,d=a.n42,A=a.n43,E=a.n44,w=new THREE.Matrix4;w.n11=l*t*d-k*y*d+k*p*A-j*t*A-l*p*E+j*y*E;w.n12=h*y*d-e*t*d-h*p*A+c*t*A+e*p*E-c*y*E;w.n13=e*k*d-h*l*d+h*j*A-c*k*A-e*j*E+c*l*E;w.n14=h*l*p-e*k*p-h*j*y+c*k*y+e*j*t-c*l*t;w.n21=k*y*o-l*t*o-k*m*A+f*t*A+l*m*E-f*y*E;w.n22=e*t*o-h*y*o+h*m*A-b*t*A-e*m*E+b*y*E;w.n23=h*l*o-e*k*o-h*f*A+b*k*A+e*f*E-b*l*E;w.n24=e*k*m-h*l*m+
h*f*y-b*k*y-e*f*t+b*l*t;w.n31=j*t*o-k*p*o+k*m*d-f*t*d-j*m*E+f*p*E;w.n32=h*p*o-c*t*o-h*m*d+b*t*d+c*m*E-b*p*E;w.n33=e*k*o-h*j*o+h*f*d-b*k*d-c*f*E+b*j*E;w.n34=h*j*m-c*k*m-h*f*p+b*k*p+c*f*t-b*j*t;w.n41=l*p*o-j*y*o-l*m*d+f*y*d+j*m*A-f*p*A;w.n42=c*y*o-e*p*o+e*m*d-b*y*d-c*m*A+b*p*A;w.n43=e*j*o-c*l*o-e*f*d+b*l*d+c*f*A-b*j*A;w.n44=c*l*m-e*j*m+e*f*p-b*l*p-c*f*y+b*j*y;w.multiplyScalar(1/a.determinant());return w};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,j=-a.n33*a.n12+a.n32*a.n13,l=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*j+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*h;c[2]=a*f;c[3]=a*j;c[4]=a*l;c[5]=a*k;c[6]=a*m;c[7]=a*p;c[8]=a*y;return b};
THREE.Matrix4.makeFrustum=function(a,b,c,e,h,f){var j,l,k;j=new THREE.Matrix4;l=2*h/(b-a);k=2*h/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+h)/(f-h);h=-2*f*h/(f-h);j.n11=l;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=k;j.n23=c;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=h;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,c,e){var h;a=c*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,c,e)};
THREE.Matrix4.makeOrtho=function(a,b,c,e,h,f){var j,l,k,m;j=new THREE.Matrix4;l=b-a;k=c-e;m=f-h;a=(b+a)/l;c=(c+e)/k;h=(f+h)/m;j.n11=2/l;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/k;j.n23=0;j.n24=-c;j.n31=0;j.n32=0;j.n33=-2/m;j.n34=-h;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,p=a.n32,x=a.n33,t=a.n34,q=a.n41,y=a.n42,z=a.n43,H=a.n44,w=new THREE.Matrix4;w.n11=k*t*y-j*x*y+j*p*z-h*t*z-k*p*H+h*x*H;w.n12=g*x*y-e*t*y-g*p*z+c*t*z+e*p*H-c*x*H;w.n13=e*j*y-g*k*y+g*h*z-c*j*z-e*h*H+c*k*H;w.n14=g*k*p-e*j*p-g*h*x+c*j*x+e*h*t-c*k*t;w.n21=j*x*q-k*t*q-j*m*z+f*t*z+k*m*H-f*x*H;w.n22=e*t*q-g*x*q+g*m*z-b*t*z-e*m*H+b*x*H;w.n23=g*k*q-e*j*q-g*f*z+b*j*z+e*f*H-b*k*H;w.n24=e*j*m-g*k*m+
g*f*x-b*j*x-e*f*t+b*k*t;w.n31=h*t*q-j*p*q+j*m*y-f*t*y-h*m*H+f*p*H;w.n32=g*p*q-c*t*q-g*m*y+b*t*y+c*m*H-b*p*H;w.n33=e*j*q-g*h*q+g*f*y-b*j*y-c*f*H+b*h*H;w.n34=g*h*m-c*j*m-g*f*p+b*j*p+c*f*t-b*h*t;w.n41=k*p*q-h*x*q-k*m*y+f*x*y+h*m*z-f*p*z;w.n42=c*x*q-e*p*q+e*m*y-b*x*y-c*m*z+b*p*z;w.n43=e*h*q-c*k*q-e*f*y+b*k*y+c*f*z-b*h*z;w.n44=c*k*m-e*h*m+e*f*p-b*k*p-c*f*x+b*h*x;w.multiplyScalar(1/a.determinant());return w};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*p;c[8]=a*x;return b};
THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
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,c,e,h){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,c,e,h,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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,c,e,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,h,f,j,l=new THREE.Vector3,k=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){f=this.faces[e];if(a&&f.vertexNormals.length){l.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)l.addSelf(f.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];j=this.vertices[f.c];l.sub(j.position,
c.position);k.sub(b.position,c.position);l.crossSelf(k)}l.isZero()||l.normalize();f.normal.copy(l)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,f,h,k=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){k.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)k.addSelf(f.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];k.sub(h.position,
c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();f.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(n,v,x,q,z,L,C){f=n.vertices[v].position;j=n.vertices[x].position;l=n.vertices[q].position;k=h[z];m=h[L];p=h[C];y=j.x-f.x;t=l.x-f.x;o=j.y-f.y;d=l.y-f.y;
A=j.z-f.z;E=l.z-f.z;w=m.u-k.u;F=p.u-k.u;u=m.v-k.v;I=p.v-k.v;Q=1/(w*I-F*u);K.set((I*y-u*t)*Q,(I*o-u*d)*Q,(I*A-u*E)*Q);W.set((w*t-F*y)*Q,(w*d-F*o)*Q,(w*E-F*A)*Q);$[v].addSelf(K);$[x].addSelf(K);$[q].addSelf(K);N[v].addSelf(W);N[x].addSelf(W);N[q].addSelf(W)}var b,c,e,h,f,j,l,k,m,p,y,t,o,d,A,E,w,F,u,I,Q,$=[],N=[],K=new THREE.Vector3,W=new THREE.Vector3,R=new THREE.Vector3,X=new THREE.Vector3,g=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){$[b]=new THREE.Vector3;N[b]=new THREE.Vector3}b=0;
for(c=this.faces.length;b<c;b++){e=this.faces[b];h=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){g.copy(this.vertices[b].normal);e=$[b];R.copy(e);R.subSelf(g.multiplyScalar(g.dot(e))).normalize();X.cross(this.vertices[b].normal,e);e=X.dot(N[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(J,X,ha,Z,ea,l,v){f=J.vertices[X].position;h=J.vertices[ha].position;k=J.vertices[Z].position;j=g[ea];m=g[l];p=g[v];x=h.x-f.x;t=k.x-f.x;q=h.y-f.y;y=k.y-
f.y;z=h.z-f.z;H=k.z-f.z;w=m.u-j.u;E=p.u-j.u;o=m.v-j.v;d=p.v-j.v;P=1/(w*d-E*o);M.set((d*x-o*t)*P,(d*q-o*y)*P,(d*z-o*H)*P);U.set((w*t-E*x)*P,(w*y-E*q)*P,(w*H-E*z)*P);aa[X].addSelf(M);aa[ha].addSelf(M);aa[Z].addSelf(M);N[X].addSelf(U);N[ha].addSelf(U);N[Z].addSelf(U)}var b,c,e,g,f,h,k,j,m,p,x,t,q,y,z,H,w,E,o,d,P,aa=[],N=[],M=new THREE.Vector3,U=new THREE.Vector3,O=new THREE.Vector3,Y=new THREE.Vector3,W=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;N[b]=new THREE.Vector3}b=
0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){W.copy(this.vertices[b].normal);e=aa[b];O.copy(e);O.subSelf(W.multiplyScalar(W.dot(e))).normalize();Y.cross(this.vertices[b].normal,e);e=Y.dot(N[b]);e=e<0?-1:1;this.vertices[b].tangent.set(O.x,O.y,O.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){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,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else 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,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(p){var y=[];b=0;for(c=p.length;b<c;b++)p[b]==undefined?y.push("undefined"):y.push(p[b].toString());return y.join("_")}var b,c,e,h,f,j,l,k,m={};e=0;for(h=this.faces.length;e<h;e++){f=this.faces[e];
j=f.materials;l=a(j);if(m[l]==undefined)m[l]={hash:l,counter:0};k=m[l].hash+"_"+m[l].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+f>65535){m[l].counter+=1;k=m[l].hash+"_"+m[l].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
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,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(p){var x=[];b=0;for(c=p.length;b<c;b++)p[b]==undefined?x.push("undefined"):x.push(p[b].toString());return x.join("_")}var b,c,e,g,f,h,k,j,m={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
h=f.materials;k=a(h);if(m[k]==undefined)m[k]={hash:k,counter:0};j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;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.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;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.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,b=this.rotation,c=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(b.x);if(b.y!=0){e.setRotY(b.y);this.rotationMatrix.multiplySelf(e)}if(b.z!=0){e.setRotZ(b.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(c.x!=0||c.y!=0||c.z!=0){e.setScale(c.x,c.y,c.z);this.matrix.multiplySelf(e)}}};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.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
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.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,b=this.rotation,c=this.scale,e=this.matrix,g=this.rotationMatrix,f=this.tmpMatrix;e.setTranslation(a.x,a.y,a.z);g.setRotX(b.x);b.y!=0&&g.multiplySelf(f.setRotY(b.y));b.z!=0&&g.multiplySelf(f.setRotZ(b.z));e.multiplySelf(g);if(c.x!=0||c.y!=0||c.z!=0)e.multiplySelf(f.setScale(c.x,
c.y,c.z))}};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.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c: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;THREE.BillboardBlending=3;
THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
@@ -96,120 +96,121 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
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 (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,c,e,h,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter};
THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,c,e,g,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f: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 (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var b,c,e,h={};for(b in a){h[b]={};for(c in a[b]){e=a[b][c];h[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var b,c,e,h={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)h[c]=e[c]}return h}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]){e=a[b][c];g[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,c,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)g[c]=e[c]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
THREE.Projector=function(){function a(N,K){return K.z-N.z}function b(N,K){var W=0,R=1,X=N.z+N.w,g=K.z+K.w,n=-N.z+N.w,v=-K.z+K.w;if(X>=0&&g>=0&&n>=0&&v>=0)return true;else if(X<0&&g<0||n<0&&v<0)return false;else{if(X<0)W=Math.max(W,X/(X-g));else if(g<0)R=Math.min(R,X/(X-g));if(n<0)W=Math.max(W,n/(n-v));else if(v<0)R=Math.min(R,n/(n-v));if(R<W)return false;else{N.lerpSelf(K,W);K.lerpSelf(N,1-R);return true}}}var c,e,h=[],f,j,l,k=[],m,p,y=[],t,o,d=[],A=new THREE.Vector4,E=new THREE.Vector4,w=new THREE.Matrix4,
F=new THREE.Matrix4,u=[],I=new THREE.Vector4,Q=new THREE.Vector4,$;this.projectObjects=function(N,K,W){var R=[],X,g;e=0;w.multiply(K.projectionMatrix,K.matrix);u[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);u[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);u[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);u[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);u[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
w.n33,w.n44-w.n34);u[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);K=0;for(X=u.length;K<X;K++){g=u[K];g.divideScalar(Math.sqrt(g.x*g.x+g.y*g.y+g.z*g.z))}X=N.objects;N=0;for(K=X.length;N<K;N++){g=X[N];var n;if(!(n=!g.visible)){if(n=g instanceof THREE.Mesh){a:{n=void 0;for(var v=g.position,x=-g.geometry.boundingSphere.radius*Math.max(g.scale.x,Math.max(g.scale.y,g.scale.z)),q=0;q<6;q++){n=u[q].x*v.x+u[q].y*v.y+u[q].z*v.z+u[q].w;if(n<=x){n=false;break a}}n=true}n=!n}n=n}if(!n){c=
h[e]=h[e]||new THREE.RenderableObject;A.copy(g.position);w.multiplyVector3(A);c.object=g;c.z=A.z;R.push(c);e++}}W&&R.sort(a);return R};this.projectScene=function(N,K,W){var R=[],X=K.near,g=K.far,n,v,x,q,z,L,C,D,G,H,J,Y,T,M,Z,ba;l=p=o=0;K.autoUpdateMatrix&&K.updateMatrix();w.multiply(K.projectionMatrix,K.matrix);L=this.projectObjects(N,K,true);N=0;for(n=L.length;N<n;N++){C=L[N].object;if(C.visible){C.autoUpdateMatrix&&C.updateMatrix();D=C.matrix;G=C.rotationMatrix;H=C.materials;J=C.overdraw;if(C instanceof
THREE.Mesh){Y=C.geometry;T=Y.vertices;v=0;for(x=T.length;v<x;v++){M=T[v];M.positionWorld.copy(M.position);D.multiplyVector3(M.positionWorld);q=M.positionScreen;q.copy(M.positionWorld);w.multiplyVector4(q);q.x/=q.w;q.y/=q.w;M.__visible=q.z>X&&q.z<g}Y=Y.faces;v=0;for(x=Y.length;v<x;v++){M=Y[v];if(M instanceof THREE.Face3){q=T[M.a];z=T[M.b];Z=T[M.c];if(q.__visible&&z.__visible&&Z.__visible)if(C.doubleSided||C.flipSided!=(Z.positionScreen.x-q.positionScreen.x)*(z.positionScreen.y-q.positionScreen.y)-
(Z.positionScreen.y-q.positionScreen.y)*(z.positionScreen.x-q.positionScreen.x)<0){f=k[l]=k[l]||new THREE.RenderableFace3;f.v1.positionWorld.copy(q.positionWorld);f.v2.positionWorld.copy(z.positionWorld);f.v3.positionWorld.copy(Z.positionWorld);f.v1.positionScreen.copy(q.positionScreen);f.v2.positionScreen.copy(z.positionScreen);f.v3.positionScreen.copy(Z.positionScreen);f.normalWorld.copy(M.normal);G.multiplyVector3(f.normalWorld);f.centroidWorld.copy(M.centroid);D.multiplyVector3(f.centroidWorld);
f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);Z=M.vertexNormals;$=f.vertexNormalsWorld;q=0;for(z=Z.length;q<z;q++){ba=$[q]=$[q]||new THREE.Vector3;ba.copy(Z[q]);G.multiplyVector3(ba)}f.z=f.centroidScreen.z;f.meshMaterials=H;f.faceMaterials=M.materials;f.overdraw=J;if(C.geometry.uvs[v]){f.uvs[0]=C.geometry.uvs[v][0];f.uvs[1]=C.geometry.uvs[v][1];f.uvs[2]=C.geometry.uvs[v][2]}R.push(f);l++}}else if(M instanceof THREE.Face4){q=T[M.a];z=T[M.b];Z=T[M.c];ba=T[M.d];if(q.__visible&&
z.__visible&&Z.__visible&&ba.__visible)if(C.doubleSided||C.flipSided!=((ba.positionScreen.x-q.positionScreen.x)*(z.positionScreen.y-q.positionScreen.y)-(ba.positionScreen.y-q.positionScreen.y)*(z.positionScreen.x-q.positionScreen.x)<0||(z.positionScreen.x-Z.positionScreen.x)*(ba.positionScreen.y-Z.positionScreen.y)-(z.positionScreen.y-Z.positionScreen.y)*(ba.positionScreen.x-Z.positionScreen.x)<0)){f=k[l]=k[l]||new THREE.RenderableFace3;f.v1.positionWorld.copy(q.positionWorld);f.v2.positionWorld.copy(z.positionWorld);
f.v3.positionWorld.copy(ba.positionWorld);f.v1.positionScreen.copy(q.positionScreen);f.v2.positionScreen.copy(z.positionScreen);f.v3.positionScreen.copy(ba.positionScreen);f.normalWorld.copy(M.normal);G.multiplyVector3(f.normalWorld);f.centroidWorld.copy(M.centroid);D.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=H;f.faceMaterials=M.materials;f.overdraw=J;if(C.geometry.uvs[v]){f.uvs[0]=C.geometry.uvs[v][0];
f.uvs[1]=C.geometry.uvs[v][1];f.uvs[2]=C.geometry.uvs[v][3]}R.push(f);l++;j=k[l]=k[l]||new THREE.RenderableFace3;j.v1.positionWorld.copy(z.positionWorld);j.v2.positionWorld.copy(Z.positionWorld);j.v3.positionWorld.copy(ba.positionWorld);j.v1.positionScreen.copy(z.positionScreen);j.v2.positionScreen.copy(Z.positionScreen);j.v3.positionScreen.copy(ba.positionScreen);j.normalWorld.copy(f.normalWorld);j.centroidWorld.copy(f.centroidWorld);j.centroidScreen.copy(f.centroidScreen);j.z=j.centroidScreen.z;
j.meshMaterials=H;j.faceMaterials=M.materials;j.overdraw=J;if(C.geometry.uvs[v]){j.uvs[0]=C.geometry.uvs[v][1];j.uvs[1]=C.geometry.uvs[v][2];j.uvs[2]=C.geometry.uvs[v][3]}R.push(j);l++}}}}else if(C instanceof THREE.Line){F.multiply(w,D);T=C.geometry.vertices;M=T[0];M.positionScreen.copy(M.position);F.multiplyVector4(M.positionScreen);v=1;for(x=T.length;v<x;v++){q=T[v];q.positionScreen.copy(q.position);F.multiplyVector4(q.positionScreen);z=T[v-1];I.copy(q.positionScreen);Q.copy(z.positionScreen);if(b(I,
Q)){I.multiplyScalar(1/I.w);Q.multiplyScalar(1/Q.w);m=y[p]=y[p]||new THREE.RenderableLine;m.v1.positionScreen.copy(I);m.v2.positionScreen.copy(Q);m.z=Math.max(I.z,Q.z);m.materials=C.materials;R.push(m);p++}}}else if(C instanceof THREE.Particle){E.set(C.position.x,C.position.y,C.position.z,1);w.multiplyVector4(E);E.z/=E.w;if(E.z>0&&E.z<1){t=d[o]=d[o]||new THREE.RenderableParticle;t.x=E.x/E.w;t.y=E.y/E.w;t.z=E.z;t.rotation=C.rotation.z;t.scale.x=C.scale.x*Math.abs(t.x-(E.x+K.projectionMatrix.n11)/(E.w+
K.projectionMatrix.n14));t.scale.y=C.scale.y*Math.abs(t.y-(E.y+K.projectionMatrix.n22)/(E.w+K.projectionMatrix.n24));t.materials=C.materials;R.push(t);o++}}}}W&&R.sort(a);return R};this.unprojectVector=function(N,K){var W=THREE.Matrix4.makeInvert(K.matrix);W.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));W.multiplyVector3(N);return N}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,h,f;this.domElement=document.createElement("div");this.setSize=function(j,l){c=j;e=l;h=c/2;f=e/2};this.render=function(j,l){var k,m,p,y,t,o,d,A;a=b.projectScene(j,l);k=0;for(m=a.length;k<m;k++){t=a[k];if(t instanceof THREE.RenderableParticle){d=t.x*h+h;A=t.y*f+f;p=0;for(y=t.material.length;p<y;p++){o=t.material[p];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=d+"px";o.style.top=A+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ga){if(t!=ga)m.globalAlpha=t=ga}function b(ga){if(o!=ga){switch(ga){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}o=ga}}var c=null,e=new THREE.Projector,h=document.createElement("canvas"),f,j,l,k,m=h.getContext("2d"),p=new THREE.Color(0),y=0,t=1,o=0,d=null,A=null,E=1,w,F,u,I,Q,$,N,K,W,R=new THREE.Color,
X=new THREE.Color,g=new THREE.Color,n=new THREE.Color,v=new THREE.Color,x,q,z,L,C,D,G,H,J,Y=new THREE.Rectangle,T=new THREE.Rectangle,M=new THREE.Rectangle,Z=false,ba=new THREE.Color,ha=new THREE.Color,ka=new THREE.Color,B=new THREE.Color,P=Math.PI*2,O=new THREE.Vector3,U,da,na,ia,fa,la,qa=16;U=document.createElement("canvas");U.width=U.height=2;da=U.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);na=da.getImageData(0,0,2,2);ia=na.data;fa=document.createElement("canvas");fa.width=
fa.height=qa;la=fa.getContext("2d");la.translate(-qa/2,-qa/2);la.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,va){f=ga;j=va;l=f/2;k=j/2;h.width=f;h.height=j;Y.set(-l,-k,l,k);t=1;o=0;A=d=null;E=1};this.setClearColor=function(ga,va){p=ga;y=va;T.set(-l,-k,l,k);m.setTransform(1,0,0,-1,l,k);this.clear()};this.setClearColorHex=function(ga,va){p.setHex(ga);y=va;T.set(-l,-k,l,k);m.setTransform(1,0,0,-1,l,k);this.clear()};this.clear=function(){m.setTransform(1,
0,0,-1,l,k);if(!T.isEmpty()){T.inflate(1);T.minSelf(Y);if(p.hex==0&&y==0)m.clearRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+y+")";m.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight())}T.empty()}};this.render=function(ga,va){function sa(S){var ea,ca,V,aa=S.lights;ha.setRGB(0,0,0);ka.setRGB(0,0,0);B.setRGB(0,0,0);S=0;for(ea=aa.length;S<ea;S++){ca=aa[S];V=ca.color;if(ca instanceof
THREE.AmbientLight){ha.r+=V.r;ha.g+=V.g;ha.b+=V.b}else if(ca instanceof THREE.DirectionalLight){ka.r+=V.r;ka.g+=V.g;ka.b+=V.b}else if(ca instanceof THREE.PointLight){B.r+=V.r;B.g+=V.g;B.b+=V.b}}}function Ca(S,ea,ca,V){var aa,ja,oa,ra,ta=S.lights;S=0;for(aa=ta.length;S<aa;S++){ja=ta[S];oa=ja.color;ra=ja.intensity;if(ja instanceof THREE.DirectionalLight){ja=ca.dot(ja.position)*ra;if(ja>0){V.r+=oa.r*ja;V.g+=oa.g*ja;V.b+=oa.b*ja}}else if(ja instanceof THREE.PointLight){O.sub(ja.position,ea);O.normalize();
ja=ca.dot(O)*ra;if(ja>0){V.r+=oa.r*ja;V.g+=oa.g*ja;V.b+=oa.b*ja}}}}function Ia(S,ea,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var V,aa,ja,oa,ra,ta;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){oa=ca.map.image;ra=oa.width>>1;ta=oa.height>>1;aa=ea.scale.x*l;ja=ea.scale.y*k;ca=aa*ra;V=ja*ta;M.set(S.x-ca,S.y-V,S.x+ca,S.y+V);if(Y.instersects(M)){m.save();m.translate(S.x,S.y);m.rotate(-ea.rotation);m.scale(aa,-ja);m.translate(-ra,-ta);m.drawImage(oa,0,0);m.restore()}}}else if(ca instanceof
THREE.ParticleCircleMaterial){if(Z){ba.r=ha.r+ka.r+B.r;ba.g=ha.g+ka.g+B.g;ba.b=ha.b+ka.b+B.b;R.r=ca.color.r*ba.r;R.g=ca.color.g*ba.g;R.b=ca.color.b*ba.b;R.updateStyleString()}else R.__styleString=ca.color.__styleString;ca=ea.scale.x*l;V=ea.scale.y*k;M.set(S.x-ca,S.y-V,S.x+ca,S.y+V);if(Y.instersects(M)){aa=R.__styleString;if(A!=aa)m.fillStyle=A=aa;m.save();m.translate(S.x,S.y);m.rotate(-ea.rotation);m.scale(ca,V);m.beginPath();m.arc(0,0,1,0,P,true);m.closePath();m.fill();m.restore()}}}}function Da(S,
ea,ca,V){if(V.opacity!=0){a(V.opacity);b(V.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ea.positionScreen.x,ea.positionScreen.y);m.closePath();if(V instanceof THREE.LineBasicMaterial){R.__styleString=V.color.__styleString;S=V.linewidth;if(E!=S)m.lineWidth=E=S;S=R.__styleString;if(d!=S)m.strokeStyle=d=S;m.stroke();M.inflate(V.linewidth*2)}}}function Ga(S,ea,ca,V,aa,ja){if(aa.opacity!=0){a(aa.opacity);b(aa.blending);I=S.positionScreen.x;Q=S.positionScreen.y;$=ea.positionScreen.x;
N=ea.positionScreen.y;K=ca.positionScreen.x;W=ca.positionScreen.y;m.beginPath();m.moveTo(I,Q);m.lineTo($,N);m.lineTo(K,W);m.lineTo(I,Q);m.closePath();if(aa instanceof THREE.MeshBasicMaterial)if(aa.map)aa.map.image.loaded&&aa.map.mapping instanceof THREE.UVMapping&&pa(I,Q,$,N,K,W,aa.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,V.uvs[2].v);else if(aa.env_map){if(aa.env_map.image.loaded)if(aa.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=va.matrix;O.copy(V.vertexNormalsWorld[0]);
L=(O.x*S.n11+O.y*S.n12+O.z*S.n13)*0.5+0.5;C=-(O.x*S.n21+O.y*S.n22+O.z*S.n23)*0.5+0.5;O.copy(V.vertexNormalsWorld[1]);D=(O.x*S.n11+O.y*S.n12+O.z*S.n13)*0.5+0.5;G=-(O.x*S.n21+O.y*S.n22+O.z*S.n23)*0.5+0.5;O.copy(V.vertexNormalsWorld[2]);H=(O.x*S.n11+O.y*S.n12+O.z*S.n13)*0.5+0.5;J=-(O.x*S.n21+O.y*S.n22+O.z*S.n23)*0.5+0.5;pa(I,Q,$,N,K,W,aa.env_map.image,L,C,D,G,H,J)}}else aa.wireframe?Ea(aa.color.__styleString,aa.wireframe_linewidth):Fa(aa.color.__styleString);else if(aa instanceof THREE.MeshLambertMaterial){if(aa.map&&
!aa.wireframe){aa.map.mapping instanceof THREE.UVMapping&&pa(I,Q,$,N,K,W,aa.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,V.uvs[2].v);b(THREE.SubtractiveBlending)}if(Z)if(!aa.wireframe&&aa.shading==THREE.SmoothShading&&V.vertexNormalsWorld.length==3){X.r=g.r=n.r=ha.r;X.g=g.g=n.g=ha.g;X.b=g.b=n.b=ha.b;Ca(ja,V.v1.positionWorld,V.vertexNormalsWorld[0],X);Ca(ja,V.v2.positionWorld,V.vertexNormalsWorld[1],g);Ca(ja,V.v3.positionWorld,V.vertexNormalsWorld[2],n);v.r=(g.r+n.r)*0.5;v.g=(g.g+
n.g)*0.5;v.b=(g.b+n.b)*0.5;z=Ja(X,g,n,v);pa(I,Q,$,N,K,W,z,0,0,1,0,0,1)}else{ba.r=ha.r;ba.g=ha.g;ba.b=ha.b;Ca(ja,V.centroidWorld,V.normalWorld,ba);R.r=aa.color.r*ba.r;R.g=aa.color.g*ba.g;R.b=aa.color.b*ba.b;R.updateStyleString();aa.wireframe?Ea(R.__styleString,aa.wireframe_linewidth):Fa(R.__styleString)}else aa.wireframe?Ea(aa.color.__styleString,aa.wireframe_linewidth):Fa(aa.color.__styleString)}else if(aa instanceof THREE.MeshDepthMaterial){x=va.near;q=va.far;X.r=X.g=X.b=1-Ka(S.positionScreen.z,
x,q);g.r=g.g=g.b=1-Ka(ea.positionScreen.z,x,q);n.r=n.g=n.b=1-Ka(ca.positionScreen.z,x,q);v.r=(g.r+n.r)*0.5;v.g=(g.g+n.g)*0.5;v.b=(g.b+n.b)*0.5;z=Ja(X,g,n,v);pa(I,Q,$,N,K,W,z,0,0,1,0,0,1)}else if(aa instanceof THREE.MeshNormalMaterial){R.r=La(V.normalWorld.x);R.g=La(V.normalWorld.y);R.b=La(V.normalWorld.z);R.updateStyleString();aa.wireframe?Ea(R.__styleString,aa.wireframe_linewidth):Fa(R.__styleString)}}}function Ea(S,ea){if(d!=S)m.strokeStyle=d=S;if(E!=ea)m.lineWidth=E=ea;m.stroke();M.inflate(ea*
2)}function Fa(S){if(A!=S)m.fillStyle=A=S;m.fill()}function pa(S,ea,ca,V,aa,ja,oa,ra,ta,za,wa,Aa,Ma){var xa,Ba;xa=oa.width-1;Ba=oa.height-1;ra*=xa;ta*=Ba;za*=xa;wa*=Ba;Aa*=xa;Ma*=Ba;ca-=S;V-=ea;aa-=S;ja-=ea;za-=ra;wa-=ta;Aa-=ra;Ma-=ta;xa=za*Ma-Aa*wa;if(xa!=0){Ba=1/xa;xa=(Ma*ca-wa*aa)*Ba;wa=(Ma*V-wa*ja)*Ba;ca=(za*aa-Aa*ca)*Ba;V=(za*ja-Aa*V)*Ba;S=S-xa*ra-ca*ta;ea=ea-wa*ra-V*ta;m.save();m.transform(xa,wa,ca,V,S,ea);m.clip();m.drawImage(oa,0,0);m.restore()}}function Ja(S,ea,ca,V){var aa=~~(S.r*255),ja=
~~(S.g*255);S=~~(S.b*255);var oa=~~(ea.r*255),ra=~~(ea.g*255);ea=~~(ea.b*255);var ta=~~(ca.r*255),za=~~(ca.g*255);ca=~~(ca.b*255);var wa=~~(V.r*255),Aa=~~(V.g*255);V=~~(V.b*255);ia[0]=aa<0?0:aa>255?255:aa;ia[1]=ja<0?0:ja>255?255:ja;ia[2]=S<0?0:S>255?255:S;ia[4]=oa<0?0:oa>255?255:oa;ia[5]=ra<0?0:ra>255?255:ra;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=ta<0?0:ta>255?255:ta;ia[9]=za<0?0:za>255?255:za;ia[10]=ca<0?0:ca>255?255:ca;ia[12]=wa<0?0:wa>255?255:wa;ia[13]=Aa<0?0:Aa>255?255:Aa;ia[14]=V<0?0:V>255?255:V;da.putImageData(na,
0,0);la.drawImage(U,0,0);return fa}function Ka(S,ea,ca){S=(S-ea)/(ca-ea);return S*S*(3-2*S)}function La(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function Na(S,ea){var ca=ea.x-S.x,V=ea.y-S.y,aa=1/Math.sqrt(ca*ca+V*V);ca*=aa;V*=aa;ea.x+=ca;ea.y+=V;S.x-=ca;S.y-=V}var ua,Qa,ma,ya,Ha,Pa,Ra,Oa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,l,k);c=e.projectScene(ga,va,this.sortElements);(Z=ga.lights.length>0)&&sa(ga);ua=0;for(Qa=c.length;ua<Qa;ua++){ma=c[ua];M.empty();if(ma instanceof THREE.RenderableParticle){w=
ma;w.x*=l;w.y*=k;ya=0;for(Ha=ma.materials.length;ya<Ha;ya++)Ia(w,ma,ma.materials[ya],ga)}else if(ma instanceof THREE.RenderableLine){w=ma.v1;F=ma.v2;w.positionScreen.x*=l;w.positionScreen.y*=k;F.positionScreen.x*=l;F.positionScreen.y*=k;M.addPoint(w.positionScreen.x,w.positionScreen.y);M.addPoint(F.positionScreen.x,F.positionScreen.y);if(Y.instersects(M)){ya=0;for(Ha=ma.materials.length;ya<Ha;)Da(w,F,ma,ma.materials[ya++],ga)}}else if(ma instanceof THREE.RenderableFace3){w=ma.v1;F=ma.v2;u=ma.v3;w.positionScreen.x*=
l;w.positionScreen.y*=k;F.positionScreen.x*=l;F.positionScreen.y*=k;u.positionScreen.x*=l;u.positionScreen.y*=k;if(ma.overdraw){Na(w.positionScreen,F.positionScreen);Na(F.positionScreen,u.positionScreen);Na(u.positionScreen,w.positionScreen)}M.add3Points(w.positionScreen.x,w.positionScreen.y,F.positionScreen.x,F.positionScreen.y,u.positionScreen.x,u.positionScreen.y);if(Y.instersects(M)){ya=0;for(Ha=ma.meshMaterials.length;ya<Ha;){Oa=ma.meshMaterials[ya++];if(Oa instanceof THREE.MeshFaceMaterial){Pa=
0;for(Ra=ma.faceMaterials.length;Pa<Ra;)(Oa=ma.faceMaterials[Pa++])&&Ga(w,F,u,ma,Oa,ga)}else Ga(w,F,u,ma,Oa,ga)}}}T.addRectangle(M)}m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(L,C,D){var G,H,J,Y;G=0;for(H=L.lights.length;G<H;G++){J=L.lights[G];if(J instanceof THREE.DirectionalLight){Y=C.normalWorld.dot(J.position)*J.intensity;if(Y>0){D.r+=J.color.r*Y;D.g+=J.color.g*Y;D.b+=J.color.b*Y}}else if(J instanceof THREE.PointLight){W.sub(J.position,C.centroidWorld);W.normalize();Y=C.normalWorld.dot(W)*J.intensity;if(Y>0){D.r+=J.color.r*Y;D.g+=J.color.g*Y;D.b+=J.color.b*Y}}}}function b(L,C,D,G,H,J){n=e(v++);n.setAttribute("d","M "+L.positionScreen.x+
" "+L.positionScreen.y+" L "+C.positionScreen.x+" "+C.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)u.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(F){I.r=Q.r;I.g=Q.g;I.b=Q.b;a(J,G,I);u.r=H.color.r*I.r;u.g=H.color.g*I.g;u.b=H.color.b*I.b;u.updateStyleString()}else u.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){K=1-H.__2near/(H.__farPlusNear-G.z*H.__farMinusNear);
u.setRGB(K,K,K)}else H instanceof THREE.MeshNormalMaterial&&u.setRGB(h(G.normalWorld.x),h(G.normalWorld.y),h(G.normalWorld.z));H.wireframe?n.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):n.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+H.opacity);l.appendChild(n)}function c(L,C,D,G,H,J,Y){n=e(v++);n.setAttribute("d",
"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+C.positionScreen.x+" "+C.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)u.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(F){I.r=Q.r;I.g=Q.g;I.b=Q.b;a(Y,H,I);u.r=J.color.r*I.r;u.g=J.color.g*I.g;u.b=J.color.b*I.b;u.updateStyleString()}else u.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){K=
1-J.__2near/(J.__farPlusNear-H.z*J.__farMinusNear);u.setRGB(K,K,K)}else J instanceof THREE.MeshNormalMaterial&&u.setRGB(h(H.normalWorld.x),h(H.normalWorld.y),h(H.normalWorld.z));J.wireframe?n.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):n.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+J.opacity);l.appendChild(n)}
function e(L){if(R[L]==null){R[L]=document.createElementNS("http://www.w3.org/2000/svg","path");z==0&&R[L].setAttribute("shape-rendering","crispEdges");return R[L]}return R[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var f=null,j=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,p,y,t,o,d,A,E=new THREE.Rectangle,w=new THREE.Rectangle,F=false,u=new THREE.Color(16777215),I=new THREE.Color(16777215),Q=new THREE.Color(0),$=new THREE.Color(0),
N=new THREE.Color(0),K,W=new THREE.Vector3,R=[],X=[],g=[],n,v,x,q,z=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":z=1;break;case "low":z=0}};this.setSize=function(L,C){k=L;m=C;p=k/2;y=m/2;l.setAttribute("viewBox",-p+" "+-y+" "+k+" "+m);l.setAttribute("width",k);l.setAttribute("height",m);E.set(-p,-y,p,y)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(L,C){var D,G,
H,J,Y,T,M,Z;this.autoClear&&this.clear();f=j.projectScene(L,C,this.sortElements);q=x=v=0;if(F=L.lights.length>0){M=L.lights;Q.setRGB(0,0,0);$.setRGB(0,0,0);N.setRGB(0,0,0);D=0;for(G=M.length;D<G;D++){H=M[D];J=H.color;if(H instanceof THREE.AmbientLight){Q.r+=J.r;Q.g+=J.g;Q.b+=J.b}else if(H instanceof THREE.DirectionalLight){$.r+=J.r;$.g+=J.g;$.b+=J.b}else if(H instanceof THREE.PointLight){N.r+=J.r;N.g+=J.g;N.b+=J.b}}}D=0;for(G=f.length;D<G;D++){M=f[D];w.empty();if(M instanceof THREE.RenderableParticle){t=
M;t.x*=p;t.y*=-y;H=0;for(J=M.materials.length;H<J;H++)if(Z=M.materials[H]){Y=t;T=M;Z=Z;var ba=x++;if(X[ba]==null){X[ba]=document.createElementNS("http://www.w3.org/2000/svg","circle");z==0&&X[ba].setAttribute("shape-rendering","crispEdges")}n=X[ba];n.setAttribute("cx",Y.x);n.setAttribute("cy",Y.y);n.setAttribute("r",T.scale.x*p);if(Z instanceof THREE.ParticleCircleMaterial){if(F){I.r=Q.r+$.r+N.r;I.g=Q.g+$.g+N.g;I.b=Q.b+$.b+N.b;u.r=Z.color.r*I.r;u.g=Z.color.g*I.g;u.b=Z.color.b*I.b;u.updateStyleString()}else u=
Z.color;n.setAttribute("style","fill: "+u.__styleString)}l.appendChild(n)}}else if(M instanceof THREE.RenderableLine){t=M.v1;o=M.v2;t.positionScreen.x*=p;t.positionScreen.y*=-y;o.positionScreen.x*=p;o.positionScreen.y*=-y;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);if(E.instersects(w)){H=0;for(J=M.materials.length;H<J;)if(Z=M.materials[H++]){Y=t;T=o;Z=Z;ba=q++;if(g[ba]==null){g[ba]=document.createElementNS("http://www.w3.org/2000/svg","line");
z==0&&g[ba].setAttribute("shape-rendering","crispEdges")}n=g[ba];n.setAttribute("x1",Y.positionScreen.x);n.setAttribute("y1",Y.positionScreen.y);n.setAttribute("x2",T.positionScreen.x);n.setAttribute("y2",T.positionScreen.y);if(Z instanceof THREE.LineBasicMaterial){u.__styleString=Z.color.__styleString;n.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+Z.linewidth+"; stroke-opacity: "+Z.opacity+"; stroke-linecap: "+Z.linecap+"; stroke-linejoin: "+Z.linejoin);l.appendChild(n)}}}}else if(M instanceof
THREE.RenderableFace3){t=M.v1;o=M.v2;d=M.v3;t.positionScreen.x*=p;t.positionScreen.y*=-y;o.positionScreen.x*=p;o.positionScreen.y*=-y;d.positionScreen.x*=p;d.positionScreen.y*=-y;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);w.addPoint(d.positionScreen.x,d.positionScreen.y);if(E.instersects(w)){H=0;for(J=M.meshMaterials.length;H<J;){Z=M.meshMaterials[H++];if(Z instanceof THREE.MeshFaceMaterial){Y=0;for(T=M.faceMaterials.length;Y<T;)(Z=M.faceMaterials[Y++])&&
b(t,o,d,M,Z,L)}else Z&&b(t,o,d,M,Z,L)}}}else if(M instanceof THREE.RenderableFace4){t=M.v1;o=M.v2;d=M.v3;A=M.v4;t.positionScreen.x*=p;t.positionScreen.y*=-y;o.positionScreen.x*=p;o.positionScreen.y*=-y;d.positionScreen.x*=p;d.positionScreen.y*=-y;A.positionScreen.x*=p;A.positionScreen.y*=-y;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);w.addPoint(d.positionScreen.x,d.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);if(E.instersects(w)){H=
0;for(J=M.meshMaterials.length;H<J;){Z=M.meshMaterials[H++];if(Z instanceof THREE.MeshFaceMaterial){Y=0;for(T=M.faceMaterials.length;Y<T;)(Z=M.faceMaterials[Y++])&&c(t,o,d,A,M,Z,L)}else Z&&c(t,o,d,A,M,Z,L)}}}}}};
THREE.WebGLRenderer=function(a){function b(g,n){g.fragment_shader=n.fragment_shader;g.vertex_shader=n.vertex_shader;g.uniforms=Uniforms.clone(n.uniforms)}function c(g,n){if(!g.__webGLVertexBuffer)g.__webGLVertexBuffer=d.createBuffer();if(!g.__webGLNormalBuffer)g.__webGLNormalBuffer=d.createBuffer();if(g.hasPos){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,g.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(n.attributes.position);d.vertexAttribPointer(n.attributes.position,
3,d.FLOAT,false,0,0)}if(g.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,g.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(n.attributes.normal);d.vertexAttribPointer(n.attributes.normal,3,d.FLOAT,false,0,0)}d.drawArrays(d.TRIANGLES,0,g.count);g.count=0}function e(g){if(w!=g.doubleSided){g.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);w=g.doubleSided}if(F!=g.flipSided){g.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);F=g.flipSided}}function h(g){I[0].set(g.n41-
g.n11,g.n42-g.n12,g.n43-g.n13,g.n44-g.n14);I[1].set(g.n41+g.n11,g.n42+g.n12,g.n43+g.n13,g.n44+g.n14);I[2].set(g.n41+g.n21,g.n42+g.n22,g.n43+g.n23,g.n44+g.n24);I[3].set(g.n41-g.n21,g.n42-g.n22,g.n43-g.n23,g.n44-g.n24);I[4].set(g.n41-g.n31,g.n42-g.n32,g.n43-g.n33,g.n44-g.n34);I[5].set(g.n41+g.n31,g.n42+g.n32,g.n43+g.n33,g.n44+g.n34);var n;for(g=0;g<5;g++){n=I[g];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}}function f(g){for(var n=g.matrix,v=-g.geometry.boundingSphere.radius*Math.max(g.scale.x,
Math.max(g.scale.y,g.scale.z)),x=0;x<6;x++){g=I[x].x*n.n14+I[x].y*n.n24+I[x].z*n.n34+I[x].w;if(g<=v)return false}return true}function j(g,n){g.list[g.count]=n;g.count+=1}function l(g){var n,v,x=g.object,q=g.opaque,z=g.transparent;z.count=0;g=q.count=0;for(n=x.materials.length;g<n;g++){v=x.materials[g];v.opacity&&v.opacity<1||v.blending!=THREE.NormalBlending?j(z,v):j(q,v)}}function k(g){var n,v,x,q,z=g.object,L=g.buffer,C=g.opaque,D=g.transparent;D.count=0;g=C.count=0;for(x=z.materials.length;g<x;g++){n=
z.materials[g];if(n instanceof THREE.MeshFaceMaterial){n=0;for(v=L.materials.length;n<v;n++)if(q=L.materials[n])q.opacity&&q.opacity<1||q.blending!=THREE.NormalBlending?j(D,q):j(C,q)}else{q=n;q.opacity&&q.opacity<1||q.blending!=THREE.NormalBlending?j(D,q):j(C,q)}}}function m(g){if(g!=u){switch(g){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);
d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}u=g}}function p(g,n){if(g&&!g.__webGLFramebuffer){g.__webGLFramebuffer=d.createFramebuffer();g.__webGLRenderbuffer=d.createRenderbuffer();g.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,g.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,g.width,g.height);d.bindTexture(d.TEXTURE_2D,g.__webGLTexture);d.texParameteri(d.TEXTURE_2D,
d.TEXTURE_WRAP_S,t(g.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,t(g.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t(g.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,t(g.min_filter));d.texImage2D(d.TEXTURE_2D,0,t(g.format),g.width,g.height,0,t(g.format),t(g.type),null);d.bindFramebuffer(d.FRAMEBUFFER,g.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,g.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,
d.RENDERBUFFER,g.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var v,x,q;if(g){v=g.__webGLFramebuffer;x=g.width;q=g.height}else{v=null;x=o.width;q=o.height}if(v!=E){d.bindFramebuffer(d.FRAMEBUFFER,v);d.viewport(0,0,x,q);n&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);E=v}}function y(g,n){var v;if(g=="fragment")v=d.createShader(d.FRAGMENT_SHADER);else if(g=="vertex")v=d.createShader(d.VERTEX_SHADER);d.shaderSource(v,
n);d.compileShader(v);if(!d.getShaderParameter(v,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(v));return null}return v}function t(g){switch(g){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;
case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;
case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var o=document.createElement("canvas"),d,A=null,E=null,w=null,F=null,u=null,I=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Q=new THREE.Matrix4,$=new Float32Array(16),N=new Float32Array(16),K=new THREE.Vector4,W=true,R=new THREE.Color(0),X=0;if(a){if(a.antialias!==undefined)W=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);
if(a.clearAlpha!==undefined)X=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(g,n,v){try{d=o.getContext("experimental-webgl",{antialias:g})}catch(x){console.log(x)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(n.r,n.g,n.b,v);_cullEnabled=true})(W,
R,X);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,n){o.width=g;o.height=n;d.viewport(0,0,o.width,o.height)};this.setClearColorHex=function(g,n){var v=new THREE.Color(g);d.clearColor(v.r,v.g,v.b,n)};this.setClearColor=function(g,n){d.clearColor(g.r,g.g,g.b,n)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(g,n){var v,x,q,z=0,L=0,C=0,D,G,H,J=
this.lights,Y=J.directional.colors,T=J.directional.positions,M=J.point.colors,Z=J.point.positions,ba=0,ha=0;v=q=q=0;for(x=n.length;v<x;v++){q=n[v];D=q.color;G=q.position;H=q.intensity;if(q instanceof THREE.AmbientLight){z+=D.r;L+=D.g;C+=D.b}else if(q instanceof THREE.DirectionalLight){q=ba*3;Y[q]=D.r*H;Y[q+1]=D.g*H;Y[q+2]=D.b*H;T[q]=G.x;T[q+1]=G.y;T[q+2]=G.z;ba+=1}else if(q instanceof THREE.PointLight){q=ha*3;M[q]=D.r*H;M[q+1]=D.g*H;M[q+2]=D.b*H;Z[q]=G.x;Z[q+1]=G.y;Z[q+2]=G.z;ha+=1}}for(v=ba*3;v<
Y.length;v++)Y[v]=0;for(v=ha*3;v<M.length;v++)M[v]=0;J.point.length=ha;J.directional.length=ba;J.ambient[0]=z;J.ambient[1]=L;J.ambient[2]=C};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=d.createBuffer();g.__webGLColorBuffer=d.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=d.createBuffer();g.__webGLColorBuffer=d.createBuffer()};this.createMeshBuffers=function(g){g.__webGLVertexBuffer=d.createBuffer();g.__webGLNormalBuffer=d.createBuffer();g.__webGLTangentBuffer=
d.createBuffer();g.__webGLColorBuffer=d.createBuffer();g.__webGLUVBuffer=d.createBuffer();g.__webGLUV2Buffer=d.createBuffer();g.__webGLFaceBuffer=d.createBuffer();g.__webGLLineBuffer=d.createBuffer()};this.initLineBuffers=function(g){var n=g.vertices.length;g.__vertexArray=new Float32Array(n*3);g.__colorArray=new Float32Array(n*3);g.__webGLLineCount=n};this.initParticleBuffers=function(g){var n=g.vertices.length;g.__vertexArray=new Float32Array(n*3);g.__colorArray=new Float32Array(n*3);g.__sortArray=
[];g.__webGLParticleCount=n};this.initMeshBuffers=function(g,n){var v,x,q=0,z=0,L=0,C=n.geometry.faces,D=g.faces;v=0;for(x=D.length;v<x;v++){fi=D[v];face=C[fi];if(face instanceof THREE.Face3){q+=3;z+=1;L+=3}else if(face instanceof THREE.Face4){q+=4;z+=2;L+=4}}g.__vertexArray=new Float32Array(q*3);g.__normalArray=new Float32Array(q*3);g.__tangentArray=new Float32Array(q*4);g.__colorArray=new Float32Array(q*3);g.__uvArray=new Float32Array(q*2);g.__uv2Array=new Float32Array(q*2);g.__faceArray=new Uint16Array(z*
3);g.__lineArray=new Uint16Array(L*2);q=false;v=0;for(x=n.materials.length;v<x;v++){C=n.materials[v];if(C instanceof THREE.MeshFaceMaterial){C=0;for(D=g.materials.length;C<D;C++)if(g.materials[C]&&g.materials[C].shading!=undefined&&g.materials[C].shading==THREE.SmoothShading){q=true;break}}else if(C&&C.shading!=undefined&&C.shading==THREE.SmoothShading){q=true;break}if(q)break}g.__needsSmoothNormals=q;g.__webGLFaceCount=z*3;g.__webGLLineCount=L*2};this.setMeshBuffers=function(g,n,v){var x,q,z,L,C,
D,G,H,J,Y,T=0,M=0,Z=0,ba=0,ha=0,ka=0,B=0,P=0,O=0,U=g.__vertexArray,da=g.__uvArray,na=g.__uv2Array,ia=g.__normalArray,fa=g.__tangentArray,la=g.__colorArray,qa=g.__faceArray,ga=g.__lineArray,va=g.__needsSmoothNormals,sa=n.geometry,Ca=sa.__dirtyVertices,Ia=sa.__dirtyElements,Da=sa.__dirtyUvs,Ga=sa.__dirtyNormals,Ea=sa.__dirtyTangents,Fa=sa.__dirtyColors,pa=sa.vertices,Ja=g.faces,Ka=sa.faces,La=sa.uvs,Na=sa.uvs2,ua=sa.colors;n=0;for(x=Ja.length;n<x;n++){q=Ja[n];z=Ka[q];D=La[q];q=Na[q];L=z.vertexNormals;
C=z.normal;if(z instanceof THREE.Face3){if(Ca){G=pa[z.a].position;H=pa[z.b].position;J=pa[z.c].position;U[M]=G.x;U[M+1]=G.y;U[M+2]=G.z;U[M+3]=H.x;U[M+4]=H.y;U[M+5]=H.z;U[M+6]=J.x;U[M+7]=J.y;U[M+8]=J.z;M+=9}if(Fa&&ua.length){G=ua[z.a];H=ua[z.b];J=ua[z.c];la[O]=G.r;la[O+1]=G.g;la[O+2]=G.b;la[O+3]=H.r;la[O+4]=H.g;la[O+5]=H.b;la[O+6]=J.r;la[O+7]=J.g;la[O+8]=J.b;O+=9}if(Ea&&sa.hasTangents){G=pa[z.a].tangent;H=pa[z.b].tangent;J=pa[z.c].tangent;fa[B]=G.x;fa[B+1]=G.y;fa[B+2]=G.z;fa[B+3]=G.w;fa[B+4]=H.x;fa[B+
5]=H.y;fa[B+6]=H.z;fa[B+7]=H.w;fa[B+8]=J.x;fa[B+9]=J.y;fa[B+10]=J.z;fa[B+11]=J.w;B+=12}if(Ga)if(L.length==3&&va)for(z=0;z<3;z++){C=L[z];ia[ka]=C.x;ia[ka+1]=C.y;ia[ka+2]=C.z;ka+=3}else for(z=0;z<3;z++){ia[ka]=C.x;ia[ka+1]=C.y;ia[ka+2]=C.z;ka+=3}if(Da&&D)for(z=0;z<3;z++){L=D[z];da[Z]=L.u;da[Z+1]=L.v;Z+=2}if(Da&&q)for(z=0;z<3;z++){D=q[z];na[ba]=D.u;na[ba+1]=D.v;ba+=2}if(Ia){qa[ha]=T;qa[ha+1]=T+1;qa[ha+2]=T+2;ha+=3;ga[P]=T;ga[P+1]=T+1;ga[P+2]=T;ga[P+3]=T+2;ga[P+4]=T+1;ga[P+5]=T+2;P+=6;T+=3}}else if(z instanceof
THREE.Face4){if(Ca){G=pa[z.a].position;H=pa[z.b].position;J=pa[z.c].position;Y=pa[z.d].position;U[M]=G.x;U[M+1]=G.y;U[M+2]=G.z;U[M+3]=H.x;U[M+4]=H.y;U[M+5]=H.z;U[M+6]=J.x;U[M+7]=J.y;U[M+8]=J.z;U[M+9]=Y.x;U[M+10]=Y.y;U[M+11]=Y.z;M+=12}if(Fa&&ua.length){G=ua[z.a];H=ua[z.b];J=ua[z.c];Y=ua[z.d];la[O]=G.r;la[O+1]=G.g;la[O+2]=G.b;la[O+3]=H.r;la[O+4]=H.g;la[O+5]=H.b;la[O+6]=J.r;la[O+7]=J.g;la[O+8]=J.b;la[O+9]=Y.r;la[O+10]=Y.g;la[O+11]=Y.b;O+=12}if(Ea&&sa.hasTangents){G=pa[z.a].tangent;H=pa[z.b].tangent;
J=pa[z.c].tangent;z=pa[z.d].tangent;fa[B]=G.x;fa[B+1]=G.y;fa[B+2]=G.z;fa[B+3]=G.w;fa[B+4]=H.x;fa[B+5]=H.y;fa[B+6]=H.z;fa[B+7]=H.w;fa[B+8]=J.x;fa[B+9]=J.y;fa[B+10]=J.z;fa[B+11]=J.w;fa[B+12]=z.x;fa[B+13]=z.y;fa[B+14]=z.z;fa[B+15]=z.w;B+=16}if(Ga)if(L.length==4&&va)for(z=0;z<4;z++){C=L[z];ia[ka]=C.x;ia[ka+1]=C.y;ia[ka+2]=C.z;ka+=3}else for(z=0;z<4;z++){ia[ka]=C.x;ia[ka+1]=C.y;ia[ka+2]=C.z;ka+=3}if(Da&&D)for(z=0;z<4;z++){L=D[z];da[Z]=L.u;da[Z+1]=L.v;Z+=2}if(Da&&q)for(z=0;z<4;z++){D=q[z];na[ba]=D.u;na[ba+
1]=D.v;ba+=2}if(Ia){qa[ha]=T;qa[ha+1]=T+1;qa[ha+2]=T+2;qa[ha+3]=T;qa[ha+4]=T+2;qa[ha+5]=T+3;ha+=6;ga[P]=T;ga[P+1]=T+1;ga[P+2]=T;ga[P+3]=T+3;ga[P+4]=T+1;ga[P+5]=T+2;ga[P+6]=T+2;ga[P+7]=T+3;P+=8;T+=4}}}if(Ca){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,U,v)}if(Fa&&ua.length){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,la,v)}if(Ga){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,ia,v)}if(Ea&&sa.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,
g.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,fa,v)}if(Da&&Z>0){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,da,v)}if(Da&&ba>0){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,na,v)}if(Ia){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,qa,v);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,ga,v)}};this.setLineBuffers=function(g,n){var v,x,q,z=g.vertices,
L=g.colors,C=z.length,D=L.length,G=g.__vertexArray,H=g.__colorArray,J=g.__dirtyColors;if(g.__dirtyVertices){for(v=0;v<C;v++){x=z[v].position;q=v*3;G[q]=x.x;G[q+1]=x.y;G[q+2]=x.z}d.bindBuffer(d.ARRAY_BUFFER,g.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,G,n)}if(J){for(v=0;v<D;v++){color=L[v];q=v*3;H[q]=color.r;H[q+1]=color.g;H[q+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,g.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,H,n)}};this.setParticleBuffers=function(g,n,v){var x,q,z,L=g.vertices,C=L.length,
D=g.colors,G=D.length,H=g.__vertexArray,J=g.__colorArray,Y=g.__sortArray,T=g.__dirtyVertices,M=g.__dirtyColors;if(v.sortParticles){Q.multiplySelf(v.matrix);for(x=0;x<C;x++){q=L[x].position;K.copy(q);Q.multiplyVector3(K);Y[x]=[K.z,x]}Y.sort(function(Z,ba){return ba[0]-Z[0]});for(x=0;x<C;x++){q=L[Y[x][1]].position;z=x*3;H[z]=q.x;H[z+1]=q.y;H[z+2]=q.z}for(x=0;x<G;x++){z=x*3;color=D[Y[x][1]];J[z]=color.r;J[z+1]=color.g;J[z+2]=color.b}}else{if(T)for(x=0;x<C;x++){q=L[x].position;z=x*3;H[z]=q.x;H[z+1]=q.y;
H[z+2]=q.z}if(M)for(x=0;x<G;x++){color=D[x];z=x*3;J[z]=color.r;J[z+1]=color.g;J[z+2]=color.b}}if(T||v.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,H,n)}if(M||v.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,J,n)}};this.initMaterial=function(g,n,v){var x,q;if(g instanceof THREE.MeshDepthMaterial)b(g,THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)b(g,THREE.ShaderLib.normal);else if(g instanceof
THREE.MeshBasicMaterial)b(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)b(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)b(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)b(g,THREE.ShaderLib.basic);else g instanceof THREE.ParticleBasicMaterial&&b(g,THREE.ShaderLib.particle_basic);var z,L,C,D;q=C=D=0;for(z=n.length;q<z;q++){L=n[q];L instanceof THREE.DirectionalLight&&C++;L instanceof THREE.PointLight&&D++}if(D+C<=4){n=C;D=D}else{n=
Math.ceil(4*C/(D+C));D=4-n}q={directional:n,point:D};D=g.fragment_shader;n=g.vertex_shader;z={fog:v,map:g.map,env_map:g.env_map,light_map:g.light_map,vertex_colors:g.vertex_colors,maxDirLights:q.directional,maxPointLights:q.point};v=d.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+z.maxDirLights,"#define MAX_POINT_LIGHTS "+z.maxPointLights,z.fog?"#define USE_FOG":"",z.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",z.map?"#define USE_MAP":"",z.env_map?
"#define USE_ENVMAP":"",z.light_map?"#define USE_LIGHTMAP":"",z.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");z=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#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":"",z.light_map?"#define USE_LIGHTMAP":"",z.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
d.attachShader(v,y("fragment",q+D));d.attachShader(v,y("vertex",z+n));d.linkProgram(v);d.getProgramParameter(v,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(v,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");v.uniforms={};v.attributes={};g.program=v;v=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(x in g.uniforms)v.push(x);x=g.program;D=0;for(n=v.length;D<n;D++){q=v[D];x.uniforms[q]=d.getUniformLocation(x,
q)}g=g.program;x=["position","normal","uv","uv2","tangent","color"];v=0;for(D=x.length;v<D;v++){n=x[v];g.attributes[n]=d.getAttribLocation(g,n)}};this.setProgram=function(g,n,v,x,q){x.program||this.initMaterial(x,n,v);var z=x.program,L=z.uniforms,C=x.uniforms;if(z!=A){d.useProgram(z);A=z;d.uniformMatrix4fv(L.projectionMatrix,false,$)}if(v&&(x instanceof THREE.MeshBasicMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshPhongMaterial||x instanceof THREE.LineBasicMaterial||x instanceof
THREE.ParticleBasicMaterial)){C.fogColor.value.setHex(v.color.hex);if(v instanceof THREE.Fog){C.fogNear.value=v.near;C.fogFar.value=v.far}else if(v instanceof THREE.FogExp2)C.fogDensity.value=v.density}if(x instanceof THREE.MeshPhongMaterial||x instanceof THREE.MeshLambertMaterial){this.setupLights(z,n);n=this.lights;C.enableLighting.value=n.directional.length+n.point.length;C.ambientLightColor.value=n.ambient;C.directionalLightColor.value=n.directional.colors;C.directionalLightDirection.value=n.directional.positions;
C.pointLightColor.value=n.point.colors;C.pointLightPosition.value=n.point.positions}if(x instanceof THREE.MeshBasicMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshPhongMaterial){C.diffuse.value.setRGB(x.color.r*x.opacity,x.color.g*x.opacity,x.color.b*x.opacity);C.opacity.value=x.opacity;C.map.texture=x.map;C.light_map.texture=x.light_map;C.env_map.texture=x.env_map;C.reflectivity.value=x.reflectivity;C.refraction_ratio.value=x.refraction_ratio;C.combine.value=x.combine;C.useRefract.value=
x.env_map&&x.env_map.mapping instanceof THREE.CubeRefractionMapping}if(x instanceof THREE.LineBasicMaterial){C.diffuse.value.setRGB(x.color.r*x.opacity,x.color.g*x.opacity,x.color.b*x.opacity);C.opacity.value=x.opacity}else if(x instanceof THREE.ParticleBasicMaterial){C.psColor.value.setRGB(x.color.r*x.opacity,x.color.g*x.opacity,x.color.b*x.opacity);C.opacity.value=x.opacity;C.size.value=x.size;C.map.texture=x.map}else if(x instanceof THREE.MeshPhongMaterial){C.ambient.value.setRGB(x.ambient.r,x.ambient.g,
x.ambient.b);C.specular.value.setRGB(x.specular.r,x.specular.g,x.specular.b);C.shininess.value=x.shininess}else if(x instanceof THREE.MeshDepthMaterial){C.mNear.value=g.near;C.mFar.value=g.far;C.opacity.value=x.opacity}else if(x instanceof THREE.MeshNormalMaterial)C.opacity.value=x.opacity;var D,G,H;for(D in C)if(H=z.uniforms[D]){v=C[D];G=v.type;n=v.value;if(G=="i")d.uniform1i(H,n);else if(G=="f")d.uniform1f(H,n);else if(G=="fv1")d.uniform1fv(H,n);else if(G=="fv")d.uniform3fv(H,n);else if(G=="v2")d.uniform2f(H,
n.x,n.y);else if(G=="v3")d.uniform3f(H,n.x,n.y,n.z);else if(G=="c")d.uniform3f(H,n.r,n.g,n.b);else if(G=="t"){d.uniform1i(H,n);if(v=v.texture)if(v.image instanceof Array&&v.image.length==6){v=v;n=n;if(v.image.length==6){if(!v.image.__webGLTextureCube&&!v.image.__cubeMapInitialized&&v.image.loadCount==6){v.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,v.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,
d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(G=0;G<6;++G)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+G,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,v.image[G]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);v.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+n);d.bindTexture(d.TEXTURE_CUBE_MAP,v.image.__webGLTextureCube)}}else{v=v;n=n;if(!v.__webGLTexture&&
v.image.loaded){v.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,v.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,v.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,t(v.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,t(v.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t(v.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,t(v.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+
n);d.bindTexture(d.TEXTURE_2D,v.__webGLTexture)}}}d.uniformMatrix4fv(L.modelViewMatrix,false,q._modelViewMatrixArray);d.uniformMatrix3fv(L.normalMatrix,false,q._normalMatrixArray);if(x instanceof THREE.MeshShaderMaterial||x instanceof THREE.MeshPhongMaterial||x.env_map)d.uniform3f(L.cameraPosition,g.position.x,g.position.y,g.position.z);if(x instanceof THREE.MeshShaderMaterial||x.env_map)d.uniformMatrix4fv(L.objectMatrix,false,q._objectMatrixArray);if(x instanceof THREE.MeshPhongMaterial||x instanceof
THREE.MeshLambertMaterial||x instanceof THREE.MeshShaderMaterial)d.uniformMatrix4fv(L.viewMatrix,false,N);return z};this.renderBuffer=function(g,n,v,x,q,z){g=this.setProgram(g,n,v,x,z).attributes;d.bindBuffer(d.ARRAY_BUFFER,q.__webGLVertexBuffer);d.vertexAttribPointer(g.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(g.position);if(g.color>=0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.vertexAttribPointer(g.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(g.color)}if(g.normal>=
0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLNormalBuffer);d.vertexAttribPointer(g.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(g.normal)}if(g.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLTangentBuffer);d.vertexAttribPointer(g.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(g.tangent)}if(g.uv>=0)if(q.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLUVBuffer);d.vertexAttribPointer(g.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(g.uv)}else d.disableVertexAttribArray(g.uv);if(g.uv2>=
0)if(q.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLUV2Buffer);d.vertexAttribPointer(g.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(g.uv2)}else d.disableVertexAttribArray(g.uv2);if(z instanceof THREE.Mesh)if(x.wireframe){d.lineWidth(x.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);d.drawElements(d.LINES,q.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,q.__webGLFaceCount,d.UNSIGNED_SHORT,
0)}else if(z instanceof THREE.Line){z=z.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(x.linewidth);d.drawArrays(z,0,q.__webGLLineCount)}else z instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,q.__webGLParticleCount)};this.render=function(g,n,v,x){var q,z,L,C,D,G,H,J=g.lights,Y=g.fog;n.autoUpdateMatrix&&n.updateMatrix();n.matrix.flattenToArray(N);n.projectionMatrix.flattenToArray($);Q.multiply(n.projectionMatrix,n.matrix);h(Q);this.initWebGLObjects(g,n);p(v,x!==undefined?x:true);this.autoClear&&
this.clear();C=g.__webGLObjects.length;for(x=0;x<C;x++){q=g.__webGLObjects[x];G=q.object;if(G.visible&&(!(G instanceof THREE.Mesh)||f(G))){if(G.autoUpdateMatrix){G.updateMatrix();G.matrix.flattenToArray(G._objectMatrixArray)}this.setupMatrices(G,n);k(q);q.render=true}else q.render=false}D=g.__webGLObjectsImmediate.length;for(x=0;x<D;x++){q=g.__webGLObjectsImmediate[x];G=q.object;if(G.visible){if(G.autoUpdateMatrix){G.updateMatrix();G.matrix.flattenToArray(G._objectMatrixArray)}this.setupMatrices(G,
n);l(q)}}m(THREE.NormalBlending);for(x=0;x<C;x++){q=g.__webGLObjects[x];if(q.render){G=q.object;H=q.buffer;L=q.opaque;e(G);for(q=0;q<L.count;q++){material=L.list[q];this.setDepthTest(material.depth_test);this.renderBuffer(n,J,Y,material,H,G)}}}for(x=0;x<D;x++){q=g.__webGLObjectsImmediate[x];G=q.object;if(G.visible){L=q.opaque;e(G);for(q=0;q<L.count;q++){material=L.list[q];this.setDepthTest(material.depth_test);z=this.setProgram(n,J,Y,material,G);G.render(function(T){c(T,z)})}}}for(x=0;x<C;x++){q=
g.__webGLObjects[x];if(q.render){G=q.object;H=q.buffer;L=q.transparent;e(G);for(q=0;q<L.count;q++){material=L.list[q];m(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(n,J,Y,material,H,G)}}}for(x=0;x<D;x++){q=g.__webGLObjectsImmediate[x];G=q.object;if(G.visible){L=q.transparent;e(G);for(q=0;q<L.count;q++){material=L.list[q];m(material.blending);this.setDepthTest(material.depth_test);z=this.setProgram(n,J,Y,material,G);G.render(function(T){c(T,z)})}}}if(v&&v.min_filter!==
THREE.NearestFilter&&v.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,v.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(g,n){function v(J,Y,T,M){if(J[Y]==undefined){g.__webGLObjects.push({buffer:T,object:M,opaque:{list:[],count:0},transparent:{list:[],count:0}});J[Y]=1}}function x(J,Y,T){if(J[Y]==undefined){g.__webGLObjectsImmediate.push({object:T,opaque:{list:[],count:0},transparent:{list:[],count:0}});J[Y]=1}}var q,z,
L,C,D,G,H;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={};g.__webGLObjectsImmediate=[]}q=0;for(z=g.objects.length;q<z;q++){L=g.objects[q];D=L.geometry;if(g.__webGLObjectsMap[L.id]==undefined){g.__webGLObjectsMap[L.id]={};L._modelViewMatrix=new THREE.Matrix4;L._normalMatrixArray=new Float32Array(9);L._modelViewMatrixArray=new Float32Array(16);L._objectMatrixArray=new Float32Array(16);L.matrix.flattenToArray(L._objectMatrixArray)}H=g.__webGLObjectsMap[L.id];if(L instanceof THREE.Mesh){for(C in D.geometryChunks){G=
D.geometryChunks[C];if(!G.__webGLVertexBuffer){this.createMeshBuffers(G);this.initMeshBuffers(G,L);D.__dirtyVertices=true;D.__dirtyElements=true;D.__dirtyUvs=true;D.__dirtyNormals=true;D.__dirtyTangents=true;D.__dirtyColors=true}if(D.__dirtyVertices||D.__dirtyElements||D.__dirtyUvs||D.__dirtyNormals||D.__dirtyColors||D.__dirtyTangents)this.setMeshBuffers(G,L,d.DYNAMIC_DRAW);v(H,C,G,L)}D.__dirtyVertices=false;D.__dirtyElements=false;D.__dirtyUvs=false;D.__dirtyNormals=false;D.__dirtyTangents=false;
D.__dirtyColors=false}else if(L instanceof THREE.Line){if(!D.__webGLVertexBuffer){this.createLineBuffers(D);this.initLineBuffers(D);D.__dirtyVertices=true;D.__dirtyColors=true}if(D.__dirtyVertices||D.__dirtyColors)this.setLineBuffers(D,d.DYNAMIC_DRAW);v(H,0,D,L);D.__dirtyVertices=false;D.__dirtyColors=false}else if(L instanceof THREE.ParticleSystem){if(!D.__webGLVertexBuffer){this.createParticleBuffers(D);this.initParticleBuffers(D);D.__dirtyVertices=true;D.__dirtyColors=true}if(D.__dirtyVertices||
D.__dirtyColors||L.sortParticles)this.setParticleBuffers(D,d.DYNAMIC_DRAW,L,n);v(H,0,D,L);D.__dirtyVertices=false;D.__dirtyColors=false}else L instanceof THREE.MarchingCubes&&x(H,0,L)}};this.removeObject=function(g,n){var v,x;for(v=g.__webGLObjects.length-1;v>=0;v--){x=g.__webGLObjects[v].object;n==x&&g.__webGLObjects.splice(v,1)}};this.setupMatrices=function(g,n){g._modelViewMatrix.multiplyToArray(n.matrix,g.matrix,g._modelViewMatrixArray);g._normalMatrix=THREE.Matrix4.makeInvert3x3(g._modelViewMatrix).transposeIntoArray(g._normalMatrixArray)};
this.setDepthTest=function(g){g?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(g,n){if(g){!n||n=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(g=="back")d.cullFace(d.BACK);else g=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.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, gl_FragColor.w ), 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\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\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\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",
THREE.Projector=function(){function a(N,M){return M.z-N.z}function b(N,M){var U=0,O=1,Y=N.z+N.w,W=M.z+M.w,J=-N.z+N.w,X=-M.z+M.w;if(Y>=0&&W>=0&&J>=0&&X>=0)return true;else if(Y<0&&W<0||J<0&&X<0)return false;else{if(Y<0)U=Math.max(U,Y/(Y-W));else if(W<0)O=Math.min(O,Y/(Y-W));if(J<0)U=Math.max(U,J/(J-X));else if(X<0)O=Math.min(O,J/(J-X));if(O<U)return false;else{N.lerpSelf(M,U);M.lerpSelf(N,1-O);return true}}}var c,e,g=[],f,h,k,j=[],m,p,x=[],t,q,y=[],z=new THREE.Vector4,H=new THREE.Vector4,w=new THREE.Matrix4,
E=new THREE.Matrix4,o=[],d=new THREE.Vector4,P=new THREE.Vector4,aa;this.projectObjects=function(N,M,U){var O=[],Y,W;e=0;w.multiply(M.projectionMatrix,M.matrix);o[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);o[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);o[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);o[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);o[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
w.n33,w.n44-w.n34);o[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);M=0;for(Y=o.length;M<Y;M++){W=o[M];W.divideScalar(Math.sqrt(W.x*W.x+W.y*W.y+W.z*W.z))}Y=N.objects;N=0;for(M=Y.length;N<M;N++){W=Y[N];var J;if(!(J=!W.visible)){if(J=W instanceof THREE.Mesh){a:{J=void 0;for(var X=W.position,ha=-W.geometry.boundingSphere.radius*Math.max(W.scale.x,Math.max(W.scale.y,W.scale.z)),Z=0;Z<6;Z++){J=o[Z].x*X.x+o[Z].y*X.y+o[Z].z*X.z+o[Z].w;if(J<=ha){J=false;break a}}J=true}J=!J}J=J}if(!J){c=
g[e]=g[e]||new THREE.RenderableObject;z.copy(W.position);w.multiplyVector3(z);c.object=W;c.z=z.z;O.push(c);e++}}U&&O.sort(a);return O};this.projectScene=function(N,M,U){var O=[],Y=M.near,W=M.far,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R;k=p=q=0;M.autoUpdateMatrix&&M.updateMatrix();w.multiply(M.projectionMatrix,M.matrix);l=this.projectObjects(N,M,true);N=0;for(J=l.length;N<J;N++){v=l[N].object;if(v.visible){v.autoUpdateMatrix&&v.updateMatrix();A=v.matrix;u=v.rotationMatrix;n=v.materials;F=v.overdraw;if(v instanceof
THREE.Mesh){L=v.geometry;G=L.vertices;X=0;for(ha=G.length;X<ha;X++){D=G[X];D.positionWorld.copy(D.position);A.multiplyVector3(D.positionWorld);Z=D.positionScreen;Z.copy(D.positionWorld);w.multiplyVector4(Z);Z.x/=Z.w;Z.y/=Z.w;D.__visible=Z.z>Y&&Z.z<W}L=L.faces;X=0;for(ha=L.length;X<ha;X++){D=L[X];if(D instanceof THREE.Face3){Z=G[D.a];ea=G[D.b];C=G[D.c];if(Z.__visible&&ea.__visible&&C.__visible)if(v.doubleSided||v.flipSided!=(C.positionScreen.x-Z.positionScreen.x)*(ea.positionScreen.y-Z.positionScreen.y)-
(C.positionScreen.y-Z.positionScreen.y)*(ea.positionScreen.x-Z.positionScreen.x)<0){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(ea.positionWorld);f.v3.positionWorld.copy(C.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(ea.positionScreen);f.v3.positionScreen.copy(C.positionScreen);f.normalWorld.copy(D.normal);u.multiplyVector3(f.normalWorld);f.centroidWorld.copy(D.centroid);A.multiplyVector3(f.centroidWorld);
f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);C=D.vertexNormals;aa=f.vertexNormalsWorld;Z=0;for(ea=C.length;Z<ea;Z++){R=aa[Z]=aa[Z]||new THREE.Vector3;R.copy(C[Z]);u.multiplyVector3(R)}f.z=f.centroidScreen.z;f.meshMaterials=n;f.faceMaterials=D.materials;f.overdraw=F;if(v.geometry.uvs[X]){f.uvs[0]=v.geometry.uvs[X][0];f.uvs[1]=v.geometry.uvs[X][1];f.uvs[2]=v.geometry.uvs[X][2]}O.push(f);k++}}else if(D instanceof THREE.Face4){Z=G[D.a];ea=G[D.b];C=G[D.c];R=G[D.d];if(Z.__visible&&
ea.__visible&&C.__visible&&R.__visible)if(v.doubleSided||v.flipSided!=((R.positionScreen.x-Z.positionScreen.x)*(ea.positionScreen.y-Z.positionScreen.y)-(R.positionScreen.y-Z.positionScreen.y)*(ea.positionScreen.x-Z.positionScreen.x)<0||(ea.positionScreen.x-C.positionScreen.x)*(R.positionScreen.y-C.positionScreen.y)-(ea.positionScreen.y-C.positionScreen.y)*(R.positionScreen.x-C.positionScreen.x)<0)){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(ea.positionWorld);
f.v3.positionWorld.copy(R.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(ea.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(D.normal);u.multiplyVector3(f.normalWorld);f.centroidWorld.copy(D.centroid);A.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=n;f.faceMaterials=D.materials;f.overdraw=F;if(v.geometry.uvs[X]){f.uvs[0]=v.geometry.uvs[X][0];
f.uvs[1]=v.geometry.uvs[X][1];f.uvs[2]=v.geometry.uvs[X][3]}O.push(f);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ea.positionWorld);h.v2.positionWorld.copy(C.positionWorld);h.v3.positionWorld.copy(R.positionWorld);h.v1.positionScreen.copy(ea.positionScreen);h.v2.positionScreen.copy(C.positionScreen);h.v3.positionScreen.copy(R.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
h.meshMaterials=n;h.faceMaterials=D.materials;h.overdraw=F;if(v.geometry.uvs[X]){h.uvs[0]=v.geometry.uvs[X][1];h.uvs[1]=v.geometry.uvs[X][2];h.uvs[2]=v.geometry.uvs[X][3]}O.push(h);k++}}}}else if(v instanceof THREE.Line){E.multiply(w,A);G=v.geometry.vertices;D=G[0];D.positionScreen.copy(D.position);E.multiplyVector4(D.positionScreen);X=1;for(ha=G.length;X<ha;X++){Z=G[X];Z.positionScreen.copy(Z.position);E.multiplyVector4(Z.positionScreen);ea=G[X-1];d.copy(Z.positionScreen);P.copy(ea.positionScreen);
if(b(d,P)){d.multiplyScalar(1/d.w);P.multiplyScalar(1/P.w);m=x[p]=x[p]||new THREE.RenderableLine;m.v1.positionScreen.copy(d);m.v2.positionScreen.copy(P);m.z=Math.max(d.z,P.z);m.materials=v.materials;O.push(m);p++}}}else if(v instanceof THREE.Particle){H.set(v.position.x,v.position.y,v.position.z,1);w.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){t=y[q]=y[q]||new THREE.RenderableParticle;t.x=H.x/H.w;t.y=H.y/H.w;t.z=H.z;t.rotation=v.rotation.z;t.scale.x=v.scale.x*Math.abs(t.x-(H.x+M.projectionMatrix.n11)/
(H.w+M.projectionMatrix.n14));t.scale.y=v.scale.y*Math.abs(t.y-(H.y+M.projectionMatrix.n22)/(H.w+M.projectionMatrix.n24));t.materials=v.materials;O.push(t);q++}}}}U&&O.sort(a);return O};this.unprojectVector=function(N,M){var U=THREE.Matrix4.makeInvert(M.matrix);U.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));U.multiplyVector3(N);return N}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,p,x,t,q,y,z;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){t=a[j];if(t instanceof THREE.RenderableParticle){y=t.x*g+g;z=t.y*f+f;p=0;for(x=t.material.length;p<x;p++){q=t.material[p];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=y+"px";q.style.top=z+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(fa){if(t!=fa)m.globalAlpha=t=fa}function b(fa){if(q!=fa){switch(fa){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=fa}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,k,j,m=g.getContext("2d"),p=new THREE.Color(0),x=0,t=1,q=0,y=null,z=null,H=1,w,E,o,d,P,aa,N,M,U,O=new THREE.Color,
Y=new THREE.Color,W=new THREE.Color,J=new THREE.Color,X=new THREE.Color,ha,Z,ea,l,v,A,u,n,F,L=new THREE.Rectangle,G=new THREE.Rectangle,D=new THREE.Rectangle,C=false,R=new THREE.Color,ba=new THREE.Color,ga=new THREE.Color,B=new THREE.Color,K=Math.PI*2,I=new THREE.Vector3,Q,da,V,ka,pa,ua,la=16;Q=document.createElement("canvas");Q.width=Q.height=2;da=Q.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);V=da.getImageData(0,0,2,2);ka=V.data;pa=document.createElement("canvas");pa.width=
pa.height=la;ua=pa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(fa,ja){f=fa;h=ja;k=f/2;j=h/2;g.width=f;g.height=h;L.set(-k,-j,k,j);t=1;q=0;z=y=null;H=1};this.setClearColor=function(fa,ja){p=fa;x=ja;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(fa,ja){p.setHex(fa);x=ja;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){m.setTransform(1,
0,0,-1,k,j);if(!G.isEmpty()){G.inflate(1);G.minSelf(L);if(p.hex==0&&x==0)m.clearRect(G.getX(),G.getY(),G.getWidth(),G.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+x+")";m.fillRect(G.getX(),G.getY(),G.getWidth(),G.getHeight())}G.empty()}};this.render=function(fa,ja){function Fa(S){var ia,ca,T,$=S.lights;ba.setRGB(0,0,0);ga.setRGB(0,0,0);B.setRGB(0,0,0);S=0;for(ia=$.length;S<ia;S++){ca=$[S];T=ca.color;if(ca instanceof
THREE.AmbientLight){ba.r+=T.r;ba.g+=T.g;ba.b+=T.b}else if(ca instanceof THREE.DirectionalLight){ga.r+=T.r;ga.g+=T.g;ga.b+=T.b}else if(ca instanceof THREE.PointLight){B.r+=T.r;B.g+=T.g;B.b+=T.b}}}function ta(S,ia,ca,T){var $,na,va,Aa,Ca=S.lights;S=0;for($=Ca.length;S<$;S++){na=Ca[S];va=na.color;Aa=na.intensity;if(na instanceof THREE.DirectionalLight){na=ca.dot(na.position)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}else if(na instanceof THREE.PointLight){I.sub(na.position,ia);I.normalize();
na=ca.dot(I)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}}}function qa(S,ia,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,$,na,va,Aa,Ca;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){va=ca.map.image;Aa=va.width>>1;Ca=va.height>>1;$=ia.scale.x*k;na=ia.scale.y*j;ca=$*Aa;T=na*Ca;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale($,-na);m.translate(-Aa,-Ca);m.drawImage(va,0,0);m.restore()}}}else if(ca instanceof
THREE.ParticleCircleMaterial){if(C){R.r=ba.r+ga.r+B.r;R.g=ba.g+ga.g+B.g;R.b=ba.b+ga.b+B.b;O.r=ca.color.r*R.r;O.g=ca.color.g*R.g;O.b=ca.color.b*R.b;O.updateStyleString()}else O.__styleString=ca.color.__styleString;ca=ia.scale.x*k;T=ia.scale.y*j;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){$=O.__styleString;if(z!=$)m.fillStyle=z=$;m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,K,true);m.closePath();m.fill();m.restore()}}}}function sa(S,ia,ca,
T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ia.positionScreen.x,ia.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){O.__styleString=T.color.__styleString;S=T.linewidth;if(H!=S)m.lineWidth=H=S;S=O.__styleString;if(y!=S)m.strokeStyle=y=S;m.stroke();D.inflate(T.linewidth*2)}}}function Ma(S,ia,ca,T,$,na){if($.opacity!=0){a($.opacity);b($.blending);d=S.positionScreen.x;P=S.positionScreen.y;aa=ia.positionScreen.x;
N=ia.positionScreen.y;M=ca.positionScreen.x;U=ca.positionScreen.y;m.beginPath();m.moveTo(d,P);m.lineTo(aa,N);m.lineTo(M,U);m.lineTo(d,P);m.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=ja.matrix;I.copy(T.vertexNormalsWorld[0]);
l=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;v=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[1]);A=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;u=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[2]);n=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;F=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;ma(d,P,aa,N,M,U,$.env_map.image,l,v,A,u,n,F)}}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&
!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(C)if(!$.wireframe&&$.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){Y.r=W.r=J.r=ba.r;Y.g=W.g=J.g=ba.g;Y.b=W.b=J.b=ba.b;ta(na,T.v1.positionWorld,T.vertexNormalsWorld[0],Y);ta(na,T.v2.positionWorld,T.vertexNormalsWorld[1],W);ta(na,T.v3.positionWorld,T.vertexNormalsWorld[2],J);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*
0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else{R.r=ba.r;R.g=ba.g;R.b=ba.b;ta(na,T.centroidWorld,T.normalWorld,R);O.r=$.color.r*R.r;O.g=$.color.g*R.g;O.b=$.color.b*R.b;O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ha=ja.near;Z=ja.far;Y.r=Y.g=Y.b=1-Da(S.positionScreen.z,ha,Z);W.r=W.g=W.b=
1-Da(ia.positionScreen.z,ha,Z);J.r=J.g=J.b=1-Da(ca.positionScreen.z,ha,Z);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){O.r=xa(T.normalWorld.x);O.g=xa(T.normalWorld.y);O.b=xa(T.normalWorld.z);O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}}}function Ga(S,ia){if(y!=S)m.strokeStyle=y=S;if(H!=ia)m.lineWidth=H=ia;m.stroke();D.inflate(ia*2)}function za(S){if(z!=
S)m.fillStyle=z=S;m.fill()}function ma(S,ia,ca,T,$,na,va,Aa,Ca,Ja,Ea,Ka,Ra){var Ha,La;Ha=va.width-1;La=va.height-1;Aa*=Ha;Ca*=La;Ja*=Ha;Ea*=La;Ka*=Ha;Ra*=La;ca-=S;T-=ia;$-=S;na-=ia;Ja-=Aa;Ea-=Ca;Ka-=Aa;Ra-=Ca;Ha=Ja*Ra-Ka*Ea;if(Ha!=0){La=1/Ha;Ha=(Ra*ca-Ea*$)*La;Ea=(Ra*T-Ea*na)*La;ca=(Ja*$-Ka*ca)*La;T=(Ja*na-Ka*T)*La;S=S-Ha*Aa-ca*Ca;ia=ia-Ea*Aa-T*Ca;m.save();m.transform(Ha,Ea,ca,T,S,ia);m.clip();m.drawImage(va,0,0);m.restore()}}function ra(S,ia,ca,T){var $=~~(S.r*255),na=~~(S.g*255);S=~~(S.b*255);var va=
~~(ia.r*255),Aa=~~(ia.g*255);ia=~~(ia.b*255);var Ca=~~(ca.r*255),Ja=~~(ca.g*255);ca=~~(ca.b*255);var Ea=~~(T.r*255),Ka=~~(T.g*255);T=~~(T.b*255);ka[0]=$<0?0:$>255?255:$;ka[1]=na<0?0:na>255?255:na;ka[2]=S<0?0:S>255?255:S;ka[4]=va<0?0:va>255?255:va;ka[5]=Aa<0?0:Aa>255?255:Aa;ka[6]=ia<0?0:ia>255?255:ia;ka[8]=Ca<0?0:Ca>255?255:Ca;ka[9]=Ja<0?0:Ja>255?255:Ja;ka[10]=ca<0?0:ca>255?255:ca;ka[12]=Ea<0?0:Ea>255?255:Ea;ka[13]=Ka<0?0:Ka>255?255:Ka;ka[14]=T<0?0:T>255?255:T;da.putImageData(V,0,0);ua.drawImage(Q,
0,0);return pa}function Da(S,ia,ca){S=(S-ia)/(ca-ia);return S*S*(3-2*S)}function xa(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function Oa(S,ia){var ca=ia.x-S.x,T=ia.y-S.y,$=1/Math.sqrt(ca*ca+T*T);ca*=$;T*=$;ia.x+=ca;ia.y+=T;S.x-=ca;S.y-=T}var ya,Pa,oa,Ba,Ia,Na,Qa,wa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(fa,ja,this.sortElements);(C=fa.lights.length>0)&&Fa(fa);ya=0;for(Pa=c.length;ya<Pa;ya++){oa=c[ya];D.empty();if(oa instanceof THREE.RenderableParticle){w=oa;w.x*=k;w.y*=
j;Ba=0;for(Ia=oa.materials.length;Ba<Ia;Ba++)qa(w,oa,oa.materials[Ba],fa)}else if(oa instanceof THREE.RenderableLine){w=oa.v1;E=oa.v2;w.positionScreen.x*=k;w.positionScreen.y*=j;E.positionScreen.x*=k;E.positionScreen.y*=j;D.addPoint(w.positionScreen.x,w.positionScreen.y);D.addPoint(E.positionScreen.x,E.positionScreen.y);if(L.instersects(D)){Ba=0;for(Ia=oa.materials.length;Ba<Ia;)sa(w,E,oa,oa.materials[Ba++],fa)}}else if(oa instanceof THREE.RenderableFace3){w=oa.v1;E=oa.v2;o=oa.v3;w.positionScreen.x*=
k;w.positionScreen.y*=j;E.positionScreen.x*=k;E.positionScreen.y*=j;o.positionScreen.x*=k;o.positionScreen.y*=j;if(oa.overdraw){Oa(w.positionScreen,E.positionScreen);Oa(E.positionScreen,o.positionScreen);Oa(o.positionScreen,w.positionScreen)}D.add3Points(w.positionScreen.x,w.positionScreen.y,E.positionScreen.x,E.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(L.instersects(D)){Ba=0;for(Ia=oa.meshMaterials.length;Ba<Ia;){wa=oa.meshMaterials[Ba++];if(wa instanceof THREE.MeshFaceMaterial){Na=
0;for(Qa=oa.faceMaterials.length;Na<Qa;)(wa=oa.faceMaterials[Na++])&&Ma(w,E,o,oa,wa,fa)}else Ma(w,E,o,oa,wa,fa)}}}G.addRectangle(D)}m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(l,v,A){var u,n,F,L;u=0;for(n=l.lights.length;u<n;u++){F=l.lights[u];if(F instanceof THREE.DirectionalLight){L=v.normalWorld.dot(F.position)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}else if(F instanceof THREE.PointLight){U.sub(F.position,v.centroidWorld);U.normalize();L=v.normalWorld.dot(U)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}}}function b(l,v,A,u,n,F){J=e(X++);J.setAttribute("d","M "+l.positionScreen.x+
" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(F,u,d);o.r=n.color.r*d.r;o.g=n.color.g*d.g;o.b=n.color.b*d.b;o.updateStyleString()}else o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshDepthMaterial){M=1-n.__2near/(n.__farPlusNear-u.z*n.__farMinusNear);
o.setRGB(M,M,M)}else n instanceof THREE.MeshNormalMaterial&&o.setRGB(g(u.normalWorld.x),g(u.normalWorld.y),g(u.normalWorld.z));n.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+n.opacity);k.appendChild(J)}function c(l,v,A,u,n,F,L){J=e(X++);J.setAttribute("d",
"M "+l.positionScreen.x+" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+" L "+u.positionScreen.x+","+u.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(L,n,d);o.r=F.color.r*d.r;o.g=F.color.g*d.g;o.b=F.color.b*d.b;o.updateStyleString()}else o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){M=
1-F.__2near/(F.__farPlusNear-n.z*F.__farMinusNear);o.setRGB(M,M,M)}else F instanceof THREE.MeshNormalMaterial&&o.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));F.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+F.opacity);k.appendChild(J)}
function e(l){if(O[l]==null){O[l]=document.createElementNS("http://www.w3.org/2000/svg","path");ea==0&&O[l].setAttribute("shape-rendering","crispEdges");return O[l]}return O[l]}function g(l){return l<0?Math.min((1+l)*0.5,0.5):0.5+Math.min(l*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,p,x,t,q,y,z,H=new THREE.Rectangle,w=new THREE.Rectangle,E=false,o=new THREE.Color(16777215),d=new THREE.Color(16777215),P=new THREE.Color(0),aa=new THREE.Color(0),
N=new THREE.Color(0),M,U=new THREE.Vector3,O=[],Y=[],W=[],J,X,ha,Z,ea=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(l){switch(l){case "high":ea=1;break;case "low":ea=0}};this.setSize=function(l,v){j=l;m=v;p=j/2;x=m/2;k.setAttribute("viewBox",-p+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(l,v){var A,
u,n,F,L,G,D,C;this.autoClear&&this.clear();f=h.projectScene(l,v,this.sortElements);Z=ha=X=0;if(E=l.lights.length>0){D=l.lights;P.setRGB(0,0,0);aa.setRGB(0,0,0);N.setRGB(0,0,0);A=0;for(u=D.length;A<u;A++){n=D[A];F=n.color;if(n instanceof THREE.AmbientLight){P.r+=F.r;P.g+=F.g;P.b+=F.b}else if(n instanceof THREE.DirectionalLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}else if(n instanceof THREE.PointLight){N.r+=F.r;N.g+=F.g;N.b+=F.b}}}A=0;for(u=f.length;A<u;A++){D=f[A];w.empty();if(D instanceof THREE.RenderableParticle){t=
D;t.x*=p;t.y*=-x;n=0;for(F=D.materials.length;n<F;n++)if(C=D.materials[n]){L=t;G=D;C=C;var R=ha++;if(Y[R]==null){Y[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");ea==0&&Y[R].setAttribute("shape-rendering","crispEdges")}J=Y[R];J.setAttribute("cx",L.x);J.setAttribute("cy",L.y);J.setAttribute("r",G.scale.x*p);if(C instanceof THREE.ParticleCircleMaterial){if(E){d.r=P.r+aa.r+N.r;d.g=P.g+aa.g+N.g;d.b=P.b+aa.b+N.b;o.r=C.color.r*d.r;o.g=C.color.g*d.g;o.b=C.color.b*d.b;o.updateStyleString()}else o=
C.color;J.setAttribute("style","fill: "+o.__styleString)}k.appendChild(J)}}else if(D instanceof THREE.RenderableLine){t=D.v1;q=D.v2;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(w)){n=0;for(F=D.materials.length;n<F;)if(C=D.materials[n++]){L=t;G=q;C=C;R=Z++;if(W[R]==null){W[R]=document.createElementNS("http://www.w3.org/2000/svg","line");ea==
0&&W[R].setAttribute("shape-rendering","crispEdges")}J=W[R];J.setAttribute("x1",L.positionScreen.x);J.setAttribute("y1",L.positionScreen.y);J.setAttribute("x2",G.positionScreen.x);J.setAttribute("y2",G.positionScreen.y);if(C instanceof THREE.LineBasicMaterial){o.__styleString=C.color.__styleString;J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+C.linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.linecap+"; stroke-linejoin: "+C.linejoin);k.appendChild(J)}}}}else if(D instanceof
THREE.RenderableFace3){t=D.v1;q=D.v2;y=D.v3;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;y.positionScreen.x*=p;y.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);if(H.instersects(w)){n=0;for(F=D.meshMaterials.length;n<F;){C=D.meshMaterials[n++];if(C instanceof THREE.MeshFaceMaterial){L=0;for(G=D.faceMaterials.length;L<G;)(C=D.faceMaterials[L++])&&
b(t,q,y,D,C,l)}else C&&b(t,q,y,D,C,l)}}}else if(D instanceof THREE.RenderableFace4){t=D.v1;q=D.v2;y=D.v3;z=D.v4;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;y.positionScreen.x*=p;y.positionScreen.y*=-x;z.positionScreen.x*=p;z.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(w)){n=
0;for(F=D.meshMaterials.length;n<F;){C=D.meshMaterials[n++];if(C instanceof THREE.MeshFaceMaterial){L=0;for(G=D.faceMaterials.length;L<G;)(C=D.faceMaterials[L++])&&c(t,q,y,z,D,C,l)}else C&&c(t,q,y,z,D,C,l)}}}}}};
THREE.WebGLRenderer=function(a){function b(l,v,A){var u,n,F,L=l.vertices,G=L.length,D=l.colors,C=D.length,R=l.__vertexArray,ba=l.__colorArray,ga=l.__sortArray,B=l.__dirtyVertices,K=l.__dirtyColors;if(A.sortParticles){Y.multiplySelf(A.matrixWorld);for(u=0;u<G;u++){n=L[u].position;X.copy(n);Y.multiplyVector3(X);ga[u]=[X.z,u]}ga.sort(function(I,Q){return Q[0]-I[0]});for(u=0;u<G;u++){n=L[ga[u][1]].position;F=u*3;R[F]=n.x;R[F+1]=n.y;R[F+2]=n.z}for(u=0;u<C;u++){F=u*3;color=D[ga[u][1]];ba[F]=color.r;ba[F+
1]=color.g;ba[F+2]=color.b}}else{if(B)for(u=0;u<G;u++){n=L[u].position;F=u*3;R[F]=n.x;R[F+1]=n.y;R[F+2]=n.z}if(K)for(u=0;u<C;u++){color=D[u];F=u*3;ba[F]=color.r;ba[F+1]=color.g;ba[F+2]=color.b}}if(B||A.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,R,v)}if(K||A.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ba,v)}}function c(l,v){l.fragment_shader=v.fragment_shader;l.vertex_shader=v.vertex_shader;l.uniforms=
Uniforms.clone(v.uniforms)}function e(l,v){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=d.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=d.createBuffer();if(l.hasPos){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,l.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(v.attributes.position);d.vertexAttribPointer(v.attributes.position,3,d.FLOAT,false,0,0)}if(l.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
l.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(v.attributes.normal);d.vertexAttribPointer(v.attributes.normal,3,d.FLOAT,false,0,0)}d.drawArrays(d.TRIANGLES,0,l.count);l.count=0}function g(l){if(N!=l.doubleSided){l.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);N=l.doubleSided}if(M!=l.flipSided){l.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);M=l.flipSided}}function f(l){O[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);O[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+
l.n14);O[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);O[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);O[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);O[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var v;for(l=0;l<5;l++){v=O[l];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}}function h(l){for(var v=l.matrix,A=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),u=0;u<6;u++){l=O[u].x*v.n14+O[u].y*v.n24+O[u].z*v.n34+O[u].w;
if(l<=A)return false}return true}function k(l,v){l.list[l.count]=v;l.count+=1}function j(l){var v,A,u=l.object,n=l.opaque,F=l.transparent;F.count=0;l=n.count=0;for(v=u.materials.length;l<v;l++){A=u.materials[l];A.opacity&&A.opacity<1||A.blending!=THREE.NormalBlending?k(F,A):k(n,A)}}function m(l){var v,A,u,n,F=l.object,L=l.buffer,G=l.opaque,D=l.transparent;D.count=0;l=G.count=0;for(u=F.materials.length;l<u;l++){v=F.materials[l];if(v instanceof THREE.MeshFaceMaterial){v=0;for(A=L.materials.length;v<
A;v++)if(n=L.materials[v])n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(D,n):k(G,n)}else{n=v;n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(D,n):k(G,n)}}}function p(l){var v,A,u,n=l.children;v=0;for(A=n.length;v<A;v++){u=n[v];u.autoUpdateMatrix&&u.updateMatrix();u.matrixWorld.multiply(l.matrixWorld,u.matrix);p(u)}}function x(l,v){var A,u,n=v.children;A=0;for(u=n.length;A<u;A++){child=n[A];t(l,child,false);x(l,child)}}function t(l,v,A){var u,n,F;n=v.geometry;if(l.__webGLObjectsMap[v.id]==
undefined){l.__webGLObjectsMap[v.id]={};v._modelViewMatrix=new THREE.Matrix4;v._normalMatrixArray=new Float32Array(9);v._modelViewMatrixArray=new Float32Array(16);v._objectMatrixArray=new Float32Array(16);v.matrix.flattenToArray(v._objectMatrixArray)}F=l.__webGLObjectsMap[v.id];objlist=l.__webGLObjects;if(v instanceof THREE.Mesh){for(u in n.geometryChunks){l=n.geometryChunks[u];if(!l.__webGLVertexBuffer){var L=l;L.__webGLVertexBuffer=d.createBuffer();L.__webGLNormalBuffer=d.createBuffer();L.__webGLTangentBuffer=
d.createBuffer();L.__webGLColorBuffer=d.createBuffer();L.__webGLUVBuffer=d.createBuffer();L.__webGLUV2Buffer=d.createBuffer();L.__webGLFaceBuffer=d.createBuffer();L.__webGLLineBuffer=d.createBuffer();L=l;var G=v,D=void 0,C=void 0,R=0,ba=0,ga=0,B=G.geometry.faces,K=L.faces;D=0;for(C=K.length;D<C;D++){fi=K[D];face=B[fi];if(face instanceof THREE.Face3){R+=3;ba+=1;ga+=3}else if(face instanceof THREE.Face4){R+=4;ba+=2;ga+=4}}L.__vertexArray=new Float32Array(R*3);L.__normalArray=new Float32Array(R*3);L.__tangentArray=
new Float32Array(R*4);L.__colorArray=new Float32Array(R*3);L.__uvArray=new Float32Array(R*2);L.__uv2Array=new Float32Array(R*2);L.__faceArray=new Uint16Array(ba*3);L.__lineArray=new Uint16Array(ga*2);C=D=L;G=G;R=void 0;B=void 0;var I=void 0,Q=void 0;I=void 0;K=false;R=0;for(B=G.materials.length;R<B;R++){I=G.materials[R];if(I instanceof THREE.MeshFaceMaterial){I=0;for(Q=C.materials.length;I<Q;I++)if(C.materials[I]&&C.materials[I].shading!=undefined&&C.materials[I].shading==THREE.SmoothShading){K=true;
break}}else if(I&&I.shading!=undefined&&I.shading==THREE.SmoothShading){K=true;break}if(K)break}D.__needsSmoothNormals=K;L.__webGLFaceCount=ba*3;L.__webGLLineCount=ga*2;n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents){L=l;ba=d.DYNAMIC_DRAW;ga=void 0;D=void 0;var da=void 0,V=void 0,ka=void 0,pa=void 0,ua=void 0;
da=void 0;var la=void 0,fa=void 0,ja=void 0,Fa=void 0;la=void 0;fa=void 0;ja=void 0;V=void 0;la=void 0;fa=void 0;ja=void 0;Fa=void 0;V=void 0;pa=void 0;ka=void 0;ua=void 0;var ta=Q=I=K=B=R=G=C=0,qa=0,sa=L.__vertexArray,Ma=L.__uvArray,Ga=L.__uv2Array,za=L.__normalArray,ma=L.__tangentArray,ra=L.__colorArray,Da=L.__faceArray,xa=L.__lineArray,Oa=L.__needsSmoothNormals,ya=v.geometry,Pa=ya.__dirtyVertices,oa=ya.__dirtyElements,Ba=ya.__dirtyUvs,Ia=ya.__dirtyNormals,Na=ya.__dirtyTangents,Qa=ya.__dirtyColors,
wa=ya.vertices,S=L.faces,ia=ya.faces,ca=ya.uvs,T=ya.uvs2,$=ya.colors;ga=0;for(D=S.length;ga<D;ga++){da=S[ga];V=ia[da];ua=ca[da];da=T[da];ka=V.vertexNormals;pa=V.normal;if(V instanceof THREE.Face3){if(Pa){la=wa[V.a].position;fa=wa[V.b].position;ja=wa[V.c].position;sa[G]=la.x;sa[G+1]=la.y;sa[G+2]=la.z;sa[G+3]=fa.x;sa[G+4]=fa.y;sa[G+5]=fa.z;sa[G+6]=ja.x;sa[G+7]=ja.y;sa[G+8]=ja.z;G+=9}if(Qa&&$.length){la=$[V.a];fa=$[V.b];ja=$[V.c];ra[qa]=la.r;ra[qa+1]=la.g;ra[qa+2]=la.b;ra[qa+3]=fa.r;ra[qa+4]=fa.g;ra[qa+
5]=fa.b;ra[qa+6]=ja.r;ra[qa+7]=ja.g;ra[qa+8]=ja.b;qa+=9}if(Na&&ya.hasTangents){la=wa[V.a].tangent;fa=wa[V.b].tangent;ja=wa[V.c].tangent;ma[Q]=la.x;ma[Q+1]=la.y;ma[Q+2]=la.z;ma[Q+3]=la.w;ma[Q+4]=fa.x;ma[Q+5]=fa.y;ma[Q+6]=fa.z;ma[Q+7]=fa.w;ma[Q+8]=ja.x;ma[Q+9]=ja.y;ma[Q+10]=ja.z;ma[Q+11]=ja.w;Q+=12}if(Ia)if(ka.length==3&&Oa)for(V=0;V<3;V++){pa=ka[V];za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}else for(V=0;V<3;V++){za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}if(Ba&&ua)for(V=0;V<3;V++){ka=ua[V];Ma[R]=ka.u;
Ma[R+1]=ka.v;R+=2}if(Ba&&da)for(V=0;V<3;V++){ua=da[V];Ga[B]=ua.u;Ga[B+1]=ua.v;B+=2}if(oa){Da[K]=C;Da[K+1]=C+1;Da[K+2]=C+2;K+=3;xa[ta]=C;xa[ta+1]=C+1;xa[ta+2]=C;xa[ta+3]=C+2;xa[ta+4]=C+1;xa[ta+5]=C+2;ta+=6;C+=3}}else if(V instanceof THREE.Face4){if(Pa){la=wa[V.a].position;fa=wa[V.b].position;ja=wa[V.c].position;Fa=wa[V.d].position;sa[G]=la.x;sa[G+1]=la.y;sa[G+2]=la.z;sa[G+3]=fa.x;sa[G+4]=fa.y;sa[G+5]=fa.z;sa[G+6]=ja.x;sa[G+7]=ja.y;sa[G+8]=ja.z;sa[G+9]=Fa.x;sa[G+10]=Fa.y;sa[G+11]=Fa.z;G+=12}if(Qa&&
$.length){la=$[V.a];fa=$[V.b];ja=$[V.c];Fa=$[V.d];ra[qa]=la.r;ra[qa+1]=la.g;ra[qa+2]=la.b;ra[qa+3]=fa.r;ra[qa+4]=fa.g;ra[qa+5]=fa.b;ra[qa+6]=ja.r;ra[qa+7]=ja.g;ra[qa+8]=ja.b;ra[qa+9]=Fa.r;ra[qa+10]=Fa.g;ra[qa+11]=Fa.b;qa+=12}if(Na&&ya.hasTangents){la=wa[V.a].tangent;fa=wa[V.b].tangent;ja=wa[V.c].tangent;V=wa[V.d].tangent;ma[Q]=la.x;ma[Q+1]=la.y;ma[Q+2]=la.z;ma[Q+3]=la.w;ma[Q+4]=fa.x;ma[Q+5]=fa.y;ma[Q+6]=fa.z;ma[Q+7]=fa.w;ma[Q+8]=ja.x;ma[Q+9]=ja.y;ma[Q+10]=ja.z;ma[Q+11]=ja.w;ma[Q+12]=V.x;ma[Q+13]=
V.y;ma[Q+14]=V.z;ma[Q+15]=V.w;Q+=16}if(Ia)if(ka.length==4&&Oa)for(V=0;V<4;V++){pa=ka[V];za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}else for(V=0;V<4;V++){za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}if(Ba&&ua)for(V=0;V<4;V++){ka=ua[V];Ma[R]=ka.u;Ma[R+1]=ka.v;R+=2}if(Ba&&da)for(V=0;V<4;V++){ua=da[V];Ga[B]=ua.u;Ga[B+1]=ua.v;B+=2}if(oa){Da[K]=C;Da[K+1]=C+1;Da[K+2]=C+2;Da[K+3]=C;Da[K+4]=C+2;Da[K+5]=C+3;K+=6;xa[ta]=C;xa[ta+1]=C+1;xa[ta+2]=C;xa[ta+3]=C+3;xa[ta+4]=C+1;xa[ta+5]=C+2;xa[ta+6]=C+2;xa[ta+7]=C+3;ta+=
8;C+=4}}}if(Pa){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,sa,ba)}if(Qa&&$.length){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ra,ba)}if(Ia){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,za,ba)}if(Na&&ya.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,ma,ba)}if(Ba&&R>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Ma,ba)}if(Ba&&
B>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ga,ba)}if(oa){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,ba);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ba)}}q(objlist,F,u,l,v,A)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(v instanceof THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=
d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*3);n.__webGLLineCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){u=d.DYNAMIC_DRAW;G=n.vertices;L=n.colors;R=G.length;ba=L.length;B=n.__vertexArray;ga=n.__colorArray;K=n.__dirtyColors;if(n.__dirtyVertices){for(D=0;D<R;D++){C=G[D].position;l=D*3;B[l]=C.x;B[l+1]=C.y;B[l+2]=C.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);
d.bufferData(d.ARRAY_BUFFER,B,u)}if(K){for(D=0;D<ba;D++){color=L[D];l=D*3;ga[l]=color.r;ga[l+1]=color.g;ga[l+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ga,u)}}q(objlist,F,0,n,v,A);n.__dirtyVertices=false;n.__dirtyColors=false}else if(v instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*
3);n.__sortArray=[];n.__webGLParticleCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors||v.sortParticles)b(n,d.DYNAMIC_DRAW,v,camera);q(objlist,F,0,n,v,A);n.__dirtyVertices=false;n.__dirtyColors=false}else if(v instanceof THREE.MarchingCubes)if(F[0]==undefined){l.__webGLObjectsImmediate.push({object:v,opaque:{list:[],count:0},transparent:{list:[],count:0},root:A});F[0]=1}}function q(l,v,A,u,n,F){if(v[A]==undefined){l.push({buffer:u,object:n,opaque:{list:[],count:0},
transparent:{list:[],count:0},root:F});v[A]=1}}function y(l,v){l._modelViewMatrix.multiplyToArray(v.matrix,l.matrixWorld,l._modelViewMatrixArray);l._normalMatrix=THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function z(l){if(l!=U){switch(l){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,
d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}U=l}}function H(l,v){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=d.createFramebuffer();l.__webGLRenderbuffer=d.createRenderbuffer();l.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,l.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,l.width,l.height);d.bindTexture(d.TEXTURE_2D,l.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,
E(l.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,E(l.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,E(l.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,E(l.min_filter));d.texImage2D(d.TEXTURE_2D,0,E(l.format),l.width,l.height,0,E(l.format),E(l.type),null);d.bindFramebuffer(d.FRAMEBUFFER,l.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,l.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,
l.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var A,u,n;if(l){A=l.__webGLFramebuffer;u=l.width;n=l.height}else{A=null;u=o.width;n=o.height}if(A!=aa){d.bindFramebuffer(d.FRAMEBUFFER,A);d.viewport(0,0,u,n);v&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);aa=A}}function w(l,v){var A;if(l=="fragment")A=d.createShader(d.FRAGMENT_SHADER);else if(l=="vertex")A=d.createShader(d.VERTEX_SHADER);d.shaderSource(A,v);d.compileShader(A);
if(!d.getShaderParameter(A,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(A));return null}return A}function E(l){switch(l){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;
case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;
case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var o=document.createElement("canvas"),d,P=null,aa=null,N=null,M=null,U=null,O=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Y=new THREE.Matrix4,W=new Float32Array(16),J=new Float32Array(16),X=new THREE.Vector4,ha=true,Z=new THREE.Color(0),ea=0;if(a){if(a.antialias!==undefined)ha=a.antialias;a.clearColor!==undefined&&Z.setHex(a.clearColor);if(a.clearAlpha!==undefined)ea=
a.clearAlpha}this.domElement=o;this.autoClear=true;(function(l,v,A){try{d=o.getContext("experimental-webgl",{antialias:l})}catch(u){console.log(u)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(v.r,v.g,v.b,A);_cullEnabled=true})(ha,Z,ea);this.context=d;this.lights=
{ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,v){o.width=l;o.height=v;d.viewport(0,0,o.width,o.height)};this.setClearColorHex=function(l,v){var A=new THREE.Color(l);d.clearColor(A.r,A.g,A.b,v)};this.setClearColor=function(l,v){d.clearColor(l.r,l.g,l.b,v)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(l,v){var A,u,n,F=0,L=0,G=0,D,C,R,ba=this.lights,ga=ba.directional.colors,
B=ba.directional.positions,K=ba.point.colors,I=ba.point.positions,Q=0,da=0;A=n=n=0;for(u=v.length;A<u;A++){n=v[A];D=n.color;C=n.position;R=n.intensity;if(n instanceof THREE.AmbientLight){F+=D.r;L+=D.g;G+=D.b}else if(n instanceof THREE.DirectionalLight){n=Q*3;ga[n]=D.r*R;ga[n+1]=D.g*R;ga[n+2]=D.b*R;B[n]=C.x;B[n+1]=C.y;B[n+2]=C.z;Q+=1}else if(n instanceof THREE.PointLight){n=da*3;K[n]=D.r*R;K[n+1]=D.g*R;K[n+2]=D.b*R;I[n]=C.x;I[n+1]=C.y;I[n+2]=C.z;da+=1}}for(A=Q*3;A<ga.length;A++)ga[A]=0;for(A=da*3;A<
K.length;A++)K[A]=0;ba.point.length=da;ba.directional.length=Q;ba.ambient[0]=F;ba.ambient[1]=L;ba.ambient[2]=G};this.initMaterial=function(l,v,A){var u,n;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);
else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var F,L,G,D;n=G=D=0;for(F=v.length;n<F;n++){L=v[n];L instanceof THREE.DirectionalLight&&G++;L instanceof THREE.PointLight&&D++}if(D+G<=4){v=G;D=D}else{v=Math.ceil(4*G/(D+G));D=4-v}n={directional:v,point:D};D=l.fragment_shader;v=l.vertex_shader;F={fog:A,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:n.directional,
maxPointLights:n.point};A=d.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.fog?"#define USE_FOG":"",F.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");F=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
d.attachShader(A,w("fragment",n+D));d.attachShader(A,w("vertex",F+v));d.linkProgram(A);d.getProgramParameter(A,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(A,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");A.uniforms={};A.attributes={};l.program=A;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in l.uniforms)A.push(u);u=l.program;D=0;for(v=A.length;D<v;D++){n=A[D];u.uniforms[n]=d.getUniformLocation(u,
n)}l=l.program;u=["position","normal","uv","uv2","tangent","color"];A=0;for(D=u.length;A<D;A++){v=u[A];l.attributes[v]=d.getAttribLocation(l,v)}};this.setProgram=function(l,v,A,u,n){u.program||this.initMaterial(u,v,A);var F=u.program,L=F.uniforms,G=u.uniforms;if(F!=P){d.useProgram(F);P=F;d.uniformMatrix4fv(L.projectionMatrix,false,W)}if(A&&(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial||u instanceof THREE.LineBasicMaterial||u instanceof
THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(A.color.hex);if(A instanceof THREE.Fog){G.fogNear.value=A.near;G.fogFar.value=A.far}else if(A instanceof THREE.FogExp2)G.fogDensity.value=A.density}if(u instanceof THREE.MeshPhongMaterial||u instanceof THREE.MeshLambertMaterial){this.setupLights(F,v);v=this.lights;G.enableLighting.value=v.directional.length+v.point.length;G.ambientLightColor.value=v.ambient;G.directionalLightColor.value=v.directional.colors;G.directionalLightDirection.value=v.directional.positions;
G.pointLightColor.value=v.point.colors;G.pointLightPosition.value=v.point.positions}if(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.map.texture=u.map;G.light_map.texture=u.light_map;G.env_map.texture=u.env_map;G.reflectivity.value=u.reflectivity;G.refraction_ratio.value=u.refraction_ratio;G.combine.value=u.combine;G.useRefract.value=
u.env_map&&u.env_map.mapping instanceof THREE.CubeRefractionMapping}if(u instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity}else if(u instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.size.value=u.size;G.map.texture=u.map}else if(u instanceof THREE.MeshPhongMaterial){G.ambient.value.setRGB(u.ambient.r,u.ambient.g,
u.ambient.b);G.specular.value.setRGB(u.specular.r,u.specular.g,u.specular.b);G.shininess.value=u.shininess}else if(u instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=u.opacity}else if(u instanceof THREE.MeshNormalMaterial)G.opacity.value=u.opacity;var D,C,R;for(D in G)if(R=F.uniforms[D]){A=G[D];C=A.type;v=A.value;if(C=="i")d.uniform1i(R,v);else if(C=="f")d.uniform1f(R,v);else if(C=="fv1")d.uniform1fv(R,v);else if(C=="fv")d.uniform3fv(R,v);else if(C=="v2")d.uniform2f(R,
v.x,v.y);else if(C=="v3")d.uniform3f(R,v.x,v.y,v.z);else if(C=="c")d.uniform3f(R,v.r,v.g,v.b);else if(C=="t"){d.uniform1i(R,v);if(A=A.texture)if(A.image instanceof Array&&A.image.length==6){A=A;v=v;if(A.image.length==6){if(!A.image.__webGLTextureCube&&!A.image.__cubeMapInitialized&&A.image.loadCount==6){A.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,
d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(C=0;C<6;++C)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,A.image[C]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);A.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+v);d.bindTexture(d.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube)}}else{A=A;v=v;if(!A.__webGLTexture&&
A.image.loaded){A.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,A.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,A.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,E(A.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,E(A.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,E(A.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,E(A.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+
v);d.bindTexture(d.TEXTURE_2D,A.__webGLTexture)}}}d.uniformMatrix4fv(L.modelViewMatrix,false,n._modelViewMatrixArray);d.uniformMatrix3fv(L.normalMatrix,false,n._normalMatrixArray);if(u instanceof THREE.MeshShaderMaterial||u instanceof THREE.MeshPhongMaterial||u.env_map)d.uniform3f(L.cameraPosition,l.position.x,l.position.y,l.position.z);if(u instanceof THREE.MeshShaderMaterial||u.env_map)d.uniformMatrix4fv(L.objectMatrix,false,n._objectMatrixArray);if(u instanceof THREE.MeshPhongMaterial||u instanceof
THREE.MeshLambertMaterial||u instanceof THREE.MeshShaderMaterial)d.uniformMatrix4fv(L.viewMatrix,false,J);return F};this.renderBuffer=function(l,v,A,u,n,F){l=this.setProgram(l,v,A,u,F).attributes;d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.vertexAttribPointer(l.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.position);if(l.color>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>=
0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>=
0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(F instanceof THREE.Mesh)if(u.wireframe){d.lineWidth(u.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT,
0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(u.linewidth);d.drawArrays(F,0,n.__webGLLineCount)}else F instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,v,A,u){var n,F,L,G,D,C,R,ba=l.lights,ga=l.fog;v.autoUpdateMatrix&&v.updateMatrix();v.matrix.flattenToArray(J);v.projectionMatrix.flattenToArray(W);Y.multiply(v.projectionMatrix,v.matrix);f(Y);this.initWebGLObjects(l,v);H(A,u!==undefined?u:true);
this.autoClear&&this.clear();G=l.__webGLObjects.length;for(u=0;u<G;u++){n=l.__webGLObjects[u];C=n.object;if(C.visible){if(n.root){C.autoUpdateMatrix&&C.updateMatrix();C.matrixWorld.copy(C.matrix);p(C)}if(!(C instanceof THREE.Mesh)||h(C)){C.matrixWorld.flattenToArray(C._objectMatrixArray);y(C,v);m(n);n.render=true}else n.render=false}else n.render=false}D=l.__webGLObjectsImmediate.length;for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){if(C.autoUpdateMatrix){C.updateMatrix();
C.matrixWorld.copy(C.matrix);C.matrixWorld.flattenToArray(C._objectMatrixArray)}y(C,v);j(n)}}z(THREE.NormalBlending);for(u=0;u<G;u++){n=l.__webGLObjects[u];if(n.render){C=n.object;R=n.buffer;L=n.opaque;g(C);for(n=0;n<L.count;n++){material=L.list[n];this.setDepthTest(material.depth_test);this.renderBuffer(v,ba,ga,material,R,C)}}}for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){L=n.opaque;g(C);for(n=0;n<L.count;n++){material=L.list[n];this.setDepthTest(material.depth_test);F=
this.setProgram(v,ba,ga,material,C);C.render(function(B){e(B,F)})}}}for(u=0;u<G;u++){n=l.__webGLObjects[u];if(n.render){C=n.object;R=n.buffer;L=n.transparent;g(C);for(n=0;n<L.count;n++){material=L.list[n];z(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(v,ba,ga,material,R,C)}}}for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){L=n.transparent;g(C);for(n=0;n<L.count;n++){material=L.list[n];z(material.blending);this.setDepthTest(material.depth_test);
F=this.setProgram(v,ba,ga,material,C);C.render(function(B){e(B,F)})}}}if(A&&A.min_filter!==THREE.NearestFilter&&A.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,A.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var v,A,u;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}v=0;for(A=l.objects.length;v<A;v++){u=l.objects[v];t(l,u,true);x(l,u)}};this.removeObject=function(l,v){var A,
u;for(A=l.__webGLObjects.length-1;A>=0;A--){u=l.__webGLObjects[A].object;v==u&&l.__webGLObjects.splice(A,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,v){if(l){!v||v=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.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, gl_FragColor.w ), 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\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\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\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 mColor = vec4( diffuse, opacity );\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\ngl_FragColor = gl_FragColor * totalLight;",
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};
@@ -230,20 +231,20 @@ THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=ne
THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}};
var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,h=c?b.geometry:b,f=a.vertices,j=h.vertices,l=a.faces,k=h.faces,m=a.uvs;h=h.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var p=0,y=j.length;p<y;p++){var t=new THREE.Vertex(j[p].position.clone());c&&b.matrix.multiplyVector3(t.position);f.push(t)}p=0;for(y=k.length;p<y;p++){j=k[p];var o,d=j.vertexNormals;if(j instanceof THREE.Face3)o=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)o=new THREE.Face4(j.a+
e,j.b+e,j.c+e,j.d+e);o.centroid.copy(j.centroid);o.normal.copy(j.normal);c=0;for(f=d.length;c<f;c++){t=d[c];o.vertexNormals.push(t.clone())}o.materials=j.materials.slice();l.push(o)}p=0;for(y=h.length;p<y;p++){e=h[p];l=[];c=0;for(f=e.length;c<f;c++)l.push(new THREE.UV(e[c].u,e[c].v));m.push(l)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image;e.onload=function(){this.loaded=true;c&&c(this)};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a,b){var c,e,h=[];c=h.loadCount=0;for(e=
a.length;c<e;++c){h[c]=new Image;h[c].loaded=0;h[c].onload=function(){h.loadCount+=1;this.loaded=true;b&&b(this)};h[c].src=a[c]}return h}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(h){function f(){for(p in N.objects)if(!n.objects[p]){A=N.objects[p];if(u=n.geometries[A.geometry]){$=[];for(i=0;i<A.materials.length;i++)$[i]=n.materials[A.materials[i]];E=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(u,$);object.position.set(E[0],E[1],E[2]);
object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;n.scene.addObject(object);n.objects[p]=object}}}function j(v){return function(x){n.geometries[v]=x;f();W-=1;l()}}function l(){e({total_models:X,total_textures:g,loaded_models:X-W,loaded_textures:g-R},n);W==0&&R==0&&c(n)}var k,m,p,y,t,o,d,A,E,w,F,u,I,Q,$,N,K,W,R,X,g,n;N=h.data;K=new THREE.Loader;R=W=0;n={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
h=function(){R-=1;l()};for(t in N.cameras){w=N.cameras[t];if(w.type=="perspective")I=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){I=new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}E=w.position;w=w.target;I.position.set(E[0],E[1],E[2]);I.target.position.set(w[0],w[1],w[2]);n.cameras[t]=I}for(y in N.lights){t=N.lights[y];if(t.type=="directional"){E=t.direction;light=new THREE.DirectionalLight;light.position.set(E[0],E[1],
E[2]);light.position.normalize()}else if(t.type=="point"){E=t.position;light=new THREE.PointLight;light.position.set(E[0],E[1],E[2])}w=t.color;i=t.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);n.scene.addLight(light);n.lights[y]=light}for(o in N.fogs){y=N.fogs[o];if(y.type=="linear")Q=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")Q=new THREE.FogExp2(0,y.density);w=y.color;Q.color.setRGB(w[0],w[1],w[2]);n.fogs[o]=Q}if(n.cameras&&N.defaults.camera)n.currentCamera=n.cameras[N.defaults.camera];
if(n.fogs&&N.defaults.fog)n.scene.fog=n.fogs[N.defaults.fog];w=N.defaults.bgcolor;n.bgColor=new THREE.Color;n.bgColor.setRGB(w[0],w[1],w[2]);n.bgColorAlpha=N.defaults.bgalpha;for(k in N.geometries){o=N.geometries[k];if(o.type=="bin_mesh"||o.type=="ascii_mesh")W+=1}X=W;for(k in N.geometries){o=N.geometries[k];if(o.type=="cube"){u=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);n.geometries[k]=u}else if(o.type=="plane"){u=new Plane(o.width,o.height,o.segments_width,
o.segments_height);n.geometries[k]=u}else if(o.type=="sphere"){u=new Sphere(o.radius,o.segments_width,o.segments_height);n.geometries[k]=u}else if(o.type=="cylinder"){u=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);n.geometries[k]=u}else if(o.type=="torus"){u=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);n.geometries[k]=u}else if(o.type=="icosahedron"){u=new Icosahedron(o.subdivisions);n.geometries[k]=u}else if(o.type=="bin_mesh")K.loadBinary({model:o.url,callback:j(k)});
else o.type=="ascii_mesh"&&K.loadAscii({model:o.url,callback:j(k)})}for(d in N.textures){k=N.textures[d];R+=k.url instanceof Array?k.url.length:1}g=R;for(d in N.textures){k=N.textures[d];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){o=ImageUtils.loadArray(k.url,h);o=new THREE.Texture(o,k.mapping)}else{o=ImageUtils.loadTexture(k.url,k.mapping,h);if(THREE[k.min_filter]!=undefined)o.min_filter=THREE[k.min_filter];if(THREE[k.mag_filter]!=
undefined)o.mag_filter=THREE[k.mag_filter]}n.textures[d]=o}for(m in N.materials){d=N.materials[m];for(F in d.parameters)if(F=="env_map"||F=="map"||F=="light_map")d.parameters[F]=n.textures[d.parameters[F]];else if(F=="shading")d.parameters[F]=d.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")d.parameters[F]=THREE[d.parameters[F]]?THREE[d.parameters[F]]:THREE.NormalBlending;else if(F=="combine")d.parameters[F]=d.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
d=new THREE[d.type](d.parameters);n.materials[m]=d}f();b(n)}},addMesh:function(a,b,c,e,h,f,j,l,k,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=h;b.position.z=f;b.rotation.x=j;b.rotation.y=l;b.rotation.z=k;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,
var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var p=0,x=h.length;p<x;p++){var t=new THREE.Vertex(h[p].position.clone());c&&b.matrix.multiplyVector3(t.position);f.push(t)}p=0;for(x=j.length;p<x;p++){h=j[p];var q,y=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)q=new THREE.Face4(h.a+
e,h.b+e,h.c+e,h.d+e);q.centroid.copy(h.centroid);q.normal.copy(h.normal);c=0;for(f=y.length;c<f;c++){t=y[c];q.vertexNormals.push(t.clone())}q.materials=h.materials.slice();k.push(q)}p=0;for(x=g.length;p<x;p++){e=g[p];k=[];c=0;for(f=e.length;c<f;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image;e.onload=function(){this.loaded=true;c&&c(this)};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a,b){var c,e,g=[];c=g.loadCount=0;for(e=
a.length;c<e;++c){g[c]=new Image;g[c].loaded=0;g[c].onload=function(){g.loadCount+=1;this.loaded=true;b&&b(this)};g[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(p in N.objects)if(!J.objects[p]){z=N.objects[p];if(o=J.geometries[z.geometry]){aa=[];for(i=0;i<z.materials.length;i++)aa[i]=J.materials[z.materials[i]];H=z.position;r=z.rotation;s=z.scale;object=new THREE.Mesh(o,aa);object.position.set(H[0],H[1],H[2]);
object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;J.scene.addObject(object);J.objects[p]=object}}}function h(X){return function(ha){J.geometries[X]=ha;f();U-=1;k()}}function k(){e({total_models:Y,total_textures:W,loaded_models:Y-U,loaded_textures:W-O},J);U==0&&O==0&&c(J)}var j,m,p,x,t,q,y,z,H,w,E,o,d,P,aa,N,M,U,O,Y,W,J;N=g.data;M=new THREE.Loader;O=U=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
g=function(){O-=1;k()};for(t in N.cameras){w=N.cameras[t];if(w.type=="perspective")d=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){d=new THREE.Camera;d.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}H=w.position;w=w.target;d.position.set(H[0],H[1],H[2]);d.target.position.set(w[0],w[1],w[2]);J.cameras[t]=d}for(x in N.lights){t=N.lights[x];if(t.type=="directional"){H=t.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
H[2]);light.position.normalize()}else if(t.type=="point"){H=t.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}w=t.color;i=t.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);J.scene.addLight(light);J.lights[x]=light}for(q in N.fogs){x=N.fogs[q];if(x.type=="linear")P=new THREE.Fog(0,x.near,x.far);else if(x.type=="exp2")P=new THREE.FogExp2(0,x.density);w=x.color;P.color.setRGB(w[0],w[1],w[2]);J.fogs[q]=P}if(J.cameras&&N.defaults.camera)J.currentCamera=J.cameras[N.defaults.camera];
if(J.fogs&&N.defaults.fog)J.scene.fog=J.fogs[N.defaults.fog];w=N.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(w[0],w[1],w[2]);J.bgColorAlpha=N.defaults.bgalpha;for(j in N.geometries){q=N.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")U+=1}Y=U;for(j in N.geometries){q=N.geometries[j];if(q.type=="cube"){o=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);J.geometries[j]=o}else if(q.type=="plane"){o=new Plane(q.width,q.height,q.segments_width,
q.segments_height);J.geometries[j]=o}else if(q.type=="sphere"){o=new Sphere(q.radius,q.segments_width,q.segments_height);J.geometries[j]=o}else if(q.type=="cylinder"){o=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);J.geometries[j]=o}else if(q.type=="torus"){o=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);J.geometries[j]=o}else if(q.type=="icosahedron"){o=new Icosahedron(q.subdivisions);J.geometries[j]=o}else if(q.type=="bin_mesh")M.loadBinary({model:q.url,callback:h(j)});
else q.type=="ascii_mesh"&&M.loadAscii({model:q.url,callback:h(j)})}for(y in N.textures){j=N.textures[y];O+=j.url instanceof Array?j.url.length:1}W=O;for(y in N.textures){j=N.textures[y];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){q=ImageUtils.loadArray(j.url,g);q=new THREE.Texture(q,j.mapping)}else{q=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)q.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
undefined)q.mag_filter=THREE[j.mag_filter]}J.textures[y]=q}for(m in N.materials){y=N.materials[m];for(E in y.parameters)if(E=="env_map"||E=="map"||E=="light_map")y.parameters[E]=J.textures[y.parameters[E]];else if(E=="shading")y.parameters[E]=y.parameters[E]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(E=="blending")y.parameters[E]=THREE[y.parameters[E]]?THREE[y.parameters[E]]:THREE.NormalBlending;else if(E=="combine")y.parameters[E]=y.parameters[E]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
y=new THREE[y.type](y.parameters);J.materials[m]=y}f();b(J)}},addMesh:function(a,b,c,e,g,f,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,
b,b,1,1,null,true),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2;b=new Plane(b,b);var h=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,h,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
SceneUtils.addMesh(a,b,1,0,-e,0,-h,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + 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, 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}",
@@ -252,38 +253,38 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\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}"}},buildKernel:function(a){var b,c,e,h,f=2*Math.ceil(a*3)+1;if(f>25)f=25;h=(f-1)*0.5;c=Array(f);for(b=e=0;b<f;++b){c[b]=Math.exp(-((b-h)*(b-h))/(2*a*a));e+=c[b]}for(b=0;b<f;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,h,f,j,l){function k(A,E,w,F,u,I,Q,$){var N,K,W=e||1,R=h||1,X=W+1,g=R+1,n=u/2,v=I/2;u=u/W;var x=I/R,q=m.vertices.length;if(A=="x"&&E=="y"||A=="y"&&E=="x")N="z";else if(A=="x"&&E=="z"||A=="z"&&E=="x")N="y";else if(A==
"z"&&E=="y"||A=="y"&&E=="z")N="x";for(K=0;K<g;K++)for(I=0;I<X;I++){var z=new THREE.Vector3;z[A]=(I*u-n)*w;z[E]=(K*x-v)*F;z[N]=Q;m.vertices.push(new THREE.Vertex(z))}for(K=0;K<R;K++)for(I=0;I<W;I++){m.faces.push(new THREE.Face4(I+X*K+q,I+X*(K+1)+q,I+1+X*(K+1)+q,I+1+X*K+q,null,$));m.uvs.push([new THREE.UV(I/W,K/R),new THREE.UV(I/W,(K+1)/R),new THREE.UV((I+1)/W,(K+1)/R),new THREE.UV((I+1)/W,K/R)])}}THREE.Geometry.call(this);var m=this,p=a/2,y=b/2,t=c/2;j=j?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=
f;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(l!=undefined)for(var d in l)if(this.sides[d]!=undefined)this.sides[d]=l[d];this.sides.px&&k("z","y",1*j,-1,c,b,-p,this.materials[0]);this.sides.nx&&k("z","y",-1*j,-1,c,b,p,this.materials[1]);this.sides.py&&k("x","z",1*j,1,a,c,y,this.materials[2]);this.sides.ny&&k("x","z",1*j,-1,a,c,-y,this.materials[3]);this.sides.pz&&k("x","y",1*j,-1,a,b,t,this.materials[4]);
this.sides.nz&&k("x","y",-1*j,-1,a,b,-t,this.materials[5]);(function(){for(var A=[],E=[],w=0,F=m.vertices.length;w<F;w++){for(var u=m.vertices[w],I=false,Q=0,$=A.length;Q<$;Q++){var N=A[Q];if(u.position.x==N.position.x&&u.position.y==N.position.y&&u.position.z==N.position.z){E[w]=Q;I=true;break}}if(!I){E[w]=A.length;A.push(new THREE.Vertex(u.position.clone()))}}w=0;for(F=m.faces.length;w<F;w++){u=m.faces[w];u.a=E[u.a];u.b=E[u.b];u.c=E[u.c];u.d=E[u.d]}m.vertices=A})();this.computeCentroids();this.computeFaceNormals();
this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,c,e,h){function f(m,p,y){j.vertices.push(new THREE.Vertex(new THREE.Vector3(m,p,y)))}THREE.Geometry.call(this);var j=this,l=Math.PI,k;for(k=0;k<a;k++)f(Math.sin(2*l*k/a)*b,Math.cos(2*l*k/a)*b,0);for(k=0;k<a;k++)f(Math.sin(2*l*k/a)*c,Math.cos(2*l*k/a)*c,e);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(c!=0){f(0,0,-h);for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){f(0,0,e+h);for(k=a+a/2;k<
2*a;k++)j.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
var Plane=function(a,b,c,e){THREE.Geometry.call(this);var h,f=a/2,j=b/2;c=c||1;e=e||1;var l=c+1,k=e+1;a=a/c;var m=b/e;for(h=0;h<k;h++)for(b=0;b<l;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(h*m-j),0)));for(h=0;h<e;h++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+l*h,b+l*(h+1),b+1+l*(h+1),b+1+l*h));this.uvs.push([new THREE.UV(b/c,h/e),new THREE.UV(b/c,(h+1)/e),new THREE.UV((b+1)/c,(h+1)/e),new THREE.UV((b+1)/c,h/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,e,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b<f;++b){c[b]=Math.exp(-((b-g)*(b-g))/(2*a*a));e+=c[b]}for(b=0;b<f;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,g,f,h,k){function j(z,H,w,E,o,d,P,aa){var N,M,U=e||1,O=g||1,Y=U+1,W=O+1,J=o/2,X=d/2;o=o/U;var ha=d/O,Z=m.vertices.length;if(z=="x"&&H=="y"||z=="y"&&H=="x")N="z";else if(z=="x"&&H=="z"||z=="z"&&H=="x")N="y";
else if(z=="z"&&H=="y"||z=="y"&&H=="z")N="x";for(M=0;M<W;M++)for(d=0;d<Y;d++){var ea=new THREE.Vector3;ea[z]=(d*o-J)*w;ea[H]=(M*ha-X)*E;ea[N]=P;m.vertices.push(new THREE.Vertex(ea))}for(M=0;M<O;M++)for(d=0;d<U;d++){m.faces.push(new THREE.Face4(d+Y*M+Z,d+Y*(M+1)+Z,d+1+Y*(M+1)+Z,d+1+Y*M+Z,null,aa));m.uvs.push([new THREE.UV(d/U,M/O),new THREE.UV(d/U,(M+1)/O),new THREE.UV((d+1)/U,(M+1)/O),new THREE.UV((d+1)/U,M/O)])}}THREE.Geometry.call(this);var m=this,p=a/2,x=b/2,t=c/2;h=h?-1:1;if(f!==undefined)if(f instanceof
Array)this.materials=f;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var y in k)if(this.sides[y]!=undefined)this.sides[y]=k[y];this.sides.px&&j("z","y",1*h,-1,c,b,-p,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,p,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,x,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-x,this.materials[3]);this.sides.pz&&j("x",
"y",1*h,-1,a,b,t,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-t,this.materials[5]);(function(){for(var z=[],H=[],w=0,E=m.vertices.length;w<E;w++){for(var o=m.vertices[w],d=false,P=0,aa=z.length;P<aa;P++){var N=z[P];if(o.position.x==N.position.x&&o.position.y==N.position.y&&o.position.z==N.position.z){H[w]=P;d=true;break}}if(!d){H[w]=z.length;z.push(new THREE.Vertex(o.position.clone()))}}w=0;for(E=m.faces.length;w<E;w++){o=m.faces[w];o.a=H[o.a];o.b=H[o.b];o.c=H[o.c];o.d=H[o.d]}m.vertices=
z})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,c,e,g){function f(m,p,x){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,p,x)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){f(0,0,e+g);for(j=a+a/2;j<
2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
var Plane=function(a,b,c,e){THREE.Geometry.call(this);var g,f=a/2,h=b/2;c=c||1;e=e||1;var k=c+1,j=e+1;a=a/c;var m=b/e;for(g=0;g<j;g++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*g,b+k*(g+1),b+1+k*(g+1),b+1+k*g));this.uvs.push([new THREE.UV(b/c,g/e),new THREE.UV(b/c,(g+1)/e),new THREE.UV((b+1)/c,(g+1)/e),new THREE.UV((b+1)/c,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,h=Math.PI,f=Math.max(3,b||8),j=Math.max(2,c||6);b=[];for(c=0;c<j+1;c++){e=c/j;var l=a*Math.cos(e*h),k=a*Math.sin(e*h),m=[],p=0;for(e=0;e<f;e++){var y=2*e/f,t=k*Math.sin(y*h);y=k*Math.cos(y*h);(c==0||c==j)&&e>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,l,t)))-1);m.push(p)}b.push(m)}var o,d,A;h=b.length;for(c=0;c<h;c++){f=b[c].length;if(c>0)for(e=0;e<f;e++){m=e==f-1;j=b[c][m?0:e+1];l=b[c][m?f-1:e];k=b[c-1][m?f-1:e];m=b[c-1][m?
0:e+1];t=c/(h-1);o=(c-1)/(h-1);d=(e+1)/f;y=e/f;p=new THREE.UV(1-d,t);t=new THREE.UV(1-y,t);y=new THREE.UV(1-y,o);var E=new THREE.UV(1-d,o);if(c<b.length-1){o=this.vertices[j].position.clone();d=this.vertices[l].position.clone();A=this.vertices[k].position.clone();o.normalize();d.normalize();A.normalize();this.faces.push(new THREE.Face3(j,l,k,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(d.x,d.y,d.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([p,t,y])}if(c>1){o=this.vertices[j].position.clone();
d=this.vertices[k].position.clone();A=this.vertices[m].position.clone();o.normalize();d.normalize();A.normalize();this.faces.push(new THREE.Face3(j,k,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(d.x,d.y,d.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([p,y,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var h=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(h))*Math.cos(e),(this.radius+this.tube*Math.cos(h))*Math.sin(e),this.tube*Math.sin(h))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;h=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,j=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,h,f,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
var Icosahedron=function(a){function b(y,t,o){var d=Math.sqrt(y*y+t*t+o*o);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(y/d,t/d,o/d)))-1}function c(y,t,o,d){d.faces.push(new THREE.Face3(y,t,o))}function e(y,t){var o=h.vertices[y].position,d=h.vertices[t].position;return b((o.x+d.x)/2,(o.y+d.y)/2,(o.z+d.z)/2)}var h=this,f=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a<this.subdivisions;a++){j=new THREE.Geometry;for(var l in f.faces){var k=e(f.faces[l].a,f.faces[l].b),m=e(f.faces[l].b,f.faces[l].c),p=e(f.faces[l].c,f.faces[l].a);c(f.faces[l].a,k,p,j);c(f.faces[l].b,m,k,j);c(f.faces[l].c,
p,m,j);c(k,m,p,j)}f.faces=j.faces}h.faces=f.faces;delete f;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function LathedObject(a,b,c){THREE.Geometry.call(this);b=b||12;c=c||2*Math.PI;b=c/b;for(var e=[],h=[],f=[],j=[],l=0;l<a.length;l++){this.vertices.push(new THREE.Vertex(a[l]));h[l]=this.vertices.length-1;e[l]=new THREE.Vector3(a[l].x,a[l].y,a[l].z)}for(var k=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(l=0;l<e.length;l++)if(m<c){e[l]=k.multiplyVector3(e[l].clone());this.vertices.push(new THREE.Vertex(e[l]));f[l]=this.vertices.length-1}else f=j;if(m==0)j=h;for(l=0;l<h.length-1;l++){this.faces.push(new THREE.Face4(f[l],
f[l+1],h[l+1],h[l]));this.uvs.push([new THREE.UV(m/c,l/a.length),new THREE.UV(m/c,(l+1)/a.length),new THREE.UV((m-b)/c,(l+1)/a.length),new THREE.UV((m-b)/c,l/a.length)])}h=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*g),j=a*Math.sin(e*g),m=[],p=0;for(e=0;e<f;e++){var x=2*e/f,t=j*Math.sin(x*g);x=j*Math.cos(x*g);(c==0||c==h)&&e>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,t)))-1);m.push(p)}b.push(m)}var q,y,z;g=b.length;for(c=0;c<g;c++){f=b[c].length;if(c>0)for(e=0;e<f;e++){m=e==f-1;h=b[c][m?0:e+1];k=b[c][m?f-1:e];j=b[c-1][m?f-1:e];m=b[c-1][m?
0:e+1];t=c/(g-1);q=(c-1)/(g-1);y=(e+1)/f;x=e/f;p=new THREE.UV(1-y,t);t=new THREE.UV(1-x,t);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-y,q);if(c<b.length-1){q=this.vertices[h].position.clone();y=this.vertices[k].position.clone();z=this.vertices[j].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,t,x])}if(c>1){q=this.vertices[h].position.clone();
y=this.vertices[j].position.clone();z=this.vertices[m].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
var Icosahedron=function(a){function b(x,t,q){var y=Math.sqrt(x*x+t*t+q*q);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(x/y,t/y,q/y)))-1}function c(x,t,q,y){y.faces.push(new THREE.Face3(x,t,q))}function e(x,t){var q=g.vertices[x].position,y=g.vertices[t].position;return b((q.x+y.x)/2,(q.y+y.y)/2,(q.z+y.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in f.faces){var j=e(f.faces[k].a,f.faces[k].b),m=e(f.faces[k].b,f.faces[k].c),p=e(f.faces[k].c,f.faces[k].a);c(f.faces[k].a,j,p,h);c(f.faces[k].b,m,j,h);c(f.faces[k].c,
p,m,h);c(j,m,p,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function LathedObject(a,b,c){THREE.Geometry.call(this);b=b||12;c=c||2*Math.PI;b=c/b;for(var e=[],g=[],f=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));g[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(k=0;k<e.length;k++)if(m<c){e[k]=j.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));f[k]=this.vertices.length-1}else f=h;if(m==0)h=g;for(k=0;k<g.length-1;k++){this.faces.push(new THREE.Face4(f[k],
f[k+1],g[k+1],g[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,h){return c+(e-c)*h};this.VIntX=function(c,e,h,f,j,l,k,m,p,y){j=(j-p)/(y-p);p=this.normal_cache;e[f]=l+j*this.delta;e[f+1]=k;e[f+2]=m;h[f]=this.lerp(p[c],p[c+3],j);h[f+1]=this.lerp(p[c+1],p[c+4],j);h[f+2]=this.lerp(p[c+2],p[c+5],j)};this.VIntY=function(c,e,h,f,j,l,k,m,p,y){j=(j-p)/(y-p);p=this.normal_cache;e[f]=l;e[f+1]=k+j*this.delta;e[f+
2]=m;e=c+this.yd*3;h[f]=this.lerp(p[c],p[e],j);h[f+1]=this.lerp(p[c+1],p[e+1],j);h[f+2]=this.lerp(p[c+2],p[e+2],j)};this.VIntZ=function(c,e,h,f,j,l,k,m,p,y){j=(j-p)/(y-p);p=this.normal_cache;e[f]=l;e[f+1]=k;e[f+2]=m+j*this.delta;e=c+this.zd*3;h[f]=this.lerp(p[c],p[e],j);h[f+1]=this.lerp(p[c+1],p[e+1],j);h[f+2]=this.lerp(p[c+2],p[e+2],j)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,h,f,j,l){var k=f+1,m=f+this.yd,p=f+this.zd,y=k+this.yd,t=k+this.zd,o=f+this.yd+this.zd,d=k+this.yd+this.zd,A=0,E=this.field[f],w=this.field[k],F=this.field[m],u=this.field[y],I=this.field[p],Q=this.field[t],$=this.field[o],N=this.field[d];if(E<j)A|=1;if(w<j)A|=2;if(F<j)A|=8;if(u<j)A|=4;if(I<j)A|=16;if(Q<j)A|=32;if($<j)A|=128;if(N<j)A|=64;var K=THREE.edgeTable[A];if(K==0)return 0;
var W=this.delta,R=c+W,X=e+W;W=h+W;if(K&1){this.compNorm(f);this.compNorm(k);this.VIntX(f*3,this.vlist,this.nlist,0,j,c,e,h,E,w)}if(K&2){this.compNorm(k);this.compNorm(y);this.VIntY(k*3,this.vlist,this.nlist,3,j,R,e,h,w,u)}if(K&4){this.compNorm(m);this.compNorm(y);this.VIntX(m*3,this.vlist,this.nlist,6,j,c,X,h,F,u)}if(K&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,j,c,e,h,E,F)}if(K&16){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,12,j,c,e,W,
I,Q)}if(K&32){this.compNorm(t);this.compNorm(d);this.VIntY(t*3,this.vlist,this.nlist,15,j,R,e,W,Q,N)}if(K&64){this.compNorm(o);this.compNorm(d);this.VIntX(o*3,this.vlist,this.nlist,18,j,c,X,W,$,N)}if(K&128){this.compNorm(p);this.compNorm(o);this.VIntY(p*3,this.vlist,this.nlist,21,j,c,e,W,I,$)}if(K&256){this.compNorm(f);this.compNorm(p);this.VIntZ(f*3,this.vlist,this.nlist,24,j,c,e,h,E,I)}if(K&512){this.compNorm(k);this.compNorm(t);this.VIntZ(k*3,this.vlist,this.nlist,27,j,R,e,h,w,Q)}if(K&1024){this.compNorm(y);
this.compNorm(d);this.VIntZ(y*3,this.vlist,this.nlist,30,j,R,X,h,u,N)}if(K&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,j,c,X,h,F,$)}A<<=4;for(j=f=0;THREE.triTable[A+j]!=-1;){c=A+j;e=c+1;h=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[h],l);j+=3;f++}return f};this.posnormtriv=function(c,e,h,f,j,l){var k=this.count*3;this.positionArray[k]=c[h];this.positionArray[k+1]=c[h+1];this.positionArray[k+2]=c[h+2];this.positionArray[k+
3]=c[f];this.positionArray[k+4]=c[f+1];this.positionArray[k+5]=c[f+2];this.positionArray[k+6]=c[j];this.positionArray[k+7]=c[j+1];this.positionArray[k+8]=c[j+2];this.normalArray[k]=e[h];this.normalArray[k+1]=e[h+1];this.normalArray[k+2]=e[h+2];this.normalArray[k+3]=e[f];this.normalArray[k+4]=e[f+1];this.normalArray[k+5]=e[f+2];this.normalArray[k+6]=e[j];this.normalArray[k+7]=e[j+1];this.normalArray[k+8]=e[j+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&l(this)};this.begin=
function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,h,f,j){var l=this.size*Math.sqrt(f/j),k=h*this.size,m=e*this.size,p=c*this.size,y=Math.floor(k-l);if(y<1)y=1;k=Math.floor(k+l);if(k>this.size-1)k=this.size-1;var t=Math.floor(m-l);if(t<1)t=1;m=Math.floor(m+l);if(m>this.size-1)m=this.size-1;var o=Math.floor(p-l);if(o<1)o=1;l=Math.floor(p+l);
if(l>this.size-1)l=this.size-1;var d,A,E,w,F,u;for(y=y;y<k;y++){p=this.size2*y;A=y/this.size-h;F=A*A;for(A=t;A<m;A++){E=p+this.size*A;d=A/this.size-e;u=d*d;for(d=o;d<l;d++){w=d/this.size-c;w=f/(1.0E-6+w*w+u+F)-j;if(w>0)this.field[E+d]+=w}}}};this.addPlaneX=function(c,e){var h,f,j,l,k,m=this.size,p=this.yd,y=this.zd,t=this.field,o=m*Math.sqrt(c/e);if(o>m)o=m;for(h=0;h<o;h++){f=h/m;f=f*f;l=c/(1.0E-4+f)-e;if(l>0)for(f=0;f<m;f++){k=h+f*p;for(j=0;j<m;j++)t[y*j+k]+=l}}};this.addPlaneY=function(c,e){var h,
f,j,l,k,m,p=this.size,y=this.yd,t=this.zd,o=this.field,d=p*Math.sqrt(c/e);if(d>p)d=p;for(f=0;f<d;f++){h=f/p;h=h*h;l=c/(1.0E-4+h)-e;if(l>0){k=f*y;for(h=0;h<p;h++){m=k+h;for(j=0;j<p;j++)o[t*j+m]+=l}}}};this.addPlaneZ=function(c,e){var h,f,j,l,k,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);if(dist>size)dist=size;for(j=0;j<dist;j++){h=j/size;h=h*h;l=c/(1.0E-4+h)-e;if(l>0){k=zd*j;for(f=0;f<size;f++){m=k+f*yd;for(h=0;h<size;h++)field[m+h]+=l}}}};this.reset=function(){var c;
for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,h,f,j,l,k,m,p,y,t=this.size-2;for(j=1;j<t;j++){y=this.size2*j;m=(j-this.halfsize)/this.halfsize;for(f=1;f<t;f++){p=y+this.size*f;k=(f-this.halfsize)/this.halfsize;for(h=1;h<t;h++){l=(h-this.halfsize)/this.halfsize;e=p+h;this.polygonize(l,k,m,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(h){var f,j,l,k,m,p,y,t;for(f=
0;f<h.count;f++){m=f*3;y=m+1;t=m+2;j=h.positionArray[m];l=h.positionArray[y];k=h.positionArray[t];p=new THREE.Vector3(j,l,k);j=h.normalArray[m];l=h.normalArray[y];k=h.normalArray[t];m=new THREE.Vector3(j,l,k);m.normalize();m=new THREE.Vertex(p,m);e.vertices.push(m)}nfaces=h.count/3;for(f=0;f<nfaces;f++){m=(c+f)*3;y=m+1;t=m+2;p=e.vertices[m].normal;j=e.vertices[y].normal;l=e.vertices[t].normal;m=new THREE.Face3(m,y,t,[p,j,l]);e.faces.push(m)}c+=nfaces;h.count=0});e.sortFacesByMaterial();return e};
0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,g){return c+(e-c)*g};this.VIntX=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k+h*this.delta;e[f+1]=j;e[f+2]=m;g[f]=this.lerp(p[c],p[c+3],h);g[f+1]=this.lerp(p[c+1],p[c+4],h);g[f+2]=this.lerp(p[c+2],p[c+5],h)};this.VIntY=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k;e[f+1]=j+h*this.delta;e[f+
2]=m;e=c+this.yd*3;g[f]=this.lerp(p[c],p[e],h);g[f+1]=this.lerp(p[c+1],p[e+1],h);g[f+2]=this.lerp(p[c+2],p[e+2],h)};this.VIntZ=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k;e[f+1]=j;e[f+2]=m+h*this.delta;e=c+this.zd*3;g[f]=this.lerp(p[c],p[e],h);g[f+1]=this.lerp(p[c+1],p[e+1],h);g[f+2]=this.lerp(p[c+2],p[e+2],h)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,g,f,h,k){var j=f+1,m=f+this.yd,p=f+this.zd,x=j+this.yd,t=j+this.zd,q=f+this.yd+this.zd,y=j+this.yd+this.zd,z=0,H=this.field[f],w=this.field[j],E=this.field[m],o=this.field[x],d=this.field[p],P=this.field[t],aa=this.field[q],N=this.field[y];if(H<h)z|=1;if(w<h)z|=2;if(E<h)z|=8;if(o<h)z|=4;if(d<h)z|=16;if(P<h)z|=32;if(aa<h)z|=128;if(N<h)z|=64;var M=THREE.edgeTable[z];if(M==0)return 0;
var U=this.delta,O=c+U,Y=e+U;U=g+U;if(M&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,c,e,g,H,w)}if(M&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,O,e,g,w,o)}if(M&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,Y,g,E,o)}if(M&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,c,e,g,H,E)}if(M&16){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,12,h,c,e,U,
d,P)}if(M&32){this.compNorm(t);this.compNorm(y);this.VIntY(t*3,this.vlist,this.nlist,15,h,O,e,U,P,N)}if(M&64){this.compNorm(q);this.compNorm(y);this.VIntX(q*3,this.vlist,this.nlist,18,h,c,Y,U,aa,N)}if(M&128){this.compNorm(p);this.compNorm(q);this.VIntY(p*3,this.vlist,this.nlist,21,h,c,e,U,d,aa)}if(M&256){this.compNorm(f);this.compNorm(p);this.VIntZ(f*3,this.vlist,this.nlist,24,h,c,e,g,H,d)}if(M&512){this.compNorm(j);this.compNorm(t);this.VIntZ(j*3,this.vlist,this.nlist,27,h,O,e,g,w,P)}if(M&1024){this.compNorm(x);
this.compNorm(y);this.VIntZ(x*3,this.vlist,this.nlist,30,h,O,Y,g,o,N)}if(M&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,Y,g,E,aa)}z<<=4;for(h=f=0;THREE.triTable[z+h]!=-1;){c=z+h;e=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[g],k);h+=3;f++}return f};this.posnormtriv=function(c,e,g,f,h,k){var j=this.count*3;this.positionArray[j]=c[g];this.positionArray[j+1]=c[g+1];this.positionArray[j+2]=c[g+2];this.positionArray[j+
3]=c[f];this.positionArray[j+4]=c[f+1];this.positionArray[j+5]=c[f+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,g,f,h){var k=this.size*Math.sqrt(f/h),j=g*this.size,m=e*this.size,p=c*this.size,x=Math.floor(j-k);if(x<1)x=1;j=Math.floor(j+k);if(j>this.size-1)j=this.size-1;var t=Math.floor(m-k);if(t<1)t=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var q=Math.floor(p-k);if(q<1)q=1;k=Math.floor(p+k);
if(k>this.size-1)k=this.size-1;var y,z,H,w,E,o;for(x=x;x<j;x++){p=this.size2*x;z=x/this.size-g;E=z*z;for(z=t;z<m;z++){H=p+this.size*z;y=z/this.size-e;o=y*y;for(y=q;y<k;y++){w=y/this.size-c;w=f/(1.0E-6+w*w+o+E)-h;if(w>0)this.field[H+y]+=w}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,p=this.yd,x=this.zd,t=this.field,q=m*Math.sqrt(c/e);if(q>m)q=m;for(g=0;g<q;g++){f=g/m;f=f*f;k=c/(1.0E-4+f)-e;if(k>0)for(f=0;f<m;f++){j=g+f*p;for(h=0;h<m;h++)t[x*h+j]+=k}}};this.addPlaneY=function(c,e){var g,
f,h,k,j,m,p=this.size,x=this.yd,t=this.zd,q=this.field,y=p*Math.sqrt(c/e);if(y>p)y=p;for(f=0;f<y;f++){g=f/p;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=f*x;for(g=0;g<p;g++){m=j+g;for(h=0;h<p;h++)q[t*h+m]+=k}}}};this.addPlaneZ=function(c,e){var g,f,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);if(dist>size)dist=size;for(h=0;h<dist;h++){g=h/size;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=zd*h;for(f=0;f<size;f++){m=j+f*yd;for(g=0;g<size;g++)field[m+g]+=k}}}};this.reset=function(){var c;
for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,g,f,h,k,j,m,p,x,t=this.size-2;for(h=1;h<t;h++){x=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<t;f++){p=x+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<t;g++){k=(g-this.halfsize)/this.halfsize;e=p+g;this.polygonize(k,j,m,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(g){var f,h,k,j,m,p,x,t;for(f=
0;f<g.count;f++){m=f*3;x=m+1;t=m+2;h=g.positionArray[m];k=g.positionArray[x];j=g.positionArray[t];p=new THREE.Vector3(h,k,j);h=g.normalArray[m];k=g.normalArray[x];j=g.normalArray[t];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(p,m);e.vertices.push(m)}nfaces=g.count/3;for(f=0;f<nfaces;f++){m=(c+f)*3;x=m+1;t=m+2;p=e.vertices[m].normal;h=e.vertices[x].normal;k=e.vertices[t].normal;m=new THREE.Face3(m,x,t,[p,h,k]);e.faces.push(m)}c+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
@@ -310,26 +311,26 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);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 c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(h){THREE.Loader.prototype.createModel(h.data,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:
THREE.Loader.prototype.extractUrlbase(b),h=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,c,h,e,f)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,h,f){var j=new XMLHttpRequest,l=e+"/"+a,k=0;
j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,c,h,b):alert("Couldn't load ["+l+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(k==0)k=j.getResponseHeader("Content-Length");f({total:k,loaded:j.responseText.length})}}else if(j.readyState==2)k=j.getResponseHeader("Content-Length")};j.open("GET",l,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
createBinModel:function(a,b,c,e){var h=function(f){function j(B,P){var O=p(B,P),U=p(B,P+1),da=p(B,P+2),na=p(B,P+3),ia=(na<<1&255|da>>7)-127;O=(da&127)<<16|U<<8|O;if(O==0&&ia==-127)return 0;return(1-2*(na>>7))*(1+O*Math.pow(2,-23))*Math.pow(2,ia)}function l(B,P){var O=p(B,P),U=p(B,P+1),da=p(B,P+2);return(p(B,P+3)<<24)+(da<<16)+(U<<8)+O}function k(B,P){var O=p(B,P);return(p(B,P+1)<<8)+O}function m(B,P){var O=p(B,P);return O>127?O-256:O}function p(B,P){return B.charCodeAt(P)&255}function y(B){var P,
O,U;P=l(a,B);O=l(a,B+$);U=l(a,B+N);B=k(a,B+K);THREE.Loader.prototype.f3(w,P,O,U,B)}function t(B){var P,O,U,da,na,ia;P=l(a,B);O=l(a,B+$);U=l(a,B+N);da=k(a,B+K);na=l(a,B+W);ia=l(a,B+R);B=l(a,B+X);THREE.Loader.prototype.f3n(w,I,P,O,U,da,na,ia,B)}function o(B){var P,O,U,da;P=l(a,B);O=l(a,B+g);U=l(a,B+n);da=l(a,B+v);B=k(a,B+x);THREE.Loader.prototype.f4(w,P,O,U,da,B)}function d(B){var P,O,U,da,na,ia,fa,la;P=l(a,B);O=l(a,B+g);U=l(a,B+n);da=l(a,B+v);na=k(a,B+x);ia=l(a,B+q);fa=l(a,B+z);la=l(a,B+L);B=l(a,B+
C);THREE.Loader.prototype.f4n(w,I,P,O,U,da,na,ia,fa,la,B)}function A(B){var P,O;P=l(a,B);O=l(a,B+D);B=l(a,B+G);THREE.Loader.prototype.uv3(w.uvs,Q[P*2],Q[P*2+1],Q[O*2],Q[O*2+1],Q[B*2],Q[B*2+1])}function E(B){var P,O,U;P=l(a,B);O=l(a,B+H);U=l(a,B+J);B=l(a,B+Y);THREE.Loader.prototype.uv4(w.uvs,Q[P*2],Q[P*2+1],Q[O*2],Q[O*2+1],Q[U*2],Q[U*2+1],Q[B*2],Q[B*2+1])}var w=this,F=0,u,I=[],Q=[],$,N,K,W,R,X,g,n,v,x,q,z,L,C,D,G,H,J,Y,T,M,Z,ba,ha,ka;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
e,f);u={signature:a.substr(F,8),header_bytes:p(a,F+8),vertex_coordinate_bytes:p(a,F+9),normal_coordinate_bytes:p(a,F+10),uv_coordinate_bytes:p(a,F+11),vertex_index_bytes:p(a,F+12),normal_index_bytes:p(a,F+13),uv_index_bytes:p(a,F+14),material_index_bytes:p(a,F+15),nvertices:l(a,F+16),nnormals:l(a,F+16+4),nuvs:l(a,F+16+8),ntri_flat:l(a,F+16+12),ntri_smooth:l(a,F+16+16),ntri_flat_uv:l(a,F+16+20),ntri_smooth_uv:l(a,F+16+24),nquad_flat:l(a,F+16+28),nquad_smooth:l(a,F+16+32),nquad_flat_uv:l(a,F+16+36),
nquad_smooth_uv:l(a,F+16+40)};F+=u.header_bytes;$=u.vertex_index_bytes;N=u.vertex_index_bytes*2;K=u.vertex_index_bytes*3;W=u.vertex_index_bytes*3+u.material_index_bytes;R=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes;X=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*2;g=u.vertex_index_bytes;n=u.vertex_index_bytes*2;v=u.vertex_index_bytes*3;x=u.vertex_index_bytes*4;q=u.vertex_index_bytes*4+u.material_index_bytes;z=u.vertex_index_bytes*4+u.material_index_bytes+
u.normal_index_bytes;L=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*2;C=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*3;D=u.uv_index_bytes;G=u.uv_index_bytes*2;H=u.uv_index_bytes;J=u.uv_index_bytes*2;Y=u.uv_index_bytes*3;f=u.vertex_index_bytes*3+u.material_index_bytes;ka=u.vertex_index_bytes*4+u.material_index_bytes;T=u.ntri_flat*f;M=u.ntri_smooth*(f+u.normal_index_bytes*3);Z=u.ntri_flat_uv*(f+u.uv_index_bytes*3);ba=u.ntri_smooth_uv*(f+u.normal_index_bytes*
3+u.uv_index_bytes*3);ha=u.nquad_flat*ka;f=u.nquad_smooth*(ka+u.normal_index_bytes*4);ka=u.nquad_flat_uv*(ka+u.uv_index_bytes*4);F+=function(B){var P,O,U,da=u.vertex_coordinate_bytes*3,na=B+u.nvertices*da;for(B=B;B<na;B+=da){P=j(a,B);O=j(a,B+u.vertex_coordinate_bytes);U=j(a,B+u.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,P,O,U)}return u.nvertices*da}(F);F+=function(B){var P,O,U,da=u.normal_coordinate_bytes*3,na=B+u.nnormals*da;for(B=B;B<na;B+=da){P=m(a,B);O=m(a,B+u.normal_coordinate_bytes);
U=m(a,B+u.normal_coordinate_bytes*2);I.push(P/127,O/127,U/127)}return u.nnormals*da}(F);F+=function(B){var P,O,U=u.uv_coordinate_bytes*2,da=B+u.nuvs*U;for(B=B;B<da;B+=U){P=j(a,B);O=j(a,B+u.uv_coordinate_bytes);Q.push(P,O)}return u.nuvs*U}(F);F=F;T=F+T;M=T+M;Z=M+Z;ba=Z+ba;ha=ba+ha;f=ha+f;ka=f+ka;(function(B){var P,O=u.vertex_index_bytes*3+u.material_index_bytes,U=O+u.uv_index_bytes*3,da=B+u.ntri_flat_uv*U;for(P=B;P<da;P+=U){y(P);A(P+O)}return da-B})(M);(function(B){var P,O=u.vertex_index_bytes*3+u.material_index_bytes+
u.normal_index_bytes*3,U=O+u.uv_index_bytes*3,da=B+u.ntri_smooth_uv*U;for(P=B;P<da;P+=U){t(P);A(P+O)}return da-B})(Z);(function(B){var P,O=u.vertex_index_bytes*4+u.material_index_bytes,U=O+u.uv_index_bytes*4,da=B+u.nquad_flat_uv*U;for(P=B;P<da;P+=U){o(P);E(P+O)}return da-B})(f);(function(B){var P,O=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,U=O+u.uv_index_bytes*4,da=B+u.nquad_smooth_uv*U;for(P=B;P<da;P+=U){d(P);E(P+O)}return da-B})(ka);(function(B){var P,O=u.vertex_index_bytes*
3+u.material_index_bytes,U=B+u.ntri_flat*O;for(P=B;P<U;P+=O)y(P);return U-B})(F);(function(B){var P,O=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*3,U=B+u.ntri_smooth*O;for(P=B;P<U;P+=O)t(P);return U-B})(T);(function(B){var P,O=u.vertex_index_bytes*4+u.material_index_bytes,U=B+u.nquad_flat*O;for(P=B;P<U;P+=O)o(P);return U-B})(ba);(function(B){var P,O=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,U=B+u.nquad_smooth*O;for(P=B;P<U;P+=O)d(P);return U-B})(ha);
this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;b(new h(c))},createModel:function(a,b,c){var e=function(h){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,h);(function(){var j,l,k,m,p;j=0;for(l=a.vertices.length;j<l;j+=3){k=a.vertices[j];m=a.vertices[j+1];p=a.vertices[j+2];THREE.Loader.prototype.v(f,k,m,p)}if(a.colors){j=0;for(l=a.colors.length;j<l;j+=3){k=a.colors[j];m=
a.colors[j+1];p=a.colors[j+2];THREE.Loader.prototype.vc(f,k,m,p)}}})();(function(){function j(d,A){THREE.Loader.prototype.f3(f,d[A],d[A+1],d[A+2],d[A+3])}function l(d,A){THREE.Loader.prototype.f3n(f,a.normals,d[A],d[A+1],d[A+2],d[A+3],d[A+4],d[A+5],d[A+6])}function k(d,A){THREE.Loader.prototype.f4(f,d[A],d[A+1],d[A+2],d[A+3],d[A+4])}function m(d,A){THREE.Loader.prototype.f4n(f,a.normals,d[A],d[A+1],d[A+2],d[A+3],d[A+4],d[A+5],d[A+6],d[A+7],d[A+8])}function p(d,A){var E,w,F,u,I,Q,$,N,K;E=d[A];w=d[A+
1];F=d[A+2];u=a.uvs[E*2];$=a.uvs[E*2+1];I=a.uvs[w*2];N=a.uvs[w*2+1];Q=a.uvs[F*2];K=a.uvs[F*2+1];THREE.Loader.prototype.uv3(f.uvs,u,$,I,N,Q,K);if(a.uvs2){u=a.uvs2[E*2];$=a.uvs2[E*2+1];I=a.uvs2[w*2];N=a.uvs2[w*2+1];Q=a.uvs2[F*2];K=a.uvs2[F*2+1];THREE.Loader.prototype.uv3(f.uvs2,u,1-$,I,1-N,Q,1-K)}}function y(d,A){var E,w,F,u,I,Q,$,N,K,W,R,X;E=d[A];w=d[A+1];F=d[A+2];u=d[A+3];I=a.uvs[E*2];K=a.uvs[E*2+1];Q=a.uvs[w*2];W=a.uvs[w*2+1];$=a.uvs[F*2];R=a.uvs[F*2+1];N=a.uvs[u*2];X=a.uvs[u*2+1];THREE.Loader.prototype.uv4(f.uvs,
I,K,Q,W,$,R,N,X);if(a.uvs2){I=a.uvs2[E*2];K=a.uvs2[E*2+1];Q=a.uvs2[w*2];W=a.uvs2[w*2+1];$=a.uvs2[F*2];R=a.uvs2[F*2+1];N=a.uvs2[u*2];X=a.uvs2[u*2+1];THREE.Loader.prototype.uv4(f.uvs2,I,1-K,Q,1-W,$,1-R,N,1-X)}}var t,o;t=0;for(o=a.triangles_uv.length;t<o;t+=7){j(a.triangles_uv,t);p(a.triangles_uv,t+4)}t=0;for(o=a.triangles_n_uv.length;t<o;t+=10){l(a.triangles_n_uv,t);p(a.triangles_n_uv,t+7)}t=0;for(o=a.quads_uv.length;t<o;t+=9){k(a.quads_uv,t);y(a.quads_uv,t+5)}t=0;for(o=a.quads_n_uv.length;t<o;t+=13){m(a.quads_n_uv,
t);y(a.quads_n_uv,t+9)}t=0;for(o=a.triangles.length;t<o;t+=4)j(a.triangles,t);t=0;for(o=a.triangles_n.length;t<o;t+=7)l(a.triangles_n,t);t=0;for(o=a.quads.length;t<o;t+=5)k(a.quads,t);t=0;for(o=a.quads_n.length;t<o;t+=9)m(a.quads_n,t)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},vc:function(a,b,c,e){var h=new THREE.Color(16777215);
h.setRGB(b,c,e);a.colors.push(h)},f3:function(a,b,c,e,h){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[h]))},f4:function(a,b,c,e,h,f){a.faces.push(new THREE.Face4(b,c,e,h,null,a.materials[f]))},f3n:function(a,b,c,e,h,f,j,l,k){f=a.materials[f];var m=b[l*3],p=b[l*3+1];l=b[l*3+2];var y=b[k*3],t=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(c,e,h,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(m,p,l),new THREE.Vector3(y,t,k)],f))},f4n:function(a,b,c,e,h,f,j,l,k,m,p){j=a.materials[j];
var y=b[k*3],t=b[k*3+1];k=b[k*3+2];var o=b[m*3],d=b[m*3+1];m=b[m*3+2];var A=b[p*3],E=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face4(c,e,h,f,[new THREE.Vector3(b[l*3],b[l*3+1],b[l*3+2]),new THREE.Vector3(y,t,k),new THREE.Vector3(o,d,m),new THREE.Vector3(A,E,p)],j))},uv3:function(a,b,c,e,h,f,j){var l=[];l.push(new THREE.UV(b,c));l.push(new THREE.UV(e,h));l.push(new THREE.UV(f,j));a.push(l)},uv4:function(a,b,c,e,h,f,j,l,k){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,h));m.push(new THREE.UV(f,
j));m.push(new THREE.UV(l,k));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(l){l=Math.log(l)/Math.LN2;return Math.floor(l)==l}function e(l,k){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),y=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));l.image.width=p;l.image.height=
y;l.image.getContext("2d").drawImage(this,0,0,p,y)}else l.image=this;l.image.loaded=1};m.src=k}var h,f,j;h="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")h="MeshPhongMaterial";if(a.map_diffuse&&b){j=document.createElement("canvas");f.map=new THREE.Texture(j);e(f.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){j=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=j;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=
a.a_dbg_color;if(a.map_lightmap&&b){j=document.createElement("canvas");f.light_map=new THREE.Texture(j);e(f.light_map,b+"/"+a.map_lightmap)}return new THREE[h](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=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,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=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 f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,g,e,f)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,g,f){var h=new XMLHttpRequest,k=e+"/"+a,j=0;
h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,g,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",k,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
createBinModel:function(a,b,c,e){var g=function(f){function h(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2),V=p(B,K+3),ka=(V<<1&255|da>>7)-127;I=(da&127)<<16|Q<<8|I;if(I==0&&ka==-127)return 0;return(1-2*(V>>7))*(1+I*Math.pow(2,-23))*Math.pow(2,ka)}function k(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2);return(p(B,K+3)<<24)+(da<<16)+(Q<<8)+I}function j(B,K){var I=p(B,K);return(p(B,K+1)<<8)+I}function m(B,K){var I=p(B,K);return I>127?I-256:I}function p(B,K){return B.charCodeAt(K)&255}function x(B){var K,I,Q;
K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);B=j(a,B+M);THREE.Loader.prototype.f3(w,K,I,Q,B)}function t(B){var K,I,Q,da,V,ka;K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);da=j(a,B+M);V=k(a,B+U);ka=k(a,B+O);B=k(a,B+Y);THREE.Loader.prototype.f3n(w,d,K,I,Q,da,V,ka,B)}function q(B){var K,I,Q,da;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);B=j(a,B+ha);THREE.Loader.prototype.f4(w,K,I,Q,da,B)}function y(B){var K,I,Q,da,V,ka,pa,ua;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);V=j(a,B+ha);ka=k(a,B+Z);pa=k(a,B+ea);ua=k(a,B+l);B=k(a,B+v);
THREE.Loader.prototype.f4n(w,d,K,I,Q,da,V,ka,pa,ua,B)}function z(B){var K,I;K=k(a,B);I=k(a,B+A);B=k(a,B+u);THREE.Loader.prototype.uv3(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[B*2],P[B*2+1])}function H(B){var K,I,Q;K=k(a,B);I=k(a,B+n);Q=k(a,B+F);B=k(a,B+L);THREE.Loader.prototype.uv4(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[Q*2],P[Q*2+1],P[B*2],P[B*2+1])}var w=this,E=0,o,d=[],P=[],aa,N,M,U,O,Y,W,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R,ba,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
e,f);o={signature:a.substr(E,8),header_bytes:p(a,E+8),vertex_coordinate_bytes:p(a,E+9),normal_coordinate_bytes:p(a,E+10),uv_coordinate_bytes:p(a,E+11),vertex_index_bytes:p(a,E+12),normal_index_bytes:p(a,E+13),uv_index_bytes:p(a,E+14),material_index_bytes:p(a,E+15),nvertices:k(a,E+16),nnormals:k(a,E+16+4),nuvs:k(a,E+16+8),ntri_flat:k(a,E+16+12),ntri_smooth:k(a,E+16+16),ntri_flat_uv:k(a,E+16+20),ntri_smooth_uv:k(a,E+16+24),nquad_flat:k(a,E+16+28),nquad_smooth:k(a,E+16+32),nquad_flat_uv:k(a,E+16+36),
nquad_smooth_uv:k(a,E+16+40)};E+=o.header_bytes;aa=o.vertex_index_bytes;N=o.vertex_index_bytes*2;M=o.vertex_index_bytes*3;U=o.vertex_index_bytes*3+o.material_index_bytes;O=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;W=o.vertex_index_bytes;J=o.vertex_index_bytes*2;X=o.vertex_index_bytes*3;ha=o.vertex_index_bytes*4;Z=o.vertex_index_bytes*4+o.material_index_bytes;ea=o.vertex_index_bytes*4+o.material_index_bytes+
o.normal_index_bytes;l=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;v=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;A=o.uv_index_bytes;u=o.uv_index_bytes*2;n=o.uv_index_bytes;F=o.uv_index_bytes*2;L=o.uv_index_bytes*3;f=o.vertex_index_bytes*3+o.material_index_bytes;ga=o.vertex_index_bytes*4+o.material_index_bytes;G=o.ntri_flat*f;D=o.ntri_smooth*(f+o.normal_index_bytes*3);C=o.ntri_flat_uv*(f+o.uv_index_bytes*3);R=o.ntri_smooth_uv*(f+o.normal_index_bytes*
3+o.uv_index_bytes*3);ba=o.nquad_flat*ga;f=o.nquad_smooth*(ga+o.normal_index_bytes*4);ga=o.nquad_flat_uv*(ga+o.uv_index_bytes*4);E+=function(B){var K,I,Q,da=o.vertex_coordinate_bytes*3,V=B+o.nvertices*da;for(B=B;B<V;B+=da){K=h(a,B);I=h(a,B+o.vertex_coordinate_bytes);Q=h(a,B+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,K,I,Q)}return o.nvertices*da}(E);E+=function(B){var K,I,Q,da=o.normal_coordinate_bytes*3,V=B+o.nnormals*da;for(B=B;B<V;B+=da){K=m(a,B);I=m(a,B+o.normal_coordinate_bytes);
Q=m(a,B+o.normal_coordinate_bytes*2);d.push(K/127,I/127,Q/127)}return o.nnormals*da}(E);E+=function(B){var K,I,Q=o.uv_coordinate_bytes*2,da=B+o.nuvs*Q;for(B=B;B<da;B+=Q){K=h(a,B);I=h(a,B+o.uv_coordinate_bytes);P.push(K,I)}return o.nuvs*Q}(E);E=E;G=E+G;D=G+D;C=D+C;R=C+R;ba=R+ba;f=ba+f;ga=f+ga;(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes,Q=I+o.uv_index_bytes*3,da=B+o.ntri_flat_uv*Q;for(K=B;K<da;K+=Q){x(K);z(K+I)}return da-B})(D);(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes+
o.normal_index_bytes*3,Q=I+o.uv_index_bytes*3,da=B+o.ntri_smooth_uv*Q;for(K=B;K<da;K+=Q){t(K);z(K+I)}return da-B})(C);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes,Q=I+o.uv_index_bytes*4,da=B+o.nquad_flat_uv*Q;for(K=B;K<da;K+=Q){q(K);H(K+I)}return da-B})(f);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,Q=I+o.uv_index_bytes*4,da=B+o.nquad_smooth_uv*Q;for(K=B;K<da;K+=Q){y(K);H(K+I)}return da-B})(ga);(function(B){var K,I=o.vertex_index_bytes*
3+o.material_index_bytes,Q=B+o.ntri_flat*I;for(K=B;K<Q;K+=I)x(K);return Q-B})(E);(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,Q=B+o.ntri_smooth*I;for(K=B;K<Q;K+=I)t(K);return Q-B})(G);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes,Q=B+o.nquad_flat*I;for(K=B;K<Q;K+=I)q(K);return Q-B})(R);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,Q=B+o.nquad_smooth*I;for(K=B;K<Q;K+=I)y(K);return Q-B})(ba);
this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(c))},createModel:function(a,b,c){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,k,j,m,p;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];p=a.vertices[h+2];THREE.Loader.prototype.v(f,j,m,p)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=
a.colors[h+1];p=a.colors[h+2];THREE.Loader.prototype.vc(f,j,m,p)}}})();(function(){function h(y,z){THREE.Loader.prototype.f3(f,y[z],y[z+1],y[z+2],y[z+3])}function k(y,z){THREE.Loader.prototype.f3n(f,a.normals,y[z],y[z+1],y[z+2],y[z+3],y[z+4],y[z+5],y[z+6])}function j(y,z){THREE.Loader.prototype.f4(f,y[z],y[z+1],y[z+2],y[z+3],y[z+4])}function m(y,z){THREE.Loader.prototype.f4n(f,a.normals,y[z],y[z+1],y[z+2],y[z+3],y[z+4],y[z+5],y[z+6],y[z+7],y[z+8])}function p(y,z){var H,w,E,o,d,P,aa,N,M;H=y[z];w=y[z+
1];E=y[z+2];o=a.uvs[H*2];aa=a.uvs[H*2+1];d=a.uvs[w*2];N=a.uvs[w*2+1];P=a.uvs[E*2];M=a.uvs[E*2+1];THREE.Loader.prototype.uv3(f.uvs,o,aa,d,N,P,M);if(a.uvs2){o=a.uvs2[H*2];aa=a.uvs2[H*2+1];d=a.uvs2[w*2];N=a.uvs2[w*2+1];P=a.uvs2[E*2];M=a.uvs2[E*2+1];THREE.Loader.prototype.uv3(f.uvs2,o,1-aa,d,1-N,P,1-M)}}function x(y,z){var H,w,E,o,d,P,aa,N,M,U,O,Y;H=y[z];w=y[z+1];E=y[z+2];o=y[z+3];d=a.uvs[H*2];M=a.uvs[H*2+1];P=a.uvs[w*2];U=a.uvs[w*2+1];aa=a.uvs[E*2];O=a.uvs[E*2+1];N=a.uvs[o*2];Y=a.uvs[o*2+1];THREE.Loader.prototype.uv4(f.uvs,
d,M,P,U,aa,O,N,Y);if(a.uvs2){d=a.uvs2[H*2];M=a.uvs2[H*2+1];P=a.uvs2[w*2];U=a.uvs2[w*2+1];aa=a.uvs2[E*2];O=a.uvs2[E*2+1];N=a.uvs2[o*2];Y=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(f.uvs2,d,1-M,P,1-U,aa,1-O,N,1-Y)}}var t,q;t=0;for(q=a.triangles_uv.length;t<q;t+=7){h(a.triangles_uv,t);p(a.triangles_uv,t+4)}t=0;for(q=a.triangles_n_uv.length;t<q;t+=10){k(a.triangles_n_uv,t);p(a.triangles_n_uv,t+7)}t=0;for(q=a.quads_uv.length;t<q;t+=9){j(a.quads_uv,t);x(a.quads_uv,t+5)}t=0;for(q=a.quads_n_uv.length;t<q;t+=
13){m(a.quads_n_uv,t);x(a.quads_n_uv,t+9)}t=0;for(q=a.triangles.length;t<q;t+=4)h(a.triangles,t);t=0;for(q=a.triangles_n.length;t<q;t+=7)k(a.triangles_n,t);t=0;for(q=a.quads.length;t<q;t+=5)j(a.quads,t);t=0;for(q=a.quads_n.length;t<q;t+=9)m(a.quads_n,t)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},vc:function(a,
b,c,e){var g=new THREE.Color(16777215);g.setRGB(b,c,e);a.colors.push(g)},f3:function(a,b,c,e,g){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[g]))},f4:function(a,b,c,e,g,f){a.faces.push(new THREE.Face4(b,c,e,g,null,a.materials[f]))},f3n:function(a,b,c,e,g,f,h,k,j){f=a.materials[f];var m=b[k*3],p=b[k*3+1];k=b[k*3+2];var x=b[j*3],t=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,p,k),new THREE.Vector3(x,t,j)],f))},f4n:function(a,
b,c,e,g,f,h,k,j,m,p){h=a.materials[h];var x=b[j*3],t=b[j*3+1];j=b[j*3+2];var q=b[m*3],y=b[m*3+1];m=b[m*3+2];var z=b[p*3],H=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face4(c,e,g,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(x,t,j),new THREE.Vector3(q,y,m),new THREE.Vector3(z,H,p)],h))},uv3:function(a,b,c,e,g,f,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,g));k.push(new THREE.UV(f,h));a.push(k)},uv4:function(a,b,c,e,g,f,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,
g));m.push(new THREE.UV(f,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function e(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));k.image.width=
p;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,p,x)}else k.image=this;k.image.loaded=1};m.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&b){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=
h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,b+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+1 -1
View File
@@ -30,7 +30,7 @@
<span id="rwebgl" class="button">WebGL renderer</span>
<br/>
<p>Models by <a href="http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1">Reallusion<a>
<p>Models by <a href="http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1">Reallusion</a>
<a href="http://sketchup.google.com/3dwarehouse/details?mid=f526cc4abf7cb68d76cab47c765b7255">iClone</a>.
<p>Using a modified version of <a href="http://github.com/alteredq/three.js">Three.js</a> by mrdoob.
+37 -18
View File
@@ -4,13 +4,14 @@
THREE.Object3D = function () {
this.id = THREE.Object3DCounter.value ++;
this.id = THREE.Object3DCounter.value ++; // TODO: Probably not needed?
this.position = new THREE.Vector3();
this.rotation = new THREE.Vector3();
this.scale = new THREE.Vector3( 1, 1, 1 );
this.matrix = new THREE.Matrix4();
this.matrixWorld = new THREE.Matrix4();
this.rotationMatrix = new THREE.Matrix4();
this.tmpMatrix = new THREE.Matrix4();
@@ -19,34 +20,52 @@ THREE.Object3D = function () {
this.autoUpdateMatrix = true;
this.visible = true;
this.children = [];
};
THREE.Object3D.prototype = {
addChild: function ( object ) {
var i = this.children.indexOf( object );
if ( i === -1 ) {
this.children.push( object );
}
},
removeChild: function ( object ) {
var i = this.children.indexOf( object );
if ( i !== -1 ) {
this.children.splice( i, 1 );
}
},
updateMatrix: function () {
var p = this.position, r = this.rotation, s = this.scale, m = this.tmpMatrix;
var p = this.position, r = this.rotation, s = this.scale,
matrix = this.matrix, rotationMatrix = this.rotationMatrix,
tmpMatrix = this.tmpMatrix;
this.matrix.setTranslation( p.x, p.y, p.z );
matrix.setTranslation( p.x, p.y, p.z );
this.rotationMatrix.setRotX( r.x );
rotationMatrix.setRotX( r.x );
if ( r.y != 0 ) {
m.setRotY( r.y );
this.rotationMatrix.multiplySelf( m );
}
if ( r.y != 0 ) rotationMatrix.multiplySelf( tmpMatrix.setRotY( r.y ) );
if ( r.z != 0 ) rotationMatrix.multiplySelf( tmpMatrix.setRotZ( r.z ) );
if ( r.z != 0 ) {
m.setRotZ( r.z );
this.rotationMatrix.multiplySelf( m );
}
matrix.multiplySelf( rotationMatrix );
this.matrix.multiplySelf( this.rotationMatrix );
if ( s.x != 0 || s.y != 0 || s.z != 0 ) {
m.setScale( s.x, s.y, s.z );
this.matrix.multiplySelf( m );
}
if ( s.x != 0 || s.y != 0 || s.z != 0 ) matrix.multiplySelf( tmpMatrix.setScale( s.x, s.y, s.z ) );
}
+236 -177
View File
@@ -87,14 +87,14 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.setClearColorHex = function( hex, alpha ) {
this.setClearColorHex = function ( hex, alpha ) {
var color = new THREE.Color( hex );
_gl.clearColor( color.r, color.g, color.b, alpha );
};
this.setClearColor = function( color, alpha ) {
this.setClearColor = function ( color, alpha ) {
_gl.clearColor( color.r, color.g, color.b, alpha );
@@ -186,21 +186,21 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.createParticleBuffers = function( geometry ) {
function createParticleBuffers ( geometry ) {
geometry.__webGLVertexBuffer = _gl.createBuffer();
geometry.__webGLColorBuffer = _gl.createBuffer();
};
this.createLineBuffers = function( geometry ) {
function createLineBuffers ( geometry ) {
geometry.__webGLVertexBuffer = _gl.createBuffer();
geometry.__webGLColorBuffer = _gl.createBuffer();
};
this.createMeshBuffers = function( geometryChunk ) {
function createMeshBuffers ( geometryChunk ) {
geometryChunk.__webGLVertexBuffer = _gl.createBuffer();
geometryChunk.__webGLNormalBuffer = _gl.createBuffer();
@@ -214,7 +214,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.initLineBuffers = function( geometry ) {
function initLineBuffers ( geometry ) {
var nvertices = geometry.vertices.length;
@@ -225,7 +225,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.initParticleBuffers = function( geometry ) {
function initParticleBuffers ( geometry ) {
var nvertices = geometry.vertices.length;
@@ -238,7 +238,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.initMeshBuffers = function( geometryChunk, object ) {
function initMeshBuffers ( geometryChunk, object ) {
var f, fl, nvertices = 0, ntris = 0, nlines = 0,
obj_faces = object.geometry.faces,
@@ -284,7 +284,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.setMeshBuffers = function ( geometryChunk, object, hint ) {
function setMeshBuffers ( geometryChunk, object, hint ) {
var f, fl, fi, face, vertexNormals, faceNormal, normal,
uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4,
@@ -735,7 +735,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.setLineBuffers = function( geometry, hint ) {
function setLineBuffers ( geometry, hint ) {
var v, c, vertex, offset,
vertices = geometry.vertices,
@@ -789,7 +789,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.setParticleBuffers = function( geometry, hint, object, camera ) {
function setParticleBuffers ( geometry, hint, object, camera ) {
var v, c, vertex, offset,
vertices = geometry.vertices,
@@ -809,7 +809,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( object.sortParticles ) {
_projScreenMatrix.multiplySelf( object.matrix );
_projScreenMatrix.multiplySelf( object.matrixWorld );
for ( v = 0; v < vl; v++ ) {
@@ -1446,6 +1446,23 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function updateChildren( object ) {
var i, l, child, children = object.children;
for ( i = 0, l = children.length; i < l; i ++ ) {
child = children[ i ];
child.autoUpdateMatrix && child.updateMatrix();
child.matrixWorld.multiply( object.matrixWorld, child.matrix );
updateChildren( child );
}
};
this.render = function( scene, camera, renderTarget, clear ) {
var i, program, opaque, transparent,
@@ -1453,7 +1470,7 @@ THREE.WebGLRenderer = function ( parameters ) {
lights = scene.lights,
fog = scene.fog,
ol;
camera.autoUpdateMatrix && camera.updateMatrix();
camera.matrix.flattenToArray( _viewMatrixArray );
@@ -1481,26 +1498,38 @@ THREE.WebGLRenderer = function ( parameters ) {
webGLObject = scene.__webGLObjects[ o ];
object = webGLObject.object;
if ( object.visible && ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) ) {
if ( object.visible ) {
if( object.autoUpdateMatrix ) {
if ( webGLObject.root ) {
object.autoUpdateMatrix && object.updateMatrix();
object.matrixWorld.copy( object.matrix );
updateChildren( object );
}
if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) {
object.matrixWorld.flattenToArray( object._objectMatrixArray );
setupMatrices( object, camera );
unrollBufferMaterials( webGLObject );
webGLObject.render = true;
object.updateMatrix();
object.matrix.flattenToArray( object._objectMatrixArray );
} else {
webGLObject.render = false;
}
this.setupMatrices( object, camera );
unrollBufferMaterials( webGLObject );
webGLObject.render = true;
} else {
webGLObject.render = false;
}
}
@@ -1517,11 +1546,12 @@ THREE.WebGLRenderer = function ( parameters ) {
if( object.autoUpdateMatrix ) {
object.updateMatrix();
object.matrix.flattenToArray( object._objectMatrixArray );
object.matrixWorld.copy( object.matrix );
object.matrixWorld.flattenToArray( object._objectMatrixArray );
}
this.setupMatrices( object, camera );
setupMatrices( object, camera );
unrollImmediateBufferMaterials( webGLObject );
@@ -1640,7 +1670,7 @@ 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 ) {
@@ -1651,37 +1681,180 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function addChildren( scene, object ) {
var i, l, children = object.children;
for ( i = 0, l = children.length; i < l; i ++ ) {
child = children[ i ];
addObject( scene, child, false );
addChildren( scene, child );
}
};
function addObject( scene, object, root ) {
var g, geometry, geometryChunk, objmap;
geometry = object.geometry;
if ( scene.__webGLObjectsMap[ object.id ] == undefined ) {
scene.__webGLObjectsMap[ object.id ] = {};
object._modelViewMatrix = new THREE.Matrix4();
object._normalMatrixArray = new Float32Array( 9 );
object._modelViewMatrixArray = new Float32Array( 16 );
object._objectMatrixArray = new Float32Array( 16 );
object.matrix.flattenToArray( object._objectMatrixArray );
}
objmap = scene.__webGLObjectsMap[ object.id ];
objlist = scene.__webGLObjects;
if ( object instanceof THREE.Mesh ) {
// create separate VBOs per geometry chunk
for ( g in geometry.geometryChunks ) {
geometryChunk = geometry.geometryChunks[ g ];
// initialise VBO on the first access
if( ! geometryChunk.__webGLVertexBuffer ) {
createMeshBuffers( geometryChunk );
initMeshBuffers( geometryChunk, object );
geometry.__dirtyVertices = true;
geometry.__dirtyElements = true;
geometry.__dirtyUvs = true;
geometry.__dirtyNormals = true;
geometry.__dirtyTangents = true;
geometry.__dirtyColors = true;
}
if( geometry.__dirtyVertices || geometry.__dirtyElements ||
geometry.__dirtyUvs || geometry.__dirtyNormals ||
geometry.__dirtyColors || geometry.__dirtyTangents ) {
setMeshBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW );
}
// create separate wrapper per each use of VBO
add_buffer( objlist, objmap, g, geometryChunk, object, root );
}
geometry.__dirtyVertices = false;
geometry.__dirtyElements = false;
geometry.__dirtyUvs = false;
geometry.__dirtyNormals = false;
geometry.__dirtyTangents = false;
geometry.__dirtyColors = false;
} else if ( object instanceof THREE.Line ) {
if( ! geometry.__webGLVertexBuffer ) {
createLineBuffers( geometry );
initLineBuffers( geometry );
geometry.__dirtyVertices = true;
geometry.__dirtyColors = true;
}
if( geometry.__dirtyVertices || geometry.__dirtyColors ) {
setLineBuffers( geometry, _gl.DYNAMIC_DRAW );
}
add_buffer( objlist, objmap, 0, geometry, object, root );
geometry.__dirtyVertices = false;
geometry.__dirtyColors = false;
} else if ( object instanceof THREE.ParticleSystem ) {
if( ! geometry.__webGLVertexBuffer ) {
createParticleBuffers( geometry );
initParticleBuffers( geometry );
geometry.__dirtyVertices = true;
geometry.__dirtyColors = true;
}
if( geometry.__dirtyVertices || geometry.__dirtyColors || object.sortParticles ) {
setParticleBuffers( geometry, _gl.DYNAMIC_DRAW, object, camera );
}
add_buffer( objlist, objmap, 0, geometry, object, root );
geometry.__dirtyVertices = false;
geometry.__dirtyColors = false;
} else if ( object instanceof THREE.MarchingCubes ) {
add_buffer_immediate( scene.__webGLObjectsImmediate, objmap, 0, object, root );
}/*else if ( object instanceof THREE.Particle ) {
}*/
};
function add_buffer( objlist, objmap, id, buffer, object, root ) {
if ( objmap[ id ] == undefined ) {
objlist.push( { buffer: buffer, object: object,
opaque: { list: [], count: 0 },
transparent: { list: [], count: 0 },
root: root
} );
objmap[ id ] = 1;
}
};
function add_buffer_immediate( objlist, objmap, id, object, root ) {
if ( objmap[ id ] == undefined ) {
objlist.push( { object: object,
opaque: { list: [], count: 0 },
transparent: { list: [], count: 0 },
root: root
} );
objmap[ id ] = 1;
}
};
this.initWebGLObjects = function( scene, camera ) {
function add_buffer( objmap, id, buffer, object ) {
if ( objmap[ id ] == undefined ) {
scene.__webGLObjects.push( { buffer: buffer, object: object,
opaque: { list: [], count: 0 },
transparent: { list: [], count: 0 }
} );
objmap[ id ] = 1;
}
};
function add_buffer_immediate( objmap, id, object ) {
if ( objmap[ id ] == undefined ) {
scene.__webGLObjectsImmediate.push( { object: object,
opaque: { list: [], count: 0 },
transparent: { list: [], count: 0 }
} );
objmap[ id ] = 1;
}
};
var o, ol, object, g, geometry, geometryChunk, objmap;
var o, ol, object;
if ( !scene.__webGLObjects ) {
@@ -1691,128 +1864,14 @@ THREE.WebGLRenderer = function ( parameters ) {
scene.__webGLObjectsImmediate = [];
}
for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
object = scene.objects[ o ];
geometry = object.geometry;
if ( scene.__webGLObjectsMap[ object.id ] == undefined ) {
scene.__webGLObjectsMap[ object.id ] = {};
object._modelViewMatrix = new THREE.Matrix4();
object._normalMatrixArray = new Float32Array( 9 );
object._modelViewMatrixArray = new Float32Array( 16 );
object._objectMatrixArray = new Float32Array( 16 );
object.matrix.flattenToArray( object._objectMatrixArray );
}
objmap = scene.__webGLObjectsMap[ object.id ];
if ( object instanceof THREE.Mesh ) {
// create separate VBOs per geometry chunk
for ( g in geometry.geometryChunks ) {
geometryChunk = geometry.geometryChunks[ g ];
// initialise VBO on the first access
if( ! geometryChunk.__webGLVertexBuffer ) {
this.createMeshBuffers( geometryChunk );
this.initMeshBuffers( geometryChunk, object );
geometry.__dirtyVertices = true;
geometry.__dirtyElements = true;
geometry.__dirtyUvs = true;
geometry.__dirtyNormals = true;
geometry.__dirtyTangents = true;
geometry.__dirtyColors = true;
}
if( geometry.__dirtyVertices || geometry.__dirtyElements ||
geometry.__dirtyUvs || geometry.__dirtyNormals ||
geometry.__dirtyColors || geometry.__dirtyTangents ) {
this.setMeshBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW );
}
// create separate wrapper per each use of VBO
add_buffer( objmap, g, geometryChunk, object );
}
geometry.__dirtyVertices = false;
geometry.__dirtyElements = false;
geometry.__dirtyUvs = false;
geometry.__dirtyNormals = false;
geometry.__dirtyTangents = false;
geometry.__dirtyColors = false;
} else if ( object instanceof THREE.Line ) {
if( ! geometry.__webGLVertexBuffer ) {
this.createLineBuffers( geometry );
this.initLineBuffers( geometry );
geometry.__dirtyVertices = true;
geometry.__dirtyColors = true;
}
if( geometry.__dirtyVertices || geometry.__dirtyColors ) {
this.setLineBuffers( geometry, _gl.DYNAMIC_DRAW );
}
add_buffer( objmap, 0, geometry, object );
geometry.__dirtyVertices = false;
geometry.__dirtyColors = false;
} else if ( object instanceof THREE.ParticleSystem ) {
if( ! geometry.__webGLVertexBuffer ) {
this.createParticleBuffers( geometry );
this.initParticleBuffers( geometry );
geometry.__dirtyVertices = true;
geometry.__dirtyColors = true;
}
if( geometry.__dirtyVertices || geometry.__dirtyColors || object.sortParticles ) {
this.setParticleBuffers( geometry, _gl.DYNAMIC_DRAW, object, camera );
}
add_buffer( objmap, 0, geometry, object );
geometry.__dirtyVertices = false;
geometry.__dirtyColors = false;
} else if ( object instanceof THREE.MarchingCubes ) {
add_buffer_immediate( objmap, 0, object );
}/*else if ( object instanceof THREE.Particle ) {
}*/
addObject( scene, object, true );
addChildren( scene, object );
}
};
@@ -1835,9 +1894,9 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.setupMatrices = function ( object, camera ) {
function setupMatrices ( object, camera ) {
object._modelViewMatrix.multiplyToArray( camera.matrix, object.matrix, object._modelViewMatrixArray );
object._modelViewMatrix.multiplyToArray( camera.matrix, object.matrixWorld, object._modelViewMatrixArray );
object._normalMatrix = THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray );
};