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