| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- // ThreeExtras.js r31 - http://github.com/mrdoob/three.js
- var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
- THREE.Color.prototype={setRGB:function(a,b,e){this.r=a;this.g=b;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
- ","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
- THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
- this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,e){this.x=a||0;this.y=b||0;this.z=e||0};
- THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
- cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,e=this.y,d=this.z;this.x=e*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-e*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=
- a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
- Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
- THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1};
- THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
- return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
- THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
- THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,g=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(f,k){return f.distance-k.distance});return g},intersectObject:function(a){function b(K,v,F,m){m=m.clone().subSelf(v);F=F.clone().subSelf(v);var N=K.clone().subSelf(v);K=m.dot(m);v=m.dot(F);m=m.dot(N);var i=F.dot(F);F=F.dot(N);N=1/(K*i-v*v);i=(i*m-v*F)*N;K=(K*F-v*m)*N;return i>0&&K>0&&i+K<1}var e,d,g,f,k,h,j,c,w,B,
- s,u=a.geometry,x=u.vertices,z=[];e=0;for(d=u.faces.length;e<d;e++){g=u.faces[e];B=this.origin.clone();s=this.direction.clone();f=a.matrix.multiplyVector3(x[g.a].position.clone());k=a.matrix.multiplyVector3(x[g.b].position.clone());h=a.matrix.multiplyVector3(x[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(x[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());w=s.dot(c);if(w<0){c=c.dot((new THREE.Vector3).sub(f,B))/w;B=B.addSelf(s.multiplyScalar(c));
- if(g instanceof THREE.Face3){if(b(B,f,k,h)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};z.push(g)}}else if(g instanceof THREE.Face4)if(b(B,f,k,j)||b(B,k,h,j)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};z.push(g)}}}return z}};
- THREE.Rectangle=function(){function a(){f=d-b;k=g-e}var b,e,d,g,f,k,h=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return f};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(j,c,w,B){h=false;b=j;e=c;d=w;g=B;a()};this.addPoint=function(j,c){if(h){h=false;b=j;e=c;d=j;g=c}else{b=b<j?b:j;e=e<c?e:c;d=d>j?d:j;g=g>c?
- g:c}a()};this.add3Points=function(j,c,w,B,s,u){if(h){h=false;b=j<w?j<s?j:s:w<s?w:s;e=c<B?c<u?c:u:B<u?B:u;d=j>w?j>s?j:s:w>s?w:s;g=c>B?c>u?c:u:B>u?B:u}else{b=j<w?j<s?j<b?j:b:s<b?s:b:w<s?w<b?w:b:s<b?s:b;e=c<B?c<u?c<e?c:e:u<e?u:e:B<u?B<e?B:e:u<e?u:e;d=j>w?j>s?j>d?j:d:s>d?s:d:w>s?w>d?w:d:s>d?s:d;g=c>B?c>u?c>g?c:g:u>g?u:g:B>u?B>g?B:g:u>g?u:g}a()};this.addRectangle=function(j){if(h){h=false;b=j.getLeft();e=j.getTop();d=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();e=e<j.getTop()?e:j.getTop();
- d=d>j.getRight()?d:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;d+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e:j.getTop();d=d<j.getRight()?d:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){h=true;g=d=e=b=0;a()};this.isEmpty=function(){return h};this.toString=
- function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+g+", width: "+f+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
- THREE.Matrix4=function(a,b,e,d,g,f,k,h,j,c,w,B,s,u,x,z){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=f||1;this.n23=k||0;this.n24=h||0;this.n31=j||0;this.n32=c||0;this.n33=w||1;this.n34=B||0;this.n41=s||0;this.n42=u||0;this.n43=x||0;this.n44=z||1};
- THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,g,f,k,h,j,c,w,B,s,u,x,z){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=f;this.n23=k;this.n24=h;this.n31=j;this.n32=c;this.n33=w;this.n34=B;this.n41=s;this.n42=u;this.n43=x;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,e){var d=new THREE.Vector3,g=new THREE.Vector3,f=new THREE.Vector3;f.sub(a,b).normalize();d.cross(e,f).normalize();g.cross(f,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=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,e=a.y,d=a.z,g=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24*
- g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var e=a.n11,d=a.n12,g=a.n13,f=a.n14,k=a.n21,h=a.n22,j=a.n23,c=a.n24,w=a.n31,B=a.n32,
- s=a.n33,u=a.n34,x=a.n41,z=a.n42,K=a.n43,v=a.n44,F=b.n11,m=b.n12,N=b.n13,i=b.n14,q=b.n21,p=b.n22,l=b.n23,r=b.n24,o=b.n31,A=b.n32,y=b.n33,D=b.n34,C=b.n41,R=b.n42,O=b.n43,M=b.n44;this.n11=e*F+d*q+g*o+f*C;this.n12=e*m+d*p+g*A+f*R;this.n13=e*N+d*l+g*y+f*O;this.n14=e*i+d*r+g*D+f*M;this.n21=k*F+h*q+j*o+c*C;this.n22=k*m+h*p+j*A+c*R;this.n23=k*N+h*l+j*y+c*O;this.n24=k*i+h*r+j*D+c*M;this.n31=w*F+B*q+s*o+u*C;this.n32=w*m+B*p+s*A+u*R;this.n33=w*N+B*l+s*y+u*O;this.n34=w*i+B*r+s*D+u*M;this.n41=x*F+z*q+K*o+v*C;
- this.n42=x*m+z*p+K*A+v*R;this.n43=x*N+z*l+K*y+v*O;this.n44=x*i+z*r+K*D+v*M;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,f=this.n21,k=this.n22,h=this.n23,j=this.n24,c=this.n31,w=this.n32,B=this.n33,s=this.n34,u=this.n41,x=this.n42,z=this.n43,K=this.n44,v=a.n11,F=a.n21,m=a.n31,N=a.n41,i=a.n12,q=a.n22,p=a.n32,l=a.n42,r=a.n13,o=a.n23,A=a.n33,y=a.n43,D=a.n14,C=a.n24,R=a.n34;a=a.n44;this.n11=b*v+e*F+d*m+g*N;this.n12=b*i+e*q+d*p+g*l;this.n13=b*r+e*o+d*A+g*y;this.n14=
- b*D+e*C+d*R+g*a;this.n21=f*v+k*F+h*m+j*N;this.n22=f*i+k*q+h*p+j*l;this.n23=f*r+k*o+h*A+j*y;this.n24=f*D+k*C+h*R+j*a;this.n31=c*v+w*F+B*m+s*N;this.n32=c*i+w*q+B*p+s*l;this.n33=c*r+w*o+B*A+s*y;this.n34=c*D+w*C+B*R+s*a;this.n41=u*v+x*F+z*m+K*N;this.n42=u*i+x*q+z*p+K*l;this.n43=u*r+x*o+z*A+K*y;this.n44=u*D+x*C+z*R+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
- a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
- this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,d){var g=b[e];b[e]=b[d];
- b[d]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
- this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=e;return d};
- THREE.Matrix4.scaleMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=e;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
- THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,d=Math.cos(b),g=Math.sin(b),f=1-d,k=a.x,h=a.y,j=a.z;e.n11=f*k*k+d;e.n12=f*k*h-g*j;e.n13=f*k*j+g*h;e.n21=f*k*h+g*j;e.n22=f*h*h+d;e.n23=f*h*j-g*k;e.n31=f*k*j-g*h;e.n32=f*h*j+g*k;e.n33=f*j*j+d;return e};
- THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
- a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
- a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
- a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
- THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],w=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*f+b[2]*j;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*d;a.m[2]=b*g;a.m[3]=b*f;a.m[4]=b*k;a.m[5]=b*h;a.m[6]=b*j;a.m[7]=b*c;a.m[8]=b*w;return a};
- THREE.Matrix4.makeFrustum=function(a,b,e,d,g,f){var k,h,j;k=new THREE.Matrix4;h=2*g/(b-a);j=2*g/(d-e);a=(b+a)/(b-a);e=(d+e)/(d-e);d=-(f+g)/(f-g);g=-2*f*g/(f-g);k.n11=h;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=j;k.n23=e;k.n24=0;k.n31=0;k.n32=0;k.n33=d;k.n34=g;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,e,d){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,d)};
- THREE.Matrix4.makeOrtho=function(a,b,e,d,g,f){var k,h,j,c;k=new THREE.Matrix4;h=b-a;j=e-d;c=f-g;a=(b+a)/h;e=(e+d)/j;g=(f+g)/c;k.n11=2/h;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/j;k.n23=0;k.n24=-e;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-g;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};
- THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
- THREE.Face3=function(a,b,e,d,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
- THREE.Face4=function(a,b,e,d,g,f){this.a=a;this.b=b;this.c=e;this.d=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
- THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a<b;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 b,e,d,g,f,k,h=new THREE.Vector3,j=new THREE.Vector3;d=0;for(g=this.vertices.length;d<g;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(g=this.faces.length;d<g;d++){f=this.faces[d];if(a&&f.vertexNormals.length){h.set(0,0,0);b=0;for(e=f.normal.length;b<e;b++)h.addSelf(f.vertexNormals[b]);h.divideScalar(3)}else{b=this.vertices[f.a];e=this.vertices[f.b];k=this.vertices[f.c];h.sub(k.position,
- e.position);j.sub(b.position,e.position);h.crossSelf(j)}h.isZero()||h.normalize();f.normal.copy(h)}},computeVertexNormals:function(){var a,b=[],e,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
- 0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(D,C,R,O){f=D.vertices[C].position;k=D.vertices[R].position;
- h=D.vertices[O].position;j=g[0];c=g[1];w=g[2];B=k.x-f.x;s=h.x-f.x;u=k.y-f.y;x=h.y-f.y;z=k.z-f.z;K=h.z-f.z;v=c.u-j.u;F=w.u-j.u;m=c.v-j.v;N=w.v-j.v;i=1/(v*N-F*m);r.set((N*B-m*s)*i,(N*u-m*x)*i,(N*z-m*K)*i);o.set((v*s-F*B)*i,(v*x-F*u)*i,(v*K-F*z)*i);p[C].addSelf(r);p[R].addSelf(r);p[O].addSelf(r);l[C].addSelf(o);l[R].addSelf(o);l[O].addSelf(o)}var b,e,d,g,f,k,h,j,c,w,B,s,u,x,z,K,v,F,m,N,i,q,p=[],l=[],r=new THREE.Vector3,o=new THREE.Vector3,A=new THREE.Vector3,y=new THREE.Vector3;q=new THREE.Vector3;b=
- 0;for(e=this.vertices.length;b<e;b++){p[b]=new THREE.Vector3;l[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];g=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
- this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(e=this.vertices.length;b<e;b++){q.copy(this.vertices[b].normal);d=p[b];A.copy(d);A.subSelf(q.multiplyScalar(q.dot(d))).normalize();y.cross(this.vertices[b].normal,d);test=y.dot(l[b]);d=test<0?-1:1;this.vertices[b].tangent.set(A.x,A.y,A.z,d)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
- y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,e=this.vertices.length;b<e;b++){a=this.vertices[b];if(a.position.x<this.bbox.x[0])this.bbox.x[0]=a.position.x;else if(a.position.x>this.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.y<this.bbox.y[0])this.bbox.y[0]=a.position.y;else if(a.position.y>this.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z<this.bbox.z[0])this.bbox.z[0]=a.position.z;else if(a.position.z>
- this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b<e;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(w){var B=[];b=0;for(e=w.length;b<e;b++)w[b]==undefined?B.push("undefined"):B.push(w[b].toString());return B.join("_")}var b,e,d,g,f,k,h,j,c={};d=0;for(g=this.faces.length;d<g;d++){f=this.faces[d];k=
- f.material;h=a(k);if(c[h]==undefined)c[h]={hash:h,counter:0};j=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:k,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){c[h].counter+=1;j=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:k,vertices:0}}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
- this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
- THREE.Camera=function(a,b,e,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,e,d);this.autoUpdateMatrix=true;this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
- this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
- THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
- THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
- this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
- THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};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.material=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.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
- this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
- THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
- a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
- a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
- this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
- THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
- a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
- a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
- this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
- THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
- "round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
- a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
- a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
- this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
- THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
- this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
- THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
- undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
- "<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
- THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
- this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
- THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
- THREE.Texture=function(a,b,e,d,g,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter;this.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.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){this.color=new THREE.Color(a);this.density=b||2.5E-4};
- THREE.Projector=function(){function a(p,l){return l.z-p.z}function b(p,l){var r=0,o=1,A=p.z+p.w,y=l.z+l.w,D=-p.z+p.w,C=-l.z+l.w;if(A>=0&&y>=0&&D>=0&&C>=0)return true;else if(A<0&&y<0||D<0&&C<0)return false;else{if(A<0)r=Math.max(r,A/(A-y));else if(y<0)o=Math.min(o,A/(A-y));if(D<0)r=Math.max(r,D/(D-C));else if(C<0)o=Math.min(o,D/(D-C));if(o<r)return false;else{p.lerpSelf(l,r);l.lerpSelf(p,1-o);return true}}}var e,d,g=[],f,k,h,j=[],c,w,B=[],s,u,x=[],z=new THREE.Vector4,K=new THREE.Vector4,v=new THREE.Matrix4,
- F=new THREE.Matrix4,m=[],N=new THREE.Vector4,i=new THREE.Vector4,q;this.projectObjects=function(p,l,r){var o=[],A,y;d=0;v.multiply(l.projectionMatrix,l.matrix);m[0]=new THREE.Vector4(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);m[1]=new THREE.Vector4(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+v.n14);m[2]=new THREE.Vector4(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);m[3]=new THREE.Vector4(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);m[4]=new THREE.Vector4(v.n41-v.n31,v.n42-v.n32,v.n43-
- v.n33,v.n44-v.n34);m[5]=new THREE.Vector4(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);l=0;for(A=m.length;l<A;l++){y=m[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}A=p.objects;p=0;for(l=A.length;p<l;p++){y=A[p];var D;if(!(D=!y.visible)){if(D=y instanceof THREE.Mesh){a:{D=void 0;for(var C=y.position,R=-y.geometry.boundingSphere.radius*Math.max(y.scale.x,Math.max(y.scale.y,y.scale.z)),O=0;O<6;O++){D=m[O].x*C.x+m[O].y*C.y+m[O].z*C.z+m[O].w;if(D<=R){D=false;break a}}D=true}D=!D}D=D}if(!D){e=
- g[d]=g[d]||new THREE.RenderableObject;z.copy(y.position);v.multiplyVector3(z);e.object=y;e.z=z.z;o.push(e);d++}}r&&o.sort(a);return o};this.projectScene=function(p,l,r){var o=[],A,y,D,C,R,O,M,J,X,U,W,H,E,Q,n,t;h=w=u=0;l.autoUpdateMatrix&&l.updateMatrix();v.multiply(l.projectionMatrix,l.matrix);O=this.projectObjects(p,l,true);p=0;for(A=O.length;p<A;p++){M=O[p].object;if(M.visible){M.autoUpdateMatrix&&M.updateMatrix();J=M.matrix;X=M.rotationMatrix;U=M.material;W=M.overdraw;if(M instanceof THREE.Mesh){H=
- M.geometry;E=H.vertices;y=0;for(D=E.length;y<D;y++){Q=E[y];Q.positionWorld.copy(Q.position);J.multiplyVector3(Q.positionWorld);C=Q.positionScreen;C.copy(Q.positionWorld);v.multiplyVector4(C);C.multiplyScalar(1/C.w);Q.__visible=C.z>0&&C.z<1}H=H.faces;y=0;for(D=H.length;y<D;y++){Q=H[y];if(Q instanceof THREE.Face3){C=E[Q.a];R=E[Q.b];n=E[Q.c];if(C.__visible&&R.__visible&&n.__visible)if(M.doubleSided||M.flipSided!=(n.positionScreen.x-C.positionScreen.x)*(R.positionScreen.y-C.positionScreen.y)-(n.positionScreen.y-
- C.positionScreen.y)*(R.positionScreen.x-C.positionScreen.x)<0){f=j[h]=j[h]||new THREE.RenderableFace3;f.v1.positionWorld.copy(C.positionWorld);f.v2.positionWorld.copy(R.positionWorld);f.v3.positionWorld.copy(n.positionWorld);f.v1.positionScreen.copy(C.positionScreen);f.v2.positionScreen.copy(R.positionScreen);f.v3.positionScreen.copy(n.positionScreen);f.normalWorld.copy(Q.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(Q.centroid);J.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
- v.multiplyVector3(f.centroidScreen);n=Q.vertexNormals;q=f.vertexNormalsWorld;C=0;for(R=n.length;C<R;C++){t=q[C]=q[C]||new THREE.Vector3;t.copy(n[C]);X.multiplyVector3(t)}f.z=f.centroidScreen.z;f.meshMaterial=U;f.faceMaterial=Q.material;f.overdraw=W;if(M.geometry.uvs[y]){f.uvs[0]=M.geometry.uvs[y][0];f.uvs[1]=M.geometry.uvs[y][1];f.uvs[2]=M.geometry.uvs[y][2]}o.push(f);h++}}else if(Q instanceof THREE.Face4){C=E[Q.a];R=E[Q.b];n=E[Q.c];t=E[Q.d];if(C.__visible&&R.__visible&&n.__visible&&t.__visible)if(M.doubleSided||
- M.flipSided!=((t.positionScreen.x-C.positionScreen.x)*(R.positionScreen.y-C.positionScreen.y)-(t.positionScreen.y-C.positionScreen.y)*(R.positionScreen.x-C.positionScreen.x)<0||(R.positionScreen.x-n.positionScreen.x)*(t.positionScreen.y-n.positionScreen.y)-(R.positionScreen.y-n.positionScreen.y)*(t.positionScreen.x-n.positionScreen.x)<0)){f=j[h]=j[h]||new THREE.RenderableFace3;f.v1.positionWorld.copy(C.positionWorld);f.v2.positionWorld.copy(R.positionWorld);f.v3.positionWorld.copy(t.positionWorld);
- f.v1.positionScreen.copy(C.positionScreen);f.v2.positionScreen.copy(R.positionScreen);f.v3.positionScreen.copy(t.positionScreen);f.normalWorld.copy(Q.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(Q.centroid);J.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);v.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=U;f.faceMaterial=Q.material;f.overdraw=W;if(M.geometry.uvs[y]){f.uvs[0]=M.geometry.uvs[y][0];f.uvs[1]=M.geometry.uvs[y][1];f.uvs[2]=
- M.geometry.uvs[y][3]}o.push(f);h++;k=j[h]=j[h]||new THREE.RenderableFace3;k.v1.positionWorld.copy(R.positionWorld);k.v2.positionWorld.copy(n.positionWorld);k.v3.positionWorld.copy(t.positionWorld);k.v1.positionScreen.copy(R.positionScreen);k.v2.positionScreen.copy(n.positionScreen);k.v3.positionScreen.copy(t.positionScreen);k.normalWorld.copy(f.normalWorld);k.centroidWorld.copy(f.centroidWorld);k.centroidScreen.copy(f.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterial=U;k.faceMaterial=Q.material;
- k.overdraw=W;if(M.geometry.uvs[y]){k.uvs[0]=M.geometry.uvs[y][1];k.uvs[1]=M.geometry.uvs[y][2];k.uvs[2]=M.geometry.uvs[y][3]}o.push(k);h++}}}}else if(M instanceof THREE.Line){F.multiply(v,J);E=M.geometry.vertices;Q=E[0];Q.positionScreen.copy(Q.position);F.multiplyVector4(Q.positionScreen);y=1;for(D=E.length;y<D;y++){C=E[y];C.positionScreen.copy(C.position);F.multiplyVector4(C.positionScreen);R=E[y-1];N.copy(C.positionScreen);i.copy(R.positionScreen);if(b(N,i)){N.multiplyScalar(1/N.w);i.multiplyScalar(1/
- i.w);c=B[w]=B[w]||new THREE.RenderableLine;c.v1.positionScreen.copy(N);c.v2.positionScreen.copy(i);c.z=Math.max(N.z,i.z);c.material=M.material;o.push(c);w++}}}else if(M instanceof THREE.Particle){K.set(M.position.x,M.position.y,M.position.z,1);v.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){s=x[u]=x[u]||new THREE.RenderableParticle;s.x=K.x/K.w;s.y=K.y/K.w;s.z=K.z;s.rotation=M.rotation.z;s.scale.x=M.scale.x*Math.abs(s.x-(K.x+l.projectionMatrix.n11)/(K.w+l.projectionMatrix.n14));s.scale.y=M.scale.y*
- Math.abs(s.y-(K.y+l.projectionMatrix.n22)/(K.w+l.projectionMatrix.n24));s.material=M.material;o.push(s);u++}}}}r&&o.sort(a);return o};this.unprojectVector=function(p,l){var r=new THREE.Matrix4;r.multiply(THREE.Matrix4.makeInvert(l.matrix),THREE.Matrix4.makeInvert(l.projectionMatrix));r.multiplyVector3(p);return p}};
- THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,f;this.domElement=document.createElement("div");this.setSize=function(k,h){e=k;d=h;g=e/2;f=d/2};this.render=function(k,h){var j,c,w,B,s,u,x,z;a=b.projectScene(k,h);j=0;for(c=a.length;j<c;j++){s=a[j];if(s instanceof THREE.RenderableParticle){x=s.x*g+g;z=s.y*f+f;w=0;for(B=s.material.length;w<B;w++){u=s.material[w];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=x+"px";u.style.top=z+"px"}}}}}};
- THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,g,f,k,h=e.getContext("2d"),j=1,c=0,w=null,B=null,s=1,u,x,z,K,v,F,m,N,i,q=new THREE.Color,p=new THREE.Color,l=new THREE.Color,r=new THREE.Color,o=new THREE.Color,A,y,D,C,R,O,M,J,X,U,W=new THREE.Rectangle,H=new THREE.Rectangle,E=new THREE.Rectangle,Q=false,n=new THREE.Color,t=new THREE.Color,G=new THREE.Color,P=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
- ea.width=ea.height=2;ma=ea.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);oa=ma.getImageData(0,0,2,2);fa=oa.data;ra=document.createElement("canvas");ra.width=ra.height=pa;va=ra.getContext("2d");va.translate(-pa/2,-pa/2);va.scale(pa,pa);pa--;this.domElement=e;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ia,wa){d=ia;g=wa;f=d/2;k=g/2;e.width=d;e.height=g;W.set(-f,-k,f,k)};this.clear=function(){if(!H.isEmpty()){H.inflate(1);H.minSelf(W);h.clearRect(H.getX(),
- H.getY(),H.getWidth(),H.getHeight());H.empty()}};this.render=function(ia,wa){function Ka(I){var V,T,L,S=I.lights;t.setRGB(0,0,0);G.setRGB(0,0,0);P.setRGB(0,0,0);I=0;for(V=S.length;I<V;I++){T=S[I];L=T.color;if(T instanceof THREE.AmbientLight){t.r+=L.r;t.g+=L.g;t.b+=L.b}else if(T instanceof THREE.DirectionalLight){G.r+=L.r;G.g+=L.g;G.b+=L.b}else if(T instanceof THREE.PointLight){P.r+=L.r;P.g+=L.g;P.b+=L.b}}}function xa(I,V,T,L){var S,$,ba,ca,da=I.lights;I=0;for(S=da.length;I<S;I++){$=da[I];ba=$.color;
- ca=$.intensity;if($ instanceof THREE.DirectionalLight){$=T.dot($.position)*ca;if($>0){L.r+=ba.r*$;L.g+=ba.g*$;L.b+=ba.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,V);Z.normalize();$=T.dot(Z)*ca;if($>0){L.r+=ba.r*$;L.g+=ba.g*$;L.b+=ba.b*$}}}}function La(I,V,T){if(T.opacity!=0){Ca(T.opacity);ya(T.blending);var L,S,$,ba,ca,da;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){ba=T.map;ca=ba.width>>1;da=ba.height>>1;S=V.scale.x*f;$=V.scale.y*k;T=S*ca;L=$*da;E.set(I.x-T,I.y-L,I.x+T,
- I.y+L);if(W.instersects(E)){h.save();h.translate(I.x,I.y);h.rotate(-V.rotation);h.scale(S,-$);h.translate(-ca,-da);h.drawImage(ba,0,0);h.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(Q){n.r=t.r+G.r+P.r;n.g=t.g+G.g+P.g;n.b=t.b+G.b+P.b;q.r=T.color.r*n.r;q.g=T.color.g*n.g;q.b=T.color.b*n.b;q.updateStyleString()}else q.__styleString=T.color.__styleString;T=V.scale.x*f;L=V.scale.y*k;E.set(I.x-T,I.y-L,I.x+T,I.y+L);if(W.instersects(E)){S=q.__styleString;if(B!=S)h.fillStyle=B=S;h.save();
- h.translate(I.x,I.y);h.rotate(-V.rotation);h.scale(T,L);h.beginPath();h.arc(0,0,1,0,Y,true);h.closePath();h.fill();h.restore()}}}}function Ma(I,V,T,L){if(L.opacity!=0){Ca(L.opacity);ya(L.blending);h.beginPath();h.moveTo(I.positionScreen.x,I.positionScreen.y);h.lineTo(V.positionScreen.x,V.positionScreen.y);h.closePath();if(L instanceof THREE.LineBasicMaterial){q.__styleString=L.color.__styleString;I=L.linewidth;if(s!=I)h.lineWidth=s=I;I=q.__styleString;if(w!=I)h.strokeStyle=w=I;h.stroke();E.inflate(L.linewidth*
- 2)}}}function Ga(I,V,T,L,S,$){if(S.opacity!=0){Ca(S.opacity);ya(S.blending);K=I.positionScreen.x;v=I.positionScreen.y;F=V.positionScreen.x;m=V.positionScreen.y;N=T.positionScreen.x;i=T.positionScreen.y;h.beginPath();h.moveTo(K,v);h.lineTo(F,m);h.lineTo(N,i);h.lineTo(K,v);h.closePath();if(S instanceof THREE.MeshBasicMaterial)if(S.map)S.map.image.loaded&&S.map.mapping instanceof THREE.UVMapping&&sa(K,v,F,m,N,i,S.map.image,L.uvs[0].u,L.uvs[0].v,L.uvs[1].u,L.uvs[1].v,L.uvs[2].u,L.uvs[2].v);else if(S.env_map){if(S.env_map.image.loaded)if(S.env_map.mapping instanceof
- THREE.SphericalReflectionMapping){I=wa.matrix;Z.copy(L.vertexNormalsWorld[0]);R=(Z.x*I.n11+Z.y*I.n12+Z.z*I.n13)*0.5+0.5;O=-(Z.x*I.n21+Z.y*I.n22+Z.z*I.n23)*0.5+0.5;Z.copy(L.vertexNormalsWorld[1]);M=(Z.x*I.n11+Z.y*I.n12+Z.z*I.n13)*0.5+0.5;J=-(Z.x*I.n21+Z.y*I.n22+Z.z*I.n23)*0.5+0.5;Z.copy(L.vertexNormalsWorld[2]);X=(Z.x*I.n11+Z.y*I.n12+Z.z*I.n13)*0.5+0.5;U=-(Z.x*I.n21+Z.y*I.n22+Z.z*I.n23)*0.5+0.5;sa(K,v,F,m,N,i,S.env_map.image,R,O,M,J,X,U)}}else S.wireframe?za(S.color.__styleString,S.wireframe_linewidth):
- Aa(S.color.__styleString);else if(S instanceof THREE.MeshLambertMaterial){if(S.map&&!S.wireframe){S.map.mapping instanceof THREE.UVMapping&&sa(K,v,F,m,N,i,S.map.image,L.uvs[0].u,L.uvs[0].v,L.uvs[1].u,L.uvs[1].v,L.uvs[2].u,L.uvs[2].v);ya(THREE.SubtractiveBlending)}if(Q)if(!S.wireframe&&S.shading==THREE.SmoothShading&&L.vertexNormalsWorld.length==3){p.r=l.r=r.r=t.r;p.g=l.g=r.g=t.g;p.b=l.b=r.b=t.b;xa($,L.v1.positionWorld,L.vertexNormalsWorld[0],p);xa($,L.v2.positionWorld,L.vertexNormalsWorld[1],l);xa($,
- L.v3.positionWorld,L.vertexNormalsWorld[2],r);o.r=(l.r+r.r)*0.5;o.g=(l.g+r.g)*0.5;o.b=(l.b+r.b)*0.5;C=Ha(p,l,r,o);sa(K,v,F,m,N,i,C,0,0,1,0,0,1)}else{n.r=t.r;n.g=t.g;n.b=t.b;xa($,L.centroidWorld,L.normalWorld,n);q.r=S.color.r*n.r;q.g=S.color.g*n.g;q.b=S.color.b*n.b;q.updateStyleString();S.wireframe?za(q.__styleString,S.wireframe_linewidth):Aa(q.__styleString)}else S.wireframe?za(S.color.__styleString,S.wireframe_linewidth):Aa(S.color.__styleString)}else if(S instanceof THREE.MeshDepthMaterial){A=S.__2near;
- y=S.__farPlusNear;D=S.__farMinusNear;p.r=p.g=p.b=1-A/(y-I.positionScreen.z*D);l.r=l.g=l.b=1-A/(y-V.positionScreen.z*D);r.r=r.g=r.b=1-A/(y-T.positionScreen.z*D);o.r=(l.r+r.r)*0.5;o.g=(l.g+r.g)*0.5;o.b=(l.b+r.b)*0.5;C=Ha(p,l,r,o);sa(K,v,F,m,N,i,C,0,0,1,0,0,1)}else if(S instanceof THREE.MeshNormalMaterial){q.r=Da(L.normalWorld.x);q.g=Da(L.normalWorld.y);q.b=Da(L.normalWorld.z);q.updateStyleString();S.wireframe?za(q.__styleString,S.wireframe_linewidth):Aa(q.__styleString)}}}function za(I,V){if(w!=I)h.strokeStyle=
- w=I;if(s!=V)h.lineWidth=s=V;h.stroke();E.inflate(V*2)}function Aa(I){if(B!=I)h.fillStyle=B=I;h.fill()}function sa(I,V,T,L,S,$,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;T-=I;L-=V;S-=I;$-=V;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*T-ga*S)*la;ga=(ta*L-ga*$)*la;T=(ja*S-ka*T)*la;L=(ja*$-ka*L)*la;I=I-na*ca-T*da;V=V-ga*ca-L*da;h.save();h.transform(na,ga,T,L,I,V);h.clip();h.drawImage(ba,0,0);h.restore()}function Ca(I){if(j!=I)h.globalAlpha=
- j=I}function ya(I){if(c!=I){switch(I){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=I}}function Ha(I,V,T,L){var S=~~(I.r*255),$=~~(I.g*255);I=~~(I.b*255);var ba=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(T.r*255),ja=~~(T.g*255);T=~~(T.b*255);var ga=~~(L.r*255),ka=~~(L.g*255);L=~~(L.b*255);fa[0]=S<0?0:S>255?255:S;fa[1]=$<0?0:
- $>255?255:$;fa[2]=I<0?0:I>255?255:I;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=V<0?0:V>255?255:V;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=T<0?0:T>255?255:T;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=L<0?0:L>255?255:L;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function Ea(I,V){var T=V.x-I.x,L=V.y-I.y,S=1/Math.sqrt(T*T+L*L);T*=S;L*=S;V.x+=T;V.y+=L;I.x-=T;I.y-=L}var Ba,Ia,aa,ha,qa,Fa,
- Ja,ua;h.setTransform(1,0,0,-1,f,k);this.autoClear&&this.clear();a=b.projectScene(ia,wa,this.sortElements);(Q=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba<Ia;Ba++){aa=a[Ba];E.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=f;u.y*=k;ha=0;for(qa=aa.material.length;ha<qa;ha++)La(u,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){u=aa.v1;x=aa.v2;u.positionScreen.x*=f;u.positionScreen.y*=k;x.positionScreen.x*=f;x.positionScreen.y*=k;E.addPoint(u.positionScreen.x,u.positionScreen.y);
- E.addPoint(x.positionScreen.x,x.positionScreen.y);if(W.instersects(E)){ha=0;for(qa=aa.material.length;ha<qa;)Ma(u,x,aa,aa.material[ha++],ia)}}else if(aa instanceof THREE.RenderableFace3){u=aa.v1;x=aa.v2;z=aa.v3;u.positionScreen.x*=f;u.positionScreen.y*=k;x.positionScreen.x*=f;x.positionScreen.y*=k;z.positionScreen.x*=f;z.positionScreen.y*=k;if(aa.overdraw){Ea(u.positionScreen,x.positionScreen);Ea(x.positionScreen,z.positionScreen);Ea(z.positionScreen,u.positionScreen)}E.add3Points(u.positionScreen.x,
- u.positionScreen.y,x.positionScreen.x,x.positionScreen.y,z.positionScreen.x,z.positionScreen.y);if(W.instersects(E)){ha=0;for(qa=aa.meshMaterial.length;ha<qa;){ua=aa.meshMaterial[ha++];if(ua instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=aa.faceMaterial.length;Fa<Ja;)(ua=aa.faceMaterial[Fa++])&&Ga(u,x,z,aa,ua,ia)}else Ga(u,x,z,aa,ua,ia)}}}H.addRectangle(E)}h.setTransform(1,0,0,1,0,0)}};
- THREE.SVGRenderer=function(){function a(J,X,U){var W,H,E,Q;W=0;for(H=J.lights.length;W<H;W++){E=J.lights[W];if(E instanceof THREE.DirectionalLight){Q=X.normalWorld.dot(E.position)*E.intensity;if(Q>0){U.r+=E.color.r*Q;U.g+=E.color.g*Q;U.b+=E.color.b*Q}}else if(E instanceof THREE.PointLight){r.sub(E.position,X.centroidWorld);r.normalize();Q=X.normalWorld.dot(r)*E.intensity;if(Q>0){U.r+=E.color.r*Q;U.g+=E.color.g*Q;U.b+=E.color.b*Q}}}}function b(J,X,U,W,H,E){D=d(C++);D.setAttribute("d","M "+J.positionScreen.x+
- " "+J.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)m.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(F){N.r=i.r;N.g=i.g;N.b=i.b;a(E,W,N);m.r=H.color.r*N.r;m.g=H.color.g*N.g;m.b=H.color.b*N.b;m.updateStyleString()}else m.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){l=1-H.__2near/(H.__farPlusNear-W.z*H.__farMinusNear);
- m.setRGB(l,l,l)}else H instanceof THREE.MeshNormalMaterial&&m.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));H.wireframe?D.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):D.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+H.opacity);h.appendChild(D)}function e(J,X,U,W,H,E,Q){D=d(C++);D.setAttribute("d",
- "M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)m.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(F){N.r=i.r;N.g=i.g;N.b=i.b;a(Q,H,N);m.r=E.color.r*N.r;m.g=E.color.g*N.g;m.b=E.color.b*N.b;m.updateStyleString()}else m.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){l=
- 1-E.__2near/(E.__farPlusNear-H.z*E.__farMinusNear);m.setRGB(l,l,l)}else E instanceof THREE.MeshNormalMaterial&&m.setRGB(g(H.normalWorld.x),g(H.normalWorld.y),g(H.normalWorld.z));E.wireframe?D.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):D.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+E.opacity);h.appendChild(D)}
- function d(J){if(o[J]==null){o[J]=document.createElementNS("http://www.w3.org/2000/svg","path");M==0&&o[J].setAttribute("shape-rendering","crispEdges");return o[J]}return o[J]}function g(J){return J<0?Math.min((1+J)*0.5,0.5):0.5+Math.min(J*0.5,0.5)}var f=null,k=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,w,B,s,u,x,z,K=new THREE.Rectangle,v=new THREE.Rectangle,F=false,m=new THREE.Color(16777215),N=new THREE.Color(16777215),i=new THREE.Color(0),q=new THREE.Color(0),
- p=new THREE.Color(0),l,r=new THREE.Vector3,o=[],A=[],y=[],D,C,R,O,M=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(J){switch(J){case "high":M=1;break;case "low":M=0}};this.setSize=function(J,X){j=J;c=X;w=j/2;B=c/2;h.setAttribute("viewBox",-w+" "+-B+" "+j+" "+c);h.setAttribute("width",j);h.setAttribute("height",c);K.set(-w,-B,w,B)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(J,X){var U,W,
- H,E,Q,n,t,G;this.autoClear&&this.clear();f=k.projectScene(J,X,this.sortElements);O=R=C=0;if(F=J.lights.length>0){t=J.lights;i.setRGB(0,0,0);q.setRGB(0,0,0);p.setRGB(0,0,0);U=0;for(W=t.length;U<W;U++){H=t[U];E=H.color;if(H instanceof THREE.AmbientLight){i.r+=E.r;i.g+=E.g;i.b+=E.b}else if(H instanceof THREE.DirectionalLight){q.r+=E.r;q.g+=E.g;q.b+=E.b}else if(H instanceof THREE.PointLight){p.r+=E.r;p.g+=E.g;p.b+=E.b}}}U=0;for(W=f.length;U<W;U++){t=f[U];v.empty();if(t instanceof THREE.RenderableParticle){s=
- t;s.x*=w;s.y*=-B;H=0;for(E=t.material.length;H<E;H++)if(G=t.material[H]){Q=s;n=t;G=G;var P=R++;if(A[P]==null){A[P]=document.createElementNS("http://www.w3.org/2000/svg","circle");M==0&&A[P].setAttribute("shape-rendering","crispEdges")}D=A[P];D.setAttribute("cx",Q.x);D.setAttribute("cy",Q.y);D.setAttribute("r",n.scale.x*w);if(G instanceof THREE.ParticleCircleMaterial){if(F){N.r=i.r+q.r+p.r;N.g=i.g+q.g+p.g;N.b=i.b+q.b+p.b;m.r=G.color.r*N.r;m.g=G.color.g*N.g;m.b=G.color.b*N.b;m.updateStyleString()}else m=
- G.color;D.setAttribute("style","fill: "+m.__styleString)}h.appendChild(D)}}else if(t instanceof THREE.RenderableLine){s=t.v1;u=t.v2;s.positionScreen.x*=w;s.positionScreen.y*=-B;u.positionScreen.x*=w;u.positionScreen.y*=-B;v.addPoint(s.positionScreen.x,s.positionScreen.y);v.addPoint(u.positionScreen.x,u.positionScreen.y);if(K.instersects(v)){H=0;for(E=t.material.length;H<E;)if(G=t.material[H++]){Q=s;n=u;G=G;P=O++;if(y[P]==null){y[P]=document.createElementNS("http://www.w3.org/2000/svg","line");M==
- 0&&y[P].setAttribute("shape-rendering","crispEdges")}D=y[P];D.setAttribute("x1",Q.positionScreen.x);D.setAttribute("y1",Q.positionScreen.y);D.setAttribute("x2",n.positionScreen.x);D.setAttribute("y2",n.positionScreen.y);if(G instanceof THREE.LineBasicMaterial){m.__styleString=G.color.__styleString;D.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+G.linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.linecap+"; stroke-linejoin: "+G.linejoin);h.appendChild(D)}}}}else if(t instanceof
- THREE.RenderableFace3){s=t.v1;u=t.v2;x=t.v3;s.positionScreen.x*=w;s.positionScreen.y*=-B;u.positionScreen.x*=w;u.positionScreen.y*=-B;x.positionScreen.x*=w;x.positionScreen.y*=-B;v.addPoint(s.positionScreen.x,s.positionScreen.y);v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(K.instersects(v)){H=0;for(E=t.meshMaterial.length;H<E;){G=t.meshMaterial[H++];if(G instanceof THREE.MeshFaceMaterial){Q=0;for(n=t.faceMaterial.length;Q<n;)(G=t.faceMaterial[Q++])&&
- b(s,u,x,t,G,J)}else G&&b(s,u,x,t,G,J)}}}else if(t instanceof THREE.RenderableFace4){s=t.v1;u=t.v2;x=t.v3;z=t.v4;s.positionScreen.x*=w;s.positionScreen.y*=-B;u.positionScreen.x*=w;u.positionScreen.y*=-B;x.positionScreen.x*=w;x.positionScreen.y*=-B;z.positionScreen.x*=w;z.positionScreen.y*=-B;v.addPoint(s.positionScreen.x,s.positionScreen.y);v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);v.addPoint(z.positionScreen.x,z.positionScreen.y);if(K.instersects(v)){H=
- 0;for(E=t.meshMaterial.length;H<E;){G=t.meshMaterial[H++];if(G instanceof THREE.MeshFaceMaterial){Q=0;for(n=t.faceMaterial.length;Q<n;)(G=t.faceMaterial[Q++])&&e(s,u,x,z,t,G,J)}else G&&e(s,u,x,z,t,G,J)}}}}}};
- THREE.WebGLRenderer=function(a){function b(i,q,p){var l=c.createProgram();p=["#ifdef GL_ES\nprecision highp float;\n#endif",p?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var r=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
- c.attachShader(l,k("fragment",p+i));c.attachShader(l,k("vertex",r+q));c.linkProgram(l);c.getProgramParameter(l,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(l,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");l.uniforms={};l.attributes={};return l}function e(i,q){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);
- c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var p=0;p<6;++p)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[p]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
- q);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}function d(i,q){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
- h(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+q);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,q){var p,l,r;p=0;for(l=q.length;p<l;p++){r=q[p];i.uniforms[r]=c.getUniformLocation(i,r)}}function f(i,q){var p,l,r;p=0;for(l=q.length;p<l;p++){r=q[p];i.attributes[r]=c.getAttribLocation(i,r)}}function k(i,q){var p;if(i=="fragment")p=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")p=c.createShader(c.VERTEX_SHADER);c.shaderSource(p,
- q);c.compileShader(p);if(!c.getShaderParameter(p,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(p));return null}return p}function h(i){switch(i){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
- case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var j=document.createElement("canvas"),c,w,B,s=new THREE.Matrix4,u,x=new Float32Array(16),z=new Float32Array(16),K=new Float32Array(16),v=new Float32Array(9),F=new Float32Array(16),m=function(i,q){if(i){var p,l,r,o=pointLights=maxDirLights=maxPointLights=0;p=0;for(l=i.lights.length;p<l;p++){r=i.lights[p];r instanceof THREE.DirectionalLight&&o++;r instanceof
- THREE.PointLight&&pointLights++}if(pointLights+o<=q){maxDirLights=o;maxPointLights=pointLights}else{maxDirLights=Math.ceil(q*o/(pointLights+o));maxPointLights=q-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:q-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=j;this.autoClear=true;
- (function(i,q,p){try{c=j.getContext("experimental-webgl",{antialias:i})}catch(l){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(q.r,q.g,q.b,p)})(antialias,clearColor,clearAlpha);w=B=function(i,q,p){var l=[i?"#define MAX_DIR_LIGHTS "+i:"",q?"#define MAX_POINT_LIGHTS "+
- q:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",q?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",q?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",q?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
- "","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
- i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",q?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",q?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",q?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
- "",q?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",q?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",q?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
- r=[i?"#define MAX_DIR_LIGHTS "+i:"",q?"#define MAX_POINT_LIGHTS "+q:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogDensity;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
- i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",q?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
- q?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",q?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",q?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",q?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",q?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",q?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",q?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",q?"float pointSpecularWeight = 0.0;":"",q?"if ( pointDotNormalHalf >= 0.0 )":
- "",q?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",q?"pointDiffuse += mColor * pointDiffuseWeight;":"",q?"pointSpecular += mSpecular * pointSpecularWeight;":"",q?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
- "",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",q?"totalLight += pointDiffuse + pointSpecular;":
- "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nconst float LOG2 = 1.442695;\nfloat z = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );\nfogFactor = clamp( fogFactor, 0.0, 1.0 );\ngl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );\n#endif\n}"].join("\n");
- l=b(r,l,p);c.useProgram(l);g(l,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);p&&g(l,["fogColor","fogDensity"]);i&&g(l,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);q&&g(l,["pointLightNumber","pointLightColor",
- "pointLightPosition"]);c.uniform1i(l.uniforms.enableMap,0);c.uniform1i(l.uniforms.tMap,0);c.uniform1i(l.uniforms.enableCubeMap,0);c.uniform1i(l.uniforms.tCube,1);c.uniform1i(l.uniforms.mixEnvMap,0);c.uniform1i(l.uniforms.useRefract,0);f(l,["position","normal","uv"]);return l}(m.directional,m.point,fog);this.setSize=function(i,q){j.width=i;j.height=q;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(i,q){c.clearColor(i.r,i.g,i.b,q)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};
- this.setupLights=function(i,q){var p,l,r,o,A,y=[],D=[],C=[];o=[];A=[];c.uniform1i(i.uniforms.enableLighting,q.length);p=0;for(l=q.length;p<l;p++){r=q[p];if(r instanceof THREE.AmbientLight)y.push(r);else if(r instanceof THREE.DirectionalLight)C.push(r);else r instanceof THREE.PointLight&&D.push(r)}p=r=o=A=0;for(l=y.length;p<l;p++){r+=y[p].color.r;o+=y[p].color.g;A+=y[p].color.b}c.uniform3f(i.uniforms.ambientLightColor,r,o,A);o=[];A=[];p=0;for(l=C.length;p<l;p++){r=C[p];o.push(r.color.r*r.intensity);
- o.push(r.color.g*r.intensity);o.push(r.color.b*r.intensity);A.push(r.position.x);A.push(r.position.y);A.push(r.position.z)}if(C.length){c.uniform1i(i.uniforms.directionalLightNumber,C.length);c.uniform3fv(i.uniforms.directionalLightDirection,A);c.uniform3fv(i.uniforms.directionalLightColor,o)}o=[];A=[];p=0;for(l=D.length;p<l;p++){r=D[p];o.push(r.color.r*r.intensity);o.push(r.color.g*r.intensity);o.push(r.color.b*r.intensity);A.push(r.position.x);A.push(r.position.y);A.push(r.position.z)}if(D.length){c.uniform1i(i.uniforms.pointLightNumber,
- D.length);c.uniform3fv(i.uniforms.pointLightPosition,A);c.uniform3fv(i.uniforms.pointLightColor,o)}};this.createBuffers=function(i,q){var p,l,r,o,A,y,D,C,R,O=[],M=[],J=[],X=[],U=[],W=[],H=0,E=i.geometry.geometryChunks[q],Q;r=false;p=0;for(l=i.material.length;p<l;p++){meshMaterial=i.material[p];if(meshMaterial instanceof THREE.MeshFaceMaterial){A=0;for(Q=E.material.length;A<Q;A++)if(E.material[A]&&E.material[A].shading!=undefined&&E.material[A].shading==THREE.SmoothShading){r=true;break}}else if(meshMaterial&&
- meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){r=true;break}if(r)break}Q=r;p=0;for(l=E.faces.length;p<l;p++){r=E.faces[p];o=i.geometry.faces[r];A=o.vertexNormals;faceNormal=o.normal;r=i.geometry.uvs[r];if(o instanceof THREE.Face3){y=i.geometry.vertices[o.a].position;D=i.geometry.vertices[o.b].position;C=i.geometry.vertices[o.c].position;J.push(y.x,y.y,y.z);J.push(D.x,D.y,D.z);J.push(C.x,C.y,C.z);if(i.geometry.hasTangents){y=i.geometry.vertices[o.a].tangent;D=i.geometry.vertices[o.b].tangent;
- C=i.geometry.vertices[o.c].tangent;U.push(y.x,y.y,y.z,y.w);U.push(D.x,D.y,D.z,D.w);U.push(C.x,C.y,C.z,C.w)}if(A.length==3&&Q)for(o=0;o<3;o++)X.push(A[o].x,A[o].y,A[o].z);else for(o=0;o<3;o++)X.push(faceNormal.x,faceNormal.y,faceNormal.z);if(r)for(o=0;o<3;o++)W.push(r[o].u,r[o].v);O.push(H,H+1,H+2);M.push(H,H+1);M.push(H,H+2);M.push(H+1,H+2);H+=3}else if(o instanceof THREE.Face4){y=i.geometry.vertices[o.a].position;D=i.geometry.vertices[o.b].position;C=i.geometry.vertices[o.c].position;R=i.geometry.vertices[o.d].position;
- J.push(y.x,y.y,y.z);J.push(D.x,D.y,D.z);J.push(C.x,C.y,C.z);J.push(R.x,R.y,R.z);if(i.geometry.hasTangents){y=i.geometry.vertices[o.a].tangent;D=i.geometry.vertices[o.b].tangent;C=i.geometry.vertices[o.c].tangent;o=i.geometry.vertices[o.d].tangent;U.push(y.x,y.y,y.z,y.w);U.push(D.x,D.y,D.z,D.w);U.push(C.x,C.y,C.z,C.w);U.push(o.x,o.y,o.z,o.w)}if(A.length==4&&Q)for(o=0;o<4;o++)X.push(A[o].x,A[o].y,A[o].z);else for(o=0;o<4;o++)X.push(faceNormal.x,faceNormal.y,faceNormal.z);if(r)for(o=0;o<4;o++)W.push(r[o].u,
- r[o].v);O.push(H,H+1,H+2);O.push(H,H+2,H+3);M.push(H,H+1);M.push(H,H+2);M.push(H,H+3);M.push(H+1,H+2);M.push(H+2,H+3);H+=4}}if(J.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(J),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW);if(i.geometry.hasTangents){E.__webGLTangentBuffer=c.createBuffer();
- c.bindBuffer(c.ARRAY_BUFFER,E.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW)}if(W.length>0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(O),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
- E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);E.__webGLFaceCount=O.length;E.__webGLLineCount=M.length}};this.renderBuffer=function(i,q,p,l,r){var o,A,y,D,C,R,O,M,J;if(l instanceof THREE.MeshShaderMaterial||l instanceof THREE.MeshDepthMaterial||l instanceof THREE.MeshNormalMaterial){if(!l.program){if(l instanceof THREE.MeshDepthMaterial){O=N.depth;l.fragment_shader=O.fragment_shader;l.vertex_shader=O.vertex_shader;l.uniforms=O.uniforms;l.uniforms.mNear.value=
- l.near;l.uniforms.mFar.value=l.far}else if(l instanceof THREE.MeshNormalMaterial){O=N.normal;l.fragment_shader=O.fragment_shader;l.vertex_shader=O.vertex_shader;l.uniforms=O.uniforms}l.program=b(l.fragment_shader,l.vertex_shader,null);O=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(J in l.uniforms)O.push(J);g(l.program,O);f(l.program,["position","normal","uv","tangent"])}J=l.program}else J=B;if(J!=w){c.useProgram(J);w=J}J==B&&this.setupLights(J,
- q);this.loadCamera(J,i);this.loadMatrices(J);if(l instanceof THREE.MeshShaderMaterial||l instanceof THREE.MeshDepthMaterial||l instanceof THREE.MeshNormalMaterial){y=l.wireframe;D=l.wireframe_linewidth;i=J;q=l.uniforms;var X;for(o in q){M=q[o].type;O=q[o].value;X=i.uniforms[o];if(M=="i")c.uniform1i(X,O);else if(M=="f")c.uniform1f(X,O);else if(M=="v3")c.uniform3f(X,O.x,O.y,O.z);else if(M=="c")c.uniform3f(X,O.r,O.g,O.b);else if(M=="t"){c.uniform1i(X,O);if(M=q[o].texture)M.image instanceof Array&&M.image.length==
- 6?e(M,O):d(M,O)}}}if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshBasicMaterial){o=l.color;A=l.opacity;y=l.wireframe;D=l.wireframe_linewidth;C=l.map;R=l.env_map;q=l.combine==THREE.MixOperation;i=l.reflectivity;M=l.env_map&&l.env_map.mapping instanceof THREE.CubeRefractionMapping;O=l.refraction_ratio;c.uniform4f(J.uniforms.mColor,o.r*A,o.g*A,o.b*A,A);c.uniform1i(J.uniforms.mixEnvMap,q);c.uniform1f(J.uniforms.mReflectivity,i);c.uniform1i(J.uniforms.useRefract,
- M);c.uniform1f(J.uniforms.mRefractionRatio,O);if(p){c.uniform1f(J.uniforms.fogDensity,p.density);c.uniform3f(J.uniforms.fogColor,p.color.r,p.color.g,p.color.b)}}if(l instanceof THREE.MeshPhongMaterial){p=l.ambient;o=l.specular;l=l.shininess;c.uniform4f(J.uniforms.mAmbient,p.r,p.g,p.b,A);c.uniform4f(J.uniforms.mSpecular,o.r,o.g,o.b,A);c.uniform1f(J.uniforms.mShininess,l);c.uniform1i(J.uniforms.material,2)}else if(l instanceof THREE.MeshLambertMaterial)c.uniform1i(J.uniforms.material,1);else l instanceof
- THREE.MeshBasicMaterial&&c.uniform1i(J.uniforms.material,0);if(C){d(C,0);c.uniform1i(J.uniforms.tMap,0);c.uniform1i(J.uniforms.enableMap,1)}else c.uniform1i(J.uniforms.enableMap,0);if(R){e(R,1);c.uniform1i(J.uniforms.tCube,1);c.uniform1i(J.uniforms.enableCubeMap,1)}else c.uniform1i(J.uniforms.enableCubeMap,0);A=J.attributes;c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.vertexAttribPointer(A.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(A.position);if(A.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,
- r.__webGLNormalBuffer);c.vertexAttribPointer(A.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(A.normal)}if(A.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.vertexAttribPointer(A.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(A.tangent)}if(A.uv>=0)if(r.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.vertexAttribPointer(A.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(A.uv)}else c.disableVertexAttribArray(A.uv);if(y){c.lineWidth(D);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
- r.__webGLLineBuffer);c.drawElements(c.LINES,r.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,r.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,q,p,l,r,o,A){var y,D,C,R,O;C=0;for(R=l.material.length;C<R;C++){y=l.material[C];if(y instanceof THREE.MeshFaceMaterial){y=0;for(D=r.material.length;y<D;y++)if((O=r.material[y])&&O.blending==o&&O.opacity<1==A){this.setBlending(O.blending);this.renderBuffer(i,q,p,
- O,r)}}else if((O=y)&&O.blending==o&&O.opacity<1==A){this.setBlending(O.blending);this.renderBuffer(i,q,p,O,r)}}};this.render=function(i,q){var p,l,r,o,A=i.lights,y=i.fog;this.initWebGLObjects(i);this.autoClear&&this.clear();q.autoUpdateMatrix&&q.updateMatrix();x.set(q.matrix.flatten());K.set(q.projectionMatrix.flatten());p=0;for(l=i.__webGLObjects.length;p<l;p++){r=i.__webGLObjects[p];o=r.object;r=r.buffer;if(o.visible){this.setupMatrices(o,q);this.renderPass(q,A,y,o,r,THREE.NormalBlending,false)}}p=
- 0;for(l=i.__webGLObjects.length;p<l;p++){r=i.__webGLObjects[p];o=r.object;r=r.buffer;if(o.visible){this.setupMatrices(o,q);this.renderPass(q,A,y,o,r,THREE.AdditiveBlending,false);this.renderPass(q,A,y,o,r,THREE.SubtractiveBlending,false);this.renderPass(q,A,y,o,r,THREE.AdditiveBlending,true);this.renderPass(q,A,y,o,r,THREE.SubtractiveBlending,true);this.renderPass(q,A,y,o,r,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var q,p,l,r,o,A;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap=
- {}}q=0;for(p=i.objects.length;q<p;q++){l=i.objects[q];if(i.__webGLObjectsMap[l.id]==undefined)i.__webGLObjectsMap[l.id]={};A=i.__webGLObjectsMap[l.id];if(l instanceof THREE.Mesh)for(o in l.geometry.geometryChunks){r=l.geometry.geometryChunks[o];r.__webGLVertexBuffer||this.createBuffers(l,o);if(A[o]==undefined){r={buffer:r,object:l};i.__webGLObjects.push(r);A[o]=1}}}};this.removeObject=function(i,q){var p,l;for(p=i.__webGLObjects.length-1;p>=0;p--){l=i.__webGLObjects[p].object;q==l&&i.__webGLObjects.splice(p,
- 1)}};this.setupMatrices=function(i,q){i.autoUpdateMatrix&&i.updateMatrix();s.multiply(q.matrix,i.matrix);z.set(s.flatten());u=THREE.Matrix4.makeInvert3x3(s).transpose();v.set(u.m);F.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,x);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,z);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,v);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,F)};
- this.loadCamera=function(i,q){c.uniform3f(i.uniforms.cameraPosition,q.position.x,q.position.y,q.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,q){if(i){!q||q=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);
- else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var N={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
- vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
- THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};
- THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
- var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,f=a.vertices,k=g.vertices,h=a.faces,j=g.faces,c=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var w=0,B=k.length;w<B;w++){var s=new THREE.Vertex(k[w].position.clone());e&&b.matrix.multiplyVector3(s.position);f.push(s)}w=0;for(B=j.length;w<B;w++){k=j[w];var u,x=k.vertexNormals;if(k instanceof THREE.Face3)u=new THREE.Face3(k.a+d,k.b+d,k.c+d);else if(k instanceof THREE.Face4)u=new THREE.Face4(k.a+d,k.b+
- d,k.c+d,k.d+d);u.centroid.copy(k.centroid);u.normal.copy(k.normal);e=0;for(f=x.length;e<f;e++){s=x[e];u.vertexNormals.push(s.clone())}u.material=k.material.slice();h.push(u)}w=0;for(B=g.length;w<B;w++){d=g[w];h=[];e=0;for(f=d.length;e<f;e++)h.push(new THREE.UV(d[e].u,d[e].v));c.push(h)}}},ImageUtils={loadTexture:function(a,b){var e=new Image;e.onload=function(){this.loaded=true};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a){var b,e,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
- new Image;d[b].loaded=0;d[b].onload=function(){d.loadCount+=1;this.loaded=true};d[b].src=a[b]}return d}},SceneUtils={addMesh:function(a,b,e,d,g,f,k,h,j,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=e;b.position.x=d;b.position.y=g;b.position.z=f;b.rotation.x=k;b.rotation.y=h;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,e){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=e;e=new THREE.MeshShaderMaterial({fragment_shader:d.fragment_shader,vertex_shader:d.vertex_shader,
- uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),e);a.addObject(b);return b},addPanoramaCube:function(a,b,e){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));
- mesh=new THREE.Mesh(new Cube(b,b,b,1,1,d,true),new THREE.MeshFaceMaterial);a.addObject(mesh);return mesh},addPanoramaCubePlanes:function(a,b,e){var d=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));SceneUtils.addMesh(a,
- b,1,0,d,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));SceneUtils.addMesh(a,b,1,0,-d,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[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(void) {\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:{tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},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 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );\nvec3 aoTex = 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( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}",
- vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
- basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"},cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
- fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,e,d,g,f,k,h){function j(z,K,v,F,m,N,i,q){var p,l=d||1,r=g||1,o=l+1,A=r+1,y=m/2,D=N/2;m=m/l;N=N/r;var C=c.vertices.length;if(z=="x"&&K=="y"||z=="y"&&K=="x")p="z";else if(z=="x"&&K=="z"||z=="z"&&K=="x")p="y";else if(z=="z"&&K=="y"||z=="y"&&K=="z")p="x";for(iy=0;iy<A;iy++)for(ix=0;ix<
- o;ix++){var R=new THREE.Vector3;R[z]=(ix*m-y)*v;R[K]=(iy*N-D)*F;R[p]=i;c.vertices.push(new THREE.Vertex(R))}for(iy=0;iy<r;iy++)for(ix=0;ix<l;ix++){c.faces.push(new THREE.Face4(ix+o*iy+C,ix+o*(iy+1)+C,ix+1+o*(iy+1)+C,ix+1+o*iy+C,null,q));c.uvs.push([new THREE.UV(ix/l,iy/r),new THREE.UV(ix/l,(iy+1)/r),new THREE.UV((ix+1)/l,(iy+1)/r),new THREE.UV((ix+1)/l,iy/r)])}}THREE.Geometry.call(this);var c=this,w=a/2,B=b/2,s=e/2;k=k?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=f;else{this.materials=
- [];for(var u=0;u<6;u++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var x in h)if(this.sides[x]!=undefined)this.sides[x]=h[x];this.sides.px&&j("z","y",1*k,-1,e,b,-w,this.materials[0]);this.sides.nx&&j("z","y",-1*k,-1,e,b,w,this.materials[1]);this.sides.py&&j("x","z",1*k,1,a,e,B,this.materials[2]);this.sides.ny&&j("x","z",1*k,-1,a,e,-B,this.materials[3]);this.sides.pz&&j("x","y",1*k,-1,a,b,s,this.materials[4]);this.sides.nz&&
- j("x","y",-1*k,-1,a,b,-s,this.materials[5]);(function(){for(var z=[],K=[],v=0,F=c.vertices.length;v<F;v++){for(var m=c.vertices[v],N=false,i=0,q=z.length;i<q;i++){var p=z[i];if(m.position.x==p.position.x&&m.position.y==p.position.y&&m.position.z==p.position.z){K[v]=i;N=true;break}}if(!N){K[v]=z.length;z.push(new THREE.Vertex(m.position.clone()))}}v=0;for(F=c.faces.length;v<F;v++){m=c.faces[v];m.a=K[m.a];m.b=K[m.b];m.c=K[m.c];m.d=K[m.d]}c.vertices=z})();this.computeCentroids();this.computeFaceNormals();
- this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
- var Cylinder=function(a,b,e,d,g){function f(c,w,B){k.vertices.push(new THREE.Vertex(new THREE.Vector3(c,w,B)))}THREE.Geometry.call(this);var k=this,h=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*h*j/a)*b,Math.cos(2*h*j/a)*b,0);for(j=0;j<a;j++)f(Math.sin(2*h*j/a)*e,Math.cos(2*h*j/a)*e,d);for(j=0;j<a;j++)k.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(e!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)k.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,d+g);for(j=a+a/2;j<
- 2*a;j++)k.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,e,d){THREE.Geometry.call(this);var g,f=a/2,k=b/2;e=e||1;d=d||1;var h=e+1,j=d+1;a=a/e;var c=b/d;for(g=0;g<j;g++)for(b=0;b<h;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*c-k),0)));for(g=0;g<d;g++)for(b=0;b<e;b++){this.faces.push(new THREE.Face4(b+h*g,b+h*(g+1),b+1+h*(g+1),b+1+h*g));this.uvs.push([new THREE.UV(b/e,g/d),new THREE.UV(b/e,(g+1)/d),new THREE.UV((b+1)/e,(g+1)/d),new THREE.UV((b+1)/e,g/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
- Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
- var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,f=Math.max(3,b||8),k=Math.max(2,e||6);b=[];for(e=0;e<k+1;e++){d=e/k;var h=a*Math.cos(d*g),j=a*Math.sin(d*g),c=[],w=0;for(d=0;d<f;d++){var B=2*d/f,s=j*Math.sin(B*g);B=j*Math.cos(B*g);(e==0||e==k)&&d>0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,h,s)))-1);c.push(w)}b.push(c)}var u,x,z;g=b.length;for(e=0;e<g;e++){f=b[e].length;if(e>0)for(d=0;d<f;d++){c=d==f-1;k=b[e][c?0:d+1];h=b[e][c?f-1:d];j=b[e-1][c?f-1:d];c=b[e-1][c?
- 0:d+1];s=e/(g-1);u=(e-1)/(g-1);x=(d+1)/f;B=d/f;w=new THREE.UV(1-x,s);s=new THREE.UV(1-B,s);B=new THREE.UV(1-B,u);var K=new THREE.UV(1-x,u);if(e<b.length-1){u=this.vertices[k].position.clone();x=this.vertices[h].position.clone();z=this.vertices[j].position.clone();u.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(k,h,j,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([w,s,B])}if(e>1){u=this.vertices[k].position.clone();
- x=this.vertices[j].position.clone();z=this.vertices[c].position.clone();u.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(k,j,c,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([w,B,K])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
- THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
- THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
- b},loadAsciiOld:function(a,b){var e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(f){THREE.Loader.prototype.loadAjaxBuffers(f.data.buffers,
- f.data.materials,b,e,g)};a.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,g){var f=new XMLHttpRequest,k=d+"/"+a,h=0;f.onreadystatechange=function(){if(f.readyState==4)f.status==200||f.status==0?THREE.Loader.prototype.createBinModel(f.responseText,e,d,b):alert("Couldn't load ["+k+"] ["+f.status+"]");else if(f.readyState==3){if(g){if(h==0)h=f.getResponseHeader("Content-Length");g({total:h,loaded:f.responseText.length})}}else if(f.readyState==
- 2)h=f.getResponseHeader("Content-Length")};f.open("GET",k,true);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)},createBinModel:function(a,b,e,d){var g=function(f){function k(n,t){var G=w(n,t),P=w(n,t+1),Y=w(n,t+2),Z=w(n,t+3),ea=(Z<<1&255|Y>>7)-127;G=(Y&127)<<16|P<<8|G;if(G==0&&ea==-127)return 0;return(1-2*(Z>>7))*(1+G*Math.pow(2,-23))*Math.pow(2,ea)}function h(n,t){var G=w(n,t),P=w(n,t+1),Y=w(n,t+2);return(w(n,t+3)<<24)+(Y<<16)+
- (P<<8)+G}function j(n,t){var G=w(n,t);return(w(n,t+1)<<8)+G}function c(n,t){var G=w(n,t);return G>127?G-256:G}function w(n,t){return n.charCodeAt(t)&255}function B(n){var t,G,P;t=h(a,n);G=h(a,n+q);P=h(a,n+p);n=j(a,n+l);THREE.Loader.prototype.f3(v,t,G,P,n)}function s(n){var t,G,P,Y,Z,ea;t=h(a,n);G=h(a,n+q);P=h(a,n+p);Y=j(a,n+l);Z=h(a,n+r);ea=h(a,n+o);n=h(a,n+A);THREE.Loader.prototype.f3n(v,N,t,G,P,Y,Z,ea,n)}function u(n){var t,G,P,Y;t=h(a,n);G=h(a,n+y);P=h(a,n+D);Y=h(a,n+C);n=j(a,n+R);THREE.Loader.prototype.f4(v,
- t,G,P,Y,n)}function x(n){var t,G,P,Y,Z,ea,ma,oa;t=h(a,n);G=h(a,n+y);P=h(a,n+D);Y=h(a,n+C);Z=j(a,n+R);ea=h(a,n+O);ma=h(a,n+M);oa=h(a,n+J);n=h(a,n+X);THREE.Loader.prototype.f4n(v,N,t,G,P,Y,Z,ea,ma,oa,n)}function z(n){var t,G;t=h(a,n);G=h(a,n+U);n=h(a,n+W);THREE.Loader.prototype.uv3(v,i[t*2],i[t*2+1],i[G*2],i[G*2+1],i[n*2],i[n*2+1])}function K(n){var t,G,P;t=h(a,n);G=h(a,n+H);P=h(a,n+E);n=h(a,n+Q);THREE.Loader.prototype.uv4(v,i[t*2],i[t*2+1],i[G*2],i[G*2+1],i[P*2],i[P*2+1],i[n*2],i[n*2+1])}var v=this,
- F=0,m,N=[],i=[],q,p,l,r,o,A,y,D,C,R,O,M,J,X,U,W,H,E,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,f);m={signature:a.substr(F,8),header_bytes:w(a,F+8),vertex_coordinate_bytes:w(a,F+9),normal_coordinate_bytes:w(a,F+10),uv_coordinate_bytes:w(a,F+11),vertex_index_bytes:w(a,F+12),normal_index_bytes:w(a,F+13),uv_index_bytes:w(a,F+14),material_index_bytes:w(a,F+15),nvertices:h(a,F+16),nnormals:h(a,F+16+4),nuvs:h(a,F+16+8),ntri_flat:h(a,F+16+12),ntri_smooth:h(a,F+16+16),ntri_flat_uv:h(a,
- F+16+20),ntri_smooth_uv:h(a,F+16+24),nquad_flat:h(a,F+16+28),nquad_smooth:h(a,F+16+32),nquad_flat_uv:h(a,F+16+36),nquad_smooth_uv:h(a,F+16+40)};F+=m.header_bytes;q=m.vertex_index_bytes;p=m.vertex_index_bytes*2;l=m.vertex_index_bytes*3;r=m.vertex_index_bytes*3+m.material_index_bytes;o=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;y=m.vertex_index_bytes;D=m.vertex_index_bytes*2;C=m.vertex_index_bytes*3;R=m.vertex_index_bytes*
- 4;O=m.vertex_index_bytes*4+m.material_index_bytes;M=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;X=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;U=m.uv_index_bytes;W=m.uv_index_bytes*2;H=m.uv_index_bytes;E=m.uv_index_bytes*2;Q=m.uv_index_bytes*3;F+=function(n){var t,G,P,Y=m.vertex_coordinate_bytes*3,Z=n+m.nvertices*Y;for(n=n;n<Z;n+=Y){t=k(a,n);G=k(a,n+m.vertex_coordinate_bytes);P=k(a,
- n+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,t,G,P)}return m.nvertices*Y}(F);F+=function(n){var t,G,P,Y=m.normal_coordinate_bytes*3,Z=n+m.nnormals*Y;for(n=n;n<Z;n+=Y){t=c(a,n);G=c(a,n+m.normal_coordinate_bytes);P=c(a,n+m.normal_coordinate_bytes*2);N.push(t/127,G/127,P/127)}return m.nnormals*Y}(F);F+=function(n){var t,G,P=m.uv_coordinate_bytes*2,Y=n+m.nuvs*P;for(n=n;n<Y;n+=P){t=k(a,n);G=k(a,n+m.uv_coordinate_bytes);i.push(t,G)}return m.nuvs*P}(F);F+=function(n){var t,G=m.vertex_index_bytes*
- 3+m.material_index_bytes,P=n+m.ntri_flat*G;for(t=n;t<P;t+=G)B(t);return P-n}(F);F+=function(n){var t,G=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,P=n+m.ntri_smooth*G;for(t=n;t<P;t+=G)s(t);return P-n}(F);F+=function(n){var t,G=m.vertex_index_bytes*3+m.material_index_bytes,P=G+m.uv_index_bytes*3,Y=n+m.ntri_flat_uv*P;for(t=n;t<Y;t+=P){B(t);z(t+G)}return Y-n}(F);F+=function(n){var t,G=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,P=G+m.uv_index_bytes*3,
- Y=n+m.ntri_smooth_uv*P;for(t=n;t<Y;t+=P){s(t);z(t+G)}return Y-n}(F);F+=function(n){var t,G=m.vertex_index_bytes*4+m.material_index_bytes,P=n+m.nquad_flat*G;for(t=n;t<P;t+=G)u(t);return P-n}(F);F+=function(n){var t,G=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,P=n+m.nquad_smooth*G;for(t=n;t<P;t+=G)x(t);return P-n}(F);F+=function(n){var t,G=m.vertex_index_bytes*4+m.material_index_bytes,P=G+m.uv_index_bytes*4,Y=n+m.nquad_flat_uv*P;for(t=n;t<Y;t+=P){u(t);K(t+G)}return Y-n}(F);
- F+=function(n){var t,G=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,P=G+m.uv_index_bytes*4,Y=n+m.nquad_smooth_uv*P;for(t=n;t<Y;t+=P){x(t);K(t+G)}return Y-n}(F);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(e))},createModel:function(a,b,e){var d=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var k,h,j,c,w;k=0;for(h=
- a.vertices.length;k<h;k+=3){j=a.vertices[k];c=a.vertices[k+1];w=a.vertices[k+2];THREE.Loader.prototype.v(f,j,c,w)}})();(function(){function k(x,z){THREE.Loader.prototype.f3(f,x[z],x[z+1],x[z+2],x[z+3])}function h(x,z){THREE.Loader.prototype.f3n(f,a.normals,x[z],x[z+1],x[z+2],x[z+3],x[z+4],x[z+5],x[z+6])}function j(x,z){THREE.Loader.prototype.f4(f,x[z],x[z+1],x[z+2],x[z+3],x[z+4])}function c(x,z){THREE.Loader.prototype.f4n(f,a.normals,x[z],x[z+1],x[z+2],x[z+3],x[z+4],x[z+5],x[z+6],x[z+7],x[z+8])}function w(x,
- z){var K,v,F;K=x[z];v=x[z+1];F=x[z+2];THREE.Loader.prototype.uv3(f,a.uvs[K*2],a.uvs[K*2+1],a.uvs[v*2],a.uvs[v*2+1],a.uvs[F*2],a.uvs[F*2+1])}function B(x,z){var K,v,F,m;K=x[z];v=x[z+1];F=x[z+2];m=x[z+3];THREE.Loader.prototype.uv4(f,a.uvs[K*2],a.uvs[K*2+1],a.uvs[v*2],a.uvs[v*2+1],a.uvs[F*2],a.uvs[F*2+1],a.uvs[m*2],a.uvs[m*2+1])}var s,u;s=0;for(u=a.triangles.length;s<u;s+=4)k(a.triangles,s);s=0;for(u=a.triangles_uv.length;s<u;s+=7){k(a.triangles_uv,s);w(a.triangles_uv,s+4)}s=0;for(u=a.triangles_n.length;s<
- u;s+=7)h(a.triangles_n,s);s=0;for(u=a.triangles_n_uv.length;s<u;s+=10){h(a.triangles_n_uv,s);w(a.triangles_n_uv,s+7)}s=0;for(u=a.quads.length;s<u;s+=5)j(a.quads,s);s=0;for(u=a.quads_uv.length;s<u;s+=9){j(a.quads_uv,s);B(a.quads_uv,s+5)}s=0;for(u=a.quads_n.length;s<u;s+=9)c(a.quads_n,s);s=0;for(u=a.quads_n_uv.length;s<u;s+=13){c(a.quads_n_uv,s);B(a.quads_n_uv,s+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
- d;b(new d(e))},v:function(a,b,e,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,d)))},f3:function(a,b,e,d,g){a.faces.push(new THREE.Face3(b,e,d,null,a.materials[g]))},f4:function(a,b,e,d,g,f){a.faces.push(new THREE.Face4(b,e,d,g,null,a.materials[f]))},f3n:function(a,b,e,d,g,f,k,h,j){f=a.materials[f];var c=b[h*3],w=b[h*3+1];h=b[h*3+2];var B=b[j*3],s=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(e,d,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,w,h),new THREE.Vector3(B,
- s,j)],f))},f4n:function(a,b,e,d,g,f,k,h,j,c,w){k=a.materials[k];var B=b[j*3],s=b[j*3+1];j=b[j*3+2];var u=b[c*3],x=b[c*3+1];c=b[c*3+2];var z=b[w*3],K=b[w*3+1];w=b[w*3+2];a.faces.push(new THREE.Face4(e,d,g,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(B,s,j),new THREE.Vector3(u,x,c),new THREE.Vector3(z,K,w)],k))},uv3:function(a,b,e,d,g,f,k){var h=[];h.push(new THREE.UV(b,e));h.push(new THREE.UV(d,g));h.push(new THREE.UV(f,k));a.uvs.push(h)},uv4:function(a,b,e,d,g,f,k,h,j){var c=[];
- c.push(new THREE.UV(b,e));c.push(new THREE.UV(d,g));c.push(new THREE.UV(f,k));c.push(new THREE.UV(h,j));a.uvs.push(c)},init_materials:function(a,b,e){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],e)]},createMaterial:function(a,b){function e(f){f=Math.log(f)/Math.LN2;return Math.floor(f)==f}var d,g;if(a.map_diffuse&&b){g=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!e(this.width)||
- !e(this.height)){var f=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));d.map.image.width=f;d.map.image.height=k;d.map.image.getContext("2d").drawImage(this,0,0,f,k)}else d.map.image=this;d.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else d=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
- new THREE.MeshLambertMaterial({color:15658734});return d}};
|