Three.js 183.0 KB
Newer Older
1
// Three.js r34 - http://github.com/mrdoob/three.js
2
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
3
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,j,k;if(b==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);k=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=k;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=k;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;g=k;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();
4
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
5 6 7 8 9 10
THREE.Vector2=function(a,c){this.set(a||0,c||0)};
THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)};
THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.set(b*a.z-d*a.y,d*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
11 12
this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var c=Math.cos(this.y);if(Math.abs(c)>1.0E-5){this.x=Math.atan2(-a.n23/c,a.n33/c);this.z=Math.atan2(-a.n13/c,a.n11/c)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},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)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)};
13 14
THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
15 16 17 18 19 20
THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(b)))}e.sort(function(g,h){return g.distance-h.distance});return e},intersectObject:function(a){function c(F,w,H,x){x=x.clone().subSelf(w);H=H.clone().subSelf(w);var Q=F.clone().subSelf(w);F=x.dot(x);w=x.dot(H);x=x.dot(Q);var M=H.dot(H);H=H.dot(Q);Q=1/(F*M-w*w);M=(M*x-w*H)*Q;F=(F*H-w*x)*Q;return M>0&&F>0&&M+F<1}var b,d,e,g,h,j,k,m,o,z,
u,p=a.geometry,A=p.vertices,D=[];b=0;for(d=p.faces.length;b<d;b++){e=p.faces[b];z=this.origin.clone();u=this.direction.clone();k=a.matrixWorld;g=k.multiplyVector3(A[e.a].position.clone());h=k.multiplyVector3(A[e.b].position.clone());j=k.multiplyVector3(A[e.c].position.clone());k=e instanceof THREE.Face4?k.multiplyVector3(A[e.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(e.normal.clone());o=u.dot(m);if(o<0){m=m.dot((new THREE.Vector3).sub(g,z))/o;z=z.addSelf(u.multiplyScalar(m));
if(e instanceof THREE.Face3){if(c(z,g,h,j)){e={distance:this.origin.distanceTo(z),point:z,face:e,object:a};D.push(e)}}else if(e instanceof THREE.Face4&&(c(z,g,h,k)||c(z,h,j,k))){e={distance:this.origin.distanceTo(z),point:z,face:e,object:a};D.push(e)}}}return D}};
THREE.Rectangle=function(){function a(){g=d-c;h=e-b}var c,b,d,e,g,h,j=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(k,m,o,z){j=!1;c=k;b=m;d=o;e=z;a()};this.addPoint=function(k,m){if(j){j=!1;c=k;b=m;d=k;e=m}else{c=c<k?c:k;b=b<m?b:m;d=d>k?d:k;e=e>m?e:m}a()};
this.add3Points=function(k,m,o,z,u,p){if(j){j=!1;c=k<o?k<u?k:u:o<u?o:u;b=m<z?m<p?m:p:z<p?z:p;d=k>o?k>u?k:u:o>u?o:u;e=m>z?m>p?m:p:z>p?z:p}else{c=k<o?k<u?k<c?k:c:u<c?u:c:o<u?o<c?o:c:u<c?u:c;b=m<z?m<p?m<b?m:b:p<b?p:b:z<p?z<b?z:b:p<b?p:b;d=k>o?k>u?k>d?k:d:u>d?u:d:o>u?o>d?o:d:u>d?u:d;e=m>z?m>p?m>e?m:e:p>e?p:e:z>p?z>e?z:e:p>e?p:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=c<k.getLeft()?c:k.getLeft();b=b<k.getTop()?b:k.getTop();d=d>k.getRight()?
d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d<k.getRight()?d:k.getRight();e=e<k.getBottom()?e:k.getBottom();a()};this.instersects=function(k){return Math.min(d,k.getRight())-Math.max(c,k.getLeft())>=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}};
21
THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
THREE.Matrix4=function(a,c,b,d,e,g,h,j,k,m,o,z,u,p,A,D){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,m||0,o||1,z||0,u||0,p||0,A||0,D||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,m,o,z,u,p,A,D){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=m;this.n33=o;this.n34=z;this.n41=u;this.n42=p;this.n43=A;this.n44=D;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__v1,
e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();d.cross(b,g).normalize();e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*e;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},
multiplyVector3OnlyZ:function(a){var c=a.x,b=a.y;a=a.z;return(this.n31*c+this.n32*b+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*b+this.n43*a+this.n44))},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+
this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,o=a.n31,z=a.n32,u=a.n33,p=a.n34,A=a.n41,D=a.n42,F=a.n43,w=a.n44,H=c.n11,x=c.n12,Q=c.n13,M=c.n14,X=c.n21,L=c.n22,f=c.n23,T=c.n24,R=c.n31,$=c.n32,ca=c.n33,J=c.n34;this.n11=b*H+d*X+e*R;this.n12=b*x+d*L+e*$;this.n13=b*
Q+d*f+e*ca;this.n14=b*M+d*T+e*J+g;this.n21=h*H+j*X+k*R;this.n22=h*x+j*L+k*$;this.n23=h*Q+j*f+k*ca;this.n24=h*M+j*T+k*J+m;this.n31=o*H+z*X+u*R;this.n32=o*x+z*L+u*$;this.n33=o*Q+z*f+u*ca;this.n34=o*M+z*T+u*J+p;this.n41=A*H+D*X+F*R;this.n42=A*x+D*L+F*$;this.n43=A*Q+D*f+F*ca;this.n44=A*M+D*T+F*J+w;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=
this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24,
k=this.n31,m=this.n32,o=this.n33,z=this.n34,u=this.n41,p=this.n42,A=this.n43,D=this.n44;return d*h*m*u-b*j*m*u-d*g*o*u+c*j*o*u+b*g*z*u-c*h*z*u-d*h*k*p+b*j*k*p+d*e*o*p-a*j*o*p-b*e*z*p+a*h*z*p+d*g*k*A-c*j*k*A-d*e*m*A+a*j*m*A+c*e*z*A-a*g*z*A-b*g*k*D+c*h*k*D+b*e*m*D-a*h*m*D-c*e*o*D+a*g*o*D},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;
this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;
this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;
return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=
Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,j=a.z,k=e*g,m=e*h;this.set(k*g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,m*h+b,m*j-d*g,0,k*j-d*h,m*j+d*g,e*j*j+b,0,0,0,0,1);return this},
setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,j=d+d;a=c*g;var k=c*h;c*=j;var m=b*h;
b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(m+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;this.n11=
a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,o=a.n31,z=a.n32,u=a.n33,p=a.n34,A=a.n41,D=a.n42,F=a.n43,w=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*p*D-m*u*D+m*z*F-j*p*F-k*z*w+j*u*w;c.n12=g*u*D-e*p*D-g*z*F+d*p*F+e*z*w-d*u*w;c.n13=e*m*D-g*k*D+g*j*F-d*m*F-e*j*w+d*k*w;c.n14=g*k*z-e*m*z-g*j*u+d*m*u+e*j*p-d*k*p;c.n21=m*u*A-k*p*A-m*o*F+h*p*F+k*o*w-h*u*w;c.n22=e*p*A-g*u*A+g*o*F-b*p*F-e*o*w+b*u*w;c.n23=g*k*A-e*m*A-g*h*F+b*m*F+e*h*w-b*k*w;
c.n24=e*m*o-g*k*o+g*h*u-b*m*u-e*h*p+b*k*p;c.n31=j*p*A-m*z*A+m*o*D-h*p*D-j*o*w+h*z*w;c.n32=g*z*A-d*p*A-g*o*D+b*p*D+d*o*w-b*z*w;c.n33=e*m*A-g*j*A+g*h*D-b*m*D-d*h*w+b*j*w;c.n34=g*j*o-d*m*o-g*h*z+b*m*z+d*h*p-b*j*p;c.n41=k*z*A-j*u*A-k*o*D+h*u*D+j*o*F-h*z*F;c.n42=d*u*A-e*z*A+e*o*D-b*u*D-d*o*F+b*z*F;c.n43=e*j*A-d*k*A-e*h*D+b*k*D+d*h*F-b*j*F;c.n44=d*k*o-e*j*o+e*h*z-b*k*z-d*h*u+b*j*u;c.multiplyScalar(1/a.determinant());return c};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,z=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*m;b[7]=a*o;b[8]=a*z;return c};
THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)};
THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,j,k,m;h=new THREE.Matrix4;j=c-a;k=b-d;m=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
42 43 44 45 46
THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
!0};
THREE.Object3D.prototype={lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,1)}},
updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,
this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,c,b)}}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==undefined?d:1)};
47 48 49 50
THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,e=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(b);b=Math.sin(b);var h=a*c,j=d*e;this.w=h*g-j*b;this.x=h*b+j*g;this.y=d*c*g+a*e*b;this.z=a*e*g-d*c*b;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,e=this.w,g=a.x,h=a.y,j=a.z;a=a.w;this.x=c*a+e*g+b*j-d*h;this.y=b*a+e*h+d*g-c*j;this.z=d*a+e*j+c*h-b*g;this.w=e*a-c*g-b*h-d*j;return this},
multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j=this.z,k=this.w,m=k*b+h*e-j*d,o=k*d+j*b-g*e,z=k*e+g*d-h*b;b=-g*b-h*d-j*e;c.x=m*k+b*-g+o*-j-z*-h;c.y=o*k+b*-h+z*-g-m*-j;c.z=z*k+b*-j+m*-h-o*-g;return c}};
THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};
51
THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
52
THREE.Face3=function(a,c,b,d,e){this.a=a;this.b=c;this.c=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};
53 54
THREE.UV=function(a,c){this.set(a||0,c||0)};THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];b.centroid.set(0,0,0);if(b instanceof THREE.Face3){b.centroid.addSelf(this.vertices[b.a].position);b.centroid.addSelf(this.vertices[b.b].position);b.centroid.addSelf(this.vertices[b.c].position);b.centroid.divideScalar(3)}else if(b instanceof THREE.Face4){b.centroid.addSelf(this.vertices[b.a].position);b.centroid.addSelf(this.vertices[b.b].position);b.centroid.addSelf(this.vertices[b.c].position);
55
b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,e,g,h,j=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){j.set(0,0,0);c=0;for(b=g.normal.length;c<b;c++)j.addSelf(g.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];j.sub(h.position,
56 57
b.position);k.sub(c.position,b.position);j.crossSelf(k)}j.isZero()||j.normalize();g.normal.copy(j)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)d[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(b instanceof THREE.Face4)b.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)d[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal)}else if(b instanceof THREE.Face4){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal);d[b.d].addSelf(b.normal)}}a=0;for(c=this.vertices.length;a<c;a++)d[a].normalize();a=0;for(c=this.faces.length;a<
58 59 60 61
c;a++){b=this.faces[a];if(b instanceof THREE.Face3){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c]);b.vertexNormals[3].copy(d[b.d])}}},computeTangents:function(){function a(J,aa,ua,Y,oa,ia,da){g=J.vertices[aa].position;h=J.vertices[ua].position;j=J.vertices[Y].position;k=e[oa];m=e[ia];o=e[da];z=h.x-g.x;u=j.x-g.x;p=h.y-g.y;
A=j.y-g.y;D=h.z-g.z;F=j.z-g.z;w=m.u-k.u;H=o.u-k.u;x=m.v-k.v;Q=o.v-k.v;M=1/(w*Q-H*x);f.set((Q*z-x*u)*M,(Q*p-x*A)*M,(Q*D-x*F)*M);T.set((w*u-H*z)*M,(w*A-H*p)*M,(w*F-H*D)*M);X[aa].addSelf(f);X[ua].addSelf(f);X[Y].addSelf(f);L[aa].addSelf(T);L[ua].addSelf(T);L[Y].addSelf(T)}var c,b,d,e,g,h,j,k,m,o,z,u,p,A,D,F,w,H,x,Q,M,X=[],L=[],f=new THREE.Vector3,T=new THREE.Vector3,R=new THREE.Vector3,$=new THREE.Vector3,ca=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){X[c]=new THREE.Vector3;L[c]=new THREE.Vector3}c=
0;for(b=this.faces.length;c<b;c++){d=this.faces[c];e=this.uvs[c];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);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,0,1,2);a(this,d.a,d.b,d.d,0,1,3);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])}}c=0;for(b=this.vertices.length;c<b;c++){ca.copy(this.vertices[c].normal);d=X[c];R.copy(d);R.subSelf(ca.multiplyScalar(ca.dot(d))).normalize();$.cross(this.vertices[c].normal,d);d=$.dot(L[c]);d=d<0?-1:1;this.vertices[c].tangent.set(R.x,R.y,R.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
62 63
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
64 65 66 67
THREE.Spline=function(){function a(u,p,A,D,F,w,H){u=(A-u)*0.5;D=(D-p)*0.5;return(2*(p-A)+u+D)*H+(-3*(p-A)-2*u-D)*w+u*F+p}var c=[],b={x:0,y:0,z:0},d,e,g,h,j,k,m,o,z;this.get2DPoint=function(u,p){d=(u.length-1)*p;e=Math.floor(d);g=d-e;c[0]=e==0?e:e-1;c[1]=e;c[2]=e>u.length-2?e:e+1;c[3]=e>u.length-3?e:e+2;k=u[c[0]];m=u[c[1]];o=u[c[2]];z=u[c[3]];h=g*g;j=g*h;b.x=a(k.x,m.x,o.x,z.x,g,h,j);b.y=a(k.y,m.y,o.y,z.y,g,h,j);b.z=a(k.z,m.z,o.z,z.z,g,h,j);return b}};
THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;g<a.length;g++)a[g].update(e)};b.addToUpdate=function(e){a.indexOf(e)===-1&&a.push(e)};b.removeFromUpdate=function(e){e=a.indexOf(e);e!==-1&&a.splice(e,1)};b.add=function(e){c[e.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+e.name+" already exists in library. Overwriting.");c[e.name]=e;if(e.initialized!==!0){e.length=parseInt(e.length*1E3,10);e.fps*=0.0010;for(var g=0;g<e.hierarchy.length;g++)for(var h=
0;h<e.hierarchy[g].keys.length;h++){if(e.hierarchy[g].keys[h].time<0)e.hierarchy[g].keys[h].time=0;e.hierarchy[g].keys[h].time=parseInt(e.hierarchy[g].keys[h].time*1E3,10);e.hierarchy[g].keys[h].index=h;if(e.hierarchy[g].keys[h].rot!==undefined&&!(e.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var j=e.hierarchy[g].keys[h].rot;e.hierarchy[g].keys[h].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}h=parseInt(e.length*e.fps*0.0010,10);e.JIT={};e.JIT.hierarchy=[];for(g=0;g<e.hierarchy.length;g++)e.JIT.hierarchy.push(Array(h));
e.initialized=!0}};b.get=function(e){if(typeof e==="string")if(c[e])return c[e];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+e);return null}};b.parse=function(e){var g=[];if(e instanceof THREE.SkinnedMesh)for(var h=0;h<e.bones.length;h++)g.push(e.bones[h]);else d(e,g);return g};var d=function(e,g){g.push(e);for(var h=0;h<e.children.length;h++)d(e.children[h],g)};b.LINEAR=0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=2;return b}();
68 69
THREE.Animation=function(a,c,b,d){this.root=a;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=b!==undefined?b:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==undefined?d:!0};
THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;for(var b=0;b<this.hierarchy.length;b++){this.hierarchy[b].useQuaternion=!0;this.hierarchy[b].matrixAutoUpdate=!0;if(this.hierarchy[b].animationCache===undefined){this.hierarchy[b].animationCache={};this.hierarchy[b].animationCache.prevKey={pos:0,rot:0,scl:0};this.hierarchy[b].animationCache.nextKey={pos:0,rot:0,scl:0};this.hierarchy[b].animationCache.originalMatrix=
70
this.hierarchy[b]instanceof THREE.Bone?this.hierarchy[b].skinMatrix:this.hierarchy[b].matrix}var d=this.hierarchy[b].animationCache.prevKey,e=this.hierarchy[b].animationCache.nextKey;d.pos=this.data.hierarchy[b].keys[0];d.rot=this.data.hierarchy[b].keys[0];d.scl=this.data.hierarchy[b].keys[0];e.pos=this.getNextKeyWith("pos",b,1);e.rot=this.getNextKeyWith("rot",b,1);e.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
M
Mr.doob 已提交
71 72
THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
73 74 75 76 77 78
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,j,k,m,o=this.data.JIT.hierarchy,z,u;this.currentTime+=a;u=this.currentTime;z=this.currentTime%=this.data.length;m=parseInt(Math.min(z*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,A=this.hierarchy.length;p<A;p++){a=this.hierarchy[p];k=a.animationCache;if(o[p][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=o[p][m];a.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,p*16);
a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!1}else{a.matrix=o[p][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var D=0;D<3;D++){b=c[D];h=k.prevKey[b];j=k.nextKey[b];if(j.time<u){if(z<u)if(this.loop){h=this.data.hierarchy[p].keys[0];j=this.getNextKeyWith(b,p,1)}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(b,p,j.index+1)}while(j.time<z)}k.prevKey[b]=
h;k.nextKey[b]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(z-h.time)/(j.time-h.time);e=h[b];g=j[b];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else{var F=[];F[0]=this.getPrevKeyWith(b,p,h.index-1)[b];F[1]=e;F[2]=g;F[3]=this.getNextKeyWith(b,p,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(F,
d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}else if(b==="rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&o[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;p<this.hierarchy.length;p++)o[p][m]=this.hierarchy[p]instanceof THREE.Bone?this.hierarchy[p].skinMatrix.clone():this.hierarchy[p].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],e,g,h,j,k,m;e=(a.length-1)*c;g=Math.floor(e);e-=g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>a.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];j=a[b[1]];k=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],m[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],m[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],m[2],e,b,h);return d};
THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b%=d.length;b<d.length;b++)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[0]};
79
THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b=b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]};
80
THREE.Camera=function(a,c,b,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix();var g=new THREE.Vector3;this.translateX=function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);g.crossSelf(this.up);if(j)g.y=0;this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=
81 82 83
function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);if(j)g.y=0;this.position.subSelf(g);this.target.position.subSelf(g)}};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
THREE.Camera.prototype.update=function(a,c,b){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
!1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};
84
THREE.QuakeCamera=function(a){function c(b,d){return function(){d.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==
85
undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phy=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=
86 87
!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};
this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?
88
this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor),this.noFly);this.moveBackward&&this.translateZ(this.movementSpeed,this.noFly);this.moveLeft&&this.translateX(-this.movementSpeed,this.noFly);this.moveRight&&this.translateX(this.movementSpeed,this.noFly);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);
89 90 91 92
this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",
c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;
THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};
A
alteredq 已提交
93
THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;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.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=
a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=
a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=
this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;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.opacity!==undefined)this.opacity=a.opacity;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.map!==undefined)this.map=a.map;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==
undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==
undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;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;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;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;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==undefined)this.vertexShader=
a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;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.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==
undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;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}};
115
THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,c,b,d,e,g){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrapS=b!==undefined?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};
116
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
117
THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
118
THREE.RenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==undefined?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==undefined?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==undefined?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==undefined?b.minFilter:THREE.LinearMipMapLinearFilter;this.format=b.format!==undefined?b.format:THREE.RGBFormat;this.type=b.type!==undefined?b.type:THREE.UnsignedByteType};
119
var Uniforms={clone:function(a){var c,b,d,e={};for(c in a){e[c]={};for(b in a[c]){d=a[c][b];e[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return e},merge:function(a){var c,b,d,e={};for(c=0;c<a.length;c++){d=this.clone(a[c]);for(b in d)e[b]=d[b]}return e}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
120 121
THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,b){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=b!=undefined?b:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c&&c.length?c:[c];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
122
THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
123
THREE.Bone.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,c,b):a.update(this.matrixWorld,!0,b)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
124
c,b)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
125 126 127
THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,d,e,g,h,j;if(this.geometry.bones!==undefined){for(b=0;b<this.geometry.bones.length;b++){e=this.geometry.bones[b];g=e.pos;h=e.rotq;j=e.scl;d=this.addBone();d.name=e.name;d.position.set(g[0],g[1],g[2]);d.quaternion.set(h[0],h[1],h[2],h[3]);j!==undefined?d.scale.set(j[0],j[1],j[2]):d.scale.set(1,1,1)}for(b=0;b<this.bones.length;b++){e=this.geometry.bones[b];d=this.bones[b];
e.parent===-1?this.addChild(d):this.bones[e.parent].addChild(d)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
THREE.SkinnedMesh.prototype.update=function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,e=this.children.length;for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,b):a.update(this.matrixWorld,c,b)}}};
128
THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
129 130
THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];c.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var d;for(a=0;a<this.geometry.skinIndices.length;a++){b=this.geometry.vertices[a].position;var e=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[e].multiplyVector3(d));d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[g].multiplyVector3(d));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){b=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=b;this.geometry.skinWeights[a].y+=b}}}};
131
THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
132 133
THREE.Sound=function(a,c,b,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=c!==undefined?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,b!==undefined?b:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;b=this.sources.length;for(a=0;a<b;a++){c=this.sources[a];c.toLowerCase();if(c.indexOf(".mp3")!==-1)e=
"audio/mpeg";else if(c.indexOf(".ogg")!==-1)e="audio/ogg";else c.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
M
Mr.doob 已提交
134 135
THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
136
THREE.Sound.prototype.update=function(a,c,b){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);c=!0}if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
137
THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(a,c){c===undefined&&(c=0);c=Math.abs(c);for(var b=0;b<this.LODs.length;b++)if(c<this.LODs[b].visibleAtDistance)break;this.LODs.splice(b,0,{visibleAtDistance:c,object3D:a});this.addChild(a)};
138 139
THREE.LOD.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}if(this.LODs.length>1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d<this.LODs.length;d++)if(a>=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible=
!1;this.LODs[d].object3D.visible=!0}else break;for(;d<this.LODs.length;d++)this.LODs[d].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
140 141 142
THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var c=0;c<a.children.length;c++)this.addChildRecurse(a.children[c])};
THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else if(a instanceof THREE.Sound){c=this.sounds.indexOf(a);c!==-1&&this.sounds.splice(c,1)}else if(!(a instanceof THREE.Camera)){c=this.objects.indexOf(a);if(c!==-1){this.objects.splice(c,1);this.__objectsRemoved.push(a)}}for(c=0;c<a.children.length;c++)this.removeChildRecurse(a.children[c])};
THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c||1;this.far=b||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
THREE.Projector=function(){function a(L,f){return f.z-L.z}function c(L,f){var T=0,R=1,$=L.z+L.w,ca=f.z+f.w,J=-L.z+L.w,aa=-f.z+f.w;if($>=0&&ca>=0&&J>=0&&aa>=0)return!0;else if($<0&&ca<0||J<0&&aa<0)return!1;else{if($<0)T=Math.max(T,$/($-ca));else ca<0&&(R=Math.min(R,$/($-ca)));if(J<0)T=Math.max(T,J/(J-aa));else aa<0&&(R=Math.min(R,J/(J-aa)));if(R<T)return!1;else{L.lerpSelf(f,T);f.lerpSelf(L,1-R);return!0}}}var b,d,e=[],g,h,j,k=[],m,o,z=[],u,p,A=[],D=new THREE.Vector4,F=new THREE.Vector4,w=new THREE.Matrix4,
H=new THREE.Matrix4,x=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Q=new THREE.Vector4,M=new THREE.Vector4,X;this.projectObjects=function(L,f,T){f=[];var R,$,ca;d=0;$=L.objects;L=0;for(R=$.length;L<R;L++){ca=$[L];var J;if(!(J=!ca.visible))if(J=ca instanceof THREE.Mesh){a:{J=void 0;for(var aa=ca.matrixWorld,ua=-ca.geometry.boundingSphere.radius*Math.max(ca.scale.x,Math.max(ca.scale.y,ca.scale.z)),Y=0;Y<6;Y++){J=x[Y].x*aa.n14+x[Y].y*aa.n24+
x[Y].z*aa.n34+x[Y].w;if(J<=ua){J=!1;break a}}J=!0}J=!J}if(!J){b=e[d]=e[d]||new THREE.RenderableObject;D.copy(ca.position);w.multiplyVector3(D);b.object=ca;b.z=D.z;f.push(b);d++}}T&&f.sort(a);return f};this.projectScene=function(L,f,T){var R=[],$=f.near,ca=f.far,J,aa,ua,Y,oa,ia,da,pa,ya,ea,Z,l,y,v,n,q;j=o=p=0;f.matrixAutoUpdate&&f.update();w.multiply(f.projectionMatrix,f.matrixWorldInverse);x[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);x[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+
w.n14);x[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);x[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);x[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-w.n33,w.n44-w.n34);x[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(J=0;J<6;J++){ia=x[J];ia.divideScalar(Math.sqrt(ia.x*ia.x+ia.y*ia.y+ia.z*ia.z))}L.update(undefined,!1,f);ia=this.projectObjects(L,f,!0);L=0;for(J=ia.length;L<J;L++){da=ia[L].object;if(da.visible){pa=da.matrixWorld;Z=da.matrixRotationWorld;ya=da.materials;ea=da.overdraw;
if(da instanceof THREE.Mesh){l=da.geometry;y=l.vertices;aa=0;for(ua=y.length;aa<ua;aa++){v=y[aa];v.positionWorld.copy(v.position);pa.multiplyVector3(v.positionWorld);Y=v.positionScreen;Y.copy(v.positionWorld);w.multiplyVector4(Y);Y.x/=Y.w;Y.y/=Y.w;v.__visible=Y.z>$&&Y.z<ca}l=l.faces;aa=0;for(ua=l.length;aa<ua;aa++){v=l[aa];if(v instanceof THREE.Face3){Y=y[v.a];oa=y[v.b];n=y[v.c];if(Y.__visible&&oa.__visible&&n.__visible&&(da.doubleSided||da.flipSided!=(n.positionScreen.x-Y.positionScreen.x)*(oa.positionScreen.y-
Y.positionScreen.y)-(n.positionScreen.y-Y.positionScreen.y)*(oa.positionScreen.x-Y.positionScreen.x)<0)){g=k[j]=k[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Y.positionWorld);g.v2.positionWorld.copy(oa.positionWorld);g.v3.positionWorld.copy(n.positionWorld);g.v1.positionScreen.copy(Y.positionScreen);g.v2.positionScreen.copy(oa.positionScreen);g.v3.positionScreen.copy(n.positionScreen);g.normalWorld.copy(v.normal);Z.multiplyVector3(g.normalWorld);g.centroidWorld.copy(v.centroid);pa.multiplyVector3(g.centroidWorld);
g.centroidScreen.copy(g.centroidWorld);w.multiplyVector3(g.centroidScreen);n=v.vertexNormals;X=g.vertexNormalsWorld;Y=0;for(oa=n.length;Y<oa;Y++){q=X[Y]=X[Y]||new THREE.Vector3;q.copy(n[Y]);Z.multiplyVector3(q)}g.z=g.centroidScreen.z;g.meshMaterials=ya;g.faceMaterials=v.materials;g.overdraw=ea;if(da.geometry.uvs[aa]){g.uvs[0]=da.geometry.uvs[aa][0];g.uvs[1]=da.geometry.uvs[aa][1];g.uvs[2]=da.geometry.uvs[aa][2]}R.push(g);j++}}else if(v instanceof THREE.Face4){Y=y[v.a];oa=y[v.b];n=y[v.c];q=y[v.d];
if(Y.__visible&&oa.__visible&&n.__visible&&q.__visible&&(da.doubleSided||da.flipSided!=((q.positionScreen.x-Y.positionScreen.x)*(oa.positionScreen.y-Y.positionScreen.y)-(q.positionScreen.y-Y.positionScreen.y)*(oa.positionScreen.x-Y.positionScreen.x)<0||(oa.positionScreen.x-n.positionScreen.x)*(q.positionScreen.y-n.positionScreen.y)-(oa.positionScreen.y-n.positionScreen.y)*(q.positionScreen.x-n.positionScreen.x)<0))){g=k[j]=k[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Y.positionWorld);g.v2.positionWorld.copy(oa.positionWorld);
g.v3.positionWorld.copy(q.positionWorld);g.v1.positionScreen.copy(Y.positionScreen);g.v2.positionScreen.copy(oa.positionScreen);g.v3.positionScreen.copy(q.positionScreen);g.normalWorld.copy(v.normal);Z.multiplyVector3(g.normalWorld);g.centroidWorld.copy(v.centroid);pa.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);w.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=ya;g.faceMaterials=v.materials;g.overdraw=ea;if(da.geometry.uvs[aa]){g.uvs[0]=da.geometry.uvs[aa][0];
g.uvs[1]=da.geometry.uvs[aa][1];g.uvs[2]=da.geometry.uvs[aa][3]}R.push(g);j++;h=k[j]=k[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(oa.positionWorld);h.v2.positionWorld.copy(n.positionWorld);h.v3.positionWorld.copy(q.positionWorld);h.v1.positionScreen.copy(oa.positionScreen);h.v2.positionScreen.copy(n.positionScreen);h.v3.positionScreen.copy(q.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=h.centroidScreen.z;
h.meshMaterials=ya;h.faceMaterials=v.materials;h.overdraw=ea;if(da.geometry.uvs[aa]){h.uvs[0]=da.geometry.uvs[aa][1];h.uvs[1]=da.geometry.uvs[aa][2];h.uvs[2]=da.geometry.uvs[aa][3]}R.push(h);j++}}}}else if(da instanceof THREE.Line){H.multiply(w,pa);y=da.geometry.vertices;v=y[0];v.positionScreen.copy(v.position);H.multiplyVector4(v.positionScreen);aa=1;for(ua=y.length;aa<ua;aa++){Y=y[aa];Y.positionScreen.copy(Y.position);H.multiplyVector4(Y.positionScreen);oa=y[aa-1];Q.copy(Y.positionScreen);M.copy(oa.positionScreen);
if(c(Q,M)){Q.multiplyScalar(1/Q.w);M.multiplyScalar(1/M.w);m=z[o]=z[o]||new THREE.RenderableLine;m.v1.positionScreen.copy(Q);m.v2.positionScreen.copy(M);m.z=Math.max(Q.z,M.z);m.materials=da.materials;R.push(m);o++}}}else if(da instanceof THREE.Particle){F.set(da.position.x,da.position.y,da.position.z,1);w.multiplyVector4(F);F.z/=F.w;if(F.z>0&&F.z<1){u=A[p]=A[p]||new THREE.RenderableParticle;u.x=F.x/F.w;u.y=F.y/F.w;u.z=F.z;u.rotation=da.rotation.z;u.scale.x=da.scale.x*Math.abs(u.x-(F.x+f.projectionMatrix.n11)/
(F.w+f.projectionMatrix.n14));u.scale.y=da.scale.y*Math.abs(u.y-(F.y+f.projectionMatrix.n22)/(F.w+f.projectionMatrix.n24));u.materials=da.materials;R.push(u);p++}}}}T&&R.sort(a);return R};this.unprojectVector=function(L,f){var T=f.matrixWorld.clone();T.multiplySelf(THREE.Matrix4.makeInvert(f.projectionMatrix));T.multiplyVector3(L);return L}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,m,o,z,u,p,A,D;a=c.projectScene(h,j);k=0;for(m=a.length;k<m;k++){u=a[k];if(u instanceof THREE.RenderableParticle){A=u.x*e+e;D=u.y*g+g;o=0;for(z=u.material.length;o<z;o++){p=u.material[o];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=A+"px";p.style.top=D+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ra){if(u!=ra)m.globalAlpha=u=ra}function c(ra){if(p!=ra){switch(ra){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=ra}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,j,k,m=e.getContext("2d"),o=new THREE.Color(0),z=0,u=1,p=0,A=null,D=null,F=1,w,H,x,Q,M,X,L,f,T,R=new THREE.Color,
$=new THREE.Color,ca=new THREE.Color,J=new THREE.Color,aa=new THREE.Color,ua,Y,oa,ia,da,pa,ya,ea,Z,l=new THREE.Rectangle,y=new THREE.Rectangle,v=new THREE.Rectangle,n=!1,q=new THREE.Color,K=new THREE.Color,G=new THREE.Color,t=new THREE.Color,C=Math.PI*2,B=new THREE.Vector3,E,S,na,ga,ja,ma,la=16;E=document.createElement("canvas");E.width=E.height=2;S=E.getContext("2d");S.fillStyle="rgba(0,0,0,1)";S.fillRect(0,0,2,2);na=S.getImageData(0,0,2,2);ga=na.data;ja=document.createElement("canvas");ja.width=
ja.height=la;ma=ja.getContext("2d");ma.translate(-la/2,-la/2);ma.scale(la,la);la--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ra,N){g=ra;h=N;j=g/2;k=h/2;e.width=g;e.height=h;l.set(-j,-k,j,k);u=1;p=0;D=A=null;F=1};this.setClearColor=function(ra,N){o=ra;z=N};this.setClearColorHex=function(ra,N){o.setHex(ra);z=N};this.clear=function(){m.setTransform(1,0,0,-1,j,k);if(!y.isEmpty()){y.inflate(1);y.minSelf(l);if(o.hex==0&&z==0)m.clearRect(y.getX(),
y.getY(),y.getWidth(),y.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+z+")";m.fillRect(y.getX(),y.getY(),y.getWidth(),y.getHeight())}y.empty()}};this.render=function(ra,N){function Ha(O){var fa,ha,P,ba=O.lights;K.setRGB(0,0,0);G.setRGB(0,0,0);t.setRGB(0,0,0);O=0;for(fa=ba.length;O<fa;O++){ha=ba[O];P=ha.color;if(ha instanceof THREE.AmbientLight){K.r+=P.r;K.g+=P.g;K.b+=P.b}else if(ha instanceof THREE.DirectionalLight){G.r+=
P.r;G.g+=P.g;G.b+=P.b}else if(ha instanceof THREE.PointLight){t.r+=P.r;t.g+=P.g;t.b+=P.b}}}function Ea(O,fa,ha,P){var ba,qa,Aa,Ga,Ia=O.lights;O=0;for(ba=Ia.length;O<ba;O++){qa=Ia[O];Aa=qa.color;Ga=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ha.dot(qa.position)*Ga;if(qa>0){P.r+=Aa.r*qa;P.g+=Aa.g*qa;P.b+=Aa.b*qa}}else if(qa instanceof THREE.PointLight){B.sub(qa.position,fa);B.normalize();qa=ha.dot(B)*Ga;if(qa>0){P.r+=Aa.r*qa;P.g+=Aa.g*qa;P.b+=Aa.b*qa}}}}function Ja(O,fa,ha){if(ha.opacity!=
0){a(ha.opacity);c(ha.blending);var P,ba,qa,Aa,Ga,Ia;if(ha instanceof THREE.ParticleBasicMaterial){if(ha.map){Aa=ha.map.image;Ga=Aa.width>>1;Ia=Aa.height>>1;ba=fa.scale.x*j;qa=fa.scale.y*k;ha=ba*Ga;P=qa*Ia;v.set(O.x-ha,O.y-P,O.x+ha,O.y+P);if(l.instersects(v)){m.save();m.translate(O.x,O.y);m.rotate(-fa.rotation);m.scale(ba,-qa);m.translate(-Ga,-Ia);m.drawImage(Aa,0,0);m.restore()}}}else if(ha instanceof THREE.ParticleCircleMaterial){if(n){q.r=K.r+G.r+t.r;q.g=K.g+G.g+t.g;q.b=K.b+G.b+t.b;R.r=ha.color.r*
q.r;R.g=ha.color.g*q.g;R.b=ha.color.b*q.b;R.updateStyleString()}else R.__styleString=ha.color.__styleString;ha=fa.scale.x*j;P=fa.scale.y*k;v.set(O.x-ha,O.y-P,O.x+ha,O.y+P);if(l.instersects(v)){ba=R.__styleString;if(D!=ba)m.fillStyle=D=ba;m.save();m.translate(O.x,O.y);m.rotate(-fa.rotation);m.scale(ha,P);m.beginPath();m.arc(0,0,1,0,C,!0);m.closePath();m.fill();m.restore()}}}}function U(O,fa,ha,P){if(P.opacity!=0){a(P.opacity);c(P.blending);m.beginPath();m.moveTo(O.positionScreen.x,O.positionScreen.y);
m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(P instanceof THREE.LineBasicMaterial){R.__styleString=P.color.__styleString;O=P.linewidth;if(F!=O)m.lineWidth=F=O;O=R.__styleString;if(A!=O)m.strokeStyle=A=O;m.stroke();v.inflate(P.linewidth*2)}}}function V(O,fa,ha,P,ba,qa){if(ba.opacity!=0){a(ba.opacity);c(ba.blending);Q=O.positionScreen.x;M=O.positionScreen.y;X=fa.positionScreen.x;L=fa.positionScreen.y;f=ha.positionScreen.x;T=ha.positionScreen.y;m.beginPath();m.moveTo(Q,M);m.lineTo(X,
L);m.lineTo(f,T);m.lineTo(Q,M);m.closePath();if(ba instanceof THREE.MeshBasicMaterial)if(ba.map)ba.map.mapping instanceof THREE.UVMapping&&Fa(Q,M,X,L,f,T,ba.map.image,P.uvs[0].u,P.uvs[0].v,P.uvs[1].u,P.uvs[1].v,P.uvs[2].u,P.uvs[2].v);else if(ba.envMap){if(ba.envMap.mapping instanceof THREE.SphericalReflectionMapping){O=N.matrixWorldInverse;B.copy(P.vertexNormalsWorld[0]);ia=(B.x*O.n11+B.y*O.n12+B.z*O.n13)*0.5+0.5;da=-(B.x*O.n21+B.y*O.n22+B.z*O.n23)*0.5+0.5;B.copy(P.vertexNormalsWorld[1]);pa=(B.x*
O.n11+B.y*O.n12+B.z*O.n13)*0.5+0.5;ya=-(B.x*O.n21+B.y*O.n22+B.z*O.n23)*0.5+0.5;B.copy(P.vertexNormalsWorld[2]);ea=(B.x*O.n11+B.y*O.n12+B.z*O.n13)*0.5+0.5;Z=-(B.x*O.n21+B.y*O.n22+B.z*O.n23)*0.5+0.5;Fa(Q,M,X,L,f,T,ba.envMap.image,ia,da,pa,ya,ea,Z)}}else ba.wireframe?W(ba.color.__styleString,ba.wireframeLinewidth):sa(ba.color.__styleString);else if(ba instanceof THREE.MeshLambertMaterial){if(ba.map&&!ba.wireframe){ba.map.mapping instanceof THREE.UVMapping&&Fa(Q,M,X,L,f,T,ba.map.image,P.uvs[0].u,P.uvs[0].v,
P.uvs[1].u,P.uvs[1].v,P.uvs[2].u,P.uvs[2].v);c(THREE.SubtractiveBlending)}if(n)if(!ba.wireframe&&ba.shading==THREE.SmoothShading&&P.vertexNormalsWorld.length==3){$.r=ca.r=J.r=K.r;$.g=ca.g=J.g=K.g;$.b=ca.b=J.b=K.b;Ea(qa,P.v1.positionWorld,P.vertexNormalsWorld[0],$);Ea(qa,P.v2.positionWorld,P.vertexNormalsWorld[1],ca);Ea(qa,P.v3.positionWorld,P.vertexNormalsWorld[2],J);aa.r=(ca.r+J.r)*0.5;aa.g=(ca.g+J.g)*0.5;aa.b=(ca.b+J.b)*0.5;oa=Ca($,ca,J,aa);Fa(Q,M,X,L,f,T,oa,0,0,1,0,0,1)}else{q.r=K.r;q.g=K.g;q.b=
K.b;Ea(qa,P.centroidWorld,P.normalWorld,q);R.r=ba.color.r*q.r;R.g=ba.color.g*q.g;R.b=ba.color.b*q.b;R.updateStyleString();ba.wireframe?W(R.__styleString,ba.wireframeLinewidth):sa(R.__styleString)}else ba.wireframe?W(ba.color.__styleString,ba.wireframeLinewidth):sa(ba.color.__styleString)}else if(ba instanceof THREE.MeshDepthMaterial){ua=N.near;Y=N.far;$.r=$.g=$.b=1-I(O.positionScreen.z,ua,Y);ca.r=ca.g=ca.b=1-I(fa.positionScreen.z,ua,Y);J.r=J.g=J.b=1-I(ha.positionScreen.z,ua,Y);aa.r=(ca.r+J.r)*0.5;
aa.g=(ca.g+J.g)*0.5;aa.b=(ca.b+J.b)*0.5;oa=Ca($,ca,J,aa);Fa(Q,M,X,L,f,T,oa,0,0,1,0,0,1)}else if(ba instanceof THREE.MeshNormalMaterial){R.r=Da(P.normalWorld.x);R.g=Da(P.normalWorld.y);R.b=Da(P.normalWorld.z);R.updateStyleString();ba.wireframe?W(R.__styleString,ba.wireframeLinewidth):sa(R.__styleString)}}}function W(O,fa){if(A!=O)m.strokeStyle=A=O;if(F!=fa)m.lineWidth=F=fa;m.stroke();v.inflate(fa*2)}function sa(O){if(D!=O)m.fillStyle=D=O;m.fill()}function Fa(O,fa,ha,P,ba,qa,Aa,Ga,Ia,La,Ba,Ma,Ta){var Na,
Oa;Na=Aa.width-1;Oa=Aa.height-1;Ga*=Na;Ia*=Oa;La*=Na;Ba*=Oa;Ma*=Na;Ta*=Oa;ha-=O;P-=fa;ba-=O;qa-=fa;La-=Ga;Ba-=Ia;Ma-=Ga;Ta-=Ia;Na=La*Ta-Ma*Ba;if(Na!=0){Oa=1/Na;Na=(Ta*ha-Ba*ba)*Oa;Ba=(Ta*P-Ba*qa)*Oa;ha=(La*ba-Ma*ha)*Oa;P=(La*qa-Ma*P)*Oa;O=O-Na*Ga-ha*Ia;fa=fa-Ba*Ga-P*Ia;m.save();m.transform(Na,Ba,ha,P,O,fa);m.clip();m.drawImage(Aa,0,0);m.restore()}}function Ca(O,fa,ha,P){var ba=~~(O.r*255),qa=~~(O.g*255);O=~~(O.b*255);var Aa=~~(fa.r*255),Ga=~~(fa.g*255);fa=~~(fa.b*255);var Ia=~~(ha.r*255),La=~~(ha.g*
255);ha=~~(ha.b*255);var Ba=~~(P.r*255),Ma=~~(P.g*255);P=~~(P.b*255);ga[0]=ba<0?0:ba>255?255:ba;ga[1]=qa<0?0:qa>255?255:qa;ga[2]=O<0?0:O>255?255:O;ga[4]=Aa<0?0:Aa>255?255:Aa;ga[5]=Ga<0?0:Ga>255?255:Ga;ga[6]=fa<0?0:fa>255?255:fa;ga[8]=Ia<0?0:Ia>255?255:Ia;ga[9]=La<0?0:La>255?255:La;ga[10]=ha<0?0:ha>255?255:ha;ga[12]=Ba<0?0:Ba>255?255:Ba;ga[13]=Ma<0?0:Ma>255?255:Ma;ga[14]=P<0?0:P>255?255:P;S.putImageData(na,0,0);ma.drawImage(E,0,0);return ja}function I(O,fa,ha){O=(O-fa)/(ha-fa);return O*O*(3-2*O)}function Da(O){O=
(O+1)*0.5;return O<0?0:O>1?1:O}function Ra(O,fa){var ha=fa.x-O.x,P=fa.y-O.y,ba=1/Math.sqrt(ha*ha+P*P);ha*=ba;P*=ba;fa.x+=ha;fa.y+=P;O.x-=ha;O.y-=P}var Pa,Ka,ka,wa,ta,xa,za,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,k);b=d.projectScene(ra,N,this.sortElements);(n=ra.lights.length>0)&&Ha(ra);Pa=0;for(Ka=b.length;Pa<Ka;Pa++){ka=b[Pa];v.empty();if(ka instanceof THREE.RenderableParticle){w=ka;w.x*=j;w.y*=k;wa=0;for(ta=ka.materials.length;wa<ta;wa++)Ja(w,ka,ka.materials[wa],ra)}else if(ka instanceof
THREE.RenderableLine){w=ka.v1;H=ka.v2;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;v.addPoint(w.positionScreen.x,w.positionScreen.y);v.addPoint(H.positionScreen.x,H.positionScreen.y);if(l.instersects(v)){wa=0;for(ta=ka.materials.length;wa<ta;)U(w,H,ka,ka.materials[wa++],ra)}}else if(ka instanceof THREE.RenderableFace3){w=ka.v1;H=ka.v2;x=ka.v3;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;x.positionScreen.x*=j;x.positionScreen.y*=
k;if(ka.overdraw){Ra(w.positionScreen,H.positionScreen);Ra(H.positionScreen,x.positionScreen);Ra(x.positionScreen,w.positionScreen)}v.add3Points(w.positionScreen.x,w.positionScreen.y,H.positionScreen.x,H.positionScreen.y,x.positionScreen.x,x.positionScreen.y);if(l.instersects(v)){wa=0;for(ta=ka.meshMaterials.length;wa<ta;){va=ka.meshMaterials[wa++];if(va instanceof THREE.MeshFaceMaterial){xa=0;for(za=ka.faceMaterials.length;xa<za;)(va=ka.faceMaterials[xa++])&&V(w,H,x,ka,va,ra)}else V(w,H,x,ka,va,
ra)}}}y.addRectangle(v)}m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(ia,da,pa){var ya,ea,Z,l;ya=0;for(ea=ia.lights.length;ya<ea;ya++){Z=ia.lights[ya];if(Z instanceof THREE.DirectionalLight){l=da.normalWorld.dot(Z.position)*Z.intensity;if(l>0){pa.r+=Z.color.r*l;pa.g+=Z.color.g*l;pa.b+=Z.color.b*l}}else if(Z instanceof THREE.PointLight){T.sub(Z.position,da.centroidWorld);T.normalize();l=da.normalWorld.dot(T)*Z.intensity;if(l>0){pa.r+=Z.color.r*l;pa.g+=Z.color.g*l;pa.b+=Z.color.b*l}}}}function c(ia,da,pa,ya,ea,Z){J=d(aa++);J.setAttribute("d",
"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+da.positionScreen.x+" "+da.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(ea instanceof THREE.MeshBasicMaterial)x.__styleString=ea.color.__styleString;else if(ea instanceof THREE.MeshLambertMaterial)if(H){Q.r=M.r;Q.g=M.g;Q.b=M.b;a(Z,ya,Q);x.r=ea.color.r*Q.r;x.g=ea.color.g*Q.g;x.b=ea.color.b*Q.b;x.updateStyleString()}else x.__styleString=ea.color.__styleString;else if(ea instanceof THREE.MeshDepthMaterial){f=1-ea.__2near/
(ea.__farPlusNear-ya.z*ea.__farMinusNear);x.setRGB(f,f,f)}else ea instanceof THREE.MeshNormalMaterial&&x.setRGB(e(ya.normalWorld.x),e(ya.normalWorld.y),e(ya.normalWorld.z));ea.wireframe?J.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+ea.wireframeLinewidth+"; stroke-opacity: "+ea.opacity+"; stroke-linecap: "+ea.wireframeLinecap+"; stroke-linejoin: "+ea.wireframeLinejoin):J.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+ea.opacity);j.appendChild(J)}
function b(ia,da,pa,ya,ea,Z,l){J=d(aa++);J.setAttribute("d","M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+da.positionScreen.x+" "+da.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+ya.positionScreen.x+","+ya.positionScreen.y+"z");if(Z instanceof THREE.MeshBasicMaterial)x.__styleString=Z.color.__styleString;else if(Z instanceof THREE.MeshLambertMaterial)if(H){Q.r=M.r;Q.g=M.g;Q.b=M.b;a(l,ea,Q);x.r=Z.color.r*Q.r;x.g=Z.color.g*Q.g;x.b=Z.color.b*Q.b;x.updateStyleString()}else x.__styleString=
Z.color.__styleString;else if(Z instanceof THREE.MeshDepthMaterial){f=1-Z.__2near/(Z.__farPlusNear-ea.z*Z.__farMinusNear);x.setRGB(f,f,f)}else Z instanceof THREE.MeshNormalMaterial&&x.setRGB(e(ea.normalWorld.x),e(ea.normalWorld.y),e(ea.normalWorld.z));Z.wireframe?J.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+Z.wireframeLinewidth+"; stroke-opacity: "+Z.opacity+"; stroke-linecap: "+Z.wireframeLinecap+"; stroke-linejoin: "+Z.wireframeLinejoin):J.setAttribute("style",
"fill: "+x.__styleString+"; fill-opacity: "+Z.opacity);j.appendChild(J)}function d(ia){if(R[ia]==null){R[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");oa==0&&R[ia].setAttribute("shape-rendering","crispEdges")}return R[ia]}function e(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,o,z,u,p,A,D,F=new THREE.Rectangle,w=new THREE.Rectangle,H=!1,x=new THREE.Color(16777215),
Q=new THREE.Color(16777215),M=new THREE.Color(0),X=new THREE.Color(0),L=new THREE.Color(0),f,T=new THREE.Vector3,R=[],$=[],ca=[],J,aa,ua,Y,oa=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ia){switch(ia){case "high":oa=1;break;case "low":oa=0}};this.setSize=function(ia,da){k=ia;m=da;o=k/2;z=m/2;j.setAttribute("viewBox",-o+" "+-z+" "+k+" "+m);j.setAttribute("width",k);j.setAttribute("height",m);F.set(-o,-z,o,z)};this.clear=function(){for(;j.childNodes.length>
0;)j.removeChild(j.childNodes[0])};this.render=function(ia,da){var pa,ya,ea,Z,l,y,v,n;this.autoClear&&this.clear();g=h.projectScene(ia,da,this.sortElements);Y=ua=aa=0;if(H=ia.lights.length>0){v=ia.lights;M.setRGB(0,0,0);X.setRGB(0,0,0);L.setRGB(0,0,0);pa=0;for(ya=v.length;pa<ya;pa++){ea=v[pa];Z=ea.color;if(ea instanceof THREE.AmbientLight){M.r+=Z.r;M.g+=Z.g;M.b+=Z.b}else if(ea instanceof THREE.DirectionalLight){X.r+=Z.r;X.g+=Z.g;X.b+=Z.b}else if(ea instanceof THREE.PointLight){L.r+=Z.r;L.g+=Z.g;L.b+=
Z.b}}}pa=0;for(ya=g.length;pa<ya;pa++){v=g[pa];w.empty();if(v instanceof THREE.RenderableParticle){u=v;u.x*=o;u.y*=-z;ea=0;for(Z=v.materials.length;ea<Z;ea++)if(n=v.materials[ea]){l=u;y=v;var q=ua++;if($[q]==null){$[q]=document.createElementNS("http://www.w3.org/2000/svg","circle");oa==0&&$[q].setAttribute("shape-rendering","crispEdges")}J=$[q];J.setAttribute("cx",l.x);J.setAttribute("cy",l.y);J.setAttribute("r",y.scale.x*o);if(n instanceof THREE.ParticleCircleMaterial){if(H){Q.r=M.r+X.r+L.r;Q.g=
M.g+X.g+L.g;Q.b=M.b+X.b+L.b;x.r=n.color.r*Q.r;x.g=n.color.g*Q.g;x.b=n.color.b*Q.b;x.updateStyleString()}else x=n.color;J.setAttribute("style","fill: "+x.__styleString)}j.appendChild(J)}}else if(v instanceof THREE.RenderableLine){u=v.v1;p=v.v2;u.positionScreen.x*=o;u.positionScreen.y*=-z;p.positionScreen.x*=o;p.positionScreen.y*=-z;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(p.positionScreen.x,p.positionScreen.y);if(F.instersects(w)){ea=0;for(Z=v.materials.length;ea<Z;)if(n=v.materials[ea++]){l=
u;y=p;q=Y++;if(ca[q]==null){ca[q]=document.createElementNS("http://www.w3.org/2000/svg","line");oa==0&&ca[q].setAttribute("shape-rendering","crispEdges")}J=ca[q];J.setAttribute("x1",l.positionScreen.x);J.setAttribute("y1",l.positionScreen.y);J.setAttribute("x2",y.positionScreen.x);J.setAttribute("y2",y.positionScreen.y);if(n instanceof THREE.LineBasicMaterial){x.__styleString=n.color.__styleString;J.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+n.linewidth+"; stroke-opacity: "+
n.opacity+"; stroke-linecap: "+n.linecap+"; stroke-linejoin: "+n.linejoin);j.appendChild(J)}}}}else if(v instanceof THREE.RenderableFace3){u=v.v1;p=v.v2;A=v.v3;u.positionScreen.x*=o;u.positionScreen.y*=-z;p.positionScreen.x*=o;p.positionScreen.y*=-z;A.positionScreen.x*=o;A.positionScreen.y*=-z;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(p.positionScreen.x,p.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);if(F.instersects(w)){ea=0;for(Z=v.meshMaterials.length;ea<
Z;){n=v.meshMaterials[ea++];if(n instanceof THREE.MeshFaceMaterial){l=0;for(y=v.faceMaterials.length;l<y;)(n=v.faceMaterials[l++])&&c(u,p,A,v,n,ia)}else n&&c(u,p,A,v,n,ia)}}}else if(v instanceof THREE.RenderableFace4){u=v.v1;p=v.v2;A=v.v3;D=v.v4;u.positionScreen.x*=o;u.positionScreen.y*=-z;p.positionScreen.x*=o;p.positionScreen.y*=-z;A.positionScreen.x*=o;A.positionScreen.y*=-z;D.positionScreen.x*=o;D.positionScreen.y*=-z;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(p.positionScreen.x,
p.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);w.addPoint(D.positionScreen.x,D.positionScreen.y);if(F.instersects(w)){ea=0;for(Z=v.meshMaterials.length;ea<Z;){n=v.meshMaterials[ea++];if(n instanceof THREE.MeshFaceMaterial){l=0;for(y=v.faceMaterials.length;l<y;)(n=v.faceMaterials[l++])&&b(u,p,A,D,v,n,ia)}else n&&b(u,p,A,D,v,n,ia)}}}}}};
THREE.WebGLRenderer=function(a){function c(l,y,v){var n,q,K,G=l.vertices,t=G.length,C=l.colors,B=C.length,E=l.__vertexArray,S=l.__colorArray,na=l.__sortArray,ga=l.__dirtyVertices,ja=l.__dirtyColors;if(v.sortParticles){oa.multiplySelf(v.matrixWorld);for(n=0;n<t;n++){q=G[n].position;pa.copy(q);oa.multiplyVector3(pa);na[n]=[pa.z,n]}na.sort(function(ma,la){return la[0]-ma[0]});for(n=0;n<t;n++){q=G[na[n][1]].position;K=n*3;E[K]=q.x;E[K+1]=q.y;E[K+2]=q.z}for(n=0;n<B;n++){K=n*3;color=C[na[n][1]];S[K]=color.r;
S[K+1]=color.g;S[K+2]=color.b}}else{if(ga)for(n=0;n<t;n++){q=G[n].position;K=n*3;E[K]=q.x;E[K+1]=q.y;E[K+2]=q.z}if(ja)for(n=0;n<B;n++){color=C[n];K=n*3;S[K]=color.r;S[K+1]=color.g;S[K+2]=color.b}}if(ga||v.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,E,y)}if(ja||v.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,S,y)}}function b(l,y){l.fragmentShader=y.fragmentShader;l.vertexShader=y.vertexShader;l.uniforms=
Uniforms.clone(y.uniforms)}function d(l,y,v,n,q){n.program||$.initMaterial(n,y,v);var K=n.program,G=K.uniforms,t=n.uniforms;if(K!=T){f.useProgram(K);T=K;f.uniformMatrix4fv(G.projectionMatrix,!1,ia)}if(v&&(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial||n instanceof THREE.LineBasicMaterial||n instanceof THREE.ParticleBasicMaterial)){t.fogColor.value.setHex(v.color.hex);if(v instanceof THREE.Fog){t.fogNear.value=v.near;t.fogFar.value=
v.far}else if(v instanceof THREE.FogExp2)t.fogDensity.value=v.density}if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){var C,B,E=0,S=0,na=0,ga,ja,ma,la=$.lights,ra=la.directional.colors,N=la.directional.positions,Ha=la.point.colors,Ea=la.point.positions,Ja=0,U=0;v=B=B=0;for(C=y.length;v<C;v++){B=y[v];ga=B.color;ja=B.position;ma=B.intensity;if(B instanceof THREE.AmbientLight){E+=ga.r;S+=ga.g;na+=ga.b}else if(B instanceof THREE.DirectionalLight){B=Ja*3;ra[B]=ga.r*ma;
ra[B+1]=ga.g*ma;ra[B+2]=ga.b*ma;N[B]=ja.x;N[B+1]=ja.y;N[B+2]=ja.z;Ja+=1}else if(B instanceof THREE.PointLight){B=U*3;Ha[B]=ga.r*ma;Ha[B+1]=ga.g*ma;Ha[B+2]=ga.b*ma;Ea[B]=ja.x;Ea[B+1]=ja.y;Ea[B+2]=ja.z;U+=1}}for(v=Ja*3;v<ra.length;v++)ra[v]=0;for(v=U*3;v<Ha.length;v++)Ha[v]=0;la.point.length=U;la.directional.length=Ja;la.ambient[0]=E;la.ambient[1]=S;la.ambient[2]=na;y=$.lights;t.enableLighting.value=y.directional.length+y.point.length;t.ambientLightColor.value=y.ambient;t.directionalLightColor.value=
y.directional.colors;t.directionalLightDirection.value=y.directional.positions;t.pointLightColor.value=y.point.colors;t.pointLightPosition.value=y.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial){t.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);t.opacity.value=n.opacity;t.map.texture=n.map;t.lightMap.texture=n.lightMap;t.envMap.texture=n.envMap;t.reflectivity.value=n.reflectivity;
t.refractionRatio.value=n.refractionRatio;t.combine.value=n.combine;t.useRefract.value=n.envMap&&n.envMap.mapping instanceof THREE.CubeRefractionMapping}if(n instanceof THREE.LineBasicMaterial){t.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);t.opacity.value=n.opacity}else if(n instanceof THREE.ParticleBasicMaterial){t.psColor.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);t.opacity.value=n.opacity;t.size.value=n.size;t.map.texture=n.map}else if(n instanceof
THREE.MeshPhongMaterial){t.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);t.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);t.shininess.value=n.shininess}else if(n instanceof THREE.MeshDepthMaterial){t.mNear.value=l.near;t.mFar.value=l.far;t.opacity.value=n.opacity}else if(n instanceof THREE.MeshNormalMaterial)t.opacity.value=n.opacity;for(var V in t)if(E=K.uniforms[V]){v=t[V];C=v.type;y=v.value;if(C=="i")f.uniform1i(E,y);else if(C=="f")f.uniform1f(E,y);else if(C=="fv1")f.uniform1fv(E,
y);else if(C=="fv")f.uniform3fv(E,y);else if(C=="v2")f.uniform2f(E,y.x,y.y);else if(C=="v3")f.uniform3f(E,y.x,y.y,y.z);else if(C=="c")f.uniform3f(E,y.r,y.g,y.b);else if(C=="t"){f.uniform1i(E,y);if(v=v.texture)if(v.image instanceof Array&&v.image.length==6){if(v.image.length==6){if(v.needsUpdate){if(v.__wasSetOnce){f.bindTexture(f.TEXTURE_CUBE_MAP,v.image.__webGLTextureCube);for(C=0;C<6;++C)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,0,0,f.RGBA,f.UNSIGNED_BYTE,v.image[C])}else{v.image.__webGLTextureCube=
f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,v.image.__webGLTextureCube);for(C=0;C<6;++C)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,v.image[C]);v.__wasSetOnce=!0}H(f.TEXTURE_CUBE_MAP,v,v.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);v.needsUpdate=!1}f.activeTexture(f.TEXTURE0+y);f.bindTexture(f.TEXTURE_CUBE_MAP,v.image.__webGLTextureCube)}}else{if(v.needsUpdate){if(v.__wasSetOnce){f.bindTexture(f.TEXTURE_2D,v.__webGLTexture);f.texSubImage2D(f.TEXTURE_2D,
0,0,0,f.RGBA,f.UNSIGNED_BYTE,v.image)}else{v.__webGLTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,v.__webGLTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,v.image);v.__wasSetOnce=!0}H(f.TEXTURE_2D,v,v.image);f.bindTexture(f.TEXTURE_2D,null);v.needsUpdate=!1}f.activeTexture(f.TEXTURE0+y);f.bindTexture(f.TEXTURE_2D,v.__webGLTexture)}}}f.uniformMatrix4fv(G.modelViewMatrix,!1,q._modelViewMatrixArray);f.uniformMatrix3fv(G.normalMatrix,!1,q._normalMatrixArray);(n instanceof THREE.MeshShaderMaterial||
n instanceof THREE.MeshPhongMaterial||n.envMap)&&f.uniform3f(G.cameraPosition,l.position.x,l.position.y,l.position.z);(n instanceof THREE.MeshShaderMaterial||n.envMap||n.skinning)&&f.uniformMatrix4fv(G.objectMatrix,!1,q._objectMatrixArray);(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshShaderMaterial||n.skinning)&&f.uniformMatrix4fv(G.viewMatrix,!1,da);if(n.skinning){f.uniformMatrix4fv(G.cameraInverseMatrix,!1,da);f.uniformMatrix4fv(G.boneGlobalMatrices,
!1,q.boneMatrices)}return K}function e(l,y,v,n,q,K){l=d(l,y,v,n,K).attributes;f.bindBuffer(f.ARRAY_BUFFER,q.__webGLVertexBuffer);f.vertexAttribPointer(l.position,3,f.FLOAT,!1,0,0);if(l.color>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLColorBuffer);f.vertexAttribPointer(l.color,3,f.FLOAT,!1,0,0)}if(l.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLNormalBuffer);f.vertexAttribPointer(l.normal,3,f.FLOAT,!1,0,0)}if(l.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLTangentBuffer);f.vertexAttribPointer(l.tangent,
4,f.FLOAT,!1,0,0)}if(l.uv>=0)if(q.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLUVBuffer);f.vertexAttribPointer(l.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv)}else f.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(q.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLUV2Buffer);f.vertexAttribPointer(l.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv2)}else f.disableVertexAttribArray(l.uv2);if(n.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,
q.__webGLSkinVertexABuffer);f.vertexAttribPointer(l.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);f.vertexAttribPointer(l.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);f.vertexAttribPointer(l.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);f.vertexAttribPointer(l.skinWeight,4,f.FLOAT,!1,0,0)}if(K instanceof THREE.Mesh)if(n.wireframe){f.lineWidth(n.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,
q.__webGLLineBuffer);f.drawElements(f.LINES,q.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,q.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(K instanceof THREE.Line){K=K.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(n.linewidth);f.drawArrays(K,0,q.__webGLLineCount)}else if(K instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,q.__webGLParticleCount);else K instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,
0,q.__webGLVertexCount)}function g(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=f.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=f.createBuffer();if(l.hasPos){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,l.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(y.attributes.position);f.vertexAttribPointer(y.attributes.position,3,f.FLOAT,!1,0,0)}if(l.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,l.normalArray,
f.DYNAMIC_DRAW);f.enableVertexAttribArray(y.attributes.normal);f.vertexAttribPointer(y.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,l.count);l.count=0}function h(l){if(ca!=l.doubleSided){l.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);ca=l.doubleSided}if(J!=l.flipSided){l.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);J=l.flipSided}}function j(l){if(ua!=l){l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);ua=l}}function k(l){Y[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,
l.n44-l.n14);Y[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);Y[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);Y[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);Y[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);Y[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<6;l++){y=Y[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}function m(l){for(var y=l.matrixWorld,v=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),
n=0;n<6;n++){l=Y[n].x*y.n14+Y[n].y*y.n24+Y[n].z*y.n34+Y[n].w;if(l<=v)return!1}return!0}function o(l,y){l.list[l.count]=y;l.count+=1}function z(l){var y,v,n=l.object,q=l.opaque,K=l.transparent;K.count=0;l=q.count=0;for(y=n.materials.length;l<y;l++){v=n.materials[l];v.opacity&&v.opacity<1||v.blending!=THREE.NormalBlending?o(K,v):o(q,v)}}function u(l){var y,v,n,q,K=l.object,G=l.buffer,t=l.opaque,C=l.transparent;C.count=0;l=t.count=0;for(n=K.materials.length;l<n;l++){y=K.materials[l];if(y instanceof THREE.MeshFaceMaterial){y=
0;for(v=G.materials.length;y<v;y++)(q=G.materials[y])&&(q.opacity&&q.opacity<1||q.blending!=THREE.NormalBlending?o(C,q):o(t,q))}else{q=y;q.opacity&&q.opacity<1||q.blending!=THREE.NormalBlending?o(C,q):o(t,q)}}}function p(l,y){return y.z-l.z}function A(l,y){l._modelViewMatrix.multiplyToArray(y.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function D(l){function y(S){var na=[];v=0;for(n=S.length;v<n;v++)S[v]==
undefined?na.push("undefined"):na.push(S[v].id);return na.join("_")}var v,n,q,K,G,t,C,B,E={};l.geometryGroups={};q=0;for(K=l.faces.length;q<K;q++){G=l.faces[q];t=G.materials;C=y(t);E[C]==undefined&&(E[C]={hash:C,counter:0});B=E[C].hash+"_"+E[C].counter;l.geometryGroups[B]==undefined&&(l.geometryGroups[B]={faces:[],materials:t,vertices:0});G=G instanceof THREE.Face3?3:4;if(l.geometryGroups[B].vertices+G>65535){E[C].counter+=1;B=E[C].hash+"_"+E[C].counter;l.geometryGroups[B]==undefined&&(l.geometryGroups[B]=
{faces:[],materials:t,vertices:0})}l.geometryGroups[B].faces.push(q);l.geometryGroups[B].vertices+=G}}function F(l,y,v){l.push({buffer:y,object:v,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function w(l){if(l!=aa){switch(l){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;
case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}aa=l}}function H(l,y,v){if((v.width&v.width-1)==0&&(v.height&v.height-1)==0){f.texParameteri(l,f.TEXTURE_WRAP_S,X(y.wrapS));f.texParameteri(l,f.TEXTURE_WRAP_T,X(y.wrapT));f.texParameteri(l,f.TEXTURE_MAG_FILTER,X(y.magFilter));f.texParameteri(l,f.TEXTURE_MIN_FILTER,X(y.minFilter));f.generateMipmap(l)}else{f.texParameteri(l,
f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(l,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(l,f.TEXTURE_MAG_FILTER,M(y.magFilter));f.texParameteri(l,f.TEXTURE_MIN_FILTER,M(y.minFilter))}}function x(l,y){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=f.createFramebuffer();l.__webGLRenderbuffer=f.createRenderbuffer();l.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,l.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,l.width,l.height);f.bindTexture(f.TEXTURE_2D,
l.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,X(l.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,X(l.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,X(l.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,X(l.minFilter));f.texImage2D(f.TEXTURE_2D,0,X(l.format),l.width,l.height,0,X(l.format),X(l.type),null);f.bindFramebuffer(f.FRAMEBUFFER,l.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,
f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var v,n,q;if(l){v=l.__webGLFramebuffer;n=l.width;q=l.height}else{v=null;n=L.width;q=L.height}if(v!=R){f.bindFramebuffer(f.FRAMEBUFFER,v);f.viewport(0,0,n,q);y&&f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT);R=v}}function Q(l,y){var v;if(l=="fragment")v=f.createShader(f.FRAGMENT_SHADER);else l=="vertex"&&(v=f.createShader(f.VERTEX_SHADER));
f.shaderSource(v,y);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function M(l){switch(l){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}function X(l){switch(l){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;
case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;
case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var L=document.createElement("canvas"),f,T=null,R=null,$=this,ca=null,J=null,aa=null,ua=null,Y=[new THREE.Vector4,
new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],oa=new THREE.Matrix4,ia=new Float32Array(16),da=new Float32Array(16),pa=new THREE.Vector4,ya=!0,ea=new THREE.Color(0),Z=0;if(a){if(a.antialias!==undefined)ya=a.antialias;a.clearColor!==undefined&&ea.setHex(a.clearColor);if(a.clearAlpha!==undefined)Z=a.clearAlpha}this.domElement=L;this.autoClear=!0;this.sortObjects=!0;(function(l,y,v){try{if(!(f=L.getContext("experimental-webgl",{antialias:l})))throw"Error creating WebGL context.";
}catch(n){console.error(n)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.clearColor(y.r,y.g,y.b,v);_cullEnabled=!0})(ya,ea,Z);this.context=f;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,y){L.width=l;L.height=y;f.viewport(0,0,L.width,L.height)};this.setClearColorHex=
function(l,y){var v=new THREE.Color(l);f.clearColor(v.r,v.g,v.b,y)};this.setClearColor=function(l,y){f.clearColor(l.r,l.g,l.b,y)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,y,v){var n,q;if(l instanceof THREE.MeshDepthMaterial)b(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)b(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)b(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)b(l,
THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)b(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)b(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&b(l,THREE.ShaderLib.particle_basic);var K,G,t,C;q=t=C=0;for(K=y.length;q<K;q++){G=y[q];G instanceof THREE.DirectionalLight&&t++;G instanceof THREE.PointLight&&C++}if(C+t<=4)y=t;else{y=Math.ceil(4*t/(C+t));C=4-y}q={directional:y,point:C};C=l.fragmentShader;y=l.vertexShader;K={fog:v,map:l.map,
envMap:l.envMap,lightMap:l.lightMap,vertexColors:l.vertexColors,skinning:l.skinning,maxDirLights:q.directional,maxPointLights:q.point};v=f.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+K.maxDirLights,"#define MAX_POINT_LIGHTS "+K.maxPointLights,K.fog?"#define USE_FOG":"",K.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",K.map?"#define USE_MAP":"",K.envMap?"#define USE_ENVMAP":"",K.lightMap?"#define USE_LIGHTMAP":"",K.vertexColors?"#define USE_COLOR":
"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");K=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+K.maxDirLights,"#define MAX_POINT_LIGHTS "+K.maxPointLights,K.map?"#define USE_MAP":"",K.envMap?"#define USE_ENVMAP":"",K.lightMap?"#define USE_LIGHTMAP":"",K.vertexColors?"#define USE_COLOR":"",K.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
f.attachShader(v,Q("fragment",q+C));f.attachShader(v,Q("vertex",K+y));f.linkProgram(v);f.getProgramParameter(v,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(v,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");v.uniforms={};v.attributes={};l.program=v;v=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(n in l.uniforms)v.push(n);n=l.program;C=0;for(y=v.length;C<
y;C++){q=v[C];n.uniforms[q]=f.getUniformLocation(n,q)}n=l.program;v=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];C=0;for(y=v.length;C<y;C++){q=v[C];n.attributes[q]=f.getAttribLocation(n,q)}n=l.program.attributes;f.enableVertexAttribArray(n.position);n.color>=0&&f.enableVertexAttribArray(n.color);n.normal>=0&&f.enableVertexAttribArray(n.normal);n.tangent>=0&&f.enableVertexAttribArray(n.tangent);if(l.skinning&&n.skinVertexA>=0&&n.skinVertexB>=
0&&n.skinIndex>=0&&n.skinWeight>=0){f.enableVertexAttribArray(n.skinVertexA);f.enableVertexAttribArray(n.skinVertexB);f.enableVertexAttribArray(n.skinIndex);f.enableVertexAttribArray(n.skinWeight)}};this.render=function(l,y,v,n){var q,K,G,t,C,B,E,S,na=l.lights,ga=l.fog;y.matrixAutoUpdate&&y.update();y.matrixWorldInverse.flattenToArray(da);y.projectionMatrix.flattenToArray(ia);oa.multiply(y.projectionMatrix,y.matrixWorldInverse);k(oa);l.update(undefined,!1,y);this.initWebGLObjects(l,y);x(v,n!==undefined?
n:!0);this.autoClear&&this.clear();C=l.__webglObjects.length;for(n=0;n<C;n++){q=l.__webglObjects[n];E=q.object;if(E.visible)if(!(E instanceof THREE.Mesh)||m(E)){E.matrixWorld.flattenToArray(E._objectMatrixArray);A(E,y);u(q);q.render=!0;if(this.sortObjects){pa.copy(E.position);oa.multiplyVector3(pa);q.z=pa.z}}else q.render=!1;else q.render=!1}this.sortObjects&&l.__webglObjects.sort(p);B=l.__webglObjectsImmediate.length;for(n=0;n<B;n++){q=l.__webglObjectsImmediate[n];E=q.object;if(E.visible){E.matrixAutoUpdate&&
E.matrixWorld.flattenToArray(E._objectMatrixArray);A(E,y);z(q)}}w(THREE.NormalBlending);for(n=0;n<C;n++){q=l.__webglObjects[n];if(q.render){E=q.object;S=q.buffer;G=q.opaque;h(E);for(q=0;q<G.count;q++){t=G.list[q];j(t.depthTest);e(y,na,ga,t,S,E)}}}for(n=0;n<B;n++){q=l.__webglObjectsImmediate[n];E=q.object;if(E.visible){G=q.opaque;h(E);for(q=0;q<G.count;q++){t=G.list[q];j(t.depthTest);K=d(y,na,ga,t,E);E.render(function(ja){g(ja,K)})}}}for(n=0;n<C;n++){q=l.__webglObjects[n];if(q.render){E=q.object;S=
q.buffer;G=q.transparent;h(E);for(q=0;q<G.count;q++){t=G.list[q];w(t.blending);j(t.depthTest);e(y,na,ga,t,S,E)}}}for(n=0;n<B;n++){q=l.__webglObjectsImmediate[n];E=q.object;if(E.visible){G=q.transparent;h(E);for(q=0;q<G.count;q++){t=G.list[q];w(t.blending);j(t.depthTest);K=d(y,na,ga,t,E);E.render(function(ja){g(ja,K)})}}}if(v&&v.minFilter!==THREE.NearestFilter&&v.minFilter!==THREE.LinearFilter){f.bindTexture(f.TEXTURE_2D,v.__webGLTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}};
this.initWebGLObjects=function(l){if(!l.__webglObjects){l.__webglObjects=[];l.__webglObjectsImmediate=[]}for(;l.__objectsAdded.length;){var y=l.__objectsAdded[0],v=l,n=void 0,q=void 0,K=void 0;if(y._modelViewMatrix==undefined){y._modelViewMatrix=new THREE.Matrix4;y._normalMatrixArray=new Float32Array(9);y._modelViewMatrixArray=new Float32Array(16);y._objectMatrixArray=new Float32Array(16);y.matrixWorld.flattenToArray(y._objectMatrixArray)}if(y instanceof THREE.Mesh){q=y.geometry;q.geometryGroups==
undefined&&D(q);for(n in q.geometryGroups){K=q.geometryGroups[n];if(!K.__webGLVertexBuffer){var G=K;G.__webGLVertexBuffer=f.createBuffer();G.__webGLNormalBuffer=f.createBuffer();G.__webGLTangentBuffer=f.createBuffer();G.__webGLColorBuffer=f.createBuffer();G.__webGLUVBuffer=f.createBuffer();G.__webGLUV2Buffer=f.createBuffer();G.__webGLSkinVertexABuffer=f.createBuffer();G.__webGLSkinVertexBBuffer=f.createBuffer();G.__webGLSkinIndicesBuffer=f.createBuffer();G.__webGLSkinWeightsBuffer=f.createBuffer();
G.__webGLFaceBuffer=f.createBuffer();G.__webGLLineBuffer=f.createBuffer();G=K;var t=y,C=void 0,B=void 0,E=0,S=0,na=0,ga=t.geometry.faces,ja=G.faces;C=0;for(B=ja.length;C<B;C++){fi=ja[C];face=ga[fi];if(face instanceof THREE.Face3){E+=3;S+=1;na+=3}else if(face instanceof THREE.Face4){E+=4;S+=2;na+=4}}G.__vertexArray=new Float32Array(E*3);G.__normalArray=new Float32Array(E*3);G.__tangentArray=new Float32Array(E*4);G.__colorArray=new Float32Array(E*3);G.__uvArray=new Float32Array(E*2);G.__uv2Array=new Float32Array(E*
2);G.__skinVertexAArray=new Float32Array(E*4);G.__skinVertexBArray=new Float32Array(E*4);G.__skinIndexArray=new Float32Array(E*4);G.__skinWeightArray=new Float32Array(E*4);G.__faceArray=new Uint16Array(S*3);G.__lineArray=new Uint16Array(na*2);B=C=G;E=void 0;ga=void 0;var ma=void 0,la=void 0;ma=void 0;ja=!1;E=0;for(ga=t.materials.length;E<ga;E++){ma=t.materials[E];if(ma instanceof THREE.MeshFaceMaterial){ma=0;for(la=B.materials.length;ma<la;ma++)if(B.materials[ma]&&B.materials[ma].shading!=undefined&&
B.materials[ma].shading==THREE.SmoothShading){ja=!0;break}}else if(ma&&ma.shading!=undefined&&ma.shading==THREE.SmoothShading){ja=!0;break}if(ja)break}C.__needsSmoothNormals=ja;G.__webGLFaceCount=S*3;G.__webGLLineCount=na*2;q.__dirtyVertices=!0;q.__dirtyElements=!0;q.__dirtyUvs=!0;q.__dirtyNormals=!0;q.__dirtyTangents=!0;q.__dirtyColors=!0}F(v.__webglObjects,K,y)}}else if(y instanceof THREE.Ribbon){q=y.geometry;if(!q.__webGLVertexBuffer){n=q;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=
f.createBuffer();n=q;K=n.vertices.length;n.__vertexArray=new Float32Array(K*3);n.__colorArray=new Float32Array(K*3);n.__webGLVertexCount=K;q.__dirtyVertices=!0;q.__dirtyColors=!0}F(v.__webglObjects,q,y)}else if(y instanceof THREE.Line){q=y.geometry;if(!q.__webGLVertexBuffer){n=q;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=q;K=n.vertices.length;n.__vertexArray=new Float32Array(K*3);n.__colorArray=new Float32Array(K*3);n.__webGLLineCount=K;q.__dirtyVertices=!0;q.__dirtyColors=
!0}F(v.__webglObjects,q,y)}else if(y instanceof THREE.ParticleSystem){q=y.geometry;if(!q.__webGLVertexBuffer){n=q;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=q;K=n.vertices.length;n.__vertexArray=new Float32Array(K*3);n.__colorArray=new Float32Array(K*3);n.__sortArray=[];n.__webGLParticleCount=K;q.__dirtyVertices=!0;q.__dirtyColors=!0}F(v.__webglObjects,q,y)}else THREE.MarchingCubes!==undefined&&y instanceof THREE.MarchingCubes&&v.__webglObjectsImmediate.push({object:y,
opaque:{list:[],count:0},transparent:{list:[],count:0}});l.__objectsAdded.splice(0,1)}for(;l.__objectsRemoved.length;){y=l.__objectsRemoved[0];v=l;q=void 0;n=void 0;for(q=v.__webglObjects.length-1;q>=0;q--){n=v.__webglObjects[q].object;y==n&&v.__webglObjects.splice(q,1)}l.__objectsRemoved.splice(0,1)}y=0;for(v=l.__webglObjects.length;y<v;y++){n=l.__webglObjects[y].object;K=void 0;q=void 0;G=void 0;if(n instanceof THREE.Mesh){q=n.geometry;for(K in q.geometryGroups){G=q.geometryGroups[K];if(q.__dirtyVertices||
q.__dirtyElements||q.__dirtyUvs||q.__dirtyNormals||q.__dirtyColors||q.__dirtyTangents){S=f.DYNAMIC_DRAW;na=void 0;C=void 0;var ra=void 0,N=void 0,Ha=void 0,Ea=void 0,Ja=void 0;ra=void 0;var U=void 0,V=void 0,W=void 0,sa=void 0;U=void 0;V=void 0;W=void 0;N=void 0;U=void 0;V=void 0;W=void 0;sa=void 0;U=void 0;V=void 0;W=void 0;sa=void 0;U=void 0;V=void 0;W=void 0;sa=void 0;U=void 0;V=void 0;W=void 0;sa=void 0;U=void 0;V=void 0;W=void 0;sa=void 0;N=void 0;Ea=void 0;Ha=void 0;Ja=void 0;var Fa=la=ma=ja=
ga=E=t=B=0,Ca=0,I=0,Da=G.__vertexArray,Ra=G.__uvArray,Pa=G.__uv2Array,Ka=G.__normalArray,ka=G.__tangentArray,wa=G.__colorArray,ta=G.__skinVertexAArray,xa=G.__skinVertexBArray,za=G.__skinIndexArray,va=G.__skinWeightArray,O=G.__faceArray,fa=G.__lineArray,ha=G.__needsSmoothNormals,P=n.geometry,ba=P.__dirtyVertices,qa=P.__dirtyElements,Aa=P.__dirtyUvs,Ga=P.__dirtyNormals,Ia=P.__dirtyTangents,La=P.__dirtyColors,Ba=P.vertices,Ma=G.faces,Ta=P.faces,Na=P.uvs,Oa=P.uvs2,Qa=P.colors,Ua=P.skinVerticesA,Va=P.skinVerticesB,
Wa=P.skinIndices,Sa=P.skinWeights;na=0;for(C=Ma.length;na<C;na++){ra=Ma[na];N=Ta[ra];Ja=Na[ra];ra=Oa[ra];Ha=N.vertexNormals;Ea=N.normal;if(N instanceof THREE.Face3){if(ba){U=Ba[N.a].position;V=Ba[N.b].position;W=Ba[N.c].position;Da[t]=U.x;Da[t+1]=U.y;Da[t+2]=U.z;Da[t+3]=V.x;Da[t+4]=V.y;Da[t+5]=V.z;Da[t+6]=W.x;Da[t+7]=W.y;Da[t+8]=W.z;t+=9}if(Sa.length){U=Sa[N.a];V=Sa[N.b];W=Sa[N.c];va[I]=U.x;va[I+1]=U.y;va[I+2]=U.z;va[I+3]=U.w;va[I+4]=V.x;va[I+5]=V.y;va[I+6]=V.z;va[I+7]=V.w;va[I+8]=W.x;va[I+9]=W.y;
va[I+10]=W.z;va[I+11]=W.w;U=Wa[N.a];V=Wa[N.b];W=Wa[N.c];za[I]=U.x;za[I+1]=U.y;za[I+2]=U.z;za[I+3]=U.w;za[I+4]=V.x;za[I+5]=V.y;za[I+6]=V.z;za[I+7]=V.w;za[I+8]=W.x;za[I+9]=W.y;za[I+10]=W.z;za[I+11]=W.w;U=Ua[N.a];V=Ua[N.b];W=Ua[N.c];ta[I]=U.x;ta[I+1]=U.y;ta[I+2]=U.z;ta[I+3]=1;ta[I+4]=V.x;ta[I+5]=V.y;ta[I+6]=V.z;ta[I+7]=1;ta[I+8]=W.x;ta[I+9]=W.y;ta[I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=B+2;fa[Fa+7]=B+3;Fa+=8;B+=4}}}if(ba){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Da,S)}if(La&&Qa.length){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,wa,S)}if(Ga){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Ka,S)}if(Ia&&P.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,
ka,S)}if(Aa&&E>0){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Ra,S)}if(Aa&&ga>0){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Pa,S)}if(qa){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,O,S);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,G.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,fa,S)}if(I>0){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,ta,S);f.bindBuffer(f.ARRAY_BUFFER,
G.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,xa,S);f.bindBuffer(f.ARRAY_BUFFER,G.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,za,S);f.bindBuffer(f.ARRAY_BUFFER,G.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,va,S)}}}q.__dirtyVertices=!1;q.__dirtyElements=!1;q.__dirtyUvs=!1;q.__dirtyNormals=!1;q.__dirtyTangents=!1;q.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){q=n.geometry;if(q.__dirtyVertices||q.__dirtyColors){n=q;K=f.DYNAMIC_DRAW;B=void 0;B=void 0;t=void 0;G=void 0;
E=n.vertices;S=n.colors;ga=E.length;na=S.length;ja=n.__vertexArray;C=n.__colorArray;ma=n.__dirtyColors;if(n.__dirtyVertices){for(B=0;B<ga;B++){t=E[B].position;G=B*3;ja[G]=t.x;ja[G+1]=t.y;ja[G+2]=t.z}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ja,K)}if(ma){for(B=0;B<na;B++){color=S[B];G=B*3;C[G]=color.r;C[G+1]=color.g;C[G+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,C,K)}}q.__dirtyVertices=!1;q.__dirtyColors=!1}else if(n instanceof
THREE.Line){q=n.geometry;if(q.__dirtyVertices||q.__dirtyColors){n=q;K=f.DYNAMIC_DRAW;B=void 0;B=void 0;t=void 0;G=void 0;E=n.vertices;S=n.colors;ga=E.length;na=S.length;ja=n.__vertexArray;C=n.__colorArray;ma=n.__dirtyColors;if(n.__dirtyVertices){for(B=0;B<ga;B++){t=E[B].position;G=B*3;ja[G]=t.x;ja[G+1]=t.y;ja[G+2]=t.z}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ja,K)}if(ma){for(B=0;B<na;B++){color=S[B];G=B*3;C[G]=color.r;C[G+1]=color.g;C[G+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,
n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,C,K)}}q.__dirtyVertices=!1;q.__dirtyColors=!1}else if(n instanceof THREE.ParticleSystem){q=n.geometry;(q.__dirtyVertices||q.__dirtyColors||n.sortParticles)&&c(q,f.DYNAMIC_DRAW,n);q.__dirtyVertices=!1;q.__dirtyColors=!1}}};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW);if(l=="back")f.cullFace(f.BACK);else l=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK);f.enable(f.CULL_FACE)}else f.disable(f.CULL_FACE)};
this.supportsVertexTextures=function(){return f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
257 258 259 260
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
261 262 263
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
264
THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
265
value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
266 267 268 269 270
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,
THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex,
THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,
THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,
271
THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,
272 273
THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,
THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,
274
THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
275
THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;",
276
THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};
277
THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,e=b.length;for(d=0;d<e;d++){a=b[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(c.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
278 279
THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
280 281 282 283 284 285 286 287 288 289 290
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,j=a.faces,k=e.faces,m=a.uvs;e=e.uvs;b&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,z=h.length;o<z;o++){var u=new THREE.Vertex(h[o].position.clone());b&&c.matrix.multiplyVector3(u.position);g.push(u)}o=0;for(z=k.length;o<z;o++){h=k[o];var p,A=h.vertexNormals;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+
d,h.b+d,h.c+d,h.d+d));p.centroid.copy(h.centroid);p.normal.copy(h.normal);b=0;for(g=A.length;b<g;b++){u=A[b];p.vertexNormals.push(u.clone())}p.materials=h.materials.slice();j.push(p)}o=0;for(z=e.length;o<z;o++){d=e[o];j=[];b=0;for(g=d.length;b<g;b++)j.push(new THREE.UV(d[b].u,d[b].v));m.push(j)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,c,b){var d,e=[],g=new THREE.Texture(e,
c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(o in L.objects)if(!J.objects[o]){D=L.objects[o];if(x=J.geometries[D.geometry]){X=[];for(i=0;i<D.materials.length;i++)X[i]=J.materials[D.materials[i]];F=D.position;r=D.rotation;s=D.scale;object=new THREE.Mesh(x,X);object.position.set(F[0],
F[1],F[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;J.scene.addObject(object);J.objects[o]=object}}}function h(aa){return function(ua){J.geometries[aa]=ua;g();T-=1;j()}}function j(){d({total_models:$,total_textures:ca,loaded_models:$-T,loaded_textures:ca-R},J);T==0&&R==0&&b(J)}var k,m,o,z,u,p,A,D,F,w,H,x,Q,M,X,L,f,T,R,$,ca,J;L=e.data;f=new THREE.Loader;R=T=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},
fogs:{}};e=function(){R-=1;j()};for(u in L.cameras){w=L.cameras[u];if(w.type=="perspective")Q=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){Q=new THREE.Camera;Q.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}F=w.position;w=w.target;Q.position.set(F[0],F[1],F[2]);Q.target.position.set(w[0],w[1],w[2]);J.cameras[u]=Q}for(z in L.lights){u=L.lights[z];if(u.type=="directional"){F=u.direction;light=new THREE.DirectionalLight;light.position.set(F[0],
F[1],F[2]);light.position.normalize()}else if(u.type=="point"){F=u.position;light=new THREE.PointLight;light.position.set(F[0],F[1],F[2])}w=u.color;i=u.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);J.scene.addLight(light);J.lights[z]=light}for(p in L.fogs){z=L.fogs[p];if(z.type=="linear")M=new THREE.Fog(0,z.near,z.far);else z.type=="exp2"&&(M=new THREE.FogExp2(0,z.density));w=z.color;M.color.setRGB(w[0],w[1],w[2]);J.fogs[p]=M}if(J.cameras&&L.defaults.camera)J.currentCamera=J.cameras[L.defaults.camera];
if(J.fogs&&L.defaults.fog)J.scene.fog=J.fogs[L.defaults.fog];w=L.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(w[0],w[1],w[2]);J.bgColorAlpha=L.defaults.bgalpha;for(k in L.geometries){p=L.geometries[k];if(p.type=="bin_mesh"||p.type=="ascii_mesh")T+=1}$=T;for(k in L.geometries){p=L.geometries[k];if(p.type=="cube"){x=new Cube(p.width,p.height,p.depth,p.segmentsWidth,p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides);J.geometries[k]=x}else if(p.type=="plane"){x=new Plane(p.width,
p.height,p.segmentsWidth,p.segmentsHeight);J.geometries[k]=x}else if(p.type=="sphere"){x=new Sphere(p.radius,p.segmentsWidth,p.segmentsHeight);J.geometries[k]=x}else if(p.type=="cylinder"){x=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);J.geometries[k]=x}else if(p.type=="torus"){x=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);J.geometries[k]=x}else if(p.type=="icosahedron"){x=new Icosahedron(p.subdivisions);J.geometries[k]=x}else if(p.type=="bin_mesh")f.loadBinary({model:p.url,
callback:h(k)});else p.type=="ascii_mesh"&&f.loadAscii({model:p.url,callback:h(k)})}for(A in L.textures){k=L.textures[A];R+=k.url instanceof Array?k.url.length:1}ca=R;for(A in L.textures){k=L.textures[A];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array)p=ImageUtils.loadTextureCube(k.url,k.mapping,e);else{p=ImageUtils.loadTexture(k.url,k.mapping,e);if(THREE[k.minFilter]!=undefined)p.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)p.magFilter=
THREE[k.magFilter]}J.textures[A]=p}for(m in L.materials){A=L.materials[m];for(H in A.parameters)if(H=="envMap"||H=="map"||H=="lightMap")A.parameters[H]=J.textures[A.parameters[H]];else if(H=="shading")A.parameters[H]=A.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")A.parameters[H]=THREE[A.parameters[H]]?THREE[A.parameters[H]]:THREE.NormalBlending;else H=="combine"&&(A.parameters[H]=A.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);
J.materials[m]=A}g();c(J)}},addMesh:function(a,c,b,d,e,g,h,j,k,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=j;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);
291
return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);
292 293
a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[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}},fragmentShader:"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}",
294
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
295
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
296 297 298 299 300 301
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}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse  += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse  += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
302 303 304 305
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,d,e,g=2*Math.ceil(a*3)+1;g>25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c<g;++c){b[c]=Math.exp(-((c-e)*(c-e))/(2*a*a));d+=b[c]}for(c=0;c<g;++c)b[c]/=d;return b}},Cube=function(a,c,b,d,e,g,h,j,k){function m(F,w,H,x,Q,M,X,L){var f,T,R=d||1,$=e||1,ca=Q/2,J=M/2,aa=o.vertices.length;if(F=="x"&&w=="y"||F=="y"&&w=="x")f="z";else if(F=="x"&&w=="z"||F=="z"&&w=="x"){f="y";$=g||1}else if(F=="z"&&w==
"y"||F=="y"&&w=="z"){f="x";R=g||1}var ua=R+1,Y=$+1;Q/=R;var oa=M/$;for(T=0;T<Y;T++)for(M=0;M<ua;M++){var ia=new THREE.Vector3;ia[F]=(M*Q-ca)*H;ia[w]=(T*oa-J)*x;ia[f]=X;o.vertices.push(new THREE.Vertex(ia))}for(T=0;T<$;T++)for(M=0;M<R;M++){o.faces.push(new THREE.Face4(M+ua*T+aa,M+ua*(T+1)+aa,M+1+ua*(T+1)+aa,M+1+ua*T+aa,null,L));o.uvs.push([new THREE.UV(M/R,T/$),new THREE.UV(M/R,(T+1)/$),new THREE.UV((M+1)/R,(T+1)/$),new THREE.UV((M+1)/R,T/$)])}}THREE.Geometry.call(this);var o=this,z=a/2,u=c/2,p=b/
2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var D in k)this.sides[D]!=undefined&&(this.sides[D]=k[D]);this.sides.px&&m("z","y",1*j,-1,b,c,-z,this.materials[0]);this.sides.nx&&m("z","y",-1*j,-1,b,c,z,this.materials[1]);this.sides.py&&m("x","z",1*j,1,a,b,u,this.materials[2]);this.sides.ny&&m("x","z",1*j,-1,a,b,-u,this.materials[3]);
this.sides.pz&&m("x","y",1*j,-1,a,c,p,this.materials[4]);this.sides.nz&&m("x","y",-1*j,-1,a,c,-p,this.materials[5]);(function(){for(var F=[],w=[],H=0,x=o.vertices.length;H<x;H++){for(var Q=o.vertices[H],M=!1,X=0,L=F.length;X<L;X++){var f=F[X];if(Q.position.x==f.position.x&&Q.position.y==f.position.y&&Q.position.z==f.position.z){w[H]=X;M=!0;break}}if(!M){w[H]=F.length;F.push(new THREE.Vertex(Q.position.clone()))}}H=0;for(x=o.faces.length;H<x;H++){Q=o.faces[H];Q.a=w[Q.a];Q.b=w[Q.b];Q.c=w[Q.c];Q.d=w[Q.d]}o.vertices=
M
Mr.doob 已提交
306
F})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
307
var Cylinder=function(a,c,b,d,e){function g(m,o,z){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,o,z)))}THREE.Geometry.call(this);var h=this,j=Math.PI,k;for(k=0;k<a;k++)g(Math.sin(2*j*k/a)*c,Math.cos(2*j*k/a)*c,0);for(k=0;k<a;k++)g(Math.sin(2*j*k/a)*b,Math.cos(2*j*k/a)*b,d);for(k=0;k<a;k++)h.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(b!=0){g(0,0,-e);for(k=a;k<a+a/2;k++)h.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(c!=0){g(0,0,d+e);for(k=a+a/2;k<
308
2*a;k++)h.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
309
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var e,g=a/2,h=c/2;b=b||1;d=d||1;var j=b+1,k=d+1;a/=b;var m=c/d;for(e=0;e<k;e++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*m-h),0)));for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*e,c+j*(e+1),c+1+j*(e+1),c+1+j*e));this.uvs.push([new THREE.UV(c/b,e/d),new THREE.UV(c/b,(e+1)/d),new THREE.UV((c+1)/b,(e+1)/d),new THREE.UV((c+1)/b,e/d)])}this.computeCentroids();this.computeFaceNormals()};
310
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
311 312 313 314 315 316 317 318 319 320
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var j=a*Math.cos(d*e),k=a*Math.sin(d*e),m=[],o=0;for(d=0;d<g;d++){var z=2*d/g,u=k*Math.sin(z*e);z=k*Math.cos(z*e);(b==0||b==h)&&d>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,j,u)))-1);m.push(o)}c.push(m)}var p,A,D;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){m=d==g-1;h=c[b][m?0:d+1];j=c[b][m?g-1:d];k=c[b-1][m?g-1:d];m=c[b-1][m?
0:d+1];u=b/(e-1);p=(b-1)/(e-1);A=(d+1)/g;z=d/g;o=new THREE.UV(1-A,u);u=new THREE.UV(1-z,u);z=new THREE.UV(1-z,p);var F=new THREE.UV(1-A,p);if(b<c.length-1){p=this.vertices[h].position.clone();A=this.vertices[j].position.clone();D=this.vertices[k].position.clone();p.normalize();A.normalize();D.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z)]));this.uvs.push([o,u,z])}if(b>1){p=this.vertices[h].position.clone();
A=this.vertices[k].position.clone();D=this.vertices[m].position.clone();p.normalize();A.normalize();D.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z)]));this.uvs.push([o,z,F])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
var Icosahedron=function(a){function c(z,u,p){var A=Math.sqrt(z*z+u*u+p*p);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(z/A,u/A,p/A)))-1}function b(z,u,p,A){A.faces.push(new THREE.Face3(z,u,p))}function d(z,u){var p=e.vertices[z].position,A=e.vertices[u].position;return c((p.x+A.x)/2,(p.y+A.y)/2,(p.z+A.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in g.faces){var k=d(g.faces[j].a,g.faces[j].b),m=d(g.faces[j].b,g.faces[j].c),o=d(g.faces[j].c,g.faces[j].a);b(g.faces[j].a,k,o,h);b(g.faces[j].b,m,k,h);b(g.faces[j].c,
o,m,h);b(k,m,o,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function LathedObject(a,c,b){THREE.Geometry.call(this);this.nsteps=c||12;this.latheAngle=b||2*Math.PI;c=this.latheAngle/this.nsteps;for(var d=[],e=[],g=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));e[j]=this.vertices.length-1;d[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var k=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.0010;m+=this.stepSize){for(j=0;j<d.length;j++)if(m<b){d[j]=k.multiplyVector3(d[j].clone());this.vertices.push(new THREE.Vertex(d[j]));
g[j]=this.vertices.length-1}else g=h;m==0&&(h=e);for(j=0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.uvs.push([new THREE.UV(m/b,j/a.length),new THREE.UV(m/b,(j+1)/a.length),new THREE.UV((m-c)/b,(j+1)/a.length),new THREE.UV((m-c)/b,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
321
if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
322
THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
323 324 325 326 327 328 329 330 331 332 333 334
0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,d,e){return b+(d-b)*e};this.VIntX=function(b,d,e,g,h,j,k,m,o,z){h=(h-o)/(z-o);o=this.normal_cache;d[g]=j+h*this.delta;d[g+1]=k;d[g+2]=m;e[g]=this.lerp(o[b],o[b+3],h);e[g+1]=this.lerp(o[b+1],o[b+4],h);e[g+2]=this.lerp(o[b+2],o[b+5],h)};this.VIntY=function(b,d,e,g,h,j,k,m,o,z){h=(h-o)/(z-o);o=this.normal_cache;d[g]=j;d[g+1]=k+h*this.delta;d[g+
2]=m;d=b+this.yd*3;e[g]=this.lerp(o[b],o[d],h);e[g+1]=this.lerp(o[b+1],o[d+1],h);e[g+2]=this.lerp(o[b+2],o[d+2],h)};this.VIntZ=function(b,d,e,g,h,j,k,m,o,z){h=(h-o)/(z-o);o=this.normal_cache;d[g]=j;d[g+1]=k;d[g+2]=m+h*this.delta;d=b+this.zd*3;e[g]=this.lerp(o[b],o[d],h);e[g+1]=this.lerp(o[b+1],o[d+1],h);e[g+2]=this.lerp(o[b+2],o[d+2],h)};this.compNorm=function(b){var d=b*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[b-1]-this.field[b+1];this.normal_cache[d+1]=this.field[b-this.yd]-
this.field[b+this.yd];this.normal_cache[d+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,d,e,g,h,j){var k=g+1,m=g+this.yd,o=g+this.zd,z=k+this.yd,u=k+this.zd,p=g+this.yd+this.zd,A=k+this.yd+this.zd,D=0,F=this.field[g],w=this.field[k],H=this.field[m],x=this.field[z],Q=this.field[o],M=this.field[u],X=this.field[p],L=this.field[A];F<h&&(D|=1);w<h&&(D|=2);H<h&&(D|=8);x<h&&(D|=4);Q<h&&(D|=16);M<h&&(D|=32);X<h&&(D|=128);L<h&&(D|=64);var f=THREE.edgeTable[D];if(f==0)return 0;
var T=this.delta,R=b+T,$=d+T;T=e+T;if(f&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,F,w)}if(f&2){this.compNorm(k);this.compNorm(z);this.VIntY(k*3,this.vlist,this.nlist,3,h,R,d,e,w,x)}if(f&4){this.compNorm(m);this.compNorm(z);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,$,e,H,x)}if(f&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,F,H)}if(f&16){this.compNorm(o);this.compNorm(u);this.VIntX(o*3,this.vlist,this.nlist,12,h,b,d,T,
Q,M)}if(f&32){this.compNorm(u);this.compNorm(A);this.VIntY(u*3,this.vlist,this.nlist,15,h,R,d,T,M,L)}if(f&64){this.compNorm(p);this.compNorm(A);this.VIntX(p*3,this.vlist,this.nlist,18,h,b,$,T,X,L)}if(f&128){this.compNorm(o);this.compNorm(p);this.VIntY(o*3,this.vlist,this.nlist,21,h,b,d,T,Q,X)}if(f&256){this.compNorm(g);this.compNorm(o);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,F,Q)}if(f&512){this.compNorm(k);this.compNorm(u);this.VIntZ(k*3,this.vlist,this.nlist,27,h,R,d,e,w,M)}if(f&1024){this.compNorm(z);
this.compNorm(A);this.VIntZ(z*3,this.vlist,this.nlist,30,h,R,$,e,x,L)}if(f&2048){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,$,e,H,X)}D<<=4;for(h=g=0;THREE.triTable[D+h]!=-1;){b=D+h;d=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[e],j);h+=3;g++}return g};this.posnormtriv=function(b,d,e,g,h,j){var k=this.count*3;this.positionArray[k]=b[e];this.positionArray[k+1]=b[e+1];this.positionArray[k+2]=b[e+2];this.positionArray[k+
3]=b[g];this.positionArray[k+4]=b[g+1];this.positionArray[k+5]=b[g+2];this.positionArray[k+6]=b[h];this.positionArray[k+7]=b[h+1];this.positionArray[k+8]=b[h+2];this.normalArray[k]=d[e];this.normalArray[k+1]=d[e+1];this.normalArray[k+2]=d[e+2];this.normalArray[k+3]=d[g];this.normalArray[k+4]=d[g+1];this.normalArray[k+5]=d[g+2];this.normalArray[k+6]=d[h];this.normalArray[k+7]=d[h+1];this.normalArray[k+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;b(this)}};this.addBall=function(b,d,e,g,h){var j=this.size*Math.sqrt(g/h),k=e*this.size,m=d*this.size,o=b*this.size,z=Math.floor(k-j);z<1&&(z=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var u=Math.floor(m-j);u<1&&(u=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var p=Math.floor(o-j);p<1&&(p=1);j=Math.floor(o+j);
j>this.size-1&&(j=this.size-1);for(var A,D,F,w,H,x;z<k;z++){o=this.size2*z;D=z/this.size-e;H=D*D;for(D=u;D<m;D++){F=o+this.size*D;A=D/this.size-d;x=A*A;for(A=p;A<j;A++){w=A/this.size-b;w=g/(1.0E-6+w*w+x+H)-h;w>0&&(this.field[F+A]+=w)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,m=this.size,o=this.yd,z=this.zd,u=this.field,p=m*Math.sqrt(b/d);p>m&&(p=m);for(e=0;e<p;e++){g=e/m;g*=g;j=b/(1.0E-4+g)-d;if(j>0)for(g=0;g<m;g++){k=e+g*o;for(h=0;h<m;h++)u[z*h+k]+=j}}};this.addPlaneY=function(b,d){var e,g,
h,j,k,m,o=this.size,z=this.yd,u=this.zd,p=this.field,A=o*Math.sqrt(b/d);A>o&&(A=o);for(g=0;g<A;g++){e=g/o;e*=e;j=b/(1.0E-4+e)-d;if(j>0){k=g*z;for(e=0;e<o;e++){m=k+e;for(h=0;h<o;h++)p[u*h+m]+=j}}}};this.addPlaneZ=function(b,d){var e,g,h,j,k,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/d);dist>size&&(dist=size);for(h=0;h<dist;h++){e=h/size;e*=e;j=b/(1.0E-4+e)-d;if(j>0){k=zd*h;for(g=0;g<size;g++){m=k+g*yd;for(e=0;e<size;e++)field[m+e]+=j}}}};this.reset=function(){var b;
for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var d,e,g,h,j,k,m,o,z,u=this.size-2;for(h=1;h<u;h++){z=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<u;g++){o=z+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<u;e++){j=(e-this.halfsize)/this.halfsize;d=o+e;this.polygonize(j,k,m,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(e){var g,h,j,k,m,o,z,u;for(g=
0;g<e.count;g++){m=g*3;z=m+1;u=m+2;h=e.positionArray[m];j=e.positionArray[z];k=e.positionArray[u];o=new THREE.Vector3(h,j,k);h=e.normalArray[m];j=e.normalArray[z];k=e.normalArray[u];m=new THREE.Vector3(h,j,k);m.normalize();m=new THREE.Vertex(o,m);d.vertices.push(m)}nfaces=e.count/3;for(g=0;g<nfaces;g++){m=(b+g)*3;z=m+1;u=m+2;o=d.vertices[m].normal;h=d.vertices[z].normal;j=d.vertices[u].normal;m=new THREE.Face3(m,z,u,[o,h,j]);d.faces.push(m)}b+=nfaces;e.count=0});return d};this.init(a)};
335
THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666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1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
360
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 c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
c},loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(e){THREE.Loader.prototype.createModel(e.data,b,d)};c.postMessage(a)},loadBinary:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:
THREE.Loader.prototype.extractUrlbase(c),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,e,d,g)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,e,g){var h=new XMLHttpRequest,j=d+"/"+a,k=0;
h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,b,e,c):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(g){k==0&&(k=h.getResponseHeader("Content-Length"));g({total:k,loaded:h.responseText.length})}}else h.readyState==2&&(k=h.getResponseHeader("Content-Length"))};h.open("GET",j,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
createBinModel:function(a,c,b,d){var e=function(g){function h(t,C){var B=o(t,C),E=o(t,C+1),S=o(t,C+2),na=o(t,C+3),ga=(na<<1&255|S>>7)-127;B|=(S&127)<<16|E<<8;if(B==0&&ga==-127)return 0;return(1-2*(na>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,ga)}function j(t,C){var B=o(t,C),E=o(t,C+1),S=o(t,C+2);return(o(t,C+3)<<24)+(S<<16)+(E<<8)+B}function k(t,C){var B=o(t,C);return(o(t,C+1)<<8)+B}function m(t,C){var B=o(t,C);return B>127?B-256:B}function o(t,C){return t.charCodeAt(C)&255}function z(t){var C,B,E;C=
j(a,t);B=j(a,t+X);E=j(a,t+L);t=k(a,t+f);THREE.Loader.prototype.f3(w,C,B,E,t)}function u(t){var C,B,E,S,na,ga;C=j(a,t);B=j(a,t+X);E=j(a,t+L);S=k(a,t+f);na=j(a,t+T);ga=j(a,t+R);t=j(a,t+$);THREE.Loader.prototype.f3n(w,Q,C,B,E,S,na,ga,t)}function p(t){var C,B,E,S;C=j(a,t);B=j(a,t+ca);E=j(a,t+J);S=j(a,t+aa);t=k(a,t+ua);THREE.Loader.prototype.f4(w,C,B,E,S,t)}function A(t){var C,B,E,S,na,ga,ja,ma;C=j(a,t);B=j(a,t+ca);E=j(a,t+J);S=j(a,t+aa);na=k(a,t+ua);ga=j(a,t+Y);ja=j(a,t+oa);ma=j(a,t+ia);t=j(a,t+da);THREE.Loader.prototype.f4n(w,
Q,C,B,E,S,na,ga,ja,ma,t)}function D(t){var C,B;C=j(a,t);B=j(a,t+pa);t=j(a,t+ya);THREE.Loader.prototype.uv3(w.uvs,M[C*2],M[C*2+1],M[B*2],M[B*2+1],M[t*2],M[t*2+1])}function F(t){var C,B,E;C=j(a,t);B=j(a,t+ea);E=j(a,t+Z);t=j(a,t+l);THREE.Loader.prototype.uv4(w.uvs,M[C*2],M[C*2+1],M[B*2],M[B*2+1],M[E*2],M[E*2+1],M[t*2],M[t*2+1])}var w=this,H=0,x,Q=[],M=[],X,L,f,T,R,$,ca,J,aa,ua,Y,oa,ia,da,pa,ya,ea,Z,l,y,v,n,q,K,G;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,g);x={signature:a.substr(H,
8),header_bytes:o(a,H+8),vertex_coordinate_bytes:o(a,H+9),normal_coordinate_bytes:o(a,H+10),uv_coordinate_bytes:o(a,H+11),vertex_index_bytes:o(a,H+12),normal_index_bytes:o(a,H+13),uv_index_bytes:o(a,H+14),material_index_bytes:o(a,H+15),nvertices:j(a,H+16),nnormals:j(a,H+16+4),nuvs:j(a,H+16+8),ntri_flat:j(a,H+16+12),ntri_smooth:j(a,H+16+16),ntri_flat_uv:j(a,H+16+20),ntri_smooth_uv:j(a,H+16+24),nquad_flat:j(a,H+16+28),nquad_smooth:j(a,H+16+32),nquad_flat_uv:j(a,H+16+36),nquad_smooth_uv:j(a,H+16+40)};
H+=x.header_bytes;X=x.vertex_index_bytes;L=x.vertex_index_bytes*2;f=x.vertex_index_bytes*3;T=x.vertex_index_bytes*3+x.material_index_bytes;R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;$=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;ca=x.vertex_index_bytes;J=x.vertex_index_bytes*2;aa=x.vertex_index_bytes*3;ua=x.vertex_index_bytes*4;Y=x.vertex_index_bytes*4+x.material_index_bytes;oa=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;ia=
x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;da=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;pa=x.uv_index_bytes;ya=x.uv_index_bytes*2;ea=x.uv_index_bytes;Z=x.uv_index_bytes*2;l=x.uv_index_bytes*3;g=x.vertex_index_bytes*3+x.material_index_bytes;G=x.vertex_index_bytes*4+x.material_index_bytes;y=x.ntri_flat*g;v=x.ntri_smooth*(g+x.normal_index_bytes*3);n=x.ntri_flat_uv*(g+x.uv_index_bytes*3);q=x.ntri_smooth_uv*(g+x.normal_index_bytes*3+x.uv_index_bytes*
3);K=x.nquad_flat*G;g=x.nquad_smooth*(G+x.normal_index_bytes*4);G=x.nquad_flat_uv*(G+x.uv_index_bytes*4);H+=function(t){for(var C,B,E,S=x.vertex_coordinate_bytes*3,na=t+x.nvertices*S;t<na;t+=S){C=h(a,t);B=h(a,t+x.vertex_coordinate_bytes);E=h(a,t+x.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,C,B,E)}return x.nvertices*S}(H);H+=function(t){for(var C,B,E,S=x.normal_coordinate_bytes*3,na=t+x.nnormals*S;t<na;t+=S){C=m(a,t);B=m(a,t+x.normal_coordinate_bytes);E=m(a,t+x.normal_coordinate_bytes*2);
Q.push(C/127,B/127,E/127)}return x.nnormals*S}(H);H+=function(t){for(var C,B,E=x.uv_coordinate_bytes*2,S=t+x.nuvs*E;t<S;t+=E){C=h(a,t);B=h(a,t+x.uv_coordinate_bytes);M.push(C,B)}return x.nuvs*E}(H);y=H+y;v=y+v;n=v+n;q=n+q;K=q+K;g=K+g;G=g+G;(function(t){var C,B=x.vertex_index_bytes*3+x.material_index_bytes,E=B+x.uv_index_bytes*3,S=t+x.ntri_flat_uv*E;for(C=t;C<S;C+=E){z(C);D(C+B)}return S-t})(v);(function(t){var C,B=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,E=B+x.uv_index_bytes*
3,S=t+x.ntri_smooth_uv*E;for(C=t;C<S;C+=E){u(C);D(C+B)}return S-t})(n);(function(t){var C,B=x.vertex_index_bytes*4+x.material_index_bytes,E=B+x.uv_index_bytes*4,S=t+x.nquad_flat_uv*E;for(C=t;C<S;C+=E){p(C);F(C+B)}return S-t})(g);(function(t){var C,B=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,E=B+x.uv_index_bytes*4,S=t+x.nquad_smooth_uv*E;for(C=t;C<S;C+=E){A(C);F(C+B)}return S-t})(G);(function(t){var C,B=x.vertex_index_bytes*3+x.material_index_bytes,E=t+x.ntri_flat*B;for(C=
t;C<E;C+=B)z(C);return E-t})(H);(function(t){var C,B=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,E=t+x.ntri_smooth*B;for(C=t;C<E;C+=B)u(C);return E-t})(y);(function(t){var C,B=x.vertex_index_bytes*4+x.material_index_bytes,E=t+x.nquad_flat*B;for(C=t;C<E;C+=B)p(C);return E-t})(q);(function(t){var C,B=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,E=t+x.nquad_smooth*B;for(C=t;C<E;C+=B)A(C);return E-t})(K);this.computeCentroids();this.computeFaceNormals()};
e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(b))},createModel:function(a,c,b){var d=function(e){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,e);(function(){var h,j,k,m,o;h=0;for(j=a.vertices.length;h<j;h+=3){k=a.vertices[h];m=a.vertices[h+1];o=a.vertices[h+2];THREE.Loader.prototype.v(g,k,m,o)}if(a.colors){h=0;for(j=a.colors.length;h<j;h+=3){k=a.colors[h];m=a.colors[h+1];o=a.colors[h+2];THREE.Loader.prototype.vc(g,k,m,o)}}})();(function(){function h(A,
D){THREE.Loader.prototype.f3(g,A[D],A[D+1],A[D+2],A[D+3])}function j(A,D){THREE.Loader.prototype.f3n(g,a.normals,A[D],A[D+1],A[D+2],A[D+3],A[D+4],A[D+5],A[D+6])}function k(A,D){THREE.Loader.prototype.f4(g,A[D],A[D+1],A[D+2],A[D+3],A[D+4])}function m(A,D){THREE.Loader.prototype.f4n(g,a.normals,A[D],A[D+1],A[D+2],A[D+3],A[D+4],A[D+5],A[D+6],A[D+7],A[D+8])}function o(A,D){var F,w,H,x,Q,M,X,L,f;F=A[D];w=A[D+1];H=A[D+2];x=a.uvs[F*2];X=a.uvs[F*2+1];Q=a.uvs[w*2];L=a.uvs[w*2+1];M=a.uvs[H*2];f=a.uvs[H*2+1];
THREE.Loader.prototype.uv3(g.uvs,x,X,Q,L,M,f);if(a.uvs2&&a.uvs2.length){x=a.uvs2[F*2];X=a.uvs2[F*2+1];Q=a.uvs2[w*2];L=a.uvs2[w*2+1];M=a.uvs2[H*2];f=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(g.uvs2,x,1-X,Q,1-L,M,1-f)}}function z(A,D){var F,w,H,x,Q,M,X,L,f,T,R,$;F=A[D];w=A[D+1];H=A[D+2];x=A[D+3];Q=a.uvs[F*2];f=a.uvs[F*2+1];M=a.uvs[w*2];T=a.uvs[w*2+1];X=a.uvs[H*2];R=a.uvs[H*2+1];L=a.uvs[x*2];$=a.uvs[x*2+1];THREE.Loader.prototype.uv4(g.uvs,Q,f,M,T,X,R,L,$);if(a.uvs2){Q=a.uvs2[F*2];f=a.uvs2[F*2+1];M=a.uvs2[w*
2];T=a.uvs2[w*2+1];X=a.uvs2[H*2];R=a.uvs2[H*2+1];L=a.uvs2[x*2];$=a.uvs2[x*2+1];THREE.Loader.prototype.uv4(g.uvs2,Q,1-f,M,1-T,X,1-R,L,1-$)}}var u,p;u=0;for(p=a.trianglesUvs.length;u<p;u+=7){h(a.trianglesUvs,u);o(a.trianglesUvs,u+4)}u=0;for(p=a.trianglesNormalsUvs.length;u<p;u+=10){j(a.trianglesNormalsUvs,u);o(a.trianglesNormalsUvs,u+7)}u=0;for(p=a.quadsUvs.length;u<p;u+=9){k(a.quadsUvs,u);z(a.quadsUvs,u+5)}u=0;for(p=a.quadsNormalsUvs.length;u<p;u+=13){m(a.quadsNormalsUvs,u);z(a.quadsNormalsUvs,u+9)}u=
0;for(p=a.triangles.length;u<p;u+=4)h(a.triangles,u);u=0;for(p=a.trianglesNormals.length;u<p;u+=7)j(a.trianglesNormals,u);u=0;for(p=a.quads.length;u<p;u+=5)k(a.quads,u);u=0;for(p=a.quadsNormals.length;u<p;u+=9)m(a.quadsNormals,u)})();(function(){var h,j,k,m;if(a.skinWeights){h=0;for(j=a.skinWeights.length;h<j;h+=2){k=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,k,m,0,0)}}if(a.skinIndices){h=0;for(j=a.skinIndices.length;h<j;h+=2){k=a.skinIndices[h];m=a.skinIndices[h+1];THREE.Loader.prototype.si(g,
k,m,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(b))},bones:function(a,c){a.bones=c},animation:function(a,c){a.animation=c},si:function(a,c,b,d,e){a.skinIndices.push(new THREE.Vector4(c,b,d,e))},sw:function(a,c,b,d,e){a.skinWeights.push(new THREE.Vector4(c,b,d,e))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,
b,d)))},vc:function(a,c,b,d){var e=new THREE.Color(16777215);e.setRGB(c,b,d);a.colors.push(e)},f3:function(a,c,b,d,e){a.faces.push(new THREE.Face3(c,b,d,null,a.materials[e]))},f4:function(a,c,b,d,e,g){a.faces.push(new THREE.Face4(c,b,d,e,null,a.materials[g]))},f3n:function(a,c,b,d,e,g,h,j,k){g=a.materials[g];var m=c[j*3],o=c[j*3+1];j=c[j*3+2];var z=c[k*3],u=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(b,d,e,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,o,j),new THREE.Vector3(z,
u,k)],g))},f4n:function(a,c,b,d,e,g,h,j,k,m,o){h=a.materials[h];var z=c[k*3],u=c[k*3+1];k=c[k*3+2];var p=c[m*3],A=c[m*3+1];m=c[m*3+2];var D=c[o*3],F=c[o*3+1];o=c[o*3+2];a.faces.push(new THREE.Face4(b,d,e,g,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(z,u,k),new THREE.Vector3(p,A,m),new THREE.Vector3(D,F,o)],h))},uv3:function(a,c,b,d,e,g,h){var j=[];j.push(new THREE.UV(c,b));j.push(new THREE.UV(d,e));j.push(new THREE.UV(g,h));a.push(j)},uv4:function(a,c,b,d,e,g,h,j,k){var m=[];m.push(new THREE.UV(c,
b));m.push(new THREE.UV(d,e));m.push(new THREE.UV(g,h));m.push(new THREE.UV(j,k));a.push(m)},init_materials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(c[d],b)]},createMaterial:function(a,c){function b(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function d(j,k){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var o=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),z=Math.pow(2,Math.round(Math.log(this.height)/
Math.LN2));j.image.width=o;j.image.height=z;j.image.getContext("2d").drawImage(this,0,0,o,z)}else j.image=this;j.needsUpdate=!0};m.src=k}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(e="MeshPhongMaterial");if(a.mapDiffuse&&c){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*
255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);d(g.lightMap,c+"/"+a.mapLightmap)}return new THREE[e](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};