Three.js 183.6 KB
Newer Older
M
Mr.doob 已提交
1
// Three.js r35 - 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,f,g,h,j,l;if(b==0)d=f=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);l=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=l;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=l;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a;g=l;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;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,f=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(b)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function c(E,u,F,v){v=v.clone().subSelf(u);F=F.clone().subSelf(u);var N=E.clone().subSelf(u);E=v.dot(v);u=v.dot(F);v=v.dot(N);var L=F.dot(F);F=F.dot(N);N=1/(E*L-u*u);L=(L*v-u*F)*N;E=(E*F-u*v)*N;return L>0&&E>0&&L+E<1}var b,d,f,g,h,j,l,n,p,w,
t,q=a.geometry,x=q.vertices,B=[];b=0;for(d=q.faces.length;b<d;b++){f=q.faces[b];w=this.origin.clone();t=this.direction.clone();l=a.matrixWorld;g=l.multiplyVector3(x[f.a].position.clone());h=l.multiplyVector3(x[f.b].position.clone());j=l.multiplyVector3(x[f.c].position.clone());l=f instanceof THREE.Face4?l.multiplyVector3(x[f.d].position.clone()):null;n=a.matrixRotationWorld.multiplyVector3(f.normal.clone());p=t.dot(n);if(p<0){n=n.dot((new THREE.Vector3).sub(g,w))/p;w=w.addSelf(t.multiplyScalar(n));
if(f instanceof THREE.Face3){if(c(w,g,h,j)){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};B.push(f)}}else if(f instanceof THREE.Face4&&(c(w,g,h,l)||c(w,h,j,l))){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};B.push(f)}}}return B}};
THREE.Rectangle=function(){function a(){g=d-c;h=f-b}var c,b,d,f,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 f};this.set=function(l,n,p,w){j=!1;c=l;b=n;d=p;f=w;a()};this.addPoint=function(l,n){if(j){j=!1;c=l;b=n;d=l;f=n}else{c=c<l?c:l;b=b<n?b:n;d=d>l?d:l;f=f>n?f:n}a()};
this.add3Points=function(l,n,p,w,t,q){if(j){j=!1;c=l<p?l<t?l:t:p<t?p:t;b=n<w?n<q?n:q:w<q?w:q;d=l>p?l>t?l:t:p>t?p:t;f=n>w?n>q?n:q:w>q?w:q}else{c=l<p?l<t?l<c?l:c:t<c?t:c:p<t?p<c?p:c:t<c?t:c;b=n<w?n<q?n<b?n:b:q<b?q:b:w<q?w<b?w:b:q<b?q:b;d=l>p?l>t?l>d?l:d:t>d?t:d:p>t?p>d?p:d:t>d?t:d;f=n>w?n>q?n>f?n:f:q>f?q:f:w>q?w>f?w:f:q>f?q:f}a()};this.addRectangle=function(l){if(j){j=!1;c=l.getLeft();b=l.getTop();d=l.getRight();f=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();b=b<l.getTop()?b:l.getTop();d=d>l.getRight()?
d:l.getRight();f=f>l.getBottom()?f:l.getBottom()}a()};this.inflate=function(l){c-=l;b-=l;d+=l;f+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();b=b>l.getTop()?b:l.getTop();d=d<l.getRight()?d:l.getRight();f=f<l.getBottom()?f:l.getBottom();a()};this.instersects=function(l){return Math.min(d,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(f,l.getBottom())-Math.max(b,l.getTop())>=0};this.empty=function(){j=!0;f=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
THREE.Matrix4=function(a,c,b,d,f,g,h,j,l,n,p,w,t,q,x,B){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,j||0,l||0,n||0,p||1,w||0,t||0,q||0,x||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,j,l,n,p,w,t,q,x,B){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=j;this.n31=l;this.n32=n;this.n33=p;this.n34=w;this.n41=t;this.n42=q;this.n43=x;this.n44=B;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,
f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();d.cross(b,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=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)*f;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},
25 26 27 28 29 30 31 32 33 34 35 36
multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();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,f=a.n13,g=a.n14,h=a.n21,j=a.n22,l=a.n23,n=a.n24,p=a.n31,w=a.n32,t=a.n33,q=a.n34,x=a.n41,B=a.n42,E=a.n43,u=a.n44,F=c.n11,v=c.n12,N=c.n13,L=c.n14,Y=c.n21,M=c.n22,e=c.n23,V=c.n24,S=c.n31,ba=c.n32,ea=c.n33,J=c.n34;this.n11=b*F+d*Y+f*S;this.n12=
b*v+d*M+f*ba;this.n13=b*N+d*e+f*ea;this.n14=b*L+d*V+f*J+g;this.n21=h*F+j*Y+l*S;this.n22=h*v+j*M+l*ba;this.n23=h*N+j*e+l*ea;this.n24=h*L+j*V+l*J+n;this.n31=p*F+w*Y+t*S;this.n32=p*v+w*M+t*ba;this.n33=p*N+w*e+t*ea;this.n34=p*L+w*V+t*J+q;this.n41=x*F+B*Y+E*S;this.n42=x*v+B*M+E*ba;this.n43=x*N+B*e+E*ea;this.n44=x*L+B*V+E*J+u;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,f=this.n21,g=
this.n22,h=this.n23,j=this.n24,l=this.n31,n=this.n32,p=this.n33,w=this.n34,t=this.n41,q=this.n42,x=this.n43,B=this.n44;return d*h*n*t-b*j*n*t-d*g*p*t+c*j*p*t+b*g*w*t-c*h*w*t-d*h*l*q+b*j*l*q+d*f*p*q-a*j*p*q-b*f*w*q+a*h*w*q+d*g*l*x-c*j*l*x-d*f*n*x+a*j*n*x+c*f*w*x-a*g*w*x-b*g*l*B+c*h*l*B+b*f*n*B-a*h*n*B-c*f*p*B+a*g*p*B},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),f=1-b,g=a.x,h=a.y,j=a.z,l=f*g,n=f*h;this.set(l*g+b,l*h-d*j,l*j+d*h,0,l*h+d*j,n*h+b,n*j-d*g,0,l*j-d*h,
n*j+d*g,f*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 f=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=f*g;this.n12=-f*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=
b+b,j=d+d;a=c*g;var l=c*h;c*=j;var n=b*h;b*=j;d*=j;g*=f;h*=f;f*=j;this.n11=1-(n+d);this.n12=l-f;this.n13=c+h;this.n21=l+f;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+n);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,f=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*f;this.n23=a.n23*f;this.n33=a.n33*f}};
37 38 39 40 41
THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,j=a.n22,l=a.n23,n=a.n24,p=a.n31,w=a.n32,t=a.n33,q=a.n34,x=a.n41,B=a.n42,E=a.n43,u=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=l*q*B-n*t*B+n*w*E-j*q*E-l*w*u+j*t*u;c.n12=g*t*B-f*q*B-g*w*E+d*q*E+f*w*u-d*t*u;c.n13=f*n*B-g*l*B+g*j*E-d*n*E-f*j*u+d*l*u;c.n14=g*l*w-f*n*w-g*j*t+d*n*t+f*j*q-d*l*q;c.n21=n*t*x-l*q*x-n*p*E+h*q*E+l*p*u-h*t*u;c.n22=f*q*x-g*t*x+g*p*E-b*q*E-f*p*u+b*t*u;c.n23=g*l*x-f*n*x-g*h*E+b*n*E+f*h*u-b*l*u;
c.n24=f*n*p-g*l*p+g*h*t-b*n*t-f*h*q+b*l*q;c.n31=j*q*x-n*w*x+n*p*B-h*q*B-j*p*u+h*w*u;c.n32=g*w*x-d*q*x-g*p*B+b*q*B+d*p*u-b*w*u;c.n33=f*n*x-g*j*x+g*h*B-b*n*B-d*h*u+b*j*u;c.n34=g*j*p-d*n*p-g*h*w+b*n*w+d*h*q-b*j*q;c.n41=l*w*x-j*t*x-l*p*B+h*t*B+j*p*E-h*w*E;c.n42=d*t*x-f*w*x+f*p*B-b*t*B-d*p*E+b*w*E;c.n43=f*j*x-d*l*x-f*h*B+b*l*B+d*h*E-b*j*E;c.n44=d*l*p-f*j*p+f*h*w-b*l*w-d*h*t+b*j*t;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,f=-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,l=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*f;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*l;b[6]=a*n;b[7]=a*p;b[8]=a*w;return c};
THREE.Matrix4.makeFrustum=function(a,c,b,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*f/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)};
THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,j,l,n;h=new THREE.Matrix4;j=c-a;l=b-d;n=g-f;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/l;h.n23=0;h.n24=-((b+d)/l);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+f)/n);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
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=
M
Mr.doob 已提交
43 44 45 46 47
!0;this._vector=new THREE.Vector3};
THREE.Object3D.prototype={translate:function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},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)};
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,f=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(b);b=Math.sin(b);var h=a*c,j=d*f;this.w=h*g-j*b;this.x=h*b+j*g;this.y=d*c*g+a*f*b;this.z=a*f*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,f=this.w,g=a.x,h=a.y,j=a.z;a=a.w;this.x=c*a+f*g+b*j-d*h;this.y=b*a+f*h+d*g-c*j;this.z=d*a+f*j+c*h-b*g;this.w=f*a-c*g-b*h-d*j;return this},
multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,f=a.z,g=this.x,h=this.y,j=this.z,l=this.w,n=l*b+h*f-j*d,p=l*d+j*b-g*f,w=l*f+g*d-h*b;b=-g*b-h*d-j*f;c.x=n*l+b*-g+p*-j-w*-h;c.y=p*l+b*-h+w*-g-n*-j;c.z=w*l+b*-j+n*-h-p*-g;return c}};
51
THREE.Quaternion.slerp=function(a,c,b,d){var f=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(f)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),h=Math.sqrt(1-f*f);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}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};
52
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};
53
THREE.Face3=function(a,c,b,d,f){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=f instanceof Array?f:[f]};THREE.Face4=function(a,c,b,d,f,g){this.a=a;this.b=c;this.c=b;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};
54 55
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);
56 57
b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,f,g,h,j=new THREE.Vector3,l=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;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,
b.position);l.sub(c.position,b.position);j.crossSelf(l)}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,
58
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<
59 60 61 62
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,ca,wa,da,ta,ha,fa){g=J.vertices[ca].position;h=J.vertices[wa].position;j=J.vertices[da].position;l=f[ta];n=f[ha];p=f[fa];w=h.x-g.x;t=j.x-g.x;q=h.y-g.y;
x=j.y-g.y;B=h.z-g.z;E=j.z-g.z;u=n.u-l.u;F=p.u-l.u;v=n.v-l.v;N=p.v-l.v;L=1/(u*N-F*v);e.set((N*w-v*t)*L,(N*q-v*x)*L,(N*B-v*E)*L);V.set((u*t-F*w)*L,(u*x-F*q)*L,(u*E-F*B)*L);Y[ca].addSelf(e);Y[wa].addSelf(e);Y[da].addSelf(e);M[ca].addSelf(V);M[wa].addSelf(V);M[da].addSelf(V)}var c,b,d,f,g,h,j,l,n,p,w,t,q,x,B,E,u,F,v,N,L,Y=[],M=[],e=new THREE.Vector3,V=new THREE.Vector3,S=new THREE.Vector3,ba=new THREE.Vector3,ea=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){Y[c]=new THREE.Vector3;M[c]=new THREE.Vector3}c=
0;for(b=this.faces.length;c<b;c++){d=this.faces[c];f=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++){ea.copy(this.vertices[c].normal);d=Y[c];S.copy(d);S.subSelf(ea.multiplyScalar(ea.dot(d))).normalize();ba.cross(this.vertices[c].normal,d);d=ba.dot(M[c]);d=d<0?-1:1;this.vertices[c].tangent.set(S.x,S.y,S.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],
63 64
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;
65
THREE.Spline=function(){function a(t,q,x,B,E,u,F){t=(x-t)*0.5;B=(B-q)*0.5;return(2*(q-x)+t+B)*F+(-3*(q-x)-2*t-B)*u+t*E+q}var c=[],b={x:0,y:0,z:0},d,f,g,h,j,l,n,p,w;this.get2DPoint=function(t,q){d=(t.length-1)*q;f=Math.floor(d);g=d-f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>t.length-2?f:f+1;c[3]=f>t.length-3?f:f+2;l=t[c[0]];n=t[c[1]];p=t[c[2]];w=t[c[3]];h=g*g;j=g*h;b.x=a(l.x,n.x,p.x,w.x,g,h,j);b.y=a(l.y,n.y,p.y,w.y,g,h,j);b.z=a(l.z,n.z,p.z,w.z,g,h,j);return b}};
66 67
THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(f){for(var g=0;g<a.length;g++)a[g].update(f)};b.addToUpdate=function(f){a.indexOf(f)===-1&&a.push(f)};b.removeFromUpdate=function(f){f=a.indexOf(f);f!==-1&&a.splice(f,1)};b.add=function(f){c[f.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+f.name+" already exists in library. Overwriting.");c[f.name]=f;if(f.initialized!==!0){f.length=parseInt(f.length*1E3,10);f.fps*=0.0010;for(var g=0;g<f.hierarchy.length;g++)for(var h=
0;h<f.hierarchy[g].keys.length;h++){if(f.hierarchy[g].keys[h].time<0)f.hierarchy[g].keys[h].time=0;f.hierarchy[g].keys[h].time=parseInt(f.hierarchy[g].keys[h].time*1E3,10);f.hierarchy[g].keys[h].index=h;if(f.hierarchy[g].keys[h].rot!==undefined&&!(f.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var j=f.hierarchy[g].keys[h].rot;f.hierarchy[g].keys[h].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}h=parseInt(f.length*f.fps*0.0010,10);f.JIT={};f.JIT.hierarchy=[];for(g=0;g<f.hierarchy.length;g++)f.JIT.hierarchy.push(Array(h));
68
f.initialized=!0}};b.get=function(f){if(typeof f==="string")if(c[f])return c[f];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+f);return null}};b.parse=function(f){var g=[];if(f instanceof THREE.SkinnedMesh)for(var h=0;h<f.bones.length;h++)g.push(f.bones[h]);else d(f,g);return g};var d=function(f,g){g.push(f);for(var h=0;h<f.children.length;h++)d(f.children[h],g)};b.LINEAR=0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=2;return b}();
69 70
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=
71
this.hierarchy[b]instanceof THREE.Bone?this.hierarchy[b].skinMatrix:this.hierarchy[b].matrix}var d=this.hierarchy[b].animationCache.prevKey,f=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];f.pos=this.getNextKeyWith("pos",b,1);f.rot=this.getNextKeyWith("rot",b,1);f.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
M
Mr.doob 已提交
72 73
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}};
74 75 76 77 78 79
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,f,g,h,j,l,n,p=this.data.JIT.hierarchy,w,t;this.currentTime+=a;t=this.currentTime;w=this.currentTime%=this.data.length;n=parseInt(Math.min(w*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,x=this.hierarchy.length;q<x;q++){a=this.hierarchy[q];l=a.animationCache;if(p[q][n]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=p[q][n];a.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,q*16);
a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!1}else{a.matrix=p[q][n];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 B=0;B<3;B++){b=c[B];h=l.prevKey[b];j=l.nextKey[b];if(j.time<t){if(w<t)if(this.loop){h=this.data.hierarchy[q].keys[0];j=this.getNextKeyWith(b,q,1)}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(b,q,j.index+1)}while(j.time<w)}l.prevKey[b]=
h;l.nextKey[b]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(w-h.time)/(j.time-h.time);f=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=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else{var E=[];E[0]=this.getPrevKeyWith(b,q,h.index-1)[b];E[1]=f;E[2]=g;E[3]=this.getNextKeyWith(b,q,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(E,
d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}else if(b==="rot")THREE.Quaternion.slerp(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&p[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;q<this.hierarchy.length;q++)p[q][n]=this.hierarchy[q]instanceof THREE.Bone?this.hierarchy[q].skinMatrix.clone():this.hierarchy[q].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],f,g,h,j,l,n;f=(a.length-1)*c;g=Math.floor(f);f-=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]];l=a[b[2]];n=a[b[3]];b=f*f;h=f*b;d[0]=this.interpolate(g[0],j[0],l[0],n[0],f,b,h);d[1]=this.interpolate(g[1],j[1],l[1],n[1],f,b,h);d[2]=this.interpolate(g[2],j[2],l[2],n[2],f,b,h);return d};
THREE.Animation.prototype.interpolate=function(a,c,b,d,f,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*f+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]};
M
Mr.doob 已提交
80 81
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]};THREE.Camera=function(a,c,b,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
82 83
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 89 90 91 92 93
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.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);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.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};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(){};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,f,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=f!==undefined?f: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,f={};for(c in a){f[c]={};for(b in a[c]){d=a[c][b];f[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return f},merge:function(a){var c,b,d,f={};for(c=0;c<a.length;c++){d=this.clone(a[c]);for(b in d)f[b]=d[b]}return f}};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,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<f;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<f;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,f,g,h,j;if(this.geometry.bones!==undefined){for(b=0;b<this.geometry.bones.length;b++){f=this.geometry.bones[b];g=f.pos;h=f.rotq;j=f.scl;d=this.addBone();d.name=f.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++){f=this.geometry.bones[b];d=this.bones[b];
f.parent===-1?this.addChild(d):this.bones[f.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,f=this.children.length;for(d=0;d<f;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 f=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[f].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 f;b=this.sources.length;for(a=0;a<b;a++){c=this.sources[a];c.toLowerCase();if(c.indexOf(".mp3")!==-1)f=
"audio/mpeg";else if(c.indexOf(".ogg")!==-1)f="audio/ogg";else c.indexOf(".wav")!==-1&&(f="audio/wav");if(this.domElement.canPlayType(f)){f=document.createElement("source");f.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(f);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 257
THREE.Projector=function(){function a(M,e){return e.z-M.z}function c(M,e){var V=0,S=1,ba=M.z+M.w,ea=e.z+e.w,J=-M.z+M.w,ca=-e.z+e.w;if(ba>=0&&ea>=0&&J>=0&&ca>=0)return!0;else if(ba<0&&ea<0||J<0&&ca<0)return!1;else{if(ba<0)V=Math.max(V,ba/(ba-ea));else ea<0&&(S=Math.min(S,ba/(ba-ea)));if(J<0)V=Math.max(V,J/(J-ca));else ca<0&&(S=Math.min(S,J/(J-ca)));if(S<V)return!1;else{M.lerpSelf(e,V);e.lerpSelf(M,1-S);return!0}}}var b,d,f=[],g,h,j,l=[],n,p,w=[],t,q,x=[],B=new THREE.Vector4,E=new THREE.Vector4,u=new THREE.Matrix4,
F=new THREE.Matrix4,v=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Vector4,L=new THREE.Vector4,Y;this.projectObjects=function(M,e,V){e=[];var S,ba,ea;d=0;ba=M.objects;M=0;for(S=ba.length;M<S;M++){ea=ba[M];var J;if(!(J=!ea.visible))if(J=ea instanceof THREE.Mesh){a:{J=void 0;for(var ca=ea.matrixWorld,wa=-ea.geometry.boundingSphere.radius*Math.max(ea.scale.x,Math.max(ea.scale.y,ea.scale.z)),da=0;da<6;da++){J=v[da].x*ca.n14+
v[da].y*ca.n24+v[da].z*ca.n34+v[da].w;if(J<=wa){J=!1;break a}}J=!0}J=!J}if(!J){b=f[d]=f[d]||new THREE.RenderableObject;B.copy(ea.position);u.multiplyVector3(B);b.object=ea;b.z=B.z;e.push(b);d++}}V&&e.sort(a);return e};this.projectScene=function(M,e,V){var S=[],ba=e.near,ea=e.far,J,ca,wa,da,ta,ha,fa,ra,xa,ga,aa,oa,pa,R,ia,m;j=p=q=0;e.matrixAutoUpdate&&e.update();u.multiply(e.projectionMatrix,e.matrixWorldInverse);v[0].set(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);v[1].set(u.n41+u.n11,u.n42+
u.n12,u.n43+u.n13,u.n44+u.n14);v[2].set(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);v[3].set(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);v[4].set(u.n41-u.n31,u.n42-u.n32,u.n43-u.n33,u.n44-u.n34);v[5].set(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);for(J=0;J<6;J++){ha=v[J];ha.divideScalar(Math.sqrt(ha.x*ha.x+ha.y*ha.y+ha.z*ha.z))}M.update(undefined,!1,e);ha=this.projectObjects(M,e,!0);M=0;for(J=ha.length;M<J;M++){fa=ha[M].object;if(fa.visible){ra=fa.matrixWorld;aa=fa.matrixRotationWorld;
xa=fa.materials;ga=fa.overdraw;if(fa instanceof THREE.Mesh){oa=fa.geometry;pa=oa.vertices;ca=0;for(wa=pa.length;ca<wa;ca++){R=pa[ca];R.positionWorld.copy(R.position);ra.multiplyVector3(R.positionWorld);da=R.positionScreen;da.copy(R.positionWorld);u.multiplyVector4(da);da.x/=da.w;da.y/=da.w;R.__visible=da.z>ba&&da.z<ea}oa=oa.faces;ca=0;for(wa=oa.length;ca<wa;ca++){R=oa[ca];if(R instanceof THREE.Face3){da=pa[R.a];ta=pa[R.b];ia=pa[R.c];if(da.__visible&&ta.__visible&&ia.__visible&&(fa.doubleSided||fa.flipSided!=
(ia.positionScreen.x-da.positionScreen.x)*(ta.positionScreen.y-da.positionScreen.y)-(ia.positionScreen.y-da.positionScreen.y)*(ta.positionScreen.x-da.positionScreen.x)<0)){g=l[j]=l[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(da.positionWorld);g.v2.positionWorld.copy(ta.positionWorld);g.v3.positionWorld.copy(ia.positionWorld);g.v1.positionScreen.copy(da.positionScreen);g.v2.positionScreen.copy(ta.positionScreen);g.v3.positionScreen.copy(ia.positionScreen);g.normalWorld.copy(R.normal);aa.multiplyVector3(g.normalWorld);
g.centroidWorld.copy(R.centroid);ra.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);u.multiplyVector3(g.centroidScreen);ia=R.vertexNormals;Y=g.vertexNormalsWorld;da=0;for(ta=ia.length;da<ta;da++){m=Y[da]=Y[da]||new THREE.Vector3;m.copy(ia[da]);aa.multiplyVector3(m)}g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=R.materials;g.overdraw=ga;if(fa.geometry.uvs[ca]){g.uvs[0]=fa.geometry.uvs[ca][0];g.uvs[1]=fa.geometry.uvs[ca][1];g.uvs[2]=fa.geometry.uvs[ca][2]}S.push(g);
j++}}else if(R instanceof THREE.Face4){da=pa[R.a];ta=pa[R.b];ia=pa[R.c];m=pa[R.d];if(da.__visible&&ta.__visible&&ia.__visible&&m.__visible&&(fa.doubleSided||fa.flipSided!=((m.positionScreen.x-da.positionScreen.x)*(ta.positionScreen.y-da.positionScreen.y)-(m.positionScreen.y-da.positionScreen.y)*(ta.positionScreen.x-da.positionScreen.x)<0||(ta.positionScreen.x-ia.positionScreen.x)*(m.positionScreen.y-ia.positionScreen.y)-(ta.positionScreen.y-ia.positionScreen.y)*(m.positionScreen.x-ia.positionScreen.x)<
0))){g=l[j]=l[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(da.positionWorld);g.v2.positionWorld.copy(ta.positionWorld);g.v3.positionWorld.copy(m.positionWorld);g.v1.positionScreen.copy(da.positionScreen);g.v2.positionScreen.copy(ta.positionScreen);g.v3.positionScreen.copy(m.positionScreen);g.normalWorld.copy(R.normal);aa.multiplyVector3(g.normalWorld);g.centroidWorld.copy(R.centroid);ra.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);u.multiplyVector3(g.centroidScreen);
g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=R.materials;g.overdraw=ga;if(fa.geometry.uvs[ca]){g.uvs[0]=fa.geometry.uvs[ca][0];g.uvs[1]=fa.geometry.uvs[ca][1];g.uvs[2]=fa.geometry.uvs[ca][3]}S.push(g);j++;h=l[j]=l[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ta.positionWorld);h.v2.positionWorld.copy(ia.positionWorld);h.v3.positionWorld.copy(m.positionWorld);h.v1.positionScreen.copy(ta.positionScreen);h.v2.positionScreen.copy(ia.positionScreen);h.v3.positionScreen.copy(m.positionScreen);
h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=xa;h.faceMaterials=R.materials;h.overdraw=ga;if(fa.geometry.uvs[ca]){h.uvs[0]=fa.geometry.uvs[ca][1];h.uvs[1]=fa.geometry.uvs[ca][2];h.uvs[2]=fa.geometry.uvs[ca][3]}S.push(h);j++}}}}else if(fa instanceof THREE.Line){F.multiply(u,ra);pa=fa.geometry.vertices;R=pa[0];R.positionScreen.copy(R.position);F.multiplyVector4(R.positionScreen);ca=1;for(wa=pa.length;ca<
wa;ca++){da=pa[ca];da.positionScreen.copy(da.position);F.multiplyVector4(da.positionScreen);ta=pa[ca-1];N.copy(da.positionScreen);L.copy(ta.positionScreen);if(c(N,L)){N.multiplyScalar(1/N.w);L.multiplyScalar(1/L.w);n=w[p]=w[p]||new THREE.RenderableLine;n.v1.positionScreen.copy(N);n.v2.positionScreen.copy(L);n.z=Math.max(N.z,L.z);n.materials=fa.materials;S.push(n);p++}}}else if(fa instanceof THREE.Particle){E.set(fa.position.x,fa.position.y,fa.position.z,1);u.multiplyVector4(E);E.z/=E.w;if(E.z>0&&
E.z<1){t=x[q]=x[q]||new THREE.RenderableParticle;t.x=E.x/E.w;t.y=E.y/E.w;t.z=E.z;t.rotation=fa.rotation.z;t.scale.x=fa.scale.x*Math.abs(t.x-(E.x+e.projectionMatrix.n11)/(E.w+e.projectionMatrix.n14));t.scale.y=fa.scale.y*Math.abs(t.y-(E.y+e.projectionMatrix.n22)/(E.w+e.projectionMatrix.n24));t.materials=fa.materials;S.push(t);q++}}}}V&&S.sort(a);return S};this.unprojectVector=function(M,e){var V=e.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(e.projectionMatrix));V.multiplyVector3(M);
return M}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;f=b/2;g=d/2};this.render=function(h,j){var l,n,p,w,t,q,x,B;a=c.projectScene(h,j);l=0;for(n=a.length;l<n;l++){t=a[l];if(t instanceof THREE.RenderableParticle){x=t.x*f+f;B=t.y*g+g;p=0;for(w=t.material.length;p<w;p++){q=t.material[p];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=x+"px";q.style.top=B+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ja){if(t!=ja)n.globalAlpha=t=ja}function c(ja){if(q!=ja){switch(ja){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}q=ja}}var b=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,j,l,n=f.getContext("2d"),p=new THREE.Color(0),w=0,t=1,q=0,x=null,B=null,E=1,u,F,v,N,L,Y,M,e,V,S=new THREE.Color,
ba=new THREE.Color,ea=new THREE.Color,J=new THREE.Color,ca=new THREE.Color,wa,da,ta,ha,fa,ra,xa,ga,aa,oa=new THREE.Rectangle,pa=new THREE.Rectangle,R=new THREE.Rectangle,ia=!1,m=new THREE.Color,z=new THREE.Color,C=new THREE.Color,k=new THREE.Color,o=Math.PI*2,y=new THREE.Vector3,A,D,P,H,O,la,ua=16;A=document.createElement("canvas");A.width=A.height=2;D=A.getContext("2d");D.fillStyle="rgba(0,0,0,1)";D.fillRect(0,0,2,2);P=D.getImageData(0,0,2,2);H=P.data;O=document.createElement("canvas");O.width=O.height=
ua;la=O.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ja,ka){g=ja;h=ka;j=g/2;l=h/2;f.width=g;f.height=h;oa.set(-j,-l,j,l);t=1;q=0;B=x=null;E=1};this.setClearColor=function(ja,ka){p=ja;w=ka};this.setClearColorHex=function(ja,ka){p.setHex(ja);w=ka};this.clear=function(){n.setTransform(1,0,0,-1,j,l);if(!pa.isEmpty()){pa.inflate(1);pa.minSelf(oa);if(p.hex==0&&w==0)n.clearRect(pa.getX(),
pa.getY(),pa.getWidth(),pa.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+w+")";n.fillRect(pa.getX(),pa.getY(),pa.getWidth(),pa.getHeight())}pa.empty()}};this.render=function(ja,ka){function sa(G){var W,T,K,$=G.lights;z.setRGB(0,0,0);C.setRGB(0,0,0);k.setRGB(0,0,0);G=0;for(W=$.length;G<W;G++){T=$[G];K=T.color;if(T instanceof THREE.AmbientLight){z.r+=K.r;z.g+=K.g;z.b+=K.b}else if(T instanceof THREE.DirectionalLight){C.r+=
K.r;C.g+=K.g;C.b+=K.b}else if(T instanceof THREE.PointLight){k.r+=K.r;k.g+=K.g;k.b+=K.b}}}function ma(G,W,T,K){var $,na,Ea,va,Ha=G.lights;G=0;for($=Ha.length;G<$;G++){na=Ha[G];Ea=na.color;va=na.intensity;if(na instanceof THREE.DirectionalLight){na=T.dot(na.position)*va;if(na>0){K.r+=Ea.r*na;K.g+=Ea.g*na;K.b+=Ea.b*na}}else if(na instanceof THREE.PointLight){y.sub(na.position,W);y.normalize();na=T.dot(y)*va;if(na>0){K.r+=Ea.r*na;K.g+=Ea.g*na;K.b+=Ea.b*na}}}}function Ka(G,W,T){if(T.opacity!=0){a(T.opacity);
c(T.blending);var K,$,na,Ea,va,Ha;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){Ea=T.map.image;va=Ea.width>>1;Ha=Ea.height>>1;$=W.scale.x*j;na=W.scale.y*l;T=$*va;K=na*Ha;R.set(G.x-T,G.y-K,G.x+T,G.y+K);if(oa.instersects(R)){n.save();n.translate(G.x,G.y);n.rotate(-W.rotation);n.scale($,-na);n.translate(-va,-Ha);n.drawImage(Ea,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(ia){m.r=z.r+C.r+k.r;m.g=z.g+C.g+k.g;m.b=z.b+C.b+k.b;S.r=T.color.r*m.r;S.g=T.color.g*m.g;S.b=T.color.b*
m.b;S.updateStyleString()}else S.__styleString=T.color.__styleString;T=W.scale.x*j;K=W.scale.y*l;R.set(G.x-T,G.y-K,G.x+T,G.y+K);if(oa.instersects(R)){$=S.__styleString;if(B!=$)n.fillStyle=B=$;n.save();n.translate(G.x,G.y);n.rotate(-W.rotation);n.scale(T,K);n.beginPath();n.arc(0,0,1,0,o,!0);n.closePath();n.fill();n.restore()}}}}function Q(G,W,T,K){if(K.opacity!=0){a(K.opacity);c(K.blending);n.beginPath();n.moveTo(G.positionScreen.x,G.positionScreen.y);n.lineTo(W.positionScreen.x,W.positionScreen.y);
n.closePath();if(K instanceof THREE.LineBasicMaterial){S.__styleString=K.color.__styleString;G=K.linewidth;if(E!=G)n.lineWidth=E=G;G=S.__styleString;if(x!=G)n.strokeStyle=x=G;n.stroke();R.inflate(K.linewidth*2)}}}function Ga(G,W,T,K,$,na){if($.opacity!=0){a($.opacity);c($.blending);N=G.positionScreen.x;L=G.positionScreen.y;Y=W.positionScreen.x;M=W.positionScreen.y;e=T.positionScreen.x;V=T.positionScreen.y;n.beginPath();n.moveTo(N,L);n.lineTo(Y,M);n.lineTo(e,V);n.lineTo(N,L);n.closePath();if($ instanceof
THREE.MeshBasicMaterial)if($.map)$.map.mapping instanceof THREE.UVMapping&&U(N,L,Y,M,e,V,$.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){G=ka.matrixWorldInverse;y.copy(K.vertexNormalsWorld[0]);ha=(y.x*G.n11+y.y*G.n12+y.z*G.n13)*0.5+0.5;fa=-(y.x*G.n21+y.y*G.n22+y.z*G.n23)*0.5+0.5;y.copy(K.vertexNormalsWorld[1]);ra=(y.x*G.n11+y.y*G.n12+y.z*G.n13)*0.5+0.5;xa=-(y.x*G.n21+y.y*G.n22+y.z*G.n23)*
0.5+0.5;y.copy(K.vertexNormalsWorld[2]);ga=(y.x*G.n11+y.y*G.n12+y.z*G.n13)*0.5+0.5;aa=-(y.x*G.n21+y.y*G.n22+y.z*G.n23)*0.5+0.5;U(N,L,Y,M,e,V,$.envMap.image,ha,fa,ra,xa,ga,aa)}}else $.wireframe?Ca($.color.__styleString,$.wireframeLinewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&U(N,L,Y,M,e,V,$.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);c(THREE.SubtractiveBlending)}if(ia)if(!$.wireframe&&
$.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){ba.r=ea.r=J.r=z.r;ba.g=ea.g=J.g=z.g;ba.b=ea.b=J.b=z.b;ma(na,K.v1.positionWorld,K.vertexNormalsWorld[0],ba);ma(na,K.v2.positionWorld,K.vertexNormalsWorld[1],ea);ma(na,K.v3.positionWorld,K.vertexNormalsWorld[2],J);ca.r=(ea.r+J.r)*0.5;ca.g=(ea.g+J.g)*0.5;ca.b=(ea.b+J.b)*0.5;ta=X(ba,ea,J,ca);U(N,L,Y,M,e,V,ta,0,0,1,0,0,1)}else{m.r=z.r;m.g=z.g;m.b=z.b;ma(na,K.centroidWorld,K.normalWorld,m);S.r=$.color.r*m.r;S.g=$.color.g*m.g;S.b=$.color.b*
m.b;S.updateStyleString();$.wireframe?Ca(S.__styleString,$.wireframeLinewidth):Fa(S.__styleString)}else $.wireframe?Ca($.color.__styleString,$.wireframeLinewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){wa=ka.near;da=ka.far;ba.r=ba.g=ba.b=1-Z(G.positionScreen.z,wa,da);ea.r=ea.g=ea.b=1-Z(W.positionScreen.z,wa,da);J.r=J.g=J.b=1-Z(T.positionScreen.z,wa,da);ca.r=(ea.r+J.r)*0.5;ca.g=(ea.g+J.g)*0.5;ca.b=(ea.b+J.b)*0.5;ta=X(ba,ea,J,ca);U(N,L,Y,M,e,V,ta,0,0,1,0,0,1)}else if($ instanceof
THREE.MeshNormalMaterial){S.r=ya(K.normalWorld.x);S.g=ya(K.normalWorld.y);S.b=ya(K.normalWorld.z);S.updateStyleString();$.wireframe?Ca(S.__styleString,$.wireframeLinewidth):Fa(S.__styleString)}}}function Ca(G,W){if(x!=G)n.strokeStyle=x=G;if(E!=W)n.lineWidth=E=W;n.stroke();R.inflate(W*2)}function Fa(G){if(B!=G)n.fillStyle=B=G;n.fill()}function U(G,W,T,K,$,na,Ea,va,Ha,Oa,Ja,Pa,Sa){var Na,Da;Na=Ea.width-1;Da=Ea.height-1;va*=Na;Ha*=Da;Oa*=Na;Ja*=Da;Pa*=Na;Sa*=Da;T-=G;K-=W;$-=G;na-=W;Oa-=va;Ja-=Ha;Pa-=
va;Sa-=Ha;Na=Oa*Sa-Pa*Ja;if(Na!=0){Da=1/Na;Na=(Sa*T-Ja*$)*Da;Ja=(Sa*K-Ja*na)*Da;T=(Oa*$-Pa*T)*Da;K=(Oa*na-Pa*K)*Da;G=G-Na*va-T*Ha;W=W-Ja*va-K*Ha;n.save();n.transform(Na,Ja,T,K,G,W);n.clip();n.drawImage(Ea,0,0);n.restore()}}function X(G,W,T,K){var $=~~(G.r*255),na=~~(G.g*255);G=~~(G.b*255);var Ea=~~(W.r*255),va=~~(W.g*255);W=~~(W.b*255);var Ha=~~(T.r*255),Oa=~~(T.g*255);T=~~(T.b*255);var Ja=~~(K.r*255),Pa=~~(K.g*255);K=~~(K.b*255);H[0]=$<0?0:$>255?255:$;H[1]=na<0?0:na>255?255:na;H[2]=G<0?0:G>255?255:
G;H[4]=Ea<0?0:Ea>255?255:Ea;H[5]=va<0?0:va>255?255:va;H[6]=W<0?0:W>255?255:W;H[8]=Ha<0?0:Ha>255?255:Ha;H[9]=Oa<0?0:Oa>255?255:Oa;H[10]=T<0?0:T>255?255:T;H[12]=Ja<0?0:Ja>255?255:Ja;H[13]=Pa<0?0:Pa>255?255:Pa;H[14]=K<0?0:K>255?255:K;D.putImageData(P,0,0);la.drawImage(A,0,0);return O}function Z(G,W,T){G=(G-W)/(T-W);return G*G*(3-2*G)}function ya(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ia(G,W){var T=W.x-G.x,K=W.y-G.y,$=1/Math.sqrt(T*T+K*K);T*=$;K*=$;W.x+=T;W.y+=K;G.x-=T;G.y-=K}var Aa,I,qa,Ma,Qa,
La,za,Ba;this.autoClear?this.clear():n.setTransform(1,0,0,-1,j,l);b=d.projectScene(ja,ka,this.sortElements);(ia=ja.lights.length>0)&&sa(ja);Aa=0;for(I=b.length;Aa<I;Aa++){qa=b[Aa];R.empty();if(qa instanceof THREE.RenderableParticle){u=qa;u.x*=j;u.y*=l;Ma=0;for(Qa=qa.materials.length;Ma<Qa;Ma++)Ka(u,qa,qa.materials[Ma],ja)}else if(qa instanceof THREE.RenderableLine){u=qa.v1;F=qa.v2;u.positionScreen.x*=j;u.positionScreen.y*=l;F.positionScreen.x*=j;F.positionScreen.y*=l;R.addPoint(u.positionScreen.x,
u.positionScreen.y);R.addPoint(F.positionScreen.x,F.positionScreen.y);if(oa.instersects(R)){Ma=0;for(Qa=qa.materials.length;Ma<Qa;)Q(u,F,qa,qa.materials[Ma++],ja)}}else if(qa instanceof THREE.RenderableFace3){u=qa.v1;F=qa.v2;v=qa.v3;u.positionScreen.x*=j;u.positionScreen.y*=l;F.positionScreen.x*=j;F.positionScreen.y*=l;v.positionScreen.x*=j;v.positionScreen.y*=l;if(qa.overdraw){Ia(u.positionScreen,F.positionScreen);Ia(F.positionScreen,v.positionScreen);Ia(v.positionScreen,u.positionScreen)}R.add3Points(u.positionScreen.x,
u.positionScreen.y,F.positionScreen.x,F.positionScreen.y,v.positionScreen.x,v.positionScreen.y);if(oa.instersects(R)){Ma=0;for(Qa=qa.meshMaterials.length;Ma<Qa;){Ba=qa.meshMaterials[Ma++];if(Ba instanceof THREE.MeshFaceMaterial){La=0;for(za=qa.faceMaterials.length;La<za;)(Ba=qa.faceMaterials[La++])&&Ga(u,F,v,qa,Ba,ja)}else Ga(u,F,v,qa,Ba,ja)}}}pa.addRectangle(R)}n.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(ha,fa,ra){var xa,ga,aa,oa;xa=0;for(ga=ha.lights.length;xa<ga;xa++){aa=ha.lights[xa];if(aa instanceof THREE.DirectionalLight){oa=fa.normalWorld.dot(aa.position)*aa.intensity;if(oa>0){ra.r+=aa.color.r*oa;ra.g+=aa.color.g*oa;ra.b+=aa.color.b*oa}}else if(aa instanceof THREE.PointLight){V.sub(aa.position,fa.centroidWorld);V.normalize();oa=fa.normalWorld.dot(V)*aa.intensity;if(oa>0){ra.r+=aa.color.r*oa;ra.g+=aa.color.g*oa;ra.b+=aa.color.b*oa}}}}function c(ha,fa,ra,
xa,ga,aa){J=d(ca++);J.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)v.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(aa,xa,N);v.r=ga.color.r*N.r;v.g=ga.color.g*N.g;v.b=ga.color.b*N.b;v.updateStyleString()}else v.__styleString=ga.color.__styleString;else if(ga instanceof
THREE.MeshDepthMaterial){e=1-ga.__2near/(ga.__farPlusNear-xa.z*ga.__farMinusNear);v.setRGB(e,e,e)}else ga instanceof THREE.MeshNormalMaterial&&v.setRGB(f(xa.normalWorld.x),f(xa.normalWorld.y),f(xa.normalWorld.z));ga.wireframe?J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):J.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+
ga.opacity);j.appendChild(J)}function b(ha,fa,ra,xa,ga,aa,oa){J=d(ca++);J.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)v.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(oa,ga,N);v.r=aa.color.r*N.r;v.g=aa.color.g*N.g;
v.b=aa.color.b*N.b;v.updateStyleString()}else v.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){e=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);v.setRGB(e,e,e)}else aa instanceof THREE.MeshNormalMaterial&&v.setRGB(f(ga.normalWorld.x),f(ga.normalWorld.y),f(ga.normalWorld.z));aa.wireframe?J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+
"; stroke-linejoin: "+aa.wireframeLinejoin):J.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+aa.opacity);j.appendChild(J)}function d(ha){if(S[ha]==null){S[ha]=document.createElementNS("http://www.w3.org/2000/svg","path");ta==0&&S[ha].setAttribute("shape-rendering","crispEdges")}return S[ha]}function f(ha){return ha<0?Math.min((1+ha)*0.5,0.5):0.5+Math.min(ha*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,p,w,t,q,x,B,E=
new THREE.Rectangle,u=new THREE.Rectangle,F=!1,v=new THREE.Color(16777215),N=new THREE.Color(16777215),L=new THREE.Color(0),Y=new THREE.Color(0),M=new THREE.Color(0),e,V=new THREE.Vector3,S=[],ba=[],ea=[],J,ca,wa,da,ta=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ha){switch(ha){case "high":ta=1;break;case "low":ta=0}};this.setSize=function(ha,fa){l=ha;n=fa;p=l/2;w=n/2;j.setAttribute("viewBox",-p+" "+-w+" "+l+" "+n);j.setAttribute("width",
l);j.setAttribute("height",n);E.set(-p,-w,p,w)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(ha,fa){var ra,xa,ga,aa,oa,pa,R,ia;this.autoClear&&this.clear();g=h.projectScene(ha,fa,this.sortElements);da=wa=ca=0;if(F=ha.lights.length>0){R=ha.lights;L.setRGB(0,0,0);Y.setRGB(0,0,0);M.setRGB(0,0,0);ra=0;for(xa=R.length;ra<xa;ra++){ga=R[ra];aa=ga.color;if(ga instanceof THREE.AmbientLight){L.r+=aa.r;L.g+=aa.g;L.b+=aa.b}else if(ga instanceof THREE.DirectionalLight){Y.r+=
aa.r;Y.g+=aa.g;Y.b+=aa.b}else if(ga instanceof THREE.PointLight){M.r+=aa.r;M.g+=aa.g;M.b+=aa.b}}}ra=0;for(xa=g.length;ra<xa;ra++){R=g[ra];u.empty();if(R instanceof THREE.RenderableParticle){t=R;t.x*=p;t.y*=-w;ga=0;for(aa=R.materials.length;ga<aa;ga++)if(ia=R.materials[ga]){oa=t;pa=R;var m=wa++;if(ba[m]==null){ba[m]=document.createElementNS("http://www.w3.org/2000/svg","circle");ta==0&&ba[m].setAttribute("shape-rendering","crispEdges")}J=ba[m];J.setAttribute("cx",oa.x);J.setAttribute("cy",oa.y);J.setAttribute("r",
pa.scale.x*p);if(ia instanceof THREE.ParticleCircleMaterial){if(F){N.r=L.r+Y.r+M.r;N.g=L.g+Y.g+M.g;N.b=L.b+Y.b+M.b;v.r=ia.color.r*N.r;v.g=ia.color.g*N.g;v.b=ia.color.b*N.b;v.updateStyleString()}else v=ia.color;J.setAttribute("style","fill: "+v.__styleString)}j.appendChild(J)}}else if(R instanceof THREE.RenderableLine){t=R.v1;q=R.v2;t.positionScreen.x*=p;t.positionScreen.y*=-w;q.positionScreen.x*=p;q.positionScreen.y*=-w;u.addPoint(t.positionScreen.x,t.positionScreen.y);u.addPoint(q.positionScreen.x,
q.positionScreen.y);if(E.instersects(u)){ga=0;for(aa=R.materials.length;ga<aa;)if(ia=R.materials[ga++]){oa=t;pa=q;m=da++;if(ea[m]==null){ea[m]=document.createElementNS("http://www.w3.org/2000/svg","line");ta==0&&ea[m].setAttribute("shape-rendering","crispEdges")}J=ea[m];J.setAttribute("x1",oa.positionScreen.x);J.setAttribute("y1",oa.positionScreen.y);J.setAttribute("x2",pa.positionScreen.x);J.setAttribute("y2",pa.positionScreen.y);if(ia instanceof THREE.LineBasicMaterial){v.__styleString=ia.color.__styleString;
J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+ia.linewidth+"; stroke-opacity: "+ia.opacity+"; stroke-linecap: "+ia.linecap+"; stroke-linejoin: "+ia.linejoin);j.appendChild(J)}}}}else if(R instanceof THREE.RenderableFace3){t=R.v1;q=R.v2;x=R.v3;t.positionScreen.x*=p;t.positionScreen.y*=-w;q.positionScreen.x*=p;q.positionScreen.y*=-w;x.positionScreen.x*=p;x.positionScreen.y*=-w;u.addPoint(t.positionScreen.x,t.positionScreen.y);u.addPoint(q.positionScreen.x,q.positionScreen.y);
u.addPoint(x.positionScreen.x,x.positionScreen.y);if(E.instersects(u)){ga=0;for(aa=R.meshMaterials.length;ga<aa;){ia=R.meshMaterials[ga++];if(ia instanceof THREE.MeshFaceMaterial){oa=0;for(pa=R.faceMaterials.length;oa<pa;)(ia=R.faceMaterials[oa++])&&c(t,q,x,R,ia,ha)}else ia&&c(t,q,x,R,ia,ha)}}}else if(R instanceof THREE.RenderableFace4){t=R.v1;q=R.v2;x=R.v3;B=R.v4;t.positionScreen.x*=p;t.positionScreen.y*=-w;q.positionScreen.x*=p;q.positionScreen.y*=-w;x.positionScreen.x*=p;x.positionScreen.y*=-w;
B.positionScreen.x*=p;B.positionScreen.y*=-w;u.addPoint(t.positionScreen.x,t.positionScreen.y);u.addPoint(q.positionScreen.x,q.positionScreen.y);u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);if(E.instersects(u)){ga=0;for(aa=R.meshMaterials.length;ga<aa;){ia=R.meshMaterials[ga++];if(ia instanceof THREE.MeshFaceMaterial){oa=0;for(pa=R.faceMaterials.length;oa<pa;)(ia=R.faceMaterials[oa++])&&b(t,q,x,B,R,ia,ha)}else ia&&b(t,q,x,B,R,ia,ha)}}}}}};
THREE.WebGLRenderer=function(a){function c(m,z,C){var k,o,y,A=m.vertices,D=A.length,P=m.colors,H=P.length,O=m.__vertexArray,la=m.__colorArray,ua=m.__sortArray,ja=m.__dirtyVertices,ka=m.__dirtyColors;if(C.sortParticles){xa.multiplySelf(C.matrixWorld);for(k=0;k<D;k++){o=A[k].position;oa.copy(o);xa.multiplyVector3(oa);ua[k]=[oa.z,k]}ua.sort(function(sa,ma){return ma[0]-sa[0]});for(k=0;k<D;k++){o=A[ua[k][1]].position;y=k*3;O[y]=o.x;O[y+1]=o.y;O[y+2]=o.z}for(k=0;k<H;k++){y=k*3;color=P[ua[k][1]];la[y]=
color.r;la[y+1]=color.g;la[y+2]=color.b}}else{if(ja)for(k=0;k<D;k++){o=A[k].position;y=k*3;O[y]=o.x;O[y+1]=o.y;O[y+2]=o.z}if(ka)for(k=0;k<H;k++){color=P[k];y=k*3;la[y]=color.r;la[y+1]=color.g;la[y+2]=color.b}}if(ja||C.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,O,z)}if(ka||C.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,la,z)}}function b(m,z){m.fragmentShader=z.fragmentShader;m.vertexShader=z.vertexShader;
m.uniforms=Uniforms.clone(z.uniforms)}function d(m,z,C,k,o){k.program||ba.initMaterial(k,z,C);var y=k.program,A=y.uniforms,D=k.uniforms;if(y!=V){e.useProgram(y);V=y;e.uniformMatrix4fv(A.projectionMatrix,!1,ga)}if(C&&(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial||k instanceof THREE.LineBasicMaterial||k instanceof THREE.ParticleBasicMaterial)){D.fogColor.value.setHex(C.color.hex);if(C instanceof THREE.Fog){D.fogNear.value=C.near;
D.fogFar.value=C.far}else if(C instanceof THREE.FogExp2)D.fogDensity.value=C.density}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial){var P,H,O=0,la=0,ua=0,ja,ka,sa,ma=ba.lights,Ka=ma.directional.colors,Q=ma.directional.positions,Ga=ma.point.colors,Ca=ma.point.positions,Fa=0,U=0;C=H=H=0;for(P=z.length;C<P;C++){H=z[C];ja=H.color;ka=H.position;sa=H.intensity;if(H instanceof THREE.AmbientLight){O+=ja.r;la+=ja.g;ua+=ja.b}else if(H instanceof THREE.DirectionalLight){H=Fa*
3;Ka[H]=ja.r*sa;Ka[H+1]=ja.g*sa;Ka[H+2]=ja.b*sa;Q[H]=ka.x;Q[H+1]=ka.y;Q[H+2]=ka.z;Fa+=1}else if(H instanceof THREE.PointLight){H=U*3;Ga[H]=ja.r*sa;Ga[H+1]=ja.g*sa;Ga[H+2]=ja.b*sa;Ca[H]=ka.x;Ca[H+1]=ka.y;Ca[H+2]=ka.z;U+=1}}for(C=Fa*3;C<Ka.length;C++)Ka[C]=0;for(C=U*3;C<Ga.length;C++)Ga[C]=0;ma.point.length=U;ma.directional.length=Fa;ma.ambient[0]=O;ma.ambient[1]=la;ma.ambient[2]=ua;z=ba.lights;D.enableLighting.value=z.directional.length+z.point.length;D.ambientLightColor.value=z.ambient;D.directionalLightColor.value=
z.directional.colors;D.directionalLightDirection.value=z.directional.positions;D.pointLightColor.value=z.point.colors;D.pointLightPosition.value=z.point.positions}if(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial){D.diffuse.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);D.opacity.value=k.opacity;D.map.texture=k.map;D.lightMap.texture=k.lightMap;D.envMap.texture=k.envMap;D.reflectivity.value=k.reflectivity;
D.refractionRatio.value=k.refractionRatio;D.combine.value=k.combine;D.useRefract.value=k.envMap&&k.envMap.mapping instanceof THREE.CubeRefractionMapping}if(k instanceof THREE.LineBasicMaterial){D.diffuse.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);D.opacity.value=k.opacity}else if(k instanceof THREE.ParticleBasicMaterial){D.psColor.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);D.opacity.value=k.opacity;D.size.value=k.size;D.map.texture=k.map}else if(k instanceof
THREE.MeshPhongMaterial){D.ambient.value.setRGB(k.ambient.r,k.ambient.g,k.ambient.b);D.specular.value.setRGB(k.specular.r,k.specular.g,k.specular.b);D.shininess.value=k.shininess}else if(k instanceof THREE.MeshDepthMaterial){D.mNear.value=m.near;D.mFar.value=m.far;D.opacity.value=k.opacity}else if(k instanceof THREE.MeshNormalMaterial)D.opacity.value=k.opacity;for(var X in D)if(O=y.uniforms[X]){C=D[X];P=C.type;z=C.value;if(P=="i")e.uniform1i(O,z);else if(P=="f")e.uniform1f(O,z);else if(P=="fv1")e.uniform1fv(O,
z);else if(P=="fv")e.uniform3fv(O,z);else if(P=="v2")e.uniform2f(O,z.x,z.y);else if(P=="v3")e.uniform3f(O,z.x,z.y,z.z);else if(P=="c")e.uniform3f(O,z.r,z.g,z.b);else if(P=="t"){e.uniform1i(O,z);if(C=C.texture)if(C.image instanceof Array&&C.image.length==6){if(C.image.length==6){if(C.needsUpdate){if(C.__wasSetOnce){e.bindTexture(e.TEXTURE_CUBE_MAP,C.image.__webGLTextureCube);for(P=0;P<6;++P)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+P,0,0,0,e.RGBA,e.UNSIGNED_BYTE,C.image[P])}else{C.image.__webGLTextureCube=
e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,C.image.__webGLTextureCube);for(P=0;P<6;++P)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+P,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,C.image[P]);C.__wasSetOnce=!0}F(e.TEXTURE_CUBE_MAP,C,C.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);C.needsUpdate=!1}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_CUBE_MAP,C.image.__webGLTextureCube)}}else{if(C.needsUpdate){if(C.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,C.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,
0,0,0,e.RGBA,e.UNSIGNED_BYTE,C.image)}else{C.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,C.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,C.image);C.__wasSetOnce=!0}F(e.TEXTURE_2D,C,C.image);e.bindTexture(e.TEXTURE_2D,null);C.needsUpdate=!1}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_2D,C.__webGLTexture)}}}e.uniformMatrix4fv(A.modelViewMatrix,!1,o._modelViewMatrixArray);e.uniformMatrix3fv(A.normalMatrix,!1,o._normalMatrixArray);(k instanceof THREE.MeshShaderMaterial||
k instanceof THREE.MeshPhongMaterial||k.envMap)&&e.uniform3f(A.cameraPosition,m.position.x,m.position.y,m.position.z);(k instanceof THREE.MeshShaderMaterial||k.envMap||k.skinning)&&e.uniformMatrix4fv(A.objectMatrix,!1,o._objectMatrixArray);(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshShaderMaterial||k.skinning)&&e.uniformMatrix4fv(A.viewMatrix,!1,aa);if(k.skinning){e.uniformMatrix4fv(A.cameraInverseMatrix,!1,aa);e.uniformMatrix4fv(A.boneGlobalMatrices,
!1,o.boneMatrices)}return y}function f(m,z,C,k,o,y){m=d(m,z,C,k,y).attributes;e.bindBuffer(e.ARRAY_BUFFER,o.__webGLVertexBuffer);e.vertexAttribPointer(m.position,3,e.FLOAT,!1,0,0);if(m.color>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.vertexAttribPointer(m.normal,3,e.FLOAT,!1,0,0)}if(m.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.vertexAttribPointer(m.tangent,
4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(o.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.vertexAttribPointer(m.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv)}else e.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(o.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2);if(k.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,
o.__webGLSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,4,e.FLOAT,!1,0,0)}if(y instanceof THREE.Mesh)if(k.wireframe){e.lineWidth(k.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
o.__webGLLineBuffer);e.drawElements(e.LINES,o.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,o.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(y instanceof THREE.Line){y=y.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(k.linewidth);e.drawArrays(y,0,o.__webGLLineCount)}else if(y instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,o.__webGLParticleCount);else y instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,
0,o.__webGLVertexCount)}function g(m,z){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=e.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=e.createBuffer();if(m.hasPos){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,m.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.position);e.vertexAttribPointer(z.attributes.position,3,e.FLOAT,!1,0,0)}if(m.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,m.normalArray,
e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.normal);e.vertexAttribPointer(z.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,m.count);m.count=0}function h(m){if(ea!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ea=m.doubleSided}if(J!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);J=m.flipSided}}function j(m){if(wa!=m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);wa=m}}function l(m){ra[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,
m.n44-m.n14);ra[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);ra[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);ra[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);ra[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);ra[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var z;for(m=0;m<6;m++){z=ra[m];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}}function n(m){for(var z=m.matrixWorld,C=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,
m.scale.z)),k=0;k<6;k++){m=ra[k].x*z.n14+ra[k].y*z.n24+ra[k].z*z.n34+ra[k].w;if(m<=C)return!1}return!0}function p(m,z){m.list[m.count]=z;m.count+=1}function w(m){var z,C,k=m.object,o=m.opaque,y=m.transparent;y.count=0;m=o.count=0;for(z=k.materials.length;m<z;m++){C=k.materials[m];C.opacity&&C.opacity<1||C.blending!=THREE.NormalBlending?p(y,C):p(o,C)}}function t(m){var z,C,k,o,y=m.object,A=m.buffer,D=m.opaque,P=m.transparent;P.count=0;m=D.count=0;for(k=y.materials.length;m<k;m++){z=y.materials[m];
if(z instanceof THREE.MeshFaceMaterial){z=0;for(C=A.materials.length;z<C;z++)(o=A.materials[z])&&(o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?p(P,o):p(D,o))}else{o=z;o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?p(P,o):p(D,o)}}}function q(m,z){return z.z-m.z}function x(m,z){m._modelViewMatrix.multiplyToArray(z.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function B(m){function z(la){var ua=
[];C=0;for(k=la.length;C<k;C++)la[C]==undefined?ua.push("undefined"):ua.push(la[C].id);return ua.join("_")}var C,k,o,y,A,D,P,H,O={};m.geometryGroups={};o=0;for(y=m.faces.length;o<y;o++){A=m.faces[o];D=A.materials;P=z(D);O[P]==undefined&&(O[P]={hash:P,counter:0});H=O[P].hash+"_"+O[P].counter;m.geometryGroups[H]==undefined&&(m.geometryGroups[H]={faces:[],materials:D,vertices:0});A=A instanceof THREE.Face3?3:4;if(m.geometryGroups[H].vertices+A>65535){O[P].counter+=1;H=O[P].hash+"_"+O[P].counter;m.geometryGroups[H]==
undefined&&(m.geometryGroups[H]={faces:[],materials:D,vertices:0})}m.geometryGroups[H].faces.push(o);m.geometryGroups[H].vertices+=A}}function E(m,z,C){m.push({buffer:z,object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function u(m){if(m!=ca){switch(m){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,
e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}ca=m}}function F(m,z,C){if((C.width&C.width-1)==0&&(C.height&C.height-1)==0){e.texParameteri(m,e.TEXTURE_WRAP_S,Y(z.wrapS));e.texParameteri(m,e.TEXTURE_WRAP_T,Y(z.wrapT));e.texParameteri(m,e.TEXTURE_MAG_FILTER,Y(z.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,Y(z.minFilter));e.generateMipmap(m)}else{e.texParameteri(m,
e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_MAG_FILTER,L(z.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,L(z.minFilter))}}function v(m,z){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=e.createFramebuffer();m.__webGLRenderbuffer=e.createRenderbuffer();m.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,m.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,m.width,m.height);e.bindTexture(e.TEXTURE_2D,
m.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,Y(m.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,Y(m.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,Y(m.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,Y(m.minFilter));e.texImage2D(e.TEXTURE_2D,0,Y(m.format),m.width,m.height,0,Y(m.format),Y(m.type),null);e.bindFramebuffer(e.FRAMEBUFFER,m.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,
e.DEPTH_ATTACHMENT,e.RENDERBUFFER,m.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,k,o;if(m){C=m.__webGLFramebuffer;k=m.width;o=m.height}else{C=null;k=ha;o=fa}if(C!=S){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(da,ta,k,o);z&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);S=C}}function N(m,z){var C;if(m=="fragment")C=e.createShader(e.FRAGMENT_SHADER);else m=="vertex"&&(C=e.createShader(e.VERTEX_SHADER));e.shaderSource(C,
z);e.compileShader(C);if(!e.getShaderParameter(C,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(C));return null}return C}function L(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return e.LINEAR}}function Y(m){switch(m){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;
case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;
case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),e,V=null,S=null,ba=this,ea=null,J=null,ca=null,wa=null,da=0,ta=0,ha=0,fa=0,ra=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Matrix4,ga=new Float32Array(16),aa=new Float32Array(16),oa=new THREE.Vector4,pa=!0,R=new THREE.Color(0),ia=0;if(a){if(a.antialias!==undefined)pa=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);if(a.clearAlpha!==undefined)ia=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(m,z,C){try{if(!(e=M.getContext("experimental-webgl",{antialias:m})))throw"Error creating WebGL context.";}catch(k){console.error(k)}e.clearColor(0,
0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(z.r,z.g,z.b,C);_cullEnabled=!0})(pa,R,ia);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(m,z){M.width=m;M.height=z;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(m,z,C,k){da=m;
ta=z;ha=C;fa=k;e.viewport(da,ta,ha,fa)};this.setScissor=function(m,z,C,k){e.scissor(m,z,C,k)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(m,z){var C=new THREE.Color(m);e.clearColor(C.r,C.g,C.b,z)};this.setClearColor=function(m,z){e.clearColor(m.r,m.g,m.b,z)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,z,C){var k,o;if(m instanceof THREE.MeshDepthMaterial)b(m,THREE.ShaderLib.depth);
else if(m instanceof THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)b(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)b(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)b(m,THREE.ShaderLib.phong);else if(m instanceof THREE.LineBasicMaterial)b(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&b(m,THREE.ShaderLib.particle_basic);var y,A,D,P;o=D=P=0;for(y=z.length;o<y;o++){A=z[o];A instanceof
THREE.DirectionalLight&&D++;A instanceof THREE.PointLight&&P++}if(P+D<=4)z=D;else{z=Math.ceil(4*D/(P+D));P=4-z}o={directional:z,point:P};P=m.fragmentShader;z=m.vertexShader;y={fog:C,map:m.map,envMap:m.envMap,lightMap:m.lightMap,vertexColors:m.vertexColors,skinning:m.skinning,maxDirLights:o.directional,maxPointLights:o.point};C=e.createProgram();o=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":
"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?"#define USE_LIGHTMAP":"",y.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");y=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?
"#define USE_LIGHTMAP":"",y.vertexColors?"#define USE_COLOR":"",y.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");
e.attachShader(C,N("fragment",o+P));e.attachShader(C,N("vertex",y+z));e.linkProgram(C);e.getProgramParameter(C,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(C,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");C.uniforms={};C.attributes={};m.program=C;C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(k in m.uniforms)C.push(k);k=m.program;P=0;for(z=C.length;P<
z;P++){o=C[P];k.uniforms[o]=e.getUniformLocation(k,o)}k=m.program;C=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];P=0;for(z=C.length;P<z;P++){o=C[P];k.attributes[o]=e.getAttribLocation(k,o)}k=m.program.attributes;e.enableVertexAttribArray(k.position);k.color>=0&&e.enableVertexAttribArray(k.color);k.normal>=0&&e.enableVertexAttribArray(k.normal);k.tangent>=0&&e.enableVertexAttribArray(k.tangent);if(m.skinning&&k.skinVertexA>=0&&k.skinVertexB>=
0&&k.skinIndex>=0&&k.skinWeight>=0){e.enableVertexAttribArray(k.skinVertexA);e.enableVertexAttribArray(k.skinVertexB);e.enableVertexAttribArray(k.skinIndex);e.enableVertexAttribArray(k.skinWeight)}};this.render=function(m,z,C,k){var o,y,A,D,P,H,O,la,ua=m.lights,ja=m.fog;z.matrixAutoUpdate&&z.update();z.matrixWorldInverse.flattenToArray(aa);z.projectionMatrix.flattenToArray(ga);xa.multiply(z.projectionMatrix,z.matrixWorldInverse);l(xa);m.update(undefined,!1,z);this.initWebGLObjects(m,z);v(C,k!==undefined?
k:!0);this.autoClear&&this.clear();P=m.__webglObjects.length;for(k=0;k<P;k++){o=m.__webglObjects[k];O=o.object;if(O.visible)if(!(O instanceof THREE.Mesh)||n(O)){O.matrixWorld.flattenToArray(O._objectMatrixArray);x(O,z);t(o);o.render=!0;if(this.sortObjects){oa.copy(O.position);xa.multiplyVector3(oa);o.z=oa.z}}else o.render=!1;else o.render=!1}this.sortObjects&&m.__webglObjects.sort(q);H=m.__webglObjectsImmediate.length;for(k=0;k<H;k++){o=m.__webglObjectsImmediate[k];O=o.object;if(O.visible){O.matrixAutoUpdate&&
O.matrixWorld.flattenToArray(O._objectMatrixArray);x(O,z);w(o)}}u(THREE.NormalBlending);for(k=0;k<P;k++){o=m.__webglObjects[k];if(o.render){O=o.object;la=o.buffer;A=o.opaque;h(O);for(o=0;o<A.count;o++){D=A.list[o];j(D.depthTest);f(z,ua,ja,D,la,O)}}}for(k=0;k<H;k++){o=m.__webglObjectsImmediate[k];O=o.object;if(O.visible){A=o.opaque;h(O);for(o=0;o<A.count;o++){D=A.list[o];j(D.depthTest);y=d(z,ua,ja,D,O);O.render(function(ka){g(ka,y)})}}}for(k=0;k<P;k++){o=m.__webglObjects[k];if(o.render){O=o.object;
la=o.buffer;A=o.transparent;h(O);for(o=0;o<A.count;o++){D=A.list[o];u(D.blending);j(D.depthTest);f(z,ua,ja,D,la,O)}}}for(k=0;k<H;k++){o=m.__webglObjectsImmediate[k];O=o.object;if(O.visible){A=o.transparent;h(O);for(o=0;o<A.count;o++){D=A.list[o];u(D.blending);j(D.depthTest);y=d(z,ua,ja,D,O);O.render(function(ka){g(ka,y)})}}}if(C&&C.minFilter!==THREE.NearestFilter&&C.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,C.__webGLTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,
null)}};this.initWebGLObjects=function(m){if(!m.__webglObjects){m.__webglObjects=[];m.__webglObjectsImmediate=[]}for(;m.__objectsAdded.length;){var z=m.__objectsAdded[0],C=m,k=void 0,o=void 0,y=void 0;if(z._modelViewMatrix==undefined){z._modelViewMatrix=new THREE.Matrix4;z._normalMatrixArray=new Float32Array(9);z._modelViewMatrixArray=new Float32Array(16);z._objectMatrixArray=new Float32Array(16);z.matrixWorld.flattenToArray(z._objectMatrixArray)}if(z instanceof THREE.Mesh){o=z.geometry;o.geometryGroups==
undefined&&B(o);for(k in o.geometryGroups){y=o.geometryGroups[k];if(!y.__webGLVertexBuffer){var A=y;A.__webGLVertexBuffer=e.createBuffer();A.__webGLNormalBuffer=e.createBuffer();A.__webGLTangentBuffer=e.createBuffer();A.__webGLColorBuffer=e.createBuffer();A.__webGLUVBuffer=e.createBuffer();A.__webGLUV2Buffer=e.createBuffer();A.__webGLSkinVertexABuffer=e.createBuffer();A.__webGLSkinVertexBBuffer=e.createBuffer();A.__webGLSkinIndicesBuffer=e.createBuffer();A.__webGLSkinWeightsBuffer=e.createBuffer();
A.__webGLFaceBuffer=e.createBuffer();A.__webGLLineBuffer=e.createBuffer();A=y;var D=z,P=void 0,H=void 0,O=0,la=0,ua=0,ja=D.geometry.faces,ka=A.faces;P=0;for(H=ka.length;P<H;P++){fi=ka[P];face=ja[fi];if(face instanceof THREE.Face3){O+=3;la+=1;ua+=3}else if(face instanceof THREE.Face4){O+=4;la+=2;ua+=4}}A.__vertexArray=new Float32Array(O*3);A.__normalArray=new Float32Array(O*3);A.__tangentArray=new Float32Array(O*4);A.__colorArray=new Float32Array(O*3);A.__uvArray=new Float32Array(O*2);A.__uv2Array=
new Float32Array(O*2);A.__skinVertexAArray=new Float32Array(O*4);A.__skinVertexBArray=new Float32Array(O*4);A.__skinIndexArray=new Float32Array(O*4);A.__skinWeightArray=new Float32Array(O*4);A.__faceArray=new Uint16Array(la*3);A.__lineArray=new Uint16Array(ua*2);H=P=A;O=void 0;ja=void 0;var sa=void 0,ma=void 0;sa=void 0;ka=!1;O=0;for(ja=D.materials.length;O<ja;O++){sa=D.materials[O];if(sa instanceof THREE.MeshFaceMaterial){sa=0;for(ma=H.materials.length;sa<ma;sa++)if(H.materials[sa]&&H.materials[sa].shading!=
undefined&&H.materials[sa].shading==THREE.SmoothShading){ka=!0;break}}else if(sa&&sa.shading!=undefined&&sa.shading==THREE.SmoothShading){ka=!0;break}if(ka)break}P.__needsSmoothNormals=ka;A.__webGLFaceCount=la*3;A.__webGLLineCount=ua*2;o.__dirtyVertices=!0;o.__dirtyElements=!0;o.__dirtyUvs=!0;o.__dirtyNormals=!0;o.__dirtyTangents=!0;o.__dirtyColors=!0}E(C.__webglObjects,y,z)}}else if(z instanceof THREE.Ribbon){o=z.geometry;if(!o.__webGLVertexBuffer){k=o;k.__webGLVertexBuffer=e.createBuffer();k.__webGLColorBuffer=
e.createBuffer();k=o;y=k.vertices.length;k.__vertexArray=new Float32Array(y*3);k.__colorArray=new Float32Array(y*3);k.__webGLVertexCount=y;o.__dirtyVertices=!0;o.__dirtyColors=!0}E(C.__webglObjects,o,z)}else if(z instanceof THREE.Line){o=z.geometry;if(!o.__webGLVertexBuffer){k=o;k.__webGLVertexBuffer=e.createBuffer();k.__webGLColorBuffer=e.createBuffer();k=o;y=k.vertices.length;k.__vertexArray=new Float32Array(y*3);k.__colorArray=new Float32Array(y*3);k.__webGLLineCount=y;o.__dirtyVertices=!0;o.__dirtyColors=
!0}E(C.__webglObjects,o,z)}else if(z instanceof THREE.ParticleSystem){o=z.geometry;if(!o.__webGLVertexBuffer){k=o;k.__webGLVertexBuffer=e.createBuffer();k.__webGLColorBuffer=e.createBuffer();k=o;y=k.vertices.length;k.__vertexArray=new Float32Array(y*3);k.__colorArray=new Float32Array(y*3);k.__sortArray=[];k.__webGLParticleCount=y;o.__dirtyVertices=!0;o.__dirtyColors=!0}E(C.__webglObjects,o,z)}else THREE.MarchingCubes!==undefined&&z instanceof THREE.MarchingCubes&&C.__webglObjectsImmediate.push({object:z,
opaque:{list:[],count:0},transparent:{list:[],count:0}});m.__objectsAdded.splice(0,1)}for(;m.__objectsRemoved.length;){z=m.__objectsRemoved[0];C=m;o=void 0;k=void 0;for(o=C.__webglObjects.length-1;o>=0;o--){k=C.__webglObjects[o].object;z==k&&C.__webglObjects.splice(o,1)}m.__objectsRemoved.splice(0,1)}z=0;for(C=m.__webglObjects.length;z<C;z++){k=m.__webglObjects[z].object;y=void 0;o=void 0;A=void 0;if(k instanceof THREE.Mesh){o=k.geometry;for(y in o.geometryGroups){A=o.geometryGroups[y];if(o.__dirtyVertices||
o.__dirtyElements||o.__dirtyUvs||o.__dirtyNormals||o.__dirtyColors||o.__dirtyTangents){la=e.DYNAMIC_DRAW;ua=void 0;P=void 0;var Ka=void 0,Q=void 0,Ga=void 0,Ca=void 0,Fa=void 0;Ka=void 0;var U=void 0,X=void 0,Z=void 0,ya=void 0;U=void 0;X=void 0;Z=void 0;Q=void 0;U=void 0;X=void 0;Z=void 0;ya=void 0;U=void 0;X=void 0;Z=void 0;ya=void 0;U=void 0;X=void 0;Z=void 0;ya=void 0;U=void 0;X=void 0;Z=void 0;ya=void 0;U=void 0;X=void 0;Z=void 0;ya=void 0;Q=void 0;Ca=void 0;Ga=void 0;Fa=void 0;var Ia=ma=sa=
ka=ja=O=D=H=0,Aa=0,I=0,qa=A.__vertexArray,Ma=A.__uvArray,Qa=A.__uv2Array,La=A.__normalArray,za=A.__tangentArray,Ba=A.__colorArray,G=A.__skinVertexAArray,W=A.__skinVertexBArray,T=A.__skinIndexArray,K=A.__skinWeightArray,$=A.__faceArray,na=A.__lineArray,Ea=A.__needsSmoothNormals,va=k.geometry,Ha=va.__dirtyVertices,Oa=va.__dirtyElements,Ja=va.__dirtyUvs,Pa=va.__dirtyNormals,Sa=va.__dirtyTangents,Na=va.__dirtyColors,Da=va.vertices,Xa=A.faces,Ya=va.faces,Za=va.uvs,$a=va.uvs2,Ra=va.colors,Ua=va.skinVerticesA,
Va=va.skinVerticesB,Wa=va.skinIndices,Ta=va.skinWeights;ua=0;for(P=Xa.length;ua<P;ua++){Ka=Xa[ua];Q=Ya[Ka];Fa=Za[Ka];Ka=$a[Ka];Ga=Q.vertexNormals;Ca=Q.normal;if(Q instanceof THREE.Face3){if(Ha){U=Da[Q.a].position;X=Da[Q.b].position;Z=Da[Q.c].position;qa[D]=U.x;qa[D+1]=U.y;qa[D+2]=U.z;qa[D+3]=X.x;qa[D+4]=X.y;qa[D+5]=X.z;qa[D+6]=Z.x;qa[D+7]=Z.y;qa[D+8]=Z.z;D+=9}if(Ta.length){U=Ta[Q.a];X=Ta[Q.b];Z=Ta[Q.c];K[I]=U.x;K[I+1]=U.y;K[I+2]=U.z;K[I+3]=U.w;K[I+4]=X.x;K[I+5]=X.y;K[I+6]=X.z;K[I+7]=X.w;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ga[Q];La[sa]=Ca.x;La[sa+1]=Ca.y;La[sa+2]=Ca.z;sa+=3}else for(Q=0;Q<4;Q++){La[sa]=Ca.x;La[sa+1]=Ca.y;La[sa+2]=Ca.z;sa+=3}if(Ja&&Fa)for(Q=0;Q<4;Q++){Ga=Fa[Q];Ma[O]=Ga.u;Ma[O+1]=Ga.v;O+=2}if(Ja&&Ka)for(Q=0;Q<4;Q++){Fa=Ka[Q];Qa[ja]=Fa.u;Qa[ja+1]=Fa.v;ja+=2}if(Oa){$[ka]=H;$[ka+1]=H+1;$[ka+2]=H+2;$[ka+3]=H;$[ka+4]=H+2;$[ka+5]=H+3;ka+=6;na[Ia]=H;na[Ia+1]=H+1;na[Ia+2]=H;na[Ia+3]=H+3;na[Ia+4]=H+1;na[Ia+5]=H+2;na[Ia+
6]=H+2;na[Ia+7]=H+3;Ia+=8;H+=4}}}if(Ha){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,qa,la)}if(Na&&Ra.length){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Ba,la)}if(Pa){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,La,la)}if(Sa&&va.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,za,la)}if(Ja&&O>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,
Ma,la)}if(Ja&&ja>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Qa,la)}if(Oa){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,$,la);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,na,la)}if(I>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,G,la);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,W,la);e.bindBuffer(e.ARRAY_BUFFER,
A.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,T,la);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,K,la)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(k instanceof THREE.Ribbon){o=k.geometry;if(o.__dirtyVertices||o.__dirtyColors){k=o;y=e.DYNAMIC_DRAW;H=void 0;H=void 0;D=void 0;A=void 0;O=k.vertices;la=k.colors;ja=O.length;ua=la.length;ka=k.__vertexArray;P=k.__colorArray;
sa=k.__dirtyColors;if(k.__dirtyVertices){for(H=0;H<ja;H++){D=O[H].position;A=H*3;ka[A]=D.x;ka[A+1]=D.y;ka[A+2]=D.z}e.bindBuffer(e.ARRAY_BUFFER,k.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ka,y)}if(sa){for(H=0;H<ua;H++){color=la[H];A=H*3;P[A]=color.r;P[A+1]=color.g;P[A+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,k.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,P,y)}}o.__dirtyVertices=!1;o.__dirtyColors=!1}else if(k instanceof THREE.Line){o=k.geometry;if(o.__dirtyVertices||o.__dirtyColors){k=o;y=
e.DYNAMIC_DRAW;H=void 0;H=void 0;D=void 0;A=void 0;O=k.vertices;la=k.colors;ja=O.length;ua=la.length;ka=k.__vertexArray;P=k.__colorArray;sa=k.__dirtyColors;if(k.__dirtyVertices){for(H=0;H<ja;H++){D=O[H].position;A=H*3;ka[A]=D.x;ka[A+1]=D.y;ka[A+2]=D.z}e.bindBuffer(e.ARRAY_BUFFER,k.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ka,y)}if(sa){for(H=0;H<ua;H++){color=la[H];A=H*3;P[A]=color.r;P[A+1]=color.g;P[A+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,k.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,
P,y)}}o.__dirtyVertices=!1;o.__dirtyColors=!1}else if(k instanceof THREE.ParticleSystem){o=k.geometry;(o.__dirtyVertices||o.__dirtyColors||k.sortParticles)&&c(o,e.DYNAMIC_DRAW,k);o.__dirtyVertices=!1;o.__dirtyColors=!1}}};this.setFaceCulling=function(m,z){if(m){!z||z=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(m=="back")e.cullFace(e.BACK);else m=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
0}};
258 259 260 261
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",
262 263 264
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"};
265
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",
266
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)}}};
267 268 269 270 271
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,
272
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,
273 274
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,
275
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;",
276
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;",
277
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")}};
278
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,f=b.length;for(d=0;d<f;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)}}}};
279 280
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};
281 282 283 284 285 286 287 288 289 290 291
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,f=b?c.geometry:c,g=a.vertices,h=f.vertices,j=a.faces,l=f.faces,n=a.uvs;f=f.uvs;b&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,w=h.length;p<w;p++){var t=new THREE.Vertex(h[p].position.clone());b&&c.matrix.multiplyVector3(t.position);g.push(t)}p=0;for(w=l.length;p<w;p++){h=l[p];var q,x=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+
d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);b=0;for(g=x.length;b<g;b++){t=x[b];q.vertexNormals.push(t.clone())}q.materials=h.materials.slice();j.push(q)}p=0;for(w=f.length;p<w;p++){d=f[p];j=[];b=0;for(g=d.length;b<g;b++)j.push(new THREE.UV(d[b].u,d[b].v));n.push(j)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,f=new THREE.Texture(d,c);d.onload=function(){f.needsUpdate=!0;b&&b(this)};d.src=a;return f},loadTextureCube:function(a,c,b){var d,f=[],g=new THREE.Texture(f,
c);c=f.loadCount=0;for(d=a.length;c<d;++c){f[c]=new Image;f[c].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;b&&b(this)};f[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(p in M.objects)if(!J.objects[p]){B=M.objects[p];if(v=J.geometries[B.geometry]){Y=[];for(i=0;i<B.materials.length;i++)Y[i]=J.materials[B.materials[i]];E=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(v,Y);object.position.set(E[0],
E[1],E[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;J.scene.addObject(object);J.objects[p]=object}}}function h(ca){return function(wa){J.geometries[ca]=wa;g();V-=1;j()}}function j(){d({total_models:ba,total_textures:ea,loaded_models:ba-V,loaded_textures:ea-S},J);V==0&&S==0&&b(J)}var l,n,p,w,t,q,x,B,E,u,F,v,N,L,Y,M,e,V,S,ba,ea,J;M=f.data;e=new THREE.Loader;S=V=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},
lights:{},fogs:{}};f=function(){S-=1;j()};for(t in M.cameras){u=M.cameras[t];if(u.type=="perspective")N=new THREE.Camera(u.fov,u.aspect,u.near,u.far);else if(u.type=="ortho"){N=new THREE.Camera;N.projectionMatrix=THREE.Matrix4.makeOrtho(u.left,u.right,u.top,u.bottom,u.near,u.far)}E=u.position;u=u.target;N.position.set(E[0],E[1],E[2]);N.target.position.set(u[0],u[1],u[2]);J.cameras[t]=N}for(w in M.lights){t=M.lights[w];if(t.type=="directional"){E=t.direction;light=new THREE.DirectionalLight;light.position.set(E[0],
E[1],E[2]);light.position.normalize()}else if(t.type=="point"){E=t.position;light=new THREE.PointLight;light.position.set(E[0],E[1],E[2])}u=t.color;i=t.intensity||1;light.color.setRGB(u[0]*i,u[1]*i,u[2]*i);J.scene.addLight(light);J.lights[w]=light}for(q in M.fogs){w=M.fogs[q];if(w.type=="linear")L=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(L=new THREE.FogExp2(0,w.density));u=w.color;L.color.setRGB(u[0],u[1],u[2]);J.fogs[q]=L}if(J.cameras&&M.defaults.camera)J.currentCamera=J.cameras[M.defaults.camera];
if(J.fogs&&M.defaults.fog)J.scene.fog=J.fogs[M.defaults.fog];u=M.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(u[0],u[1],u[2]);J.bgColorAlpha=M.defaults.bgalpha;for(l in M.geometries){q=M.geometries[l];if(q.type=="bin_mesh"||q.type=="ascii_mesh")V+=1}ba=V;for(l in M.geometries){q=M.geometries[l];if(q.type=="cube"){v=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);J.geometries[l]=v}else if(q.type=="plane"){v=new Plane(q.width,
q.height,q.segmentsWidth,q.segmentsHeight);J.geometries[l]=v}else if(q.type=="sphere"){v=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);J.geometries[l]=v}else if(q.type=="cylinder"){v=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);J.geometries[l]=v}else if(q.type=="torus"){v=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);J.geometries[l]=v}else if(q.type=="icosahedron"){v=new Icosahedron(q.subdivisions);J.geometries[l]=v}else if(q.type=="bin_mesh")e.loadBinary({model:q.url,
callback:h(l)});else q.type=="ascii_mesh"&&e.loadAscii({model:q.url,callback:h(l)})}for(x in M.textures){l=M.textures[x];S+=l.url instanceof Array?l.url.length:1}ea=S;for(x in M.textures){l=M.textures[x];if(l.mapping!=undefined&&THREE[l.mapping]!=undefined)l.mapping=new THREE[l.mapping];if(l.url instanceof Array)q=ImageUtils.loadTextureCube(l.url,l.mapping,f);else{q=ImageUtils.loadTexture(l.url,l.mapping,f);if(THREE[l.minFilter]!=undefined)q.minFilter=THREE[l.minFilter];if(THREE[l.magFilter]!=undefined)q.magFilter=
THREE[l.magFilter]}J.textures[x]=q}for(n in M.materials){x=M.materials[n];for(F in x.parameters)if(F=="envMap"||F=="map"||F=="lightMap")x.parameters[F]=J.textures[x.parameters[F]];else if(F=="shading")x.parameters[F]=x.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")x.parameters[F]=THREE[x.parameters[F]]?THREE[x.parameters[F]]:THREE.NormalBlending;else F=="combine"&&(x.parameters[F]=x.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=new THREE[x.type](x.parameters);
J.materials[n]=x}g();c(J)}},addMesh:function(a,c,b,d,f,g,h,j,l,n){c=new THREE.Mesh(c,n);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=f;c.position.z=g;c.rotation.x=h;c.rotation.y=j;c.rotation.z=l;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);
292
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);
293 294
a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var f=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,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,f,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}",
295
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}"},
296
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},
297 298 299 300 301 302
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}",
303 304 305 306 307 308 309 310
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=d=0;c<g;++c){b[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));d+=b[c]}for(c=0;c<g;++c)b[c]/=d;return b}},Cube=function(a,c,b,d,f,g,h,j,l){function n(E,u,F,v,N,L,Y,M){var e,V,S=d||1,ba=f||1,ea=N/2,J=L/2,ca=p.vertices.length;if(E=="x"&&u=="y"||E=="y"&&u=="x")e="z";else if(E=="x"&&u=="z"||E=="z"&&u=="x"){e="y";ba=g||1}else if(E=="z"&&
u=="y"||E=="y"&&u=="z"){e="x";S=g||1}var wa=S+1,da=ba+1;N/=S;var ta=L/ba;for(V=0;V<da;V++)for(L=0;L<wa;L++){var ha=new THREE.Vector3;ha[E]=(L*N-ea)*F;ha[u]=(V*ta-J)*v;ha[e]=Y;p.vertices.push(new THREE.Vertex(ha))}for(V=0;V<ba;V++)for(L=0;L<S;L++){p.faces.push(new THREE.Face4(L+wa*V+ca,L+wa*(V+1)+ca,L+1+wa*(V+1)+ca,L+1+wa*V+ca,null,M));p.uvs.push([new THREE.UV(L/S,V/ba),new THREE.UV(L/S,(V+1)/ba),new THREE.UV((L+1)/S,(V+1)/ba),new THREE.UV((L+1)/S,V/ba)])}}THREE.Geometry.call(this);var p=this,w=a/
2,t=c/2,q=b/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var x=0;x<6;x++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(l!=undefined)for(var B in l)this.sides[B]!=undefined&&(this.sides[B]=l[B]);this.sides.px&&n("z","y",1*j,-1,b,c,-w,this.materials[0]);this.sides.nx&&n("z","y",-1*j,-1,b,c,w,this.materials[1]);this.sides.py&&n("x","z",1*j,1,a,b,t,this.materials[2]);this.sides.ny&&n("x","z",1*j,-1,
a,b,-t,this.materials[3]);this.sides.pz&&n("x","y",1*j,-1,a,c,q,this.materials[4]);this.sides.nz&&n("x","y",-1*j,-1,a,c,-q,this.materials[5]);(function(){for(var E=[],u=[],F=0,v=p.vertices.length;F<v;F++){for(var N=p.vertices[F],L=!1,Y=0,M=E.length;Y<M;Y++){var e=E[Y];if(N.position.x==e.position.x&&N.position.y==e.position.y&&N.position.z==e.position.z){u[F]=Y;L=!0;break}}if(!L){u[F]=E.length;E.push(new THREE.Vertex(N.position.clone()))}}F=0;for(v=p.faces.length;F<v;F++){N=p.faces[F];N.a=u[N.a];N.b=
u[N.b];N.c=u[N.c];N.d=u[N.d]}p.vertices=E})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,c,b,d,f){function g(n,p,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(n,p,w)))}THREE.Geometry.call(this);var h=this,j=Math.PI,l;for(l=0;l<a;l++)g(Math.sin(2*j*l/a)*c,Math.cos(2*j*l/a)*c,0);for(l=0;l<a;l++)g(Math.sin(2*j*l/a)*b,Math.cos(2*j*l/a)*b,d);for(l=0;l<a;l++)h.faces.push(new THREE.Face4(l,l+a,a+(l+1)%a,(l+1)%a));if(b!=0){g(0,0,-f);for(l=a;l<a+a/2;l++)h.faces.push(new THREE.Face4(2*a,(2*l-2*a)%a,(2*l-2*a+1)%a,(2*l-2*a+2)%a))}if(c!=0){g(0,0,d+f);for(l=a+a/2;l<
2*a;l++)h.faces.push(new THREE.Face4((2*l-2*a+2)%a+a,(2*l-2*a+1)%a+a,(2*l-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var f,g=a/2,h=c/2;b=b||1;d=d||1;var j=b+1,l=d+1;a/=b;var n=c/d;for(f=0;f<l;f++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(f*n-h),0)));for(f=0;f<d;f++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*f,c+j*(f+1),c+1+j*(f+1),c+1+j*f));this.uvs.push([new THREE.UV(c/b,f/d),new THREE.UV(c/b,(f+1)/d),new THREE.UV((c+1)/b,(f+1)/d),new THREE.UV((c+1)/b,f/d)])}this.computeCentroids();this.computeFaceNormals()};
311
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
312 313 314 315 316 317 318 319
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,f=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*f),l=a*Math.sin(d*f),n=[],p=0;for(d=0;d<g;d++){var w=2*d/g,t=l*Math.sin(w*f);w=l*Math.cos(w*f);(b==0||b==h)&&d>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,j,t)))-1);n.push(p)}c.push(n)}var q,x,B;f=c.length;for(b=0;b<f;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){n=d==g-1;h=c[b][n?0:d+1];j=c[b][n?g-1:d];l=c[b-1][n?g-1:d];n=c[b-1][n?
0:d+1];t=b/(f-1);q=(b-1)/(f-1);x=(d+1)/g;w=d/g;p=new THREE.UV(1-x,t);t=new THREE.UV(1-w,t);w=new THREE.UV(1-w,q);var E=new THREE.UV(1-x,q);if(b<c.length-1){q=this.vertices[h].position.clone();x=this.vertices[j].position.clone();B=this.vertices[l].position.clone();q.normalize();x.normalize();B.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([p,t,w])}if(b>1){q=this.vertices[h].position.clone();
x=this.vertices[l].position.clone();B=this.vertices[n].position.clone();q.normalize();x.normalize();B.normalize();this.faces.push(new THREE.Face3(h,l,n,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([p,w,E])}}}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 f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));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;f=(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,f,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][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(w,t,q){var x=Math.sqrt(w*w+t*t+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,t/x,q/x)))-1}function b(w,t,q,x){x.faces.push(new THREE.Face3(w,t,q))}function d(w,t){var q=f.vertices[w].position,x=f.vertices[t].position;return c((q.x+x.x)/2,(q.y+x.y)/2,(q.z+x.z)/2)}var f=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 l=d(g.faces[j].a,g.faces[j].b),n=d(g.faces[j].b,g.faces[j].c),p=d(g.faces[j].c,g.faces[j].a);b(g.faces[j].a,l,p,h);b(g.faces[j].b,n,l,h);b(g.faces[j].c,
p,n,h);b(l,n,p,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
320
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=[],f=[],g=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));f[j]=this.vertices.length-1;d[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var l=THREE.Matrix4.rotationZMatrix(this.stepSize),n=0;n<=this.latheAngle+0.0010;n+=this.stepSize){for(j=0;j<d.length;j++)if(n<b){d[j]=l.multiplyVector3(d[j].clone());this.vertices.push(new THREE.Vertex(d[j]));
321
g[j]=this.vertices.length-1}else g=h;n==0&&(h=f);for(j=0;j<f.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],f[j+1],f[j]));this.uvs.push([new THREE.UV(n/b,j/a.length),new THREE.UV(n/b,(j+1)/a.length),new THREE.UV((n-c)/b,(j+1)/a.length),new THREE.UV((n-c)/b,j/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
322
if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
323
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=
324 325 326 327 328 329 330 331 332 333 334 335
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,f){return b+(d-b)*f};this.VIntX=function(b,d,f,g,h,j,l,n,p,w){h=(h-p)/(w-p);p=this.normal_cache;d[g]=j+h*this.delta;d[g+1]=l;d[g+2]=n;f[g]=this.lerp(p[b],p[b+3],h);f[g+1]=this.lerp(p[b+1],p[b+4],h);f[g+2]=this.lerp(p[b+2],p[b+5],h)};this.VIntY=function(b,d,f,g,h,j,l,n,p,w){h=(h-p)/(w-p);p=this.normal_cache;d[g]=j;d[g+1]=l+h*this.delta;d[g+
2]=n;d=b+this.yd*3;f[g]=this.lerp(p[b],p[d],h);f[g+1]=this.lerp(p[b+1],p[d+1],h);f[g+2]=this.lerp(p[b+2],p[d+2],h)};this.VIntZ=function(b,d,f,g,h,j,l,n,p,w){h=(h-p)/(w-p);p=this.normal_cache;d[g]=j;d[g+1]=l;d[g+2]=n+h*this.delta;d=b+this.zd*3;f[g]=this.lerp(p[b],p[d],h);f[g+1]=this.lerp(p[b+1],p[d+1],h);f[g+2]=this.lerp(p[b+2],p[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,f,g,h,j){var l=g+1,n=g+this.yd,p=g+this.zd,w=l+this.yd,t=l+this.zd,q=g+this.yd+this.zd,x=l+this.yd+this.zd,B=0,E=this.field[g],u=this.field[l],F=this.field[n],v=this.field[w],N=this.field[p],L=this.field[t],Y=this.field[q],M=this.field[x];E<h&&(B|=1);u<h&&(B|=2);F<h&&(B|=8);v<h&&(B|=4);N<h&&(B|=16);L<h&&(B|=32);Y<h&&(B|=128);M<h&&(B|=64);var e=THREE.edgeTable[B];if(e==0)return 0;
var V=this.delta,S=b+V,ba=d+V;V=f+V;if(e&1){this.compNorm(g);this.compNorm(l);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,f,E,u)}if(e&2){this.compNorm(l);this.compNorm(w);this.VIntY(l*3,this.vlist,this.nlist,3,h,S,d,f,u,v)}if(e&4){this.compNorm(n);this.compNorm(w);this.VIntX(n*3,this.vlist,this.nlist,6,h,b,ba,f,F,v)}if(e&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,f,E,F)}if(e&16){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,12,h,b,d,
V,N,L)}if(e&32){this.compNorm(t);this.compNorm(x);this.VIntY(t*3,this.vlist,this.nlist,15,h,S,d,V,L,M)}if(e&64){this.compNorm(q);this.compNorm(x);this.VIntX(q*3,this.vlist,this.nlist,18,h,b,ba,V,Y,M)}if(e&128){this.compNorm(p);this.compNorm(q);this.VIntY(p*3,this.vlist,this.nlist,21,h,b,d,V,N,Y)}if(e&256){this.compNorm(g);this.compNorm(p);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,f,E,N)}if(e&512){this.compNorm(l);this.compNorm(t);this.VIntZ(l*3,this.vlist,this.nlist,27,h,S,d,f,u,L)}if(e&1024){this.compNorm(w);
this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,S,ba,f,v,M)}if(e&2048){this.compNorm(n);this.compNorm(q);this.VIntZ(n*3,this.vlist,this.nlist,33,h,b,ba,f,F,Y)}B<<=4;for(h=g=0;THREE.triTable[B+h]!=-1;){b=B+h;d=b+1;f=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[f],j);h+=3;g++}return g};this.posnormtriv=function(b,d,f,g,h,j){var l=this.count*3;this.positionArray[l]=b[f];this.positionArray[l+1]=b[f+1];this.positionArray[l+2]=b[f+2];this.positionArray[l+
3]=b[g];this.positionArray[l+4]=b[g+1];this.positionArray[l+5]=b[g+2];this.positionArray[l+6]=b[h];this.positionArray[l+7]=b[h+1];this.positionArray[l+8]=b[h+2];this.normalArray[l]=d[f];this.normalArray[l+1]=d[f+1];this.normalArray[l+2]=d[f+2];this.normalArray[l+3]=d[g];this.normalArray[l+4]=d[g+1];this.normalArray[l+5]=d[g+2];this.normalArray[l+6]=d[h];this.normalArray[l+7]=d[h+1];this.normalArray[l+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,f,g,h){var j=this.size*Math.sqrt(g/h),l=f*this.size,n=d*this.size,p=b*this.size,w=Math.floor(l-j);w<1&&(w=1);l=Math.floor(l+j);l>this.size-1&&(l=this.size-1);var t=Math.floor(n-j);t<1&&(t=1);n=Math.floor(n+j);n>this.size-1&&(n=this.size-1);var q=Math.floor(p-j);q<1&&(q=1);j=Math.floor(p+j);
j>this.size-1&&(j=this.size-1);for(var x,B,E,u,F,v;w<l;w++){p=this.size2*w;B=w/this.size-f;F=B*B;for(B=t;B<n;B++){E=p+this.size*B;x=B/this.size-d;v=x*x;for(x=q;x<j;x++){u=x/this.size-b;u=g/(1.0E-6+u*u+v+F)-h;u>0&&(this.field[E+x]+=u)}}}};this.addPlaneX=function(b,d){var f,g,h,j,l,n=this.size,p=this.yd,w=this.zd,t=this.field,q=n*Math.sqrt(b/d);q>n&&(q=n);for(f=0;f<q;f++){g=f/n;g*=g;j=b/(1.0E-4+g)-d;if(j>0)for(g=0;g<n;g++){l=f+g*p;for(h=0;h<n;h++)t[w*h+l]+=j}}};this.addPlaneY=function(b,d){var f,g,
h,j,l,n,p=this.size,w=this.yd,t=this.zd,q=this.field,x=p*Math.sqrt(b/d);x>p&&(x=p);for(g=0;g<x;g++){f=g/p;f*=f;j=b/(1.0E-4+f)-d;if(j>0){l=g*w;for(f=0;f<p;f++){n=l+f;for(h=0;h<p;h++)q[t*h+n]+=j}}}};this.addPlaneZ=function(b,d){var f,g,h,j,l,n;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++){f=h/size;f*=f;j=b/(1.0E-4+f)-d;if(j>0){l=zd*h;for(g=0;g<size;g++){n=l+g*yd;for(f=0;f<size;f++)field[n+f]+=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,f,g,h,j,l,n,p,w,t=this.size-2;for(h=1;h<t;h++){w=this.size2*h;n=(h-this.halfsize)/this.halfsize;for(g=1;g<t;g++){p=w+this.size*g;l=(g-this.halfsize)/this.halfsize;for(f=1;f<t;f++){j=(f-this.halfsize)/this.halfsize;d=p+f;this.polygonize(j,l,n,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(f){var g,h,j,l,n,p,w,t;for(g=
0;g<f.count;g++){n=g*3;w=n+1;t=n+2;h=f.positionArray[n];j=f.positionArray[w];l=f.positionArray[t];p=new THREE.Vector3(h,j,l);h=f.normalArray[n];j=f.normalArray[w];l=f.normalArray[t];n=new THREE.Vector3(h,j,l);n.normalize();n=new THREE.Vertex(p,n);d.vertices.push(n)}nfaces=f.count/3;for(g=0;g<nfaces;g++){n=(b+g)*3;w=n+1;t=n+2;p=d.vertices[n].normal;h=d.vertices[w].normal;j=d.vertices[t].normal;n=new THREE.Face3(n,w,t,[p,h,j]);d.faces.push(n)}b+=nfaces;f.count=0});return d};this.init(a)};
336
THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
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,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,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,-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};
361
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=
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
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(f){THREE.Loader.prototype.createModel(f.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),f=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,f,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,f,g){var h=new XMLHttpRequest,j=d+"/"+a,l=0;
h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,b,f,c):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(g){l==0&&(l=h.getResponseHeader("Content-Length"));g({total:l,loaded:h.responseText.length})}}else h.readyState==2&&(l=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 f=function(g){function h(k,o){var y=p(k,o),A=p(k,o+1),D=p(k,o+2),P=p(k,o+3),H=(P<<1&255|D>>7)-127;y|=(D&127)<<16|A<<8;if(y==0&&H==-127)return 0;return(1-2*(P>>7))*(1+y*Math.pow(2,-23))*Math.pow(2,H)}function j(k,o){var y=p(k,o),A=p(k,o+1),D=p(k,o+2);return(p(k,o+3)<<24)+(D<<16)+(A<<8)+y}function l(k,o){var y=p(k,o);return(p(k,o+1)<<8)+y}function n(k,o){var y=p(k,o);return y>127?y-256:y}function p(k,o){return k.charCodeAt(o)&255}function w(k){var o,y,A;o=j(a,k);
y=j(a,k+Y);A=j(a,k+M);k=l(a,k+e);THREE.Loader.prototype.f3(u,o,y,A,k)}function t(k){var o,y,A,D,P,H;o=j(a,k);y=j(a,k+Y);A=j(a,k+M);D=l(a,k+e);P=j(a,k+V);H=j(a,k+S);k=j(a,k+ba);THREE.Loader.prototype.f3n(u,N,o,y,A,D,P,H,k)}function q(k){var o,y,A,D;o=j(a,k);y=j(a,k+ea);A=j(a,k+J);D=j(a,k+ca);k=l(a,k+wa);THREE.Loader.prototype.f4(u,o,y,A,D,k)}function x(k){var o,y,A,D,P,H,O,la;o=j(a,k);y=j(a,k+ea);A=j(a,k+J);D=j(a,k+ca);P=l(a,k+wa);H=j(a,k+da);O=j(a,k+ta);la=j(a,k+ha);k=j(a,k+fa);THREE.Loader.prototype.f4n(u,
N,o,y,A,D,P,H,O,la,k)}function B(k){var o,y;o=j(a,k);y=j(a,k+ra);k=j(a,k+xa);THREE.Loader.prototype.uv3(u.uvs,L[o*2],L[o*2+1],L[y*2],L[y*2+1],L[k*2],L[k*2+1])}function E(k){var o,y,A;o=j(a,k);y=j(a,k+ga);A=j(a,k+aa);k=j(a,k+oa);THREE.Loader.prototype.uv4(u.uvs,L[o*2],L[o*2+1],L[y*2],L[y*2+1],L[A*2],L[A*2+1],L[k*2],L[k*2+1])}var u=this,F=0,v,N=[],L=[],Y,M,e,V,S,ba,ea,J,ca,wa,da,ta,ha,fa,ra,xa,ga,aa,oa,pa,R,ia,m,z,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,d,g);v={signature:a.substr(F,
8),header_bytes:p(a,F+8),vertex_coordinate_bytes:p(a,F+9),normal_coordinate_bytes:p(a,F+10),uv_coordinate_bytes:p(a,F+11),vertex_index_bytes:p(a,F+12),normal_index_bytes:p(a,F+13),uv_index_bytes:p(a,F+14),material_index_bytes:p(a,F+15),nvertices:j(a,F+16),nnormals:j(a,F+16+4),nuvs:j(a,F+16+8),ntri_flat:j(a,F+16+12),ntri_smooth:j(a,F+16+16),ntri_flat_uv:j(a,F+16+20),ntri_smooth_uv:j(a,F+16+24),nquad_flat:j(a,F+16+28),nquad_smooth:j(a,F+16+32),nquad_flat_uv:j(a,F+16+36),nquad_smooth_uv:j(a,F+16+40)};
F+=v.header_bytes;Y=v.vertex_index_bytes;M=v.vertex_index_bytes*2;e=v.vertex_index_bytes*3;V=v.vertex_index_bytes*3+v.material_index_bytes;S=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes;ba=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*2;ea=v.vertex_index_bytes;J=v.vertex_index_bytes*2;ca=v.vertex_index_bytes*3;wa=v.vertex_index_bytes*4;da=v.vertex_index_bytes*4+v.material_index_bytes;ta=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes;ha=
v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*2;fa=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*3;ra=v.uv_index_bytes;xa=v.uv_index_bytes*2;ga=v.uv_index_bytes;aa=v.uv_index_bytes*2;oa=v.uv_index_bytes*3;g=v.vertex_index_bytes*3+v.material_index_bytes;C=v.vertex_index_bytes*4+v.material_index_bytes;pa=v.ntri_flat*g;R=v.ntri_smooth*(g+v.normal_index_bytes*3);ia=v.ntri_flat_uv*(g+v.uv_index_bytes*3);m=v.ntri_smooth_uv*(g+v.normal_index_bytes*3+v.uv_index_bytes*
3);z=v.nquad_flat*C;g=v.nquad_smooth*(C+v.normal_index_bytes*4);C=v.nquad_flat_uv*(C+v.uv_index_bytes*4);F+=function(k){for(var o,y,A,D=v.vertex_coordinate_bytes*3,P=k+v.nvertices*D;k<P;k+=D){o=h(a,k);y=h(a,k+v.vertex_coordinate_bytes);A=h(a,k+v.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,o,y,A)}return v.nvertices*D}(F);F+=function(k){for(var o,y,A,D=v.normal_coordinate_bytes*3,P=k+v.nnormals*D;k<P;k+=D){o=n(a,k);y=n(a,k+v.normal_coordinate_bytes);A=n(a,k+v.normal_coordinate_bytes*2);N.push(o/
127,y/127,A/127)}return v.nnormals*D}(F);F+=function(k){for(var o,y,A=v.uv_coordinate_bytes*2,D=k+v.nuvs*A;k<D;k+=A){o=h(a,k);y=h(a,k+v.uv_coordinate_bytes);L.push(o,y)}return v.nuvs*A}(F);pa=F+pa;R=pa+R;ia=R+ia;m=ia+m;z=m+z;g=z+g;C=g+C;(function(k){var o,y=v.vertex_index_bytes*3+v.material_index_bytes,A=y+v.uv_index_bytes*3,D=k+v.ntri_flat_uv*A;for(o=k;o<D;o+=A){w(o);B(o+y)}return D-k})(R);(function(k){var o,y=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*3,A=y+v.uv_index_bytes*
3,D=k+v.ntri_smooth_uv*A;for(o=k;o<D;o+=A){t(o);B(o+y)}return D-k})(ia);(function(k){var o,y=v.vertex_index_bytes*4+v.material_index_bytes,A=y+v.uv_index_bytes*4,D=k+v.nquad_flat_uv*A;for(o=k;o<D;o+=A){q(o);E(o+y)}return D-k})(g);(function(k){var o,y=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*4,A=y+v.uv_index_bytes*4,D=k+v.nquad_smooth_uv*A;for(o=k;o<D;o+=A){x(o);E(o+y)}return D-k})(C);(function(k){var o,y=v.vertex_index_bytes*3+v.material_index_bytes,A=k+v.ntri_flat*y;for(o=
k;o<A;o+=y)w(o);return A-k})(F);(function(k){var o,y=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*3,A=k+v.ntri_smooth*y;for(o=k;o<A;o+=y)t(o);return A-k})(pa);(function(k){var o,y=v.vertex_index_bytes*4+v.material_index_bytes,A=k+v.nquad_flat*y;for(o=k;o<A;o+=y)q(o);return A-k})(m);(function(k){var o,y=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*4,A=k+v.nquad_smooth*y;for(o=k;o<A;o+=y)x(o);return A-k})(z);this.computeCentroids();this.computeFaceNormals()};
f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(b))},createModel:function(a,c,b){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,j,l,n,p;h=0;for(j=a.vertices.length;h<j;h+=3){l=a.vertices[h];n=a.vertices[h+1];p=a.vertices[h+2];THREE.Loader.prototype.v(g,l,n,p)}if(a.colors){h=0;for(j=a.colors.length;h<j;h+=3){l=a.colors[h];n=a.colors[h+1];p=a.colors[h+2];THREE.Loader.prototype.vc(g,l,n,p)}}})();(function(){function h(x,
B){THREE.Loader.prototype.f3(g,x[B],x[B+1],x[B+2],x[B+3])}function j(x,B){THREE.Loader.prototype.f3n(g,a.normals,x[B],x[B+1],x[B+2],x[B+3],x[B+4],x[B+5],x[B+6])}function l(x,B){THREE.Loader.prototype.f4(g,x[B],x[B+1],x[B+2],x[B+3],x[B+4])}function n(x,B){THREE.Loader.prototype.f4n(g,a.normals,x[B],x[B+1],x[B+2],x[B+3],x[B+4],x[B+5],x[B+6],x[B+7],x[B+8])}function p(x,B){var E,u,F,v,N,L,Y,M,e;E=x[B];u=x[B+1];F=x[B+2];v=a.uvs[E*2];Y=a.uvs[E*2+1];N=a.uvs[u*2];M=a.uvs[u*2+1];L=a.uvs[F*2];e=a.uvs[F*2+1];
THREE.Loader.prototype.uv3(g.uvs,v,Y,N,M,L,e);if(a.uvs2&&a.uvs2.length){v=a.uvs2[E*2];Y=a.uvs2[E*2+1];N=a.uvs2[u*2];M=a.uvs2[u*2+1];L=a.uvs2[F*2];e=a.uvs2[F*2+1];THREE.Loader.prototype.uv3(g.uvs2,v,1-Y,N,1-M,L,1-e)}}function w(x,B){var E,u,F,v,N,L,Y,M,e,V,S,ba;E=x[B];u=x[B+1];F=x[B+2];v=x[B+3];N=a.uvs[E*2];e=a.uvs[E*2+1];L=a.uvs[u*2];V=a.uvs[u*2+1];Y=a.uvs[F*2];S=a.uvs[F*2+1];M=a.uvs[v*2];ba=a.uvs[v*2+1];THREE.Loader.prototype.uv4(g.uvs,N,e,L,V,Y,S,M,ba);if(a.uvs2){N=a.uvs2[E*2];e=a.uvs2[E*2+1];L=
a.uvs2[u*2];V=a.uvs2[u*2+1];Y=a.uvs2[F*2];S=a.uvs2[F*2+1];M=a.uvs2[v*2];ba=a.uvs2[v*2+1];THREE.Loader.prototype.uv4(g.uvs2,N,1-e,L,1-V,Y,1-S,M,1-ba)}}var t,q;t=0;for(q=a.trianglesUvs.length;t<q;t+=7){h(a.trianglesUvs,t);p(a.trianglesUvs,t+4)}t=0;for(q=a.trianglesNormalsUvs.length;t<q;t+=10){j(a.trianglesNormalsUvs,t);p(a.trianglesNormalsUvs,t+7)}t=0;for(q=a.quadsUvs.length;t<q;t+=9){l(a.quadsUvs,t);w(a.quadsUvs,t+5)}t=0;for(q=a.quadsNormalsUvs.length;t<q;t+=13){n(a.quadsNormalsUvs,t);w(a.quadsNormalsUvs,
t+9)}t=0;for(q=a.triangles.length;t<q;t+=4)h(a.triangles,t);t=0;for(q=a.trianglesNormals.length;t<q;t+=7)j(a.trianglesNormals,t);t=0;for(q=a.quads.length;t<q;t+=5)l(a.quads,t);t=0;for(q=a.quadsNormals.length;t<q;t+=9)n(a.quadsNormals,t)})();(function(){var h,j,l,n;if(a.skinWeights){h=0;for(j=a.skinWeights.length;h<j;h+=2){l=a.skinWeights[h];n=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,l,n,0,0)}}if(a.skinIndices){h=0;for(j=a.skinIndices.length;h<j;h+=2){l=a.skinIndices[h];n=a.skinIndices[h+1];
THREE.Loader.prototype.si(g,l,n,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,f){a.skinIndices.push(new THREE.Vector4(c,b,d,f))},sw:function(a,c,b,d,f){a.skinWeights.push(new THREE.Vector4(c,b,d,f))},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 f=new THREE.Color(16777215);f.setRGB(c,b,d);a.colors.push(f)},f3:function(a,c,b,d,f){a.faces.push(new THREE.Face3(c,b,d,null,a.materials[f]))},f4:function(a,c,b,d,f,g){a.faces.push(new THREE.Face4(c,b,d,f,null,a.materials[g]))},f3n:function(a,c,b,d,f,g,h,j,l){g=a.materials[g];var n=c[j*3],p=c[j*3+1];j=c[j*3+2];var w=c[l*3],t=c[l*3+1];l=c[l*3+2];a.faces.push(new THREE.Face3(b,d,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(n,p,j),new THREE.Vector3(w,
t,l)],g))},f4n:function(a,c,b,d,f,g,h,j,l,n,p){h=a.materials[h];var w=c[l*3],t=c[l*3+1];l=c[l*3+2];var q=c[n*3],x=c[n*3+1];n=c[n*3+2];var B=c[p*3],E=c[p*3+1];p=c[p*3+2];a.faces.push(new THREE.Face4(b,d,f,g,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(w,t,l),new THREE.Vector3(q,x,n),new THREE.Vector3(B,E,p)],h))},uv3:function(a,c,b,d,f,g,h){var j=[];j.push(new THREE.UV(c,b));j.push(new THREE.UV(d,f));j.push(new THREE.UV(g,h));a.push(j)},uv4:function(a,c,b,d,f,g,h,j,l){var n=[];n.push(new THREE.UV(c,
b));n.push(new THREE.UV(d,f));n.push(new THREE.UV(g,h));n.push(new THREE.UV(j,l));a.push(n)},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,l){var n=new Image;n.onload=function(){if(!b(this.width)||!b(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/
Math.LN2));j.image.width=p;j.image.height=w;j.image.getContext("2d").drawImage(this,0,0,p,w)}else j.image=this;j.needsUpdate=!0};n.src=l}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(f="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[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};