Three.js 338.5 KB
Newer Older
M
Mr.doob 已提交
1
// Three.js r46dev - http://github.com/mrdoob/three.js
A
alteredq 已提交
2
var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Clock=function(a){this.autoStart=a!==void 0?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){this.elapsedTime+=this.getDelta();return this.elapsedTime};
A
alteredq 已提交
3
THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var c=Date.now(),a=0.0010*(c-this.oldTime);this.oldTime=c;this.elapsedTime+=a}return a};THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
A
alteredq 已提交
4 5 6 7 8 9 10 11
THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;return this},setHSV:function(a,c,b){var d,g,e;if(b===0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),g=a*6-d,a=b*(1-c),e=b*(1-
c*g),c=b*(1-c*(1-g)),d){case 1:this.r=e;this.g=b;this.b=a;break;case 2:this.r=a;this.g=b;this.b=c;break;case 3:this.r=a;this.g=e;this.b=b;break;case 4:this.r=c;this.g=a;this.b=b;break;case 5:this.r=b;this.g=a;this.b=e;break;case 6:case 0:this.r=b,this.g=c,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+
Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,a=this.y-a.y;return c*c+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},
equals:function(a){return a.x===this.x&&a.y===this.y}};THREE.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};
THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},
addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},
12 13 14
divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},
cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.x=b*a.z-d*a.y;this.y=d*a.x-c*a.z;this.z=c*a.y-b*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var c=Math.cos(this.y);
this.y=Math.asin(a.n13);Math.abs(c)>1.0E-5?(this.x=Math.atan2(-a.n23/c,a.n33/c),this.z=Math.atan2(-a.n12/c,a.n11/c)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,c,b,d){this.x=a||0;this.y=c||0;this.z=b||0;this.w=d!==void 0?d:1};
A
alteredq 已提交
15 16
THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-
c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
M
Mr.doob 已提交
17
normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}};
A
alteredq 已提交
18 19 20 21 22 23 24
THREE.Ray=function(a,c){function b(a,b,c){o.sub(c,a);r=o.dot(b);if(r<=0)return null;m=p.add(a,n.copy(b).multiplyScalar(r));return s=c.distanceTo(m)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);n.sub(a,b);u=o.dot(o);t=o.dot(p);q=o.dot(n);A=p.dot(p);w=p.dot(n);E=1/(u*A-t*t);x=(A*q-t*w)*E;I=(u*w-t*q)*E;return x>=0&&I>=0&&x+I<1}this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var g=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,c=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3;this.intersectObject=function(n){for(var m,o=[],p=0,r=n.children.length;p<r;p++)Array.prototype.push.apply(o,this.intersectObject(n.children[p]));if(n instanceof THREE.Particle){p=
b(this.origin,this.direction,n.matrixWorld.getPosition());if(p===null||p>n.scale.x)return[];m={distance:p,point:n.position,face:null,object:n};o.push(m)}else if(n instanceof THREE.Mesh){p=b(this.origin,this.direction,n.matrixWorld.getPosition());if(p===null||p>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return o;var s,q=n.geometry,u=q.vertices,t;n.matrixRotationWorld.extractRotation(n.matrixWorld);p=0;for(r=q.faces.length;p<r;p++)if(m=q.faces[p],a.copy(this.origin),
c.copy(this.direction),t=n.matrixWorld,i=t.multiplyVector3(i.copy(m.centroid)).subSelf(a),s=i.dot(c),!(s<=0)&&(g=t.multiplyVector3(g.copy(u[m.a].position)),e=t.multiplyVector3(e.copy(u[m.b].position)),f=t.multiplyVector3(f.copy(u[m.c].position)),h=m instanceof THREE.Face4?t.multiplyVector3(h.copy(u[m.d].position)):null,k=n.matrixRotationWorld.multiplyVector3(k.copy(m.normal)),s=c.dot(k),n.doubleSided||(n.flipSided?s>0:s<0)))if(s=k.dot(i.sub(g,a))/s,l.add(a,c.multiplyScalar(s)),m instanceof THREE.Face3)d(l,
g,e,f)&&(m={distance:a.distanceTo(l),point:l.clone(),face:m,object:n},o.push(m));else if(m instanceof THREE.Face4&&(d(l,g,e,h)||d(l,e,f,h)))m={distance:a.distanceTo(l),point:l.clone(),face:m,object:n},o.push(m)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,n=new THREE.Vector3,r,m,s,u,t,q,A,w,E,x,I};
THREE.Rectangle=function(){function a(){e=d-c;f=g-b}var c,b,d,g,e,f,h=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return e};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(e,f,l,o){h=!1;c=e;b=f;d=l;g=o;a()};this.addPoint=function(e,f){h?(h=!1,c=e,b=f,d=e,g=f):(c=c<e?c:e,b=b<f?b:f,d=d>e?d:e,g=g>f?g:f);a()};this.add3Points=
function(e,f,l,o,p,n){h?(h=!1,c=e<l?e<p?e:p:l<p?l:p,b=f<o?f<n?f:n:o<n?o:n,d=e>l?e>p?e:p:l>p?l:p,g=f>o?f>n?f:n:o>n?o:n):(c=e<l?e<p?e<c?e:c:p<c?p:c:l<p?l<c?l:c:p<c?p:c,b=f<o?f<n?f<b?f:b:n<b?n:b:o<n?o<b?o:b:n<b?n:b,d=e>l?e>p?e>d?e:d:p>d?p:d:l>p?l>d?l:d:p>d?p:d,g=f>o?f>n?f>g?f:g:n>g?n:g:o>n?o>g?o:g:n>g?n:g);a()};this.addRectangle=function(e){h?(h=!1,c=e.getLeft(),b=e.getTop(),d=e.getRight(),g=e.getBottom()):(c=c<e.getLeft()?c:e.getLeft(),b=b<e.getTop()?b:e.getTop(),d=d>e.getRight()?d:e.getRight(),g=g>
A
alteredq 已提交
25 26 27
e.getBottom()?g:e.getBottom());a()};this.inflate=function(e){c-=e;b-=e;d+=e;g+=e;a()};this.minSelf=function(e){c=c>e.getLeft()?c:e.getLeft();b=b>e.getTop()?b:e.getTop();d=d<e.getRight()?d:e.getRight();g=g<e.getBottom()?g:e.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(c,a.getLeft())>=0&&Math.min(g,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){h=!0;g=d=b=c=0;a()};this.isEmpty=function(){return h}};
THREE.Math={clamp:function(a,c,b){return a<c?c:a>b?b:a},clampBottom:function(a,c){return a<c?c:a},mapLinear:function(a,c,b,d,g){return d+(a-c)*(g-d)/(b-c)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,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}};
A
alteredq 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
THREE.Matrix4=function(a,c,b,d,g,e,f,h,i,k,l,o,p,n,r,m){this.set(a!==void 0?a:1,c||0,b||0,d||0,g||0,e!==void 0?e:1,f||0,h||0,i||0,k||0,l!==void 0?l:1,o||0,p||0,n||0,r||0,m!==void 0?m:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,d,g,e,f,h,i,k,l,o,p,n,r,m){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=g;this.n22=e;this.n23=f;this.n24=h;this.n31=i;this.n32=k;this.n33=l;this.n34=o;this.n41=p;this.n42=n;this.n43=r;this.n44=m;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
c,b){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,c).normalize();if(e.length()===0)e.z=1;d.cross(b,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(b,e).normalize());g.cross(e,d).normalize();this.n11=d.x;this.n12=g.x;this.n13=e.x;this.n21=d.y;this.n22=g.y;this.n23=e.y;this.n31=d.z;this.n32=g.z;this.n33=e.z;return this},multiply:function(a,c){var b=a.n11,d=a.n12,g=a.n13,e=a.n14,f=a.n21,h=a.n22,i=a.n23,k=a.n24,l=a.n31,o=a.n32,p=a.n33,n=a.n34,r=a.n41,m=a.n42,s=a.n43,
u=a.n44,t=c.n11,q=c.n12,A=c.n13,w=c.n14,E=c.n21,x=c.n22,I=c.n23,M=c.n24,D=c.n31,F=c.n32,P=c.n33,K=c.n34,$=c.n41,S=c.n42,R=c.n43,V=c.n44;this.n11=b*t+d*E+g*D+e*$;this.n12=b*q+d*x+g*F+e*S;this.n13=b*A+d*I+g*P+e*R;this.n14=b*w+d*M+g*K+e*V;this.n21=f*t+h*E+i*D+k*$;this.n22=f*q+h*x+i*F+k*S;this.n23=f*A+h*I+i*P+k*R;this.n24=f*w+h*M+i*K+k*V;this.n31=l*t+o*E+p*D+n*$;this.n32=l*q+o*x+p*F+n*S;this.n33=l*A+o*I+p*P+n*R;this.n34=l*w+o*M+p*K+n*V;this.n41=r*t+m*E+s*D+u*$;this.n42=r*q+m*x+s*F+u*S;this.n43=r*A+m*
I+s*P+u*R;this.n44=r*w+m*M+s*K+u*V;return this},multiplySelf:function(a){return this.multiply(this,a)},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},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},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,g=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)*g;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*g;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,g=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*g;a.y=this.n21*c+this.n22*
b+this.n23*d+this.n24*g;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*g;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*g;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*
a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,g=this.n21,e=this.n22,f=this.n23,h=this.n24,i=this.n31,k=this.n32,l=this.n33,o=this.n34,p=this.n41,n=this.n42,r=this.n43,m=this.n44;return d*f*k*p-b*h*k*p-d*e*l*p+c*h*l*p+b*e*o*p-c*f*o*p-d*f*i*n+b*h*i*n+d*g*l*n-a*h*l*n-b*g*o*n+a*f*o*n+d*e*i*r-c*h*i*r-d*g*k*r+a*h*k*r+c*g*o*r-a*e*o*r-b*e*i*m+c*f*i*m+b*g*k*m-a*f*k*m-c*g*l*m+a*e*l*m},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),g=1-b,e=a.x,f=a.y,h=a.z,i=g*e,k=g*f;this.set(i*e+b,i*f-d*h,i*h+d*f,0,i*f+d*h,k*f+b,k*h-d*e,0,i*h-d*f,k*h+d*e,g*h*h+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},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var c=a.n11,b=a.n12,d=a.n13,g=a.n14,e=a.n21,f=a.n22,h=a.n23,i=a.n24,k=a.n31,l=a.n32,o=a.n33,p=a.n34,n=a.n41,r=a.n42,m=a.n43,s=a.n44;this.n11=h*p*r-i*o*r+i*l*m-f*p*m-h*l*s+f*o*s;this.n12=g*o*r-d*p*r-g*l*m+b*p*m+d*l*s-b*o*s;this.n13=d*i*r-g*h*r+g*f*m-b*i*m-d*f*s+b*h*s;this.n14=g*h*l-d*i*l-g*f*o+b*i*o+d*f*p-b*h*p;this.n21=i*o*n-h*p*n-i*k*m+e*p*m+h*k*s-e*o*s;this.n22=d*p*n-g*o*n+
g*k*m-c*p*m-d*k*s+c*o*s;this.n23=g*h*n-d*i*n-g*e*m+c*i*m+d*e*s-c*h*s;this.n24=d*i*k-g*h*k+g*e*o-c*i*o-d*e*p+c*h*p;this.n31=f*p*n-i*l*n+i*k*r-e*p*r-f*k*s+e*l*s;this.n32=g*l*n-b*p*n-g*k*r+c*p*r+b*k*s-c*l*s;this.n33=d*i*n-g*f*n+g*e*r-c*i*r-b*e*s+c*f*s;this.n34=g*f*k-b*i*k-g*e*l+c*i*l+b*e*p-c*f*p;this.n41=h*l*n-f*o*n-h*k*r+e*o*r+f*k*m-e*l*m;this.n42=b*o*n-d*l*n+d*k*r-c*o*r-b*k*m+c*l*m;this.n43=d*f*n-b*h*n-d*e*r+c*h*r+b*e*m-c*f*m;this.n44=b*h*k-d*f*k+d*e*l-c*h*l-b*e*o+c*f*o;this.multiplyScalar(1/a.determinant());
return this},setRotationFromEuler:function(a,c){var b=a.x,d=a.y,g=a.z,e=Math.cos(b),b=Math.sin(b),f=Math.cos(d),d=Math.sin(d),h=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var i=f*h,k=f*g,l=d*h,o=d*g;this.n11=i+o*b;this.n12=l*b-k;this.n13=e*d;this.n21=e*g;this.n22=e*h;this.n23=-b;this.n31=k*b-l;this.n32=o+i*b;this.n33=e*f;break;case "ZXY":i=f*h;k=f*g;l=d*h;o=d*g;this.n11=i-o*b;this.n12=-e*g;this.n13=l+k*b;this.n21=k+l*b;this.n22=e*h;this.n23=o-i*b;this.n31=-e*d;this.n32=b;this.n33=e*f;break;case "ZYX":i=
e*h;k=e*g;l=b*h;o=b*g;this.n11=f*h;this.n12=l*d-k;this.n13=i*d+o;this.n21=f*g;this.n22=o*d+i;this.n23=k*d-l;this.n31=-d;this.n32=b*f;this.n33=e*f;break;case "YZX":i=e*f;k=e*d;l=b*f;o=b*d;this.n11=f*h;this.n12=o-i*g;this.n13=l*g+k;this.n21=g;this.n22=e*h;this.n23=-b*h;this.n31=-d*h;this.n32=k*g+l;this.n33=i-o*g;break;case "XZY":i=e*f;k=e*d;l=b*f;o=b*d;this.n11=f*h;this.n12=-g;this.n13=d*h;this.n21=i*g+o;this.n22=e*h;this.n23=k*g-l;this.n31=l*g-k;this.n32=b*h;this.n33=o*g+i;break;default:i=e*h,k=e*
g,l=b*h,o=b*g,this.n11=f*h,this.n12=-f*g,this.n13=d,this.n21=k+l*d,this.n22=i-o*d,this.n23=-b*f,this.n31=o-i*d,this.n32=l+k*d,this.n33=e*f}return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,g=a.w,e=c+c,f=b+b,h=d+d,a=c*e,i=c*f;c*=h;var k=b*f;b*=h;d*=h;e*=g;f*=g;g*=h;this.n11=1-(k+d);this.n12=i-g;this.n13=c+f;this.n21=i+g;this.n22=1-(a+d);this.n23=b-e;this.n31=c-f;this.n32=b+e;this.n33=1-(a+k);return this},scale:function(a){var c=a.x,b=a.y,a=a.z;this.n11*=c;this.n12*=b;this.n13*=
A
alteredq 已提交
46 47 48
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},compose:function(a,c,b){var d=THREE.Matrix4.__m1,g=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(c);g.setScale(b.x,b.y,b.z);this.multiply(d,g);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,c,b){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);g.set(this.n12,this.n22,this.n32);e.set(this.n13,
this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;b=b instanceof THREE.Vector3?b:new THREE.Vector3;b.x=d.length();b.y=g.length();b.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=b.x;d.n21/=b.x;d.n31/=b.x;d.n12/=b.y;d.n22/=b.y;d.n32/=b.y;d.n13/=b.z;d.n23/=b.z;d.n33/=b.z;c.setFromRotationMatrix(d);return[a,c,b]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
return this},extractRotation:function(a){var c=THREE.Matrix4.__v1,b=1/c.set(a.n11,a.n21,a.n31).length(),d=1/c.set(a.n12,a.n22,a.n32).length(),c=1/c.set(a.n13,a.n23,a.n33).length();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*c;this.n23=a.n23*c;this.n33=a.n33*c;return this}};
A
alteredq 已提交
49
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,o=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*k;a===0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;b[0]=a*d;b[1]=a*g;b[2]=a*e;b[3]=a*f;b[4]=a*h;b[5]=a*i;b[6]=a*k;b[7]=a*l;b[8]=a*o;return c};
A
alteredq 已提交
50
THREE.Matrix4.makeFrustum=function(a,c,b,d,g,e){var f;f=new THREE.Matrix4;f.n11=2*g/(c-a);f.n12=0;f.n13=(c+a)/(c-a);f.n14=0;f.n21=0;f.n22=2*g/(d-b);f.n23=(d+b)/(d-b);f.n24=0;f.n31=0;f.n32=0;f.n33=-(e+g)/(e-g);f.n34=-2*e*g/(e-g);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,c,b,d){var g,a=b*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,b,d)};
A
alteredq 已提交
51
THREE.Matrix4.makeOrtho=function(a,c,b,d,g,e){var f,h,i,k;f=new THREE.Matrix4;h=c-a;i=b-d;k=e-g;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((c+a)/h);f.n21=0;f.n22=2/i;f.n23=0;f.n24=-((b+d)/i);f.n31=0;f.n32=0;f.n33=-2/k;f.n34=-((e+g)/k);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
A
alteredq 已提交
52 53 54 55 56 57
THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(this.children.indexOf(a)===
-1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addObject(a)}},remove:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=void 0;this.children.splice(c,1);for(c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.removeObject(a)}},getChildByName:function(a,c){var b,d,g;b=0;for(d=this.children.length;b<d;b++){g=this.children[b];if(g.name===a)return g;
if(c&&(g=g.getChildByName(a,c),g!==void 0))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var c=0,b=this.children.length;c<b;c++)this.children[c].updateMatrixWorld(a)}};THREE.Object3DCount=0;
A
alteredq 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70
THREE.Projector=function(){function a(){var a=f[e]=f[e]||new THREE.RenderableObject;e++;return a}function c(){var a=k[i]=k[i]||new THREE.RenderableVertex;i++;return a}function b(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,g=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;return e>=0&&g>=0&&f>=0&&h>=0?!0:e<0&&g<0||f<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g))),f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var g,e,f=[],h,i,k=[],
l,o,p=[],n,r=[],m,s,u=[],t,q,A=[],w={objects:[],sprites:[],lights:[],elements:[]},E=new THREE.Vector3,x=new THREE.Vector4,I=new THREE.Matrix4,M=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,P=new THREE.Vector4;this.computeFrustum=function(a){D[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);D[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);D[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+
a.n23,a.n44+a.n24);D[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);D[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);D[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=D[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);I.multiply(b.projectionMatrix,b.matrixWorldInverse);I.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
I.multiply(b.matrixWorld,b.projectionMatrixInverse);I.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(c,d){e=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var f=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld,
e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),h=0;h<6;h++)if(c=D[h].x*d.n14+D[h].y*d.n24+D[h].z*d.n34+D[h].w,c<=e){c=!1;break a}c=!0}c?(I.multiplyVector3(E.copy(b.position)),g=a(),g.object=b,g.z=E.z,w.objects.push(g)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(I.multiplyVector3(E.copy(b.position)),g=a(),g.object=b,g.z=E.z,w.sprites.push(g)):b instanceof THREE.Light&&w.lights.push(b);c=0;for(d=b.children.length;c<d;c++)f(b.children[c])}};f(c);d&&
w.objects.sort(b);return w};this.projectScene=function(a,e,g){var f=e.near,E=e.far,D,y,H,z,L,j,aa,ga,N,W,T,ca,Q,C,ka,da;q=s=n=o=0;w.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);I.multiply(e.projectionMatrix,e.matrixWorldInverse);this.computeFrustum(I);w=this.projectGraph(a,!1);a=0;for(D=w.objects.length;a<D;a++)if(N=w.objects[a].object,W=N.matrixWorld,
ca=N.material,i=0,N instanceof THREE.Mesh){T=N.geometry;Q=N.geometry.materials;z=T.vertices;C=T.faces;ka=T.faceVertexUvs;T=N.matrixRotationWorld.extractRotation(W);y=0;for(H=z.length;y<H;y++)h=c(),h.positionWorld.copy(z[y].position),W.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),I.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>f&&h.positionScreen.z<E;z=0;for(y=C.length;z<y;z++){H=
C[z];if(H instanceof THREE.Face3)if(L=k[H.a],j=k[H.b],aa=k[H.c],L.visible&&j.visible&&aa.visible&&(N.doubleSided||N.flipSided!=(aa.positionScreen.x-L.positionScreen.x)*(j.positionScreen.y-L.positionScreen.y)-(aa.positionScreen.y-L.positionScreen.y)*(j.positionScreen.x-L.positionScreen.x)<0))ga=p[o]=p[o]||new THREE.RenderableFace3,o++,l=ga,l.v1.copy(L),l.v2.copy(j),l.v3.copy(aa);else continue;else if(H instanceof THREE.Face4)if(L=k[H.a],j=k[H.b],aa=k[H.c],ga=k[H.d],L.visible&&j.visible&&aa.visible&&
ga.visible&&(N.doubleSided||N.flipSided!=((ga.positionScreen.x-L.positionScreen.x)*(j.positionScreen.y-L.positionScreen.y)-(ga.positionScreen.y-L.positionScreen.y)*(j.positionScreen.x-L.positionScreen.x)<0||(j.positionScreen.x-aa.positionScreen.x)*(ga.positionScreen.y-aa.positionScreen.y)-(j.positionScreen.y-aa.positionScreen.y)*(ga.positionScreen.x-aa.positionScreen.x)<0)))da=r[n]=r[n]||new THREE.RenderableFace4,n++,l=da,l.v1.copy(L),l.v2.copy(j),l.v3.copy(aa),l.v4.copy(ga);else continue;l.normalWorld.copy(H.normal);
T.multiplyVector3(l.normalWorld);l.centroidWorld.copy(H.centroid);W.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);I.multiplyVector3(l.centroidScreen);aa=H.vertexNormals;L=0;for(j=aa.length;L<j;L++)ga=l.vertexNormalsWorld[L],ga.copy(aa[L]),T.multiplyVector3(ga);L=0;for(j=ka.length;L<j;L++)if(da=ka[L][z]){aa=0;for(ga=da.length;aa<ga;aa++)l.uvs[L][aa]=da[aa]}l.material=ca;l.faceMaterial=H.materialIndex!==null?Q[H.materialIndex]:null;l.z=l.centroidScreen.z;w.elements.push(l)}}else if(N instanceof
THREE.Line){M.multiply(I,W);z=N.geometry.vertices;L=c();L.positionScreen.copy(z[0].position);M.multiplyVector4(L.positionScreen);y=1;for(H=z.length;y<H;y++)if(L=c(),L.positionScreen.copy(z[y].position),M.multiplyVector4(L.positionScreen),j=k[i-2],F.copy(L.positionScreen),P.copy(j.positionScreen),d(F,P))F.multiplyScalar(1/F.w),P.multiplyScalar(1/P.w),N=u[s]=u[s]||new THREE.RenderableLine,s++,m=N,m.v1.positionScreen.copy(F),m.v2.positionScreen.copy(P),m.z=Math.max(F.z,P.z),m.material=ca,w.elements.push(m)}a=
0;for(D=w.sprites.length;a<D;a++)if(N=w.sprites[a].object,W=N.matrixWorld,N instanceof THREE.Particle&&(x.set(W.n14,W.n24,W.n34,1),I.multiplyVector4(x),x.z/=x.w,x.z>0&&x.z<1))f=A[q]=A[q]||new THREE.RenderableParticle,q++,t=f,t.x=x.x/x.w,t.y=x.y/x.w,t.z=x.z,t.rotation=N.rotation.z,t.scale.x=N.scale.x*Math.abs(t.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),t.scale.y=N.scale.y*Math.abs(t.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),t.material=N.material,w.elements.push(t);
g&&w.elements.sort(b);return w}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)};
A
alteredq 已提交
71 72 73
THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,d=a.y*c,g=a.z*c,a=Math.cos(d),d=Math.sin(d),c=Math.cos(-g),g=Math.sin(-g),e=Math.cos(b),b=Math.sin(b),f=a*c,h=d*g;this.w=f*e-h*b;this.x=f*b+h*e;this.y=d*c*e+a*g*b;this.z=a*g*e-d*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,d=Math.sin(b);
this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
this.normalize();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);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var c=
A
alteredq 已提交
74 75
this.x,b=this.y,d=this.z,g=this.w,e=a.x,f=a.y,h=a.z,a=a.w;this.x=c*a+g*e+b*h-d*f;this.y=b*a+g*f+d*e-c*h;this.z=d*a+g*h+c*f-b*e;this.w=g*a-c*e-b*f-d*h;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,g=a.z,e=this.x,f=this.y,h=this.z,i=this.w,k=i*b+f*g-h*d,l=i*d+h*b-e*g,o=i*g+e*d-f*b,b=-e*
b-f*d-h*g;c.x=k*i+b*-e+l*-h-o*-f;c.y=l*i+b*-f+o*-e-k*-h;c.z=o*i+b*-h+k*-f-l*-e;return c}};
A
alteredq 已提交
76
THREE.Quaternion.slerp=function(a,c,b,d){var g=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;g<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,g=-g):b.copy(c);if(Math.abs(g)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var e=Math.acos(g),g=Math.sqrt(1-g*g);if(Math.abs(g)<0.0010)return 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),b;c=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;b.w=a.w*c+b.w*d;b.x=a.x*c+b.x*d;b.y=a.y*c+b.y*d;b.z=a.z*c+b.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
A
alteredq 已提交
77 78 79 80 81 82 83 84 85
THREE.Face3=function(a,c,b,d,g,e){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};
THREE.Face4=function(a,c,b,d,g,e,f){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
THREE.UV.prototype={constructor:THREE.UV,set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var c=new THREE.Matrix4;c.extractRotation(a,new THREE.Vector3(1,1,1));for(var b=0,d=this.vertices.length;b<d;b++)a.multiplyVector3(this.vertices[b].position);b=0;for(d=this.faces.length;b<d;b++){var g=this.faces[b];c.multiplyVector3(g.normal);for(var e=0,f=g.vertexNormals.length;e<f;e++)c.multiplyVector3(g.vertexNormals[e]);a.multiplyVector3(g.centroid)}},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),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)):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,g,e,f,h=new THREE.Vector3,i=new THREE.Vector3;d=0;for(g=this.faces.length;d<g;d++){e=this.faces[d];if(a&&e.vertexNormals.length){h.set(0,0,0);c=0;for(b=e.vertexNormals.length;c<b;c++)h.addSelf(e.vertexNormals[c]);h.divideScalar(3)}else c=this.vertices[e.a],b=this.vertices[e.b],f=this.vertices[e.c],h.sub(f.position,b.position),i.sub(c.position,b.position),h.crossSelf(i);h.isZero()||h.normalize();e.normal.copy(h)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices===void 0){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++)if(b=this.faces[a],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],b instanceof
THREE.Face3?(d[b.a].addSelf(b.normal),d[b.b].addSelf(b.normal),d[b.c].addSelf(b.normal)):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],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])):b instanceof THREE.Face4&&(b.vertexNormals[0].copy(d[b.a]),
A
alteredq 已提交
86 87 88
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(a,b,c,d,e,g,j){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;l=f[e];o=f[g];p=f[j];n=i.x-h.x;r=k.x-h.x;m=i.y-h.y;s=k.y-h.y;u=i.z-h.z;t=k.z-h.z;q=o.u-l.u;A=p.u-l.u;w=o.v-l.v;E=p.v-l.v;x=1/(q*E-A*w);F.set((E*n-w*r)*x,(E*m-w*s)*x,(E*u-w*t)*x);P.set((q*r-A*n)*x,(q*s-A*m)*x,(q*t-A*u)*x);M[b].addSelf(F);M[c].addSelf(F);M[d].addSelf(F);D[b].addSelf(P);
D[c].addSelf(P);D[d].addSelf(P)}var c,b,d,g,e,f,h,i,k,l,o,p,n,r,m,s,u,t,q,A,w,E,x,I,M=[],D=[],F=new THREE.Vector3,P=new THREE.Vector3,K=new THREE.Vector3,$=new THREE.Vector3,S=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++)M[c]=new THREE.Vector3,D[c]=new THREE.Vector3;c=0;for(b=this.faces.length;c<b;c++)e=this.faces[c],f=this.faceVertexUvs[0][c],e instanceof THREE.Face3?a(this,e.a,e.b,e.c,0,1,2):e instanceof THREE.Face4&&(a(this,e.a,e.b,e.c,0,1,2),a(this,e.a,e.b,e.d,0,1,3));var R=["a","b",
"c","d"];c=0;for(b=this.faces.length;c<b;c++){e=this.faces[c];for(d=0;d<e.vertexNormals.length;d++)S.copy(e.vertexNormals[d]),g=e[R[d]],I=M[g],K.copy(I),K.subSelf(S.multiplyScalar(S.dot(I))).normalize(),$.cross(e.vertexNormals[d],I),g=$.dot(D[g]),g=g<0?-1:1,e.vertexTangents[d]=new THREE.Vector4(K.x,K.y,K.z,g)}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,
A
alteredq 已提交
89 90 91
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=0,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},c=[],b=[],d,g=Math.pow(10,4),e,f;e=0;for(f=this.vertices.length;e<f;e++)d=this.vertices[e].position,d=[Math.round(d.x*g),Math.round(d.y*g),Math.round(d.z*g)].join("_"),a[d]===void 0?(a[d]=e,c.push(this.vertices[e]),
b[e]=c.length-1):b[e]=b[a[d]];e=0;for(f=this.faces.length;e<f;e++)if(a=this.faces[e],a instanceof THREE.Face3)a.a=b[a.a],a.b=b[a.b],a.c=b[a.c];else if(a instanceof THREE.Face4)a.a=b[a.a],a.b=b[a.b],a.c=b[a.c],a.d=b[a.d];this.vertices=c}};THREE.GeometryCount=0;
A
alteredq 已提交
92 93
THREE.Spline=function(a){function c(a,b,c,d,e,g,f){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var b=[],d={x:0,y:0,z:0},g,e,f,h,i,k,l,o,p;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){g=(this.points.length-1)*a;e=Math.floor(g);f=g-e;b[0]=e===0?e:e-1;b[1]=e;b[2]=e>this.points.length-2?e:e+1;b[3]=e>this.points.length-3?e:e+2;k=this.points[b[0]];l=this.points[b[1]];
o=this.points[b[2]];p=this.points[b[3]];h=f*f;i=f*h;d.x=c(k.x,l.x,o.x,p.x,f,h,i);d.y=c(k.y,l.y,o.y,p.y,f,h,i);d.z=c(k.z,l.z,o.z,p.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,g=new THREE.Vector3,f=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;g.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),f.copy(d),i+=f.distanceTo(g),
94
g.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,g,f,h=[],i=new THREE.Vector3,l=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];f=Math.ceil(a*c/l.total);e=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(c=1;c<f-1;c++)d=e+c*(1/f)*(g-e),d=this.getPoint(d),h.push(i.copy(d).clone());h.push(i.copy(this.points[b]).clone())}this.points=
A
alteredq 已提交
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
h}};THREE.Edge=function(a,c,b,d){this.vertices=[a,c];this.vertexIndices=[b,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,c,b,d,g,e){THREE.Camera.call(this);this.left=a;this.right=c;this.top=b;this.bottom=d;this.near=g!==void 0?g:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,c,b,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=c!==void 0?c:1;this.near=b!==void 0?b:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,c){this.fov=2*Math.atan((c!==void 0?c:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,c,b,d,g,e){this.fullWidth=a;this.fullHeight=c;this.x=b;this.y=d;this.width=g;this.height=e;this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,b=-c,d=a*b,a=Math.abs(a*c-d),b=Math.abs(c-b);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,c-(this.y+this.height)*b/this.fullHeight,c-this.y*b/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
this.far)};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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c!==void 0?c:1;this.distance=b!==void 0?b:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=c!==void 0?c:1;this.distance=b!==void 0?b:0};THREE.PointLight.prototype=new THREE.Light;
THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(a,c,b,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=c!==void 0?c:1;this.distance=b!==void 0?b:0;this.castShadow=d!==void 0?d:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
THREE.Material=function(a){this.name="";this.id=THREE.MaterialCount++;a=a||{};this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:!1;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.depthTest=a.depthTest!==void 0?a.depthTest:!0;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:!0;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:!1;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=
a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:!1};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;
THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==void 0?a.linewidth:1;this.linecap=a.linecap!==void 0?a.linecap:"round";this.linejoin=a.linejoin!==void 0?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1;this.fog=a.fog!==void 0?a.fog:!0};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:
!0;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:
!1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(328965);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=
a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:!0;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=
a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(328965);this.specular=a.specular!==void 0?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=a.shininess!==void 0?a.shininess:30;this.metal=a.metal!==void 0?a.metal:!1;this.perPixel=a.perPixel!==void 0?a.perPixel:!1;this.map=a.map!==void 0?a.map:null;this.lightMap=
a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:!0;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=
a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;
THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
THREE.MeshShaderMaterial=function(a){console.warn("DEPRECATED: MeshShaderMaterial() is now ShaderMaterial().");return new THREE.ShaderMaterial(a)};
THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.fog=a.fog!==void 0?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==void 0?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};
THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=a.fog!==
void 0?a.fog:!1;this.lights=a.lights!==void 0?a.lights:!1;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
122
THREE.Texture=function(a,c,b,d,g,e){this.id=THREE.TextureCount++;this.image=a;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=b!==void 0?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=g!==void 0?g:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1;this.onUpdate=null};
A
alteredq 已提交
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;
THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,c,b,d,g,e,f,h,i){THREE.Texture.call(this,null,g,e,f,h,i);this.image={data:a,width:c,height:b};this.format=d!==void 0?d:THREE.RGBAFormat};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};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.material=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.material=c;this.type=b!==void 0?b:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};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.material=c;if(c instanceof Array)console.warn("DEPRECATED: Mesh material can no longer be an Array. Using material at index 0..."),this.material=c[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};
for(var b=0;b<this.geometry.morphTargets.length;b++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[b].name]=b}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
THREE.Bone.prototype.update=function(a,c){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var b,d=this.children.length;for(b=0;b<d;b++)this.children[b].update(this.skinMatrix,c)};
THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,d,g,e,f,h;if(this.geometry.bones!==void 0){for(b=0;b<this.geometry.bones.length;b++)g=this.geometry.bones[b],e=g.pos,f=g.rotq,h=g.scl,d=this.addBone(),d.name=g.name,d.position.set(e[0],e[1],e[2]),d.quaternion.set(f[0],f[1],f[2],f[3]),d.useQuaternion=!0,h!==void 0?d.scale.set(h[0],h[1],h[2]):d.scale.set(1,1,1);for(b=0;b<this.bones.length;b++)g=this.geometry.bones[b],
d=this.bones[b],g.parent===-1?this.add(d):this.bones[g.parent].add(d);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,c=this.children.length;a<c;a++){var b=this.children[a];b instanceof THREE.Bone?b.update(this.identityMatrix,!1):b.updateMatrixWorld(!0)}for(var c=this.bones.length,b=this.bones,d=this.boneMatrices,a=0;a<c;a++)b[a].skinMatrix.flattenToArrayOffset(d,
a*16)};
THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];var d=new THREE.Matrix4;d.getInverse(a.skinMatrix);c.push(d);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.vertices[a].position,g=this.geometry.skinIndices[a].x,e=this.geometry.skinIndices[a].y,d=
new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[g].multiplyVector3(d));d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[e].multiplyVector3(d));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.MorphAnimMesh=function(a,c){THREE.Mesh.call(this,a,c);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype=new THREE.Mesh;THREE.MorphAnimMesh.prototype.constructor=THREE.MorphAnimMesh;
THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var c=this.duration/(this.geometry.morphTargets.length-1);this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration;a=THREE.Math.clamp(Math.floor(this.time/c),0,this.geometry.morphTargets.length-1);if(a!=this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a;c=this.time%c/c;this.directionBackwards&&(c=1-c);this.morphTargetInfluences[this.currentKeyframe]=c;this.morphTargetInfluences[this.lastKeyframe]=1-c};THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
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.addLevel=function(a,c){c===void 0&&(c=0);for(var c=Math.abs(c),b=0;b<this.LODs.length;b++)if(c<this.LODs[b].visibleAtDistance)break;this.LODs.splice(b,0,{visibleAtDistance:c,object3D:a});this.add(a)};
THREE.LOD.prototype.update=function(a){if(this.LODs.length>1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.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 c=1;c<this.LODs.length;c++)if(a>=this.LODs[c].visibleAtDistance)this.LODs[c-1].object3D.visible=!1,this.LODs[c].object3D.visible=!0;else break;for(;c<this.LODs.length;c++)this.LODs[c].object3D.visible=!1}};
THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map instanceof THREE.Texture?a.map:THREE.ImageUtils.loadTexture(a.map);this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.useScreenCoordinates=a.useScreenCoordinates!==void 0?a.useScreenCoordinates:!0;this.mergeWith3D=a.mergeWith3D!==void 0?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=a.affectedByDistance!==void 0?a.affectedByDistance:
!this.useScreenCoordinates;this.scaleByViewport=a.scaleByViewport!==void 0?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;
THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.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);var c=this.__objectsRemoved.indexOf(a);c!==-1&&this.__objectsRemoved.splice(c,1)}for(c=0;c<a.children.length;c++)this.addObject(a.children[c])};
THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else a instanceof THREE.Camera||(c=this.objects.indexOf(a),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(a),c=this.__objectsAdded.indexOf(a),c!==-1&&this.__objectsAdded.splice(c,1)));for(c=0;c<a.children.length;c++)this.removeObject(a.children[c])};
THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c!==void 0?c:1;this.far=b!==void 0?b:1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c!==void 0?c:2.5E-4};
A
alteredq 已提交
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,g,e;this.domElement=document.createElement("div");this.setSize=function(a,c){b=a;d=c;g=b/2;e=d/2};this.render=function(b,d){var i,k,l,o,p,n,r,m;a=c.projectScene(b,d);i=0;for(k=a.length;i<k;i++)if(p=a[i],p instanceof THREE.RenderableParticle){r=p.x*g+g;m=p.y*e+e;l=0;for(o=p.material.length;l<o;l++)if(n=p.material[l],n instanceof THREE.ParticleDOMMaterial)n=n.domElement,n.style.left=r+"px",n.style.top=m+"px"}}};
THREE.CanvasRenderer=function(a){function c(a){if(t!=a)m.globalAlpha=t=a}function b(a){if(q!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=a}}function d(a){if(A!=a)m.strokeStyle=A=a}function g(a){if(w!=a)m.fillStyle=w=a}var e=this,f,h,i,k=new THREE.Projector,a=a||{},l=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
o,p,n,r,m=l.getContext("2d"),s=new THREE.Color(0),u=0,t=1,q=0,A=null,w=null,E=null,x=null,I=null,M,D,F,P,K=new THREE.RenderableVertex,$=new THREE.RenderableVertex,S,R,V,ja,y,H,z,L,j,aa,ga,N,W=new THREE.Color,T=new THREE.Color,ca=new THREE.Color,Q=new THREE.Color,C=new THREE.Color,ka=[],da,X,oa,la,ra,ta,pa,qa,wa,U,v=new THREE.Rectangle,J=new THREE.Rectangle,Y=new THREE.Rectangle,ea=!1,ba=new THREE.Color,ua=new THREE.Color,Z=new THREE.Color,fa=new THREE.Vector3,ia,xa,O,ma,sa,ha,a=16;ia=document.createElement("canvas");
ia.width=ia.height=2;xa=ia.getContext("2d");xa.fillStyle="rgba(0,0,0,1)";xa.fillRect(0,0,2,2);O=xa.getImageData(0,0,2,2);ma=O.data;sa=document.createElement("canvas");sa.width=sa.height=a;ha=sa.getContext("2d");ha.translate(-a/2,-a/2);ha.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;p=b;n=Math.floor(o/2);r=Math.floor(p/2);l.width=o;l.height=p;v.set(-n,-r,n,r);J.set(-n,-r,n,r);t=1;q=0;I=x=
E=w=A=null};this.setClearColor=function(a,b){s.copy(a);u=b;J.set(-n,-r,n,r)};this.setClearColorHex=function(a,b){s.setHex(a);u=b;J.set(-n,-r,n,r)};this.clear=function(){m.setTransform(1,0,0,-1,n,r);J.isEmpty()||(J.minSelf(v),J.inflate(2),u<1&&m.clearRect(Math.floor(J.getX()),Math.floor(J.getY()),Math.floor(J.getWidth()),Math.floor(J.getHeight())),u>0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+u+")"),m.fillRect(Math.floor(J.getX()),
Math.floor(J.getY()),Math.floor(J.getWidth()),Math.floor(J.getHeight()))),J.empty())};this.render=function(a,l){function p(a){var b,c,d,e;ba.setRGB(0,0,0);ua.setRGB(0,0,0);Z.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(ba.r+=e.r,ba.g+=e.g,ba.b+=e.b):d instanceof THREE.DirectionalLight?(ua.r+=e.r,ua.g+=e.g,ua.b+=e.b):d instanceof THREE.PointLight&&(Z.r+=e.r,Z.g+=e.g,Z.b+=e.b)}function o(a,b,c,d){var e,g,f,j,h,i;e=0;for(g=a.length;e<g;e++)f=a[e],j=f.color,
f instanceof THREE.DirectionalLight?(h=f.matrixWorld.getPosition(),i=c.dot(h),i<=0||(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):f instanceof THREE.PointLight&&(h=f.matrixWorld.getPosition(),i=c.dot(fa.sub(h,b).normalize()),i<=0||(i*=f.distance==0?1:1-Math.min(b.distanceTo(h)/f.distance,1),i!=0&&(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function s(a,e,f){c(f.opacity);b(f.blending);var j,h,i,l,k,ha;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)l=f.map.image,k=l.width>>1,ha=
l.height>>1,f=e.scale.x*n,i=e.scale.y*r,j=f*k,h=i*ha,Y.set(a.x-j,a.y-h,a.x+j,a.y+h),v.intersects(Y)&&(m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(f,-i),m.translate(-k,-ha),m.drawImage(l,0,0),m.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*n,h=e.scale.y*r,Y.set(a.x-j,a.y-h,a.x+j,a.y+h),v.intersects(Y)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(j,h),f.program(m),m.restore()))}function q(a,
e,g,f){c(f.opacity);b(f.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(E!=a)m.lineWidth=E=a;a=f.linecap;if(x!=a)m.lineCap=x=a;a=f.linejoin;if(I!=a)m.lineJoin=I=a;d(f.color.getContextStyle());m.stroke();Y.inflate(f.linewidth*2)}}function u(a,d,g,f,j,h,n,k){e.info.render.vertices+=3;e.info.render.faces++;c(k.opacity);b(k.blending);S=a.positionScreen.x;R=a.positionScreen.y;
V=d.positionScreen.x;ja=d.positionScreen.y;y=g.positionScreen.x;H=g.positionScreen.y;A(S,R,V,ja,y,H);if(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&(la=n.uvs[0],Ga(S,R,V,ja,y,H,la[f].u,la[f].v,la[j].u,la[j].v,la[h].u,la[h].v,k.map));else if(k.envMap){if(k.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,fa.copy(n.vertexNormalsWorld[f]),ra=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,ta=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+
0.5,fa.copy(n.vertexNormalsWorld[j]),pa=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,qa=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+0.5,fa.copy(n.vertexNormalsWorld[h]),wa=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,U=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+0.5,Ga(S,R,V,ja,y,H,ra,ta,pa,qa,wa,U,k.envMap)}else k.wireframe?ya(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):w(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&&
(la=n.uvs[0],Ga(S,R,V,ja,y,H,la[f].u,la[f].v,la[j].u,la[j].v,la[h].u,la[h].v,k.map)),b(THREE.SubtractiveBlending)),ea?!k.wireframe&&k.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==3?(T.r=ca.r=Q.r=ba.r,T.g=ca.g=Q.g=ba.g,T.b=ca.b=Q.b=ba.b,o(i,n.v1.positionWorld,n.vertexNormalsWorld[0],T),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],ca),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],Q),T.r=Math.max(0,Math.min(k.color.r*T.r,1)),T.g=Math.max(0,Math.min(k.color.g*T.g,1)),T.b=Math.max(0,Math.min(k.color.b*
T.b,1)),ca.r=Math.max(0,Math.min(k.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(k.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(k.color.b*ca.b,1)),Q.r=Math.max(0,Math.min(k.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(k.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(k.color.b*Q.b,1)),C.r=(ca.r+Q.r)*0.5,C.g=(ca.g+Q.g)*0.5,C.b=(ca.b+Q.b)*0.5,oa=Da(T,ca,Q,C),Ba(S,R,V,ja,y,H,0,0,1,0,0,1,oa)):(W.r=ba.r,W.g=ba.g,W.b=ba.b,o(i,n.centroidWorld,n.normalWorld,W),W.r=Math.max(0,Math.min(k.color.r*W.r,1)),W.g=Math.max(0,Math.min(k.color.g*
W.g,1)),W.b=Math.max(0,Math.min(k.color.b*W.b,1)),k.wireframe?ya(W,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):w(W)):k.wireframe?ya(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):w(k.color);else if(k instanceof THREE.MeshDepthMaterial)da=l.near,X=l.far,T.r=T.g=T.b=1-Aa(a.positionScreen.z,da,X),ca.r=ca.g=ca.b=1-Aa(d.positionScreen.z,da,X),Q.r=Q.g=Q.b=1-Aa(g.positionScreen.z,da,X),C.r=(ca.r+Q.r)*0.5,C.g=(ca.g+Q.g)*0.5,C.b=(ca.b+Q.b)*0.5,oa=Da(T,ca,Q,C),Ba(S,R,
V,ja,y,H,0,0,1,0,0,1,oa);else if(k instanceof THREE.MeshNormalMaterial)W.r=Ca(n.normalWorld.x),W.g=Ca(n.normalWorld.y),W.b=Ca(n.normalWorld.z),k.wireframe?ya(W,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):w(W)}function t(a,d,g,f,h,k,n,m,ha){e.info.render.vertices+=4;e.info.render.faces++;c(m.opacity);b(m.blending);if(m.map||m.envMap)u(a,d,f,0,1,3,n,m,ha),u(h,g,k,1,2,3,n,m,ha);else if(S=a.positionScreen.x,R=a.positionScreen.y,V=d.positionScreen.x,ja=d.positionScreen.y,y=g.positionScreen.x,
H=g.positionScreen.y,z=f.positionScreen.x,L=f.positionScreen.y,j=h.positionScreen.x,aa=h.positionScreen.y,ga=k.positionScreen.x,N=k.positionScreen.y,m instanceof THREE.MeshBasicMaterial)Ea(S,R,V,ja,y,H,z,L),m.wireframe?ya(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(m.color);else if(m instanceof THREE.MeshLambertMaterial)ea?!m.wireframe&&m.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(T.r=ca.r=Q.r=C.r=ba.r,T.g=ca.g=Q.g=C.g=ba.g,T.b=ca.b=Q.b=C.b=ba.b,o(i,n.v1.positionWorld,
n.vertexNormalsWorld[0],T),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],ca),o(i,n.v4.positionWorld,n.vertexNormalsWorld[3],Q),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],C),T.r=Math.max(0,Math.min(m.color.r*T.r,1)),T.g=Math.max(0,Math.min(m.color.g*T.g,1)),T.b=Math.max(0,Math.min(m.color.b*T.b,1)),ca.r=Math.max(0,Math.min(m.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(m.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(m.color.b*ca.b,1)),Q.r=Math.max(0,Math.min(m.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(m.color.g*
Q.g,1)),Q.b=Math.max(0,Math.min(m.color.b*Q.b,1)),C.r=Math.max(0,Math.min(m.color.r*C.r,1)),C.g=Math.max(0,Math.min(m.color.g*C.g,1)),C.b=Math.max(0,Math.min(m.color.b*C.b,1)),oa=Da(T,ca,Q,C),A(S,R,V,ja,z,L),Ba(S,R,V,ja,z,L,0,0,1,0,0,1,oa),A(j,aa,y,H,ga,N),Ba(j,aa,y,H,ga,N,1,0,1,1,0,1,oa)):(W.r=ba.r,W.g=ba.g,W.b=ba.b,o(i,n.centroidWorld,n.normalWorld,W),W.r=Math.max(0,Math.min(m.color.r*W.r,1)),W.g=Math.max(0,Math.min(m.color.g*W.g,1)),W.b=Math.max(0,Math.min(m.color.b*W.b,1)),Ea(S,R,V,ja,y,H,z,L),
m.wireframe?ya(W,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(W)):(Ea(S,R,V,ja,y,H,z,L),m.wireframe?ya(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(m.color));else if(m instanceof THREE.MeshNormalMaterial)W.r=Ca(n.normalWorld.x),W.g=Ca(n.normalWorld.y),W.b=Ca(n.normalWorld.z),Ea(S,R,V,ja,y,H,z,L),m.wireframe?ya(W,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(W);else if(m instanceof THREE.MeshDepthMaterial)da=l.near,X=l.far,T.r=T.g=T.b=1-
Aa(a.positionScreen.z,da,X),ca.r=ca.g=ca.b=1-Aa(d.positionScreen.z,da,X),Q.r=Q.g=Q.b=1-Aa(f.positionScreen.z,da,X),C.r=C.g=C.b=1-Aa(g.positionScreen.z,da,X),oa=Da(T,ca,Q,C),A(S,R,V,ja,z,L),Ba(S,R,V,ja,z,L,0,0,1,0,0,1,oa),A(j,aa,y,H,ga,N),Ba(j,aa,y,H,ga,N,1,0,1,1,0,1,oa)}function A(a,b,c,d,e,g){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,g);m.lineTo(a,b);m.closePath()}function Ea(a,b,c,d,e,g,f,j){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,g);m.lineTo(f,j);m.lineTo(a,b);m.closePath()}
function ya(a,b,c,e){if(E!=b)m.lineWidth=E=b;if(x!=c)m.lineCap=x=c;if(I!=e)m.lineJoin=I=e;d(a.getContextStyle());m.stroke();Y.inflate(b*2)}function w(a){g(a.getContextStyle());m.fill()}function Ga(a,b,c,d,e,f,j,h,i,n,k,l,ha){if(ha.image.width!=0){if(ha.needsUpdate==!0||ka[ha.id]==void 0){var o=ha.wrapS==THREE.RepeatWrapping,p=ha.wrapT==THREE.RepeatWrapping;ka[ha.id]=m.createPattern(ha.image,o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y":"no-repeat");ha.needsUpdate=!1}g(ka[ha.id]);var o=ha.offset.x/
ha.repeat.x,p=ha.offset.y/ha.repeat.y,U=(ha.image.width-1)*ha.repeat.x,ha=(ha.image.height-1)*ha.repeat.y,j=(j+o)*U,h=(h+p)*ha,i=(i+o)*U,n=(n+p)*ha,k=(k+o)*U,l=(l+p)*ha;c-=a;d-=b;e-=a;f-=b;i-=j;n-=h;k-=j;l-=h;o=1/(i*l-k*n);ha=(l*c-n*e)*o;n=(l*d-n*f)*o;c=(i*e-k*c)*o;d=(i*f-k*d)*o;a=a-ha*j-c*h;b=b-n*j-d*h;m.save();m.transform(ha,n,c,d,a,b);m.fill();m.restore()}}function Ba(a,b,c,d,e,g,f,j,h,i,n,k,l){var ha,o;ha=l.width-1;o=l.height-1;f*=ha;j*=o;h*=ha;i*=o;n*=ha;k*=o;c-=a;d-=b;e-=a;g-=b;h-=f;i-=j;n-=
f;k-=j;o=1/(h*k-n*i);ha=(k*c-i*e)*o;i=(k*d-i*g)*o;c=(h*e-n*c)*o;d=(h*g-n*d)*o;a=a-ha*f-c*j;b=b-i*f-d*j;m.save();m.transform(ha,i,c,d,a,b);m.clip();m.drawImage(l,0,0);m.restore()}function Da(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),n=~~(d.r*255),k=~~(d.g*255),d=~~(d.b*255);ma[0]=e<0?0:e>255?255:e;ma[1]=f<0?0:f>255?255:f;ma[2]=a<0?0:a>255?255:a;ma[4]=g<0?0:g>255?255:g;ma[5]=j<0?0:j>255?255:j;ma[6]=b<0?
0:b>255?255:b;ma[8]=h<0?0:h>255?255:h;ma[9]=i<0?0:i>255?255:i;ma[10]=c<0?0:c>255?255:c;ma[12]=n<0?0:n>255?255:n;ma[13]=k<0?0:k>255?255:k;ma[14]=d<0?0:d>255?255:d;xa.putImageData(O,0,0);ha.drawImage(ia,0,0);return sa}function Aa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ca(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function za(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Fa,Ha,na,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,n,r);
e.info.render.vertices=0;e.info.render.faces=0;f=k.projectScene(a,l,this.sortElements);h=f.elements;i=f.lights;(ea=i.length>0)&&p(i);Fa=0;for(Ha=h.length;Fa<Ha;Fa++)if(na=h[Fa],va=na.material,va=va instanceof THREE.MeshFaceMaterial?na.faceMaterial:va,!(va==null||va.opacity==0)){Y.empty();if(na instanceof THREE.RenderableParticle)M=na,M.x*=n,M.y*=r,s(M,na,va,a);else if(na instanceof THREE.RenderableLine)M=na.v1,D=na.v2,M.positionScreen.x*=n,M.positionScreen.y*=r,D.positionScreen.x*=n,D.positionScreen.y*=
r,Y.addPoint(M.positionScreen.x,M.positionScreen.y),Y.addPoint(D.positionScreen.x,D.positionScreen.y),v.intersects(Y)&&q(M,D,na,va,a);else if(na instanceof THREE.RenderableFace3)M=na.v1,D=na.v2,F=na.v3,M.positionScreen.x*=n,M.positionScreen.y*=r,D.positionScreen.x*=n,D.positionScreen.y*=r,F.positionScreen.x*=n,F.positionScreen.y*=r,va.overdraw&&(za(M.positionScreen,D.positionScreen),za(D.positionScreen,F.positionScreen),za(F.positionScreen,M.positionScreen)),Y.add3Points(M.positionScreen.x,M.positionScreen.y,
D.positionScreen.x,D.positionScreen.y,F.positionScreen.x,F.positionScreen.y),v.intersects(Y)&&u(M,D,F,0,1,2,na,va,a);else if(na instanceof THREE.RenderableFace4)M=na.v1,D=na.v2,F=na.v3,P=na.v4,M.positionScreen.x*=n,M.positionScreen.y*=r,D.positionScreen.x*=n,D.positionScreen.y*=r,F.positionScreen.x*=n,F.positionScreen.y*=r,P.positionScreen.x*=n,P.positionScreen.y*=r,K.positionScreen.copy(D.positionScreen),$.positionScreen.copy(P.positionScreen),va.overdraw&&(za(M.positionScreen,D.positionScreen),
za(D.positionScreen,P.positionScreen),za(P.positionScreen,M.positionScreen),za(F.positionScreen,K.positionScreen),za(F.positionScreen,$.positionScreen)),Y.addPoint(M.positionScreen.x,M.positionScreen.y),Y.addPoint(D.positionScreen.x,D.positionScreen.y),Y.addPoint(F.positionScreen.x,F.positionScreen.y),Y.addPoint(P.positionScreen.x,P.positionScreen.y),v.intersects(Y)&&t(M,D,F,P,K,$,na,va,a);J.addRectangle(Y)}m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,j,h,i;e=0;for(f=a.length;e<f;e++)g=a[e],j=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),i=c.dot(h),i<=0||(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),i=c.dot(M.sub(h,b).normalize()),i<=0||(i*=g.distance==0?1:1-Math.min(b.distanceTo(h)/g.distance,1),i!=0&&(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function c(a){D[a]==null&&(D[a]=document.createElementNS("http://www.w3.org/2000/svg",
"path"),S==0&&D[a].setAttribute("shape-rendering","crispEdges"));return D[a]}function b(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,o,p,n,r,m,s,u=new THREE.Rectangle,t=new THREE.Rectangle,q=!1,A=new THREE.Color,w=new THREE.Color,E=new THREE.Color,x=new THREE.Color,I,M=new THREE.Vector3,D=[],F=[],P,K,$,S=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
faces:0}};this.setQuality=function(a){switch(a){case "high":S=1;break;case "low":S=0}};this.setSize=function(a,b){k=a;l=b;o=k/2;p=l/2;i.setAttribute("viewBox",-o+" "+-p+" "+k+" "+l);i.setAttribute("width",k);i.setAttribute("height",l);u.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var M,y,H,z;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(k,l,this.sortElements);e=g.elements;
f=g.lights;$=K=0;if(q=f.length>0){w.setRGB(0,0,0);E.setRGB(0,0,0);x.setRGB(0,0,0);M=0;for(y=f.length;M<y;M++)z=f[M],H=z.color,z instanceof THREE.AmbientLight?(w.r+=H.r,w.g+=H.g,w.b+=H.b):z instanceof THREE.DirectionalLight?(E.r+=H.r,E.g+=H.g,E.b+=H.b):z instanceof THREE.PointLight&&(x.r+=H.r,x.g+=H.g,x.b+=H.b)}M=0;for(y=e.length;M<y;M++)if(H=e[M],z=H.material,z=z instanceof THREE.MeshFaceMaterial?H.faceMaterial:z,!(z==null||z.opacity==0))if(t.empty(),H instanceof THREE.RenderableParticle)n=H,n.x*=
o,n.y*=-p;else if(H instanceof THREE.RenderableLine){if(n=H.v1,r=H.v2,n.positionScreen.x*=o,n.positionScreen.y*=-p,r.positionScreen.x*=o,r.positionScreen.y*=-p,t.addPoint(n.positionScreen.x,n.positionScreen.y),t.addPoint(r.positionScreen.x,r.positionScreen.y),u.intersects(t)){H=n;var L=r,j=$++;F[j]==null&&(F[j]=document.createElementNS("http://www.w3.org/2000/svg","line"),S==0&&F[j].setAttribute("shape-rendering","crispEdges"));P=F[j];P.setAttribute("x1",H.positionScreen.x);P.setAttribute("y1",H.positionScreen.y);
P.setAttribute("x2",L.positionScreen.x);P.setAttribute("y2",L.positionScreen.y);z instanceof THREE.LineBasicMaterial&&(P.setAttribute("style","fill: none; stroke: "+z.color.getContextStyle()+"; stroke-width: "+z.linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.linecap+"; stroke-linejoin: "+z.linejoin),i.appendChild(P))}}else if(H instanceof THREE.RenderableFace3){if(n=H.v1,r=H.v2,m=H.v3,n.positionScreen.x*=o,n.positionScreen.y*=-p,r.positionScreen.x*=o,r.positionScreen.y*=-p,m.positionScreen.x*=
o,m.positionScreen.y*=-p,t.addPoint(n.positionScreen.x,n.positionScreen.y),t.addPoint(r.positionScreen.x,r.positionScreen.y),t.addPoint(m.positionScreen.x,m.positionScreen.y),u.intersects(t)){var L=n,j=r,D=m;d.info.render.vertices+=3;d.info.render.faces++;P=c(K++);P.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+j.positionScreen.x+" "+j.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");z instanceof THREE.MeshBasicMaterial?A.copy(z.color):z instanceof THREE.MeshLambertMaterial?
q?(A.r=w.r,A.g=w.g,A.b=w.b,a(f,H.centroidWorld,H.normalWorld,A),A.r=Math.max(0,Math.min(z.color.r*A.r,1)),A.g=Math.max(0,Math.min(z.color.g*A.g,1)),A.b=Math.max(0,Math.min(z.color.b*A.b,1))):A.copy(z.color):z instanceof THREE.MeshDepthMaterial?(I=1-z.__2near/(z.__farPlusNear-H.z*z.__farMinusNear),A.setRGB(I,I,I)):z instanceof THREE.MeshNormalMaterial&&A.setRGB(b(H.normalWorld.x),b(H.normalWorld.y),b(H.normalWorld.z));z.wireframe?P.setAttribute("style","fill: none; stroke: "+A.getContextStyle()+"; stroke-width: "+
z.wireframeLinewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframeLinecap+"; stroke-linejoin: "+z.wireframeLinejoin):P.setAttribute("style","fill: "+A.getContextStyle()+"; fill-opacity: "+z.opacity);i.appendChild(P)}}else if(H instanceof THREE.RenderableFace4&&(n=H.v1,r=H.v2,m=H.v3,s=H.v4,n.positionScreen.x*=o,n.positionScreen.y*=-p,r.positionScreen.x*=o,r.positionScreen.y*=-p,m.positionScreen.x*=o,m.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,t.addPoint(n.positionScreen.x,
n.positionScreen.y),t.addPoint(r.positionScreen.x,r.positionScreen.y),t.addPoint(m.positionScreen.x,m.positionScreen.y),t.addPoint(s.positionScreen.x,s.positionScreen.y),u.intersects(t))){var L=n,j=r,D=m,ga=s;d.info.render.vertices+=4;d.info.render.faces++;P=c(K++);P.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+j.positionScreen.x+" "+j.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+" L "+ga.positionScreen.x+","+ga.positionScreen.y+"z");z instanceof THREE.MeshBasicMaterial?
A.copy(z.color):z instanceof THREE.MeshLambertMaterial?q?(A.r=w.r,A.g=w.g,A.b=w.b,a(f,H.centroidWorld,H.normalWorld,A),A.r=Math.max(0,Math.min(z.color.r*A.r,1)),A.g=Math.max(0,Math.min(z.color.g*A.g,1)),A.b=Math.max(0,Math.min(z.color.b*A.b,1))):A.copy(z.color):z instanceof THREE.MeshDepthMaterial?(I=1-z.__2near/(z.__farPlusNear-H.z*z.__farMinusNear),A.setRGB(I,I,I)):z instanceof THREE.MeshNormalMaterial&&A.setRGB(b(H.normalWorld.x),b(H.normalWorld.y),b(H.normalWorld.z));z.wireframe?P.setAttribute("style",
"fill: none; stroke: "+A.getContextStyle()+"; stroke-width: "+z.wireframeLinewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframeLinecap+"; stroke-linejoin: "+z.wireframeLinejoin):P.setAttribute("style","fill: "+A.getContextStyle()+"; fill-opacity: "+z.opacity);i.appendChild(P)}}};
A
alteredq 已提交
191 192 193
THREE.ShaderChunk={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 float flipEnvMap;\nuniform int combine;\n#endif",
envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\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_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",
194 195
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_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\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 ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif",
lights_lambert_vertex:"vLightWeighting = vec3( 0.0 );\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 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;",
A
alteredq 已提交
196 197 198 199 200 201 202 203 204 205
lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif",
lights_phong_pars_fragment:"uniform 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 ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse  = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDistance = lDistance;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );\nfloat pointSpecularWeight = pow( pointDotNormalHalf, shininess );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n#endif\npointDiffuse  += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse  = vec3( 0.0 );\nvec3 dirSpecular = vec3( 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 + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = pow( dirDotNormalHalf, shininess );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\ndirDiffuse  += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
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\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\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#endif",
morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
THREE.UniformsUtils={merge:function(a){var c,b,d,g={};for(c=0;c<a.length;c++)for(b in d=this.clone(a[c]),d)g[b]=d[b];return g},clone:function(a){var c,b,d,g={};for(c in a)for(b in g[c]={},a[c])d=a[c][b],g[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector2||d instanceof THREE.Vector3||d instanceof THREE.Vector4||d instanceof THREE.Matrix4||d instanceof THREE.Texture?d.clone():d instanceof Array?d.slice():d;return g}};
THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",
206 207
value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{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)}},shadowmap:{shadowMap:{type:"tv",value:6,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
A
alteredq 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
THREE.ShaderLib={sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\n}"},
depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",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}"},normal:{uniforms:{opacity:{type:"f",value:1}},
vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex,
THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,
THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)}}]),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,
THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",
THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",
THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",
value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),vertexShader:["varying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = -mvPosition.xyz;\nvec3 transformedNormal = normalMatrix * normal;\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,
"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,
THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,
THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,
THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,
THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
THREE.WebGLRenderer=function(a){function c(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(a.__webglCustomAttributesList===void 0)a.__webglCustomAttributesList=[];for(var e in d.attributes){var g=d.attributes[e];if(!g.__webglInitialized||g.createUniqueBuffers){g.__webglInitialized=!0;var f=1;g.type==="v2"?f=2:g.type==="v3"?f=3:g.type==="v4"?f=4:g.type==="c"&&(f=3);g.size=f;g.array=new Float32Array(c*f);g.buffer=j.createBuffer();g.buffer.belongsToAttribute=e;g.needsUpdate=!0}a.__webglCustomAttributesList.push(g)}}}
A
alteredq 已提交
225 226 227
function b(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,g,f,h=a.vertices;f=h.length;var i=a.colors,n=i.length,k=a.__vertexArray,l=a.__colorArray,m=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,U=a.__webglCustomAttributesList;if(c.sortParticles){J.multiplySelf(c.matrixWorld);for(d=0;d<f;d++)e=h[d].position,ba.copy(e),J.multiplyVector3(ba),m[d]=[ba.z,d];m.sort(function(a,
b){return b[0]-a[0]});for(d=0;d<f;d++)e=h[m[d][1]].position,g=d*3,k[g]=e.x,k[g+1]=e.y,k[g+2]=e.z;for(d=0;d<n;d++)g=d*3,e=i[m[d][1]],l[g]=e.r,l[g+1]=e.g,l[g+2]=e.b;if(U){i=0;for(n=U.length;i<n;i++)if(h=U[i],h.boundTo===void 0||h.boundTo==="vertices")if(g=0,e=h.value.length,h.size===1)for(d=0;d<e;d++)f=m[d][1],h.array[d]=h.value[f];else if(h.size===2)for(d=0;d<e;d++)f=m[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,g+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)f=m[d][1],f=h.value[f],
h.array[g]=f.r,h.array[g+1]=f.g,h.array[g+2]=f.b,g+=3;else for(d=0;d<e;d++)f=m[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,g+=3;else if(h.size===4)for(d=0;d<e;d++)f=m[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,h.array[g+3]=f.w,g+=4}}else{if(o)for(d=0;d<f;d++)e=h[d].position,g=d*3,k[g]=e.x,k[g+1]=e.y,k[g+2]=e.z;if(p)for(d=0;d<n;d++)e=i[d],g=d*3,l[g]=e.r,l[g+1]=e.g,l[g+2]=e.b;if(U){i=0;for(n=U.length;i<n;i++)if(h=U[i],h.needsUpdate&&(h.boundTo===void 0||
228
h.boundTo==="vertices"))if(e=h.value.length,g=0,h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,g+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.r,h.array[g+1]=f.g,h.array[g+2]=f.b,g+=3;else for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,g+=3;else if(h.size===4)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,h.array[g+3]=f.w,
A
alteredq 已提交
229 230 231
g+=4}}if(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,k,b);if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,l,b);if(U){i=0;for(n=U.length;i<n;i++)if(h=U[i],h.needsUpdate||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,h.buffer),j.bufferData(j.ARRAY_BUFFER,h.array,b)}}function g(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();
a.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(b.attributes.position),j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,!1,0,0));if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,g,f,h,i,n,k,l,m,o=a.count*3;for(m=0;m<o;m+=9)c=a.normalArray,d=c[m],e=c[m+1],g=c[m+2],f=c[m+3],i=c[m+4],k=c[m+5],h=c[m+6],n=c[m+7],l=c[m+8],d=(d+f+h)/3,e=(e+i+n)/3,g=
(g+k+l)/3,c[m]=d,c[m+1]=e,c[m+2]=g,c[m+3]=d,c[m+4]=e,c[m+5]=g,c[m+6]=d,c[m+7]=e,c[m+8]=g}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,0,a.count);a.count=0}function e(a,b,c,d,e,g){if(d.opacity!==0){var f,h,c=s(a,b,c,d,g),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==T&&(T=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(j.bindBuffer(j.ARRAY_BUFFER,
232
e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){f=0;var i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;f<d.numSupportedMorphTargets&&
A
alteredq 已提交
233 234
f<i.length;)j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[f]]),j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0),g.__webglMorphTargetInfluences[f]=h[i[f]],f++}else{var i=[],n=-1,k=0;h=g.morphTargetInfluences;var l,m=h.length;f=0;for(g.morphTargetBase!==-1&&(i[g.morphTargetBase]=!0);f<d.numSupportedMorphTargets;){for(l=0;l<m;l++)!i[l]&&h[l]>n&&(k=l,n=h[k]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[f]=
n;i[k]=1;n=-1;f++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){f=0;for(h=e.__webglCustomAttributesList.length;f<h;f++)c=e.__webglCustomAttributesList[f],b[c.buffer.belongsToAttribute]>=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color,
235 236
3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer),
j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,
A
alteredq 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249
4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ta&&(j.lineWidth(d),ta=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),L.info.render.calls++,L.info.render.vertices+=
e.__webglFaceCount,L.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ta&&(j.lineWidth(d),ta=d),j.drawArrays(g,0,e.__webglLineCount),L.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),L.info.render.calls++):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),L.info.render.calls++)}}function f(a){v[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-
a.n13,a.n44-a.n14);v[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);v[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);v[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);v[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);v[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=v[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,
a.scale.z)),d=0;d<6;d++)if(a=v[d].x*b.n14+v[d].y*b.n24+v[d].z*b.n34+v[d].w,a<=c)return!1;return!0}function i(a,b){return b.z-a.z}function k(a){var b,c,d,i,n,k,l,m,o=0,p=a.lights;Z||(Z=new THREE.PerspectiveCamera(L.shadowCameraFov,L.shadowMapWidth/L.shadowMapHeight,L.shadowCameraNear,L.shadowCameraFar));b=0;for(c=p.length;b<c;b++)if(m=p[b],m.castShadow&&m instanceof THREE.SpotLight){W=-1;L.shadowMap[o]||(L.shadowMap[o]=new THREE.WebGLRenderTarget(L.shadowMapWidth,L.shadowMapHeight,{minFilter:THREE.LinearFilter,
magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),fa[o]=new THREE.Matrix4);d=L.shadowMap[o];i=fa[o];Z.position.copy(m.position);Z.lookAt(m.target.position);Z.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),a.add(Z));this.autoUpdateScene&&a.updateMatrixWorld();Z.matrixWorldInverse.getInverse(Z.matrixWorld);i.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);i.multiplySelf(Z.projectionMatrix);i.multiplySelf(Z.matrixWorldInverse);Z.matrixWorldInverse.flattenToArray(ea);Z.projectionMatrix.flattenToArray(Y);
J.multiply(Z.projectionMatrix,Z.matrixWorldInverse);f(J);F(d);j.clearColor(1,1,1,1);L.clear();j.clearColor(y.r,y.g,y.b,H);i=a.__webglObjects.length;for(d=0;d<i;d++)if(k=a.__webglObjects[d],m=k.object,k.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||h(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),u(m,Z,!1),k.render=!0;q(!0);E(THREE.NormalBlending);for(d=0;d<i;d++)if(k=a.__webglObjects[d],k.render)m=k.object,k=k.buffer,t(m),l=m.customDepthMaterial?m.customDepthMaterial:
m.geometry.morphTargets.length?xa:ia,e(Z,p,null,l,k,m);i=a.__webglObjectsImmediate.length;for(d=0;d<i;d++)k=a.__webglObjectsImmediate[d],m=k.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),T=-1,u(m,Z,!1),t(m),n=s(Z,p,null,ia,m),m.immediateRenderCallback?m.immediateRenderCallback(n,j,v):m.render(function(a){g(a,n,ia.shading)}));o++}}function l(a,b,c,d,g,f,h,j){var i,k,m,n;b?(k=a.length-1,n=b=-1):(k=0,b=a.length,n=1);for(var l=k;l!==b;l+=n)if(i=
a[l],i.render){k=i.object;m=i.buffer;if(j)i=j;else{i=i[c];if(!i)continue;h&&E(i.blending);q(i.depthTest);A(i.depthWrite);w(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}t(k);e(d,g,f,i,m,k)}}function o(a,b,c,d,e,f,h){for(var i,k,m,n,l=0,o=a.length;l<o;l++)if(i=a[l],k=i.object,k.visible){T=-1;if(h)m=h;else{m=i[b];if(!m)continue;f&&E(m.blending);q(m.depthTest);A(m.depthWrite);w(m.polygonOffset,m.polygonOffsetFactor,m.polygonOffsetUnits)}t(k);n=s(c,d,e,m,k);k.immediateRenderCallback?k.immediateRenderCallback(n,
j,v):k.render(function(a){g(a,n,m.shading)})}}function p(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function n(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function r(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function m(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function s(a,b,c,d,e){d.program||L.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(L.maxMorphTargets);
for(var g=0,f=L.maxMorphTargets;g<f;g++)e.__webglMorphTargetInfluences[g]=0}var h=!1,g=d.program,f=g.uniforms,i=d.uniforms;g!==ga&&(j.useProgram(g),ga=g,h=!0);if(d.id!==W)W=d.id,h=!0;if(h){j.uniformMatrix4fv(f.projectionMatrix,!1,Y);if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=c.near,i.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){for(var k,
m,n=0,l=0,o=0,p,U,r,J=ua,s=J.directional.colors,v=J.directional.positions,q=J.point.colors,u=J.point.positions,t=J.point.distances,A=0,C=0,c=k=r=0,h=b.length;c<h;c++)if(k=b[c],m=k.color,p=k.position,U=k.intensity,r=k.distance,k instanceof THREE.AmbientLight)L.gammaInput?(n+=m.r*m.r,l+=m.g*m.g,o+=m.b*m.b):(n+=m.r,l+=m.g,o+=m.b);else if(k instanceof THREE.DirectionalLight)r=A*3,L.gammaInput?(s[r]=m.r*m.r*U*U,s[r+1]=m.g*m.g*U*U,s[r+2]=m.b*m.b*U*U):(s[r]=m.r*U,s[r+1]=m.g*U,s[r+2]=m.b*U),v[r]=p.x,v[r+
1]=p.y,v[r+2]=p.z,A+=1;else if(k instanceof THREE.SpotLight)r=A*3,L.gammaInput?(s[r]=m.r*m.r*U*U,s[r+1]=m.g*m.g*U*U,s[r+2]=m.b*m.b*U*U):(s[r]=m.r*U,s[r+1]=m.g*U,s[r+2]=m.b*U),m=1/p.length(),v[r]=p.x*m,v[r+1]=p.y*m,v[r+2]=p.z*m,A+=1;else if(k instanceof THREE.PointLight)k=C*3,L.gammaInput?(q[k]=m.r*m.r*U*U,q[k+1]=m.g*m.g*U*U,q[k+2]=m.b*m.b*U*U):(q[k]=m.r*U,q[k+1]=m.g*U,q[k+2]=m.b*U),u[k]=p.x,u[k+1]=p.y,u[k+2]=p.z,t[C]=r,C+=1;c=A*3;for(h=s.length;c<h;c++)s[c]=0;c=C*3;for(h=q.length;c<h;c++)q[c]=0;J.point.length=
C;J.directional.length=A;J.ambient[0]=n;J.ambient[1]=l;J.ambient[2]=o;b=ua;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=b.point.colors;i.pointLightPosition.value=b.point.positions;i.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,L.gammaInput?
M
Mr.doob 已提交
250
i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color,(i.map.texture=d.map)&&i.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),i.lightMap.texture=d.lightMap,i.envMap.texture=d.envMap,i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,i.reflectivity.value=d.reflectivity,i.refractionRatio.value=d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof
A
alteredq 已提交
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=$.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,L.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.specular.value=d.specular);else if(d instanceof THREE.MeshLambertMaterial)L.gammaInput?
i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient;else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<fa.length;b++)i.shadowMatrix.value[b]=fa[b],i.shadowMap.texture[b]=L.shadowMap[b];i.shadowDarkness.value=L.shadowMapDarkness;i.shadowBias.value=L.shadowMapBias}b=d.uniformsList;i=0;for(c=
b.length;i<c;i++)if(l=g.uniforms[b[i][1]])if(n=b[i][0],o=n.type,h=n.value,o==="i")j.uniform1i(l,h);else if(o==="f")j.uniform1f(l,h);else if(o==="v2")j.uniform2f(l,h.x,h.y);else if(o==="v3")j.uniform3f(l,h.x,h.y,h.z);else if(o==="v4")j.uniform4f(l,h.x,h.y,h.z,h.w);else if(o==="c")j.uniform3f(l,h.r,h.g,h.b);else if(o==="fv1")j.uniform1fv(l,h);else if(o==="fv")j.uniform3fv(l,h);else if(o==="v3v"){if(!n._array)n._array=new Float32Array(3*h.length);o=0;for(p=h.length;o<p;o++)J=o*3,n._array[J]=h[o].x,n._array[J+
1]=h[o].y,n._array[J+2]=h[o].z;j.uniform3fv(l,n._array)}else if(o==="m4"){if(!n._array)n._array=new Float32Array(16);h.flattenToArray(n._array);j.uniformMatrix4fv(l,!1,n._array)}else if(o==="m4v"){if(!n._array)n._array=new Float32Array(16*h.length);o=0;for(p=h.length;o<p;o++)h[o].flattenToArrayOffset(n._array,o*16);j.uniformMatrix4fv(l,!1,n._array)}else if(o==="t"){if(j.uniform1i(l,h),l=n.texture)if(l.image instanceof Array&&l.image.length===6){if(n=l,n.image.length===6)if(n.needsUpdate){if(!n.image.__webglTextureCube)n.image.__webglTextureCube=
j.createTexture();j.activeTexture(j.TEXTURE0+h);j.bindTexture(j.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(h=0;h<6;h++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,n.image[h]);I(j.TEXTURE_CUBE_MAP,n,n.image[0]);n.needsUpdate=!1}else j.activeTexture(j.TEXTURE0+h),j.bindTexture(j.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}else l instanceof THREE.WebGLRenderTargetCube?(n=l,j.activeTexture(j.TEXTURE0+h),j.bindTexture(j.TEXTURE_CUBE_MAP,n.__webglTexture)):M(l,h)}else if(o===
"tv"){if(!n._array){n._array=[];o=0;for(p=n.texture.length;o<p;o++)n._array[o]=h+o}j.uniform1iv(l,n._array);o=0;for(p=n.texture.length;o<p;o++)(l=n.texture[o])&&M(l,n._array[o])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&f.cameraPosition!==null&&j.uniform3f(f.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&f.viewMatrix!==null&&
j.uniformMatrix4fv(f.viewMatrix,!1,ea);d.skinning&&(j.uniformMatrix4fv(f.cameraInverseMatrix,!1,ea),j.uniformMatrix4fv(f.boneGlobalMatrices,!1,e.boneMatrices))}j.uniformMatrix4fv(f.modelViewMatrix,!1,e._modelViewMatrixArray);f.normalMatrix&&j.uniformMatrix3fv(f.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&f.objectMatrix!==null&&j.uniformMatrix4fv(f.objectMatrix,!1,e._objectMatrixArray);return g}function u(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,
a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function t(a){if(Q!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),Q=a.doubleSided;if(C!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),C=a.flipSided}function q(a){da!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),da=a)}function A(a){X!==a&&(j.depthMask(a),X=a)}function w(a,b,c){oa!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):
j.disable(j.POLYGON_OFFSET_FILL),oa=a);if(a&&(la!==b||ra!==c))j.polygonOffset(b,c),la=b,ra=c}function E(a){if(a!==ka){switch(a){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);break;default:j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,
j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}ka=a}}function x(a,b){var c;a==="fragment"?c=j.createShader(j.FRAGMENT_SHADER):a==="vertex"&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,b);j.compileShader(c);if(!j.getShaderParameter(c,j.COMPILE_STATUS))return console.error(j.getShaderInfoLog(c)),console.error(b),null;return c}function I(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(j.texParameteri(a,j.TEXTURE_WRAP_S,K(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,K(b.wrapT)),
j.texParameteri(a,j.TEXTURE_MAG_FILTER,K(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,K(b.minFilter)),j.generateMipmap(a)):(j.texParameteri(a,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_MAG_FILTER,P(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,P(b.minFilter)))}function M(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),L.info.memory.textures++;j.activeTexture(j.TEXTURE0+
b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,K(a.format),a.image.width,a.image.height,0,K(a.format),j.UNSIGNED_BYTE,a.image.data):j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,a.image);I(j.TEXTURE_2D,a,a.image);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)}function D(a,b){j.bindRenderbuffer(j.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,
j.DEPTH_COMPONENT16,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,a)):j.renderbufferStorage(j.RENDERBUFFER,j.RGBA4,b.width,b.height)}function F(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;
if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=j.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);I(j.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,K(a.format),a.width,a.height,0,K(a.format),K(a.type),null);var d=a,e=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,
a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,e,d.__webglTexture,0);D(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),I(j.TEXTURE_2D,a,a),j.texImage2D(j.TEXTURE_2D,0,K(a.format),a.width,a.height,0,K(a.format),K(a.type),null),c=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,
c,a.__webglTexture,0),j.bindRenderbuffer(j.RENDERBUFFER,a.__webglRenderbuffer),D(a.__webglRenderbuffer,a);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=wa,a=U,d=pa,e=qa);b!==N&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(d,e,c,a),N=b)}function P(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;
default:return j.LINEAR}}function K(a){switch(a){case THREE.RepeatWrapping:return j.REPEAT;case THREE.ClampToEdgeWrapping:return j.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return j.MIRRORED_REPEAT;case THREE.NearestFilter:return j.NEAREST;case THREE.NearestMipMapNearestFilter:return j.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return j.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return j.LINEAR;case THREE.LinearMipMapNearestFilter:return j.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return j.LINEAR_MIPMAP_LINEAR;
M
Mr.doob 已提交
268
case THREE.ByteType:return j.BYTE;case THREE.UnsignedByteType:return j.UNSIGNED_BYTE;case THREE.ShortType:return j.SHORT;case THREE.UnsignedShortType:return j.UNSIGNED_SHORT;case THREE.IntType:return j.INT;case THREE.UnsignedShortType:return j.UNSIGNED_INT;case THREE.FloatType:return j.FLOAT;case THREE.AlphaFormat:return j.ALPHA;case THREE.RGBFormat:return j.RGB;case THREE.RGBAFormat:return j.RGBA;case THREE.LuminanceFormat:return j.LUMINANCE;case THREE.LuminanceAlphaFormat:return j.LUMINANCE_ALPHA}return 0}
A
alteredq 已提交
269 270 271 272 273 274 275 276 277 278 279
var a=a||{},$=a.canvas!==void 0?a.canvas:document.createElement("canvas"),S=a.precision!==void 0?a.precision:"highp",R=a.antialias!==void 0?a.antialias:!1,V=a.stencil!==void 0?a.stencil:!0,ja=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,y=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),H=a.clearAlpha!==void 0?a.clearAlpha:0,z=a.maxLights!==void 0?a.maxLights:4;this.domElement=$;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=
this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};var L=
this,j,aa=[],ga=null,N=null,W=-1,T=null,ca=0,Q=null,C=null,ka=null,da=null,X=null,oa=null,la=null,ra=null,ta=null,pa=0,qa=0,wa=0,U=0,v=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],J=new THREE.Matrix4,Y=new Float32Array(16),ea=new Float32Array(16),ba=new THREE.Vector4,ua={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},Z,fa=[],ia,xa,O={},ma=!1;j=function(){var a;try{if(!(a=
$.getContext("experimental-webgl",{antialias:R,stencil:V,preserveDrawingBuffer:ja})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();j.clearColor(0,0,0,1);j.clearDepth(1);j.clearStencil(0);j.enable(j.DEPTH_TEST);j.depthFunc(j.LEQUAL);j.frontFace(j.CCW);j.cullFace(j.BACK);j.enable(j.CULL_FACE);j.enable(j.BLEND);
j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA);j.clearColor(y.r,y.g,y.b,H);(function(){O.vertices=new Float32Array(16);O.faces=new Uint16Array(6);var a=0;O.vertices[a++]=-1;O.vertices[a++]=-1;O.vertices[a++]=0;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=-1;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=0;O.vertices[a++]=-1;O.vertices[a++]=1;O.vertices[a++]=0;a=O.vertices[a++]=0;O.faces[a++]=0;O.faces[a++]=
1;O.faces[a++]=2;O.faces[a++]=0;O.faces[a++]=2;O.faces[a++]=3;O.vertexBuffer=j.createBuffer();O.elementBuffer=j.createBuffer();j.bindBuffer(j.ARRAY_BUFFER,O.vertexBuffer);j.bufferData(j.ARRAY_BUFFER,O.vertices,j.STATIC_DRAW);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,O.elementBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,O.faces,j.STATIC_DRAW);O.program=j.createProgram();j.attachShader(O.program,x("fragment",THREE.ShaderLib.sprite.fragmentShader));j.attachShader(O.program,x("vertex",THREE.ShaderLib.sprite.vertexShader));
j.linkProgram(O.program);O.attributes={};O.uniforms={};O.attributes.position=j.getAttribLocation(O.program,"position");O.attributes.uv=j.getAttribLocation(O.program,"uv");O.uniforms.uvOffset=j.getUniformLocation(O.program,"uvOffset");O.uniforms.uvScale=j.getUniformLocation(O.program,"uvScale");O.uniforms.rotation=j.getUniformLocation(O.program,"rotation");O.uniforms.scale=j.getUniformLocation(O.program,"scale");O.uniforms.alignment=j.getUniformLocation(O.program,"alignment");O.uniforms.color=j.getUniformLocation(O.program,
"color");O.uniforms.map=j.getUniformLocation(O.program,"map");O.uniforms.opacity=j.getUniformLocation(O.program,"opacity");O.uniforms.useScreenCoordinates=j.getUniformLocation(O.program,"useScreenCoordinates");O.uniforms.affectedByDistance=j.getUniformLocation(O.program,"affectedByDistance");O.uniforms.screenPosition=j.getUniformLocation(O.program,"screenPosition");O.uniforms.modelViewMatrix=j.getUniformLocation(O.program,"modelViewMatrix");O.uniforms.projectionMatrix=j.getUniformLocation(O.program,
"projectionMatrix")})();(function(){var a=THREE.ShaderLib.depthRGBA,b=THREE.UniformsUtils.clone(a.uniforms);ia=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b});xa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b,morphTargets:!0});ia._shadowPass=!0;xa._shadowPass=!0})();this.context=j;var sa=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return j};this.supportsVertexTextures=
function(){return sa};this.setSize=function(a,b){$.width=a;$.height=b;this.setViewport(0,0,$.width,$.height)};this.setViewport=function(a,b,c,d){pa=a;qa=b;wa=c;U=d;j.viewport(pa,qa,wa,U)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){y.setHex(a);H=b;j.clearColor(y.r,y.g,y.b,H)};this.setClearColor=function(a,b){y.copy(a);H=b;j.clearColor(y.r,y.g,y.b,H)};this.getClearColor=
function(){return y};this.getClearAlpha=function(){return H};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){F(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=
M
Mr.doob 已提交
280
a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer);j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=
A
alteredq 已提交
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
0,e=c.numMorphTargets;d<e;d++)j.deleteBuffer(c.__webglMorphTargetsBuffers[d]);L.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),L.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),L.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),
L.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),L.info.memory.textures--};this.updateShadowMap=function(a,b){k(a,b)};this.render=function(a,b,c,d){var e,g,m,n,p=a.lights,r=a.fog;W=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&k(a,b);L.info.render.calls=0;L.info.render.vertices=0;L.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(ea);b.projectionMatrix.flattenToArray(Y);J.multiply(b.projectionMatrix,b.matrixWorldInverse);f(J);F(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;d=0;for(e=n.length;d<e;d++)if(g=n[d],m=g.object,g.render=!1,m.visible&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||h(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);
u(m,b,!0);var s=g,v=s.object,t=s.buffer,C=void 0,C=C=void 0,C=v.material;if(C instanceof THREE.MeshFaceMaterial){if(C=t.materialIndex,C>=0)C=v.geometry.materials[C],C.transparent?(s.transparent=C,s.opaque=null):(s.opaque=C,s.transparent=null)}else if(C)C.transparent?(s.transparent=C,s.opaque=null):(s.opaque=C,s.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(ba.copy(m.position),J.multiplyVector3(ba),g.z=ba.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;
d=0;for(e=n.length;d<e;d++)if(g=n[d],m=g.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),u(m,b,!0),m=g.object.material,m.transparent?(g.transparent=m,g.opaque=null):(g.opaque=m,g.transparent=null);a.overrideMaterial?(E(a.overrideMaterial.blending),q(a.overrideMaterial.depthTest),A(a.overrideMaterial.depthWrite),w(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),l(a.__webglObjects,!1,"",b,p,r,!0,a.overrideMaterial),
o(a.__webglObjectsImmediate,"",b,p,r,!1,a.overrideMaterial)):(E(THREE.NormalBlending),l(a.__webglObjects,!0,"opaque",b,p,r,!1),o(a.__webglObjectsImmediate,"opaque",b,p,r,!1),l(a.__webglObjects,!1,"transparent",b,p,r,!0),o(a.__webglObjectsImmediate,"transparent",b,p,r,!0));if(a.__webglSprites.length){m=O.attributes;p=O.uniforms;r=U/wa;d=[];e=wa*0.5;n=U*0.5;g=!0;j.useProgram(O.program);ga=O.program;T=da=ka=-1;ma||(j.enableVertexAttribArray(O.attributes.position),j.enableVertexAttribArray(O.attributes.uv),
ma=!0);j.disable(j.CULL_FACE);j.enable(j.BLEND);j.depthMask(!0);j.bindBuffer(j.ARRAY_BUFFER,O.vertexBuffer);j.vertexAttribPointer(m.position,2,j.FLOAT,!1,16,0);j.vertexAttribPointer(m.uv,2,j.FLOAT,!1,16,8);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,O.elementBuffer);j.uniformMatrix4fv(p.projectionMatrix,!1,Y);j.activeTexture(j.TEXTURE0);j.uniform1i(p.map,0);m=0;for(s=a.__webglSprites.length;m<s;m++)if(v=a.__webglSprites[m],v.visible&&v.opacity!==0)v.useScreenCoordinates?v.z=-v.position.z:(v._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,
v.matrixWorld,v._modelViewMatrixArray),v.z=-v._modelViewMatrix.n34);a.__webglSprites.sort(i);m=0;for(s=a.__webglSprites.length;m<s;m++)v=a.__webglSprites[m],v.visible&&v.opacity!==0&&v.map&&v.map.image&&v.map.image.width&&(v.useScreenCoordinates?(j.uniform1i(p.useScreenCoordinates,1),j.uniform3f(p.screenPosition,(v.position.x-e)/e,(n-v.position.y)/n,Math.max(0,Math.min(1,v.position.z)))):(j.uniform1i(p.useScreenCoordinates,0),j.uniform1i(p.affectedByDistance,v.affectedByDistance?1:0),j.uniformMatrix4fv(p.modelViewMatrix,
!1,v._modelViewMatrixArray)),b=v.map.image.width/(v.scaleByViewport?U:1),d[0]=b*r*v.scale.x,d[1]=b*v.scale.y,j.uniform2f(p.uvScale,v.uvScale.x,v.uvScale.y),j.uniform2f(p.uvOffset,v.uvOffset.x,v.uvOffset.y),j.uniform2f(p.alignment,v.alignment.x,v.alignment.y),j.uniform1f(p.opacity,v.opacity),j.uniform3f(p.color,v.color.r,v.color.g,v.color.b),j.uniform1f(p.rotation,v.rotation),j.uniform2fv(p.scale,d),v.mergeWith3D&&!g?(j.enable(j.DEPTH_TEST),g=!0):!v.mergeWith3D&&g&&(j.disable(j.DEPTH_TEST),g=!1),E(v.blending),
M(v.map,0),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0));j.enable(j.CULL_FACE);j.enable(j.DEPTH_TEST);j.depthMask(X)}c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(j.bindTexture(j.TEXTURE_CUBE_MAP,c.__webglTexture),j.generateMipmap(j.TEXTURE_CUBE_MAP),j.bindTexture(j.TEXTURE_CUBE_MAP,null)):(j.bindTexture(j.TEXTURE_2D,c.__webglTexture),j.generateMipmap(j.TEXTURE_2D),j.bindTexture(j.TEXTURE_2D,null)))};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=
[],a.__webglObjectsImmediate=[],a.__webglSprites=[];for(;a.__objectsAdded.length;){var e=a.__objectsAdded[0],g=a,f=void 0,h=void 0,i=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh){h=e.geometry;if(h.geometryGroups===void 0){var i=h,k=void 0,l=void 0,o=void 0,U=void 0,
v=void 0,J=void 0,s=void 0,q={},u=i.morphTargets.length;i.geometryGroups={};k=0;for(l=i.faces.length;k<l;k++)o=i.faces[k],U=o.materialIndex,J=U!==void 0?U:-1,q[J]===void 0&&(q[J]={hash:J,counter:0}),s=q[J].hash+"_"+q[J].counter,i.geometryGroups[s]===void 0&&(i.geometryGroups[s]={faces3:[],faces4:[],materialIndex:U,vertices:0,numMorphTargets:u}),v=o instanceof THREE.Face3?3:4,i.geometryGroups[s].vertices+v>65535&&(q[J].counter+=1,s=q[J].hash+"_"+q[J].counter,i.geometryGroups[s]===void 0&&(i.geometryGroups[s]=
{faces3:[],faces4:[],materialIndex:U,vertices:0,numMorphTargets:u})),o instanceof THREE.Face3?i.geometryGroups[s].faces3.push(k):i.geometryGroups[s].faces4.push(k),i.geometryGroups[s].vertices+=v;i.geometryGroupsList=[];k=void 0;for(k in i.geometryGroups)i.geometryGroups[k].id=ca++,i.geometryGroupsList.push(i.geometryGroups[k])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){k=i;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();k.__webglTangentBuffer=
j.createBuffer();k.__webglColorBuffer=j.createBuffer();k.__webglUVBuffer=j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer=j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){o=l=void 0;k.__webglMorphTargetsBuffers=[];l=0;for(o=k.numMorphTargets;l<o;l++)k.__webglMorphTargetsBuffers.push(j.createBuffer())}L.info.memory.geometries++;
U=e;v=U.geometry;l=i.faces3;J=i.faces4;k=l.length*3+J.length*4;o=l.length*1+J.length*2;J=l.length*3+J.length*4;l=b(U,i);s=l.map||l.lightMap||l instanceof THREE.ShaderMaterial?!0:!1;q=l instanceof THREE.MeshBasicMaterial&&!l.envMap||l instanceof THREE.MeshDepthMaterial?!1:l&&l.shading!==void 0&&l.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;u=l.vertexColors?l.vertexColors:!1;i.__vertexArray=new Float32Array(k*3);if(q)i.__normalArray=new Float32Array(k*3);if(v.hasTangents)i.__tangentArray=
new Float32Array(k*4);if(u)i.__colorArray=new Float32Array(k*3);if(s){if(v.faceUvs.length>0||v.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(v.faceUvs.length>1||v.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(U.geometry.skinWeights.length&&U.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(o*3);
i.__lineArray=new Uint16Array(J*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];U=0;for(v=i.numMorphTargets;U<v;U++)i.__morphTargetsArrays.push(new Float32Array(k*3))}i.__needsSmoothNormals=q===THREE.SmoothShading;i.__uvType=s;i.__vertexColorType=u;i.__normalType=q;i.__webglFaceCount=o*3;i.__webglLineCount=J*2;if(l.attributes){if(i.__webglCustomAttributesList===void 0)i.__webglCustomAttributesList=[];o=void 0;for(o in l.attributes){var U=l.attributes[o],v={},t;for(t in U)v[t]=U[t];if(!v.__webglInitialized||
v.createUniqueBuffers)v.__webglInitialized=!0,J=1,v.type==="v2"?J=2:v.type==="v3"?J=3:v.type==="v4"?J=4:v.type==="c"&&(J=3),v.size=J,v.array=new Float32Array(k*J),v.buffer=j.createBuffer(),v.buffer.belongsToAttribute=o,U.needsUpdate=!0,v.__original=U;i.__webglCustomAttributesList.push(v)}}i.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(h=e.geometry,
!h.__webglVertexBuffer)i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.memory.geometries++,i=h,k=i.vertices.length,i.__vertexArray=new Float32Array(k*3),i.__colorArray=new Float32Array(k*3),i.__webglVertexCount=k,h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.Line){if(h=e.geometry,!h.__webglVertexBuffer)i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.memory.geometries++,i=h,k=e,l=i.vertices.length,
i.__vertexArray=new Float32Array(l*3),i.__colorArray=new Float32Array(l*3),i.__webglLineCount=l,c(i,k),h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(h=e.geometry,!h.__webglVertexBuffer))i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.geometries++,i=h,k=e,l=i.vertices.length,i.__vertexArray=new Float32Array(l*3),i.__colorArray=new Float32Array(l*3),i.__sortArray=[],i.__webglParticleCount=l,c(i,k),h.__dirtyVertices=!0,h.__dirtyColors=
!0;if(!e.__webglActive){if(e instanceof THREE.Mesh)for(f in h=e.geometry,h.geometryGroups)i=h.geometryGroups[f],p(g.__webglObjects,i,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(h=e.geometry,p(g.__webglObjects,h,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes||e.immediateRenderCallback?g.__webglObjectsImmediate.push({object:e,opaque:null,transparent:null}):e instanceof THREE.Sprite&&g.__webglSprites.push(e);e.__webglActive=!0}a.__objectsAdded.splice(0,
1)}for(;a.__objectsRemoved.length;){e=a.__objectsRemoved[0];g=a;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)m(g.__webglObjects,e);else if(e instanceof THREE.Sprite){g=g.__webglSprites;f=e;for(h=g.length-1;h>=0;h--)g[h]===f&&g.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&m(g.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(g=a.__webglObjects.length;e<g;e++)if(t=
a.__webglObjects[e].object,f=t.geometry,h=o=l=void 0,t instanceof THREE.Mesh){i=0;for(k=f.geometryGroupsList.length;i<k;i++)if(l=f.geometryGroupsList[i],h=b(t,l),o=h.attributes&&n(h),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||o)if(o=j.DYNAMIC_DRAW,U=!f.dynamic,l.__inittedArrays){var A=J=v=void 0,C=void 0,Y=void 0,F=void 0,w=void 0,ba=void 0,E=void 0,M=void 0,ka=void 0,H=A=F=void 0,x=void 0,z=void 0,y=void 0,I=C=
void 0,K=void 0,ea=C=E=ka=void 0,O=void 0,da=y=z=x=w=void 0,D=C=y=z=x=da=y=z=x=da=y=z=x=void 0,Z=void 0,P=F=void 0,W=void 0,X=void 0,ua=void 0,R=void 0,N=H=X=Z=0,fa=0,T=D=A=0,Q=w=I=0,G=0,S=void 0,Q=l.__vertexArray,W=l.__uvArray,G=l.__uv2Array,P=l.__normalArray,Y=l.__tangentArray,K=l.__colorArray,ea=l.__skinVertexAArray,O=l.__skinVertexBArray,ba=l.__skinIndexArray,V=l.__skinWeightArray,da=l.__morphTargetsArrays,s=l.__webglCustomAttributesList,B=void 0,B=l.__faceArray,S=l.__lineArray,$=l.__needsSmoothNormals,
ka=l.__vertexColorType,M=l.__uvType,F=l.__normalType,E=t.geometry,aa=E.__dirtyElements,oa=E.__dirtyUvs,ja=E.__dirtyNormals,ga=E.__dirtyTangents,xa=E.__dirtyColors,ua=E.__dirtyMorphTargets,R=E.vertices,q=l.faces3,u=l.faces4,ia=E.faces,la=E.faceVertexUvs[0],ta=E.faceVertexUvs[1],sa=E.skinVerticesA,ra=E.skinVerticesB,qa=E.skinIndices,ma=E.skinWeights,pa=E.morphTargets;if(E.__dirtyVertices){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],x=R[C.a].position,z=R[C.b].position,y=R[C.c].position,Q[X]=x.x,Q[X+1]=x.y,
Q[X+2]=x.z,Q[X+3]=z.x,Q[X+4]=z.y,Q[X+5]=z.z,Q[X+6]=y.x,Q[X+7]=y.y,Q[X+8]=y.z,X+=9;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],x=R[C.a].position,z=R[C.b].position,y=R[C.c].position,C=R[C.d].position,Q[X]=x.x,Q[X+1]=x.y,Q[X+2]=x.z,Q[X+3]=z.x,Q[X+4]=z.y,Q[X+5]=z.z,Q[X+6]=y.x,Q[X+7]=y.y,Q[X+8]=y.z,Q[X+9]=C.x,Q[X+10]=C.y,Q[X+11]=C.z,X+=12;j.bindBuffer(j.ARRAY_BUFFER,l.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Q,o)}if(ua){X=0;for(ua=pa.length;X<ua;X++){v=Q=0;for(J=q.length;v<J;v++)C=ia[q[v]],x=pa[X].vertices[C.a].position,
z=pa[X].vertices[C.b].position,y=pa[X].vertices[C.c].position,R=da[X],R[Q]=x.x,R[Q+1]=x.y,R[Q+2]=x.z,R[Q+3]=z.x,R[Q+4]=z.y,R[Q+5]=z.z,R[Q+6]=y.x,R[Q+7]=y.y,R[Q+8]=y.z,Q+=9;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],x=pa[X].vertices[C.a].position,z=pa[X].vertices[C.b].position,y=pa[X].vertices[C.c].position,C=pa[X].vertices[C.d].position,R=da[X],R[Q]=x.x,R[Q+1]=x.y,R[Q+2]=x.z,R[Q+3]=z.x,R[Q+4]=z.y,R[Q+5]=z.z,R[Q+6]=y.x,R[Q+7]=y.y,R[Q+8]=y.z,R[Q+9]=C.x,R[Q+10]=C.y,R[Q+11]=C.z,Q+=12;j.bindBuffer(j.ARRAY_BUFFER,
l.__webglMorphTargetsBuffers[X]);j.bufferData(j.ARRAY_BUFFER,da[X],o)}}if(ma.length){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],x=ma[C.a],z=ma[C.b],y=ma[C.c],V[w]=x.x,V[w+1]=x.y,V[w+2]=x.z,V[w+3]=x.w,V[w+4]=z.x,V[w+5]=z.y,V[w+6]=z.z,V[w+7]=z.w,V[w+8]=y.x,V[w+9]=y.y,V[w+10]=y.z,V[w+11]=y.w,x=qa[C.a],z=qa[C.b],y=qa[C.c],ba[w]=x.x,ba[w+1]=x.y,ba[w+2]=x.z,ba[w+3]=x.w,ba[w+4]=z.x,ba[w+5]=z.y,ba[w+6]=z.z,ba[w+7]=z.w,ba[w+8]=y.x,ba[w+9]=y.y,ba[w+10]=y.z,ba[w+11]=y.w,x=sa[C.a],z=sa[C.b],y=sa[C.c],ea[w]=x.x,ea[w+
1]=x.y,ea[w+2]=x.z,ea[w+3]=1,ea[w+4]=z.x,ea[w+5]=z.y,ea[w+6]=z.z,ea[w+7]=1,ea[w+8]=y.x,ea[w+9]=y.y,ea[w+10]=y.z,ea[w+11]=1,x=ra[C.a],z=ra[C.b],y=ra[C.c],O[w]=x.x,O[w+1]=x.y,O[w+2]=x.z,O[w+3]=1,O[w+4]=z.x,O[w+5]=z.y,O[w+6]=z.z,O[w+7]=1,O[w+8]=y.x,O[w+9]=y.y,O[w+10]=y.z,O[w+11]=1,w+=12;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],x=ma[C.a],z=ma[C.b],y=ma[C.c],da=ma[C.d],V[w]=x.x,V[w+1]=x.y,V[w+2]=x.z,V[w+3]=x.w,V[w+4]=z.x,V[w+5]=z.y,V[w+6]=z.z,V[w+7]=z.w,V[w+8]=y.x,V[w+9]=y.y,V[w+10]=y.z,V[w+11]=y.w,V[w+12]=
da.x,V[w+13]=da.y,V[w+14]=da.z,V[w+15]=da.w,x=qa[C.a],z=qa[C.b],y=qa[C.c],da=qa[C.d],ba[w]=x.x,ba[w+1]=x.y,ba[w+2]=x.z,ba[w+3]=x.w,ba[w+4]=z.x,ba[w+5]=z.y,ba[w+6]=z.z,ba[w+7]=z.w,ba[w+8]=y.x,ba[w+9]=y.y,ba[w+10]=y.z,ba[w+11]=y.w,ba[w+12]=da.x,ba[w+13]=da.y,ba[w+14]=da.z,ba[w+15]=da.w,x=sa[C.a],z=sa[C.b],y=sa[C.c],da=sa[C.d],ea[w]=x.x,ea[w+1]=x.y,ea[w+2]=x.z,ea[w+3]=1,ea[w+4]=z.x,ea[w+5]=z.y,ea[w+6]=z.z,ea[w+7]=1,ea[w+8]=y.x,ea[w+9]=y.y,ea[w+10]=y.z,ea[w+11]=1,ea[w+12]=da.x,ea[w+13]=da.y,ea[w+14]=
da.z,ea[w+15]=1,x=ra[C.a],z=ra[C.b],y=ra[C.c],C=ra[C.d],O[w]=x.x,O[w+1]=x.y,O[w+2]=x.z,O[w+3]=1,O[w+4]=z.x,O[w+5]=z.y,O[w+6]=z.z,O[w+7]=1,O[w+8]=y.x,O[w+9]=y.y,O[w+10]=y.z,O[w+11]=1,O[w+12]=C.x,O[w+13]=C.y,O[w+14]=C.z,O[w+15]=1,w+=16;w>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,ea,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,O,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,
ba,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,V,o))}if(xa&&ka){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],w=C.vertexColors,ba=C.color,w.length===3&&ka===THREE.VertexColors?(C=w[0],ea=w[1],O=w[2]):O=ea=C=ba,K[I]=C.r,K[I+1]=C.g,K[I+2]=C.b,K[I+3]=ea.r,K[I+4]=ea.g,K[I+5]=ea.b,K[I+6]=O.r,K[I+7]=O.g,K[I+8]=O.b,I+=9;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],w=C.vertexColors,ba=C.color,w.length===4&&ka===THREE.VertexColors?(C=w[0],ea=w[1],O=w[2],w=w[3]):w=O=ea=C=ba,K[I]=
C.r,K[I+1]=C.g,K[I+2]=C.b,K[I+3]=ea.r,K[I+4]=ea.g,K[I+5]=ea.b,K[I+6]=O.r,K[I+7]=O.g,K[I+8]=O.b,K[I+9]=w.r,K[I+10]=w.g,K[I+11]=w.b,I+=12;I>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,K,o))}if(ga&&E.hasTangents){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],E=C.vertexTangents,I=E[0],K=E[1],ka=E[2],Y[D]=I.x,Y[D+1]=I.y,Y[D+2]=I.z,Y[D+3]=I.w,Y[D+4]=K.x,Y[D+5]=K.y,Y[D+6]=K.z,Y[D+7]=K.w,Y[D+8]=ka.x,Y[D+9]=ka.y,Y[D+10]=ka.z,Y[D+11]=ka.w,D+=12;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],
E=C.vertexTangents,I=E[0],K=E[1],ka=E[2],E=E[3],Y[D]=I.x,Y[D+1]=I.y,Y[D+2]=I.z,Y[D+3]=I.w,Y[D+4]=K.x,Y[D+5]=K.y,Y[D+6]=K.z,Y[D+7]=K.w,Y[D+8]=ka.x,Y[D+9]=ka.y,Y[D+10]=ka.z,Y[D+11]=ka.w,Y[D+12]=E.x,Y[D+13]=E.y,Y[D+14]=E.z,Y[D+15]=E.w,D+=16;j.bindBuffer(j.ARRAY_BUFFER,l.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,Y,o)}if(ja&&F){v=0;for(J=q.length;v<J;v++)if(C=ia[q[v]],Y=C.vertexNormals,F=C.normal,Y.length===3&&$)for(D=0;D<3;D++)F=Y[D],P[A]=F.x,P[A+1]=F.y,P[A+2]=F.z,A+=3;else for(D=0;D<3;D++)P[A]=
F.x,P[A+1]=F.y,P[A+2]=F.z,A+=3;v=0;for(J=u.length;v<J;v++)if(C=ia[u[v]],Y=C.vertexNormals,F=C.normal,Y.length===4&&$)for(D=0;D<4;D++)F=Y[D],P[A]=F.x,P[A+1]=F.y,P[A+2]=F.z,A+=3;else for(D=0;D<4;D++)P[A]=F.x,P[A+1]=F.y,P[A+2]=F.z,A+=3;j.bindBuffer(j.ARRAY_BUFFER,l.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,P,o)}if(oa&&la&&M){v=0;for(J=q.length;v<J;v++)if(A=q[v],A=la[A],A!==void 0)for(D=0;D<3;D++)P=A[D],W[H]=P.u,W[H+1]=P.v,H+=2;v=0;for(J=u.length;v<J;v++)if(A=u[v],A=la[A],A!==void 0)for(D=0;D<
4;D++)P=A[D],W[H]=P.u,W[H+1]=P.v,H+=2;H>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,W,o))}if(oa&&ta&&M){v=0;for(J=q.length;v<J;v++)if(A=q[v],H=ta[A],H!==void 0)for(D=0;D<3;D++)W=H[D],G[N]=W.u,G[N+1]=W.v,N+=2;v=0;for(J=u.length;v<J;v++)if(A=u[v],H=ta[A],H!==void 0)for(D=0;D<4;D++)W=H[D],G[N]=W.u,G[N+1]=W.v,N+=2;N>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,G,o))}if(aa){v=0;for(J=q.length;v<J;v++)B[fa]=Z,B[fa+1]=Z+1,B[fa+2]=Z+2,
fa+=3,S[T]=Z,S[T+1]=Z+1,S[T+2]=Z,S[T+3]=Z+2,S[T+4]=Z+1,S[T+5]=Z+2,T+=6,Z+=3;v=0;for(J=u.length;v<J;v++)B[fa]=Z,B[fa+1]=Z+1,B[fa+2]=Z+3,B[fa+3]=Z+1,B[fa+4]=Z+2,B[fa+5]=Z+3,fa+=6,S[T]=Z,S[T+1]=Z+1,S[T+2]=Z,S[T+3]=Z+3,S[T+4]=Z+1,S[T+5]=Z+2,S[T+6]=Z+2,S[T+7]=Z+3,T+=8,Z+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,l.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,B,o);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,l.__webglLineBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,S,o)}if(s){D=0;for(Z=s.length;D<Z;D++)if(B=
s[D],B.__original.needsUpdate){G=0;if(B.size===1)if(B.boundTo===void 0||B.boundTo==="vertices"){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],B.array[G]=B.value[C.a],B.array[G+1]=B.value[C.b],B.array[G+2]=B.value[C.c],G+=3;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],B.array[G]=B.value[C.a],B.array[G+1]=B.value[C.b],B.array[G+2]=B.value[C.c],B.array[G+3]=B.value[C.d],G+=4}else{if(B.boundTo==="faces"){v=0;for(J=q.length;v<J;v++)S=B.value[q[v]],B.array[G]=S,B.array[G+1]=S,B.array[G+2]=S,G+=3;v=0;for(J=u.length;v<
J;v++)S=B.value[u[v]],B.array[G]=S,B.array[G+1]=S,B.array[G+2]=S,B.array[G+3]=S,G+=4}}else if(B.size===2)if(B.boundTo===void 0||B.boundTo==="vertices"){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],x=B.value[C.a],z=B.value[C.b],y=B.value[C.c],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=z.x,B.array[G+3]=z.y,B.array[G+4]=y.x,B.array[G+5]=y.y,G+=6;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],x=B.value[C.a],z=B.value[C.b],y=B.value[C.c],C=B.value[C.d],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=z.x,B.array[G+3]=z.y,
B.array[G+4]=y.x,B.array[G+5]=y.y,B.array[G+6]=C.x,B.array[G+7]=C.y,G+=8}else{if(B.boundTo==="faces"){v=0;for(J=q.length;v<J;v++)y=z=x=S=B.value[q[v]],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=z.x,B.array[G+3]=z.y,B.array[G+4]=y.x,B.array[G+5]=y.y,G+=6;v=0;for(J=u.length;v<J;v++)C=y=z=x=S=B.value[u[v]],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=z.x,B.array[G+3]=z.y,B.array[G+4]=y.x,B.array[G+5]=y.y,B.array[G+6]=C.x,B.array[G+7]=C.y,G+=8}}else if(B.size===3)if(N=B.type==="c"?["r","g","b"]:["x",
"y","z"],B.boundTo===void 0||B.boundTo==="vertices"){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],x=B.value[C.a],z=B.value[C.b],y=B.value[C.c],B.array[G]=x[N[0]],B.array[G+1]=x[N[1]],B.array[G+2]=x[N[2]],B.array[G+3]=z[N[0]],B.array[G+4]=z[N[1]],B.array[G+5]=z[N[2]],B.array[G+6]=y[N[0]],B.array[G+7]=y[N[1]],B.array[G+8]=y[N[2]],G+=9;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],x=B.value[C.a],z=B.value[C.b],y=B.value[C.c],C=B.value[C.d],B.array[G]=x[N[0]],B.array[G+1]=x[N[1]],B.array[G+2]=x[N[2]],B.array[G+3]=z[N[0]],
B.array[G+4]=z[N[1]],B.array[G+5]=z[N[2]],B.array[G+6]=y[N[0]],B.array[G+7]=y[N[1]],B.array[G+8]=y[N[2]],B.array[G+9]=C[N[0]],B.array[G+10]=C[N[1]],B.array[G+11]=C[N[2]],G+=12}else{if(B.boundTo==="faces"){v=0;for(J=q.length;v<J;v++)y=z=x=S=B.value[q[v]],B.array[G]=x[N[0]],B.array[G+1]=x[N[1]],B.array[G+2]=x[N[2]],B.array[G+3]=z[N[0]],B.array[G+4]=z[N[1]],B.array[G+5]=z[N[2]],B.array[G+6]=y[N[0]],B.array[G+7]=y[N[1]],B.array[G+8]=y[N[2]],G+=9;v=0;for(J=u.length;v<J;v++)C=y=z=x=S=B.value[u[v]],B.array[G]=
x[N[0]],B.array[G+1]=x[N[1]],B.array[G+2]=x[N[2]],B.array[G+3]=z[N[0]],B.array[G+4]=z[N[1]],B.array[G+5]=z[N[2]],B.array[G+6]=y[N[0]],B.array[G+7]=y[N[1]],B.array[G+8]=y[N[2]],B.array[G+9]=C[N[0]],B.array[G+10]=C[N[1]],B.array[G+11]=C[N[2]],G+=12}}else if(B.size===4)if(B.boundTo===void 0||B.boundTo==="vertices"){v=0;for(J=q.length;v<J;v++)C=ia[q[v]],x=B.value[C.a],z=B.value[C.b],y=B.value[C.c],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=x.z,B.array[G+3]=x.w,B.array[G+4]=z.x,B.array[G+5]=z.y,B.array[G+
6]=z.z,B.array[G+7]=z.w,B.array[G+8]=y.x,B.array[G+9]=y.y,B.array[G+10]=y.z,B.array[G+11]=y.w,G+=12;v=0;for(J=u.length;v<J;v++)C=ia[u[v]],x=B.value[C.a],z=B.value[C.b],y=B.value[C.c],C=B.value[C.d],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=x.z,B.array[G+3]=x.w,B.array[G+4]=z.x,B.array[G+5]=z.y,B.array[G+6]=z.z,B.array[G+7]=z.w,B.array[G+8]=y.x,B.array[G+9]=y.y,B.array[G+10]=y.z,B.array[G+11]=y.w,B.array[G+12]=C.x,B.array[G+13]=C.y,B.array[G+14]=C.z,B.array[G+15]=C.w,G+=16}else if(B.boundTo==="faces"){v=
0;for(J=q.length;v<J;v++)y=z=x=S=B.value[q[v]],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=x.z,B.array[G+3]=x.w,B.array[G+4]=z.x,B.array[G+5]=z.y,B.array[G+6]=z.z,B.array[G+7]=z.w,B.array[G+8]=y.x,B.array[G+9]=y.y,B.array[G+10]=y.z,B.array[G+11]=y.w,G+=12;v=0;for(J=u.length;v<J;v++)C=y=z=x=S=B.value[u[v]],B.array[G]=x.x,B.array[G+1]=x.y,B.array[G+2]=x.z,B.array[G+3]=x.w,B.array[G+4]=z.x,B.array[G+5]=z.y,B.array[G+6]=z.z,B.array[G+7]=z.w,B.array[G+8]=y.x,B.array[G+9]=y.y,B.array[G+10]=y.z,B.array[G+
11]=y.w,B.array[G+12]=C.x,B.array[G+13]=C.y,B.array[G+14]=C.z,B.array[G+15]=C.w,G+=16}j.bindBuffer(j.ARRAY_BUFFER,B.buffer);j.bufferData(j.ARRAY_BUFFER,B.array,o)}}U&&(delete l.__inittedArrays,delete l.__colorArray,delete l.__normalArray,delete l.__tangentArray,delete l.__uvArray,delete l.__uv2Array,delete l.__faceArray,delete l.__vertexArray,delete l.__lineArray,delete l.__skinVertexAArray,delete l.__skinVertexBArray,delete l.__skinIndexArray,delete l.__skinWeightArray)}f.__dirtyVertices=!1;f.__dirtyMorphTargets=
!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyColors=!1;f.__dirtyTangents=!1;h.attributes&&r(h)}else if(t instanceof THREE.Ribbon){if(f.__dirtyVertices||f.__dirtyColors){h=f;t=j.DYNAMIC_DRAW;v=i=v=U=U=void 0;J=h.vertices;k=h.colors;s=J.length;l=k.length;q=h.__vertexArray;o=h.__colorArray;u=h.__dirtyColors;if(h.__dirtyVertices){for(U=0;U<s;U++)v=J[U].position,i=U*3,q[i]=v.x,q[i+1]=v.y,q[i+2]=v.z;j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,q,
t)}if(u){for(U=0;U<l;U++)v=k[U],i=U*3,o[i]=v.r,o[i+1]=v.g,o[i+2]=v.b;j.bindBuffer(j.ARRAY_BUFFER,h.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,o,t)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(t instanceof THREE.Line){h=b(t,l);o=h.attributes&&n(h);if(f.__dirtyVertices||f.__dirtyColors||o){t=f;i=j.DYNAMIC_DRAW;s=k=Z=J=ia=void 0;J=t.vertices;l=t.colors;s=J.length;o=l.length;q=t.__vertexArray;U=t.__colorArray;u=t.__dirtyColors;v=t.__webglCustomAttributesList;H=T=fa=N=Z=ia=void 0;if(t.__dirtyVertices){for(ia=
0;ia<s;ia++)Z=J[ia].position,k=ia*3,q[k]=Z.x,q[k+1]=Z.y,q[k+2]=Z.z;j.bindBuffer(j.ARRAY_BUFFER,t.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,q,i)}if(u){for(J=0;J<o;J++)s=l[J],k=J*3,U[k]=s.r,U[k+1]=s.g,U[k+2]=s.b;j.bindBuffer(j.ARRAY_BUFFER,t.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,U,i)}if(v){ia=0;for(Z=v.length;ia<Z;ia++)if(H=v[ia],H.needsUpdate&&(H.boundTo===void 0||H.boundTo==="vertices")){k=0;fa=H.value.length;if(H.size===1)for(N=0;N<fa;N++)H.array[N]=H.value[N];else if(H.size===2)for(N=
0;N<fa;N++)T=H.value[N],H.array[k]=T.x,H.array[k+1]=T.y,k+=2;else if(H.size===3)if(H.type==="c")for(N=0;N<fa;N++)T=H.value[N],H.array[k]=T.r,H.array[k+1]=T.g,H.array[k+2]=T.b,k+=3;else for(N=0;N<fa;N++)T=H.value[N],H.array[k]=T.x,H.array[k+1]=T.y,H.array[k+2]=T.z,k+=3;else if(H.size===4)for(N=0;N<fa;N++)T=H.value[N],H.array[k]=T.x,H.array[k+1]=T.y,H.array[k+2]=T.z,H.array[k+3]=T.w,k+=4;j.bindBuffer(j.ARRAY_BUFFER,H.buffer);j.bufferData(j.ARRAY_BUFFER,H.array,i)}}}f.__dirtyVertices=!1;f.__dirtyColors=
!1;h.attributes&&r(h)}else if(t instanceof THREE.ParticleSystem)h=b(t,l),o=h.attributes&&n(h),(f.__dirtyVertices||f.__dirtyColors||t.sortParticles||o)&&d(f,j.DYNAMIC_DRAW,t),f.__dirtyVertices=!1,f.__dirtyColors=!1,h.attributes&&r(h)};this.initMaterial=function(a,b,c,d){var e,g,f,h;a instanceof THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?
h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var k,l,m;k=m=i=0;for(l=b.length;k<l;k++)f=b[k],f instanceof THREE.SpotLight&&m++,f instanceof THREE.DirectionalLight&&m++,f instanceof THREE.PointLight&&i++;i+m<=z?k=m:(k=Math.ceil(z*m/(i+m)),i=z-k);f={directional:k,point:i};i=m=0;for(k=
b.length;i<k;i++)l=b[i],l instanceof THREE.SpotLight&&l.castShadow&&m++;var n=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)n=d.bones.length;var o;a:{k=a.fragmentShader;l=a.vertexShader;var i=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:f.directional,maxPointLights:f.point,maxBones:n,
shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},v,d=[];h?d.push(h):(d.push(k),d.push(l));for(v in c)d.push(v),d.push(c[v]);h=d.join();v=0;for(d=aa.length;v<d;v++)if(aa[v].code===h){o=aa[v].program;break a}v=j.createProgram();d=[sa?"#define VERTEX_TEXTURES":"",L.gammaInput?"#define GAMMA_INPUT":"",L.gammaOutput?"#define GAMMA_OUTPUT":
"",L.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":
"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","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 vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
f=["#ifdef GL_ES","precision "+S+" float;","#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",L.gammaInput?"#define GAMMA_INPUT":"",L.gammaOutput?"#define GAMMA_OUTPUT":"",L.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":
"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(v,x("fragment",f+k));j.attachShader(v,
x("vertex",d+l));j.linkProgram(v);j.getProgramParameter(v,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(v,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");v.uniforms={};v.attributes={};var p,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(p in i)d.push(p);p=d;d=0;for(i=p.length;d<i;d++)k=p[d],v.uniforms[k]=j.getUniformLocation(v,
k);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(p=0;p<c.maxMorphTargets;p++)d.push("morphTarget"+p);for(o in b)d.push(o);o=d;p=0;for(b=o.length;p<b;p++)c=o[p],v.attributes[c]=j.getAttribLocation(v,c);v.id=aa.length;aa.push({program:v,code:h});L.info.memory.programs=aa.length;o=v}a.program=o;o=a.program.attributes;o.position>=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal);
o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(g in a.attributes)o[g]!==void 0&&o[g]>=0&&j.enableVertexAttribArray(o[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g<this.maxMorphTargets;g++)p="morphTarget"+g,o[p]>=0&&(j.enableVertexAttribArray(o[p]),
342
a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)}};
A
alteredq 已提交
343 344 345 346 347 348 349 350 351
THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type:
THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0};
THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,c,b){THREE.WebGLRenderTarget.call(this,a,c,b);this.activeCubeFace=0};
THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};
THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
THREE.ColorUtils={adjustHSV:function(a,c,b,d){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.Math.clamp(g.h+c,0,1);g.s=THREE.Math.clamp(g.s+b,0,1);g.v=THREE.Math.clamp(g.v+d,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,g=a.b,e=Math.max(Math.max(b,d),g),f=Math.min(Math.min(b,d),g);if(f===e)f=b=0;else{var h=e-f,f=h/e,b=b===e?(d-g)/h:d===e?2+(g-b)/h:4+(b-d)/h;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=f;c.v=e;return c}};
THREE.ColorUtils.__hsv={h:0,s:0,v:0};
A
alteredq 已提交
352 353 354 355
THREE.GeometryUtils={merge:function(a,c){for(var b,d,g=a.vertices.length,e=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,h=e.vertices,i=a.faces,k=e.faces,l=a.faceVertexUvs[0],o=e.faceVertexUvs[0],p={},n=0;n<a.materials.length;n++)p[a.materials[n].id]=n;if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),b=c.matrix,d=new THREE.Matrix4,d.extractRotation(b,c.scale);for(var n=0,r=h.length;n<r;n++){var m=new THREE.Vertex(h[n].position.clone());b&&b.multiplyVector3(m.position);f.push(m)}n=
0;for(r=k.length;n<r;n++){var f=k[n],s,u,t=f.vertexNormals,q=f.vertexColors;f instanceof THREE.Face3?s=new THREE.Face3(f.a+g,f.b+g,f.c+g):f instanceof THREE.Face4&&(s=new THREE.Face4(f.a+g,f.b+g,f.c+g,f.d+g));s.normal.copy(f.normal);d&&d.multiplyVector3(s.normal);h=0;for(m=t.length;h<m;h++)u=t[h].clone(),d&&d.multiplyVector3(u),s.vertexNormals.push(u);s.color.copy(f.color);h=0;for(m=q.length;h<m;h++)u=q[h],s.vertexColors.push(u.clone());if(f.materialIndex!==void 0){h=e.materials[f.materialIndex];
m=p[h.id];if(m===void 0)m=a.materials.length,a.materials.push(h);s.materialIndex=m}s.centroid.copy(f.centroid);b&&b.multiplyVector3(s.centroid);i.push(s)}n=0;for(r=o.length;n<r;n++){b=o[n];d=[];h=0;for(m=b.length;h<m;h++)d.push(new THREE.UV(b[h].u,b[h].v));l.push(d)}},clone:function(a){var c=new THREE.Geometry,b,d=a.vertices,g=a.faces,e=a.faceVertexUvs[0];if(a.materials)c.materials=a.materials.slice();a=0;for(b=d.length;a<b;a++){var f=new THREE.Vertex(d[a].position.clone());c.vertices.push(f)}a=0;
for(b=g.length;a<b;a++){var h=g[a],i,k,l=h.vertexNormals,o=h.vertexColors;h instanceof THREE.Face3?i=new THREE.Face3(h.a,h.b,h.c):h instanceof THREE.Face4&&(i=new THREE.Face4(h.a,h.b,h.c,h.d));i.normal.copy(h.normal);d=0;for(f=l.length;d<f;d++)k=l[d],i.vertexNormals.push(k.clone());i.color.copy(h.color);d=0;for(f=o.length;d<f;d++)k=o[d],i.vertexColors.push(k.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);c.faces.push(i)}a=0;for(b=e.length;a<b;a++){g=e[a];i=[];d=0;for(f=g.length;d<
A
alteredq 已提交
356 357
f;d++)i.push(new THREE.UV(g[d].u,g[d].v));c.faceVertexUvs[0].push(i)}return c},randomPointInTriangle:function(a,c,b){var d,g,e,f=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();g=THREE.GeometryUtils.random();d+g>1&&(d=1-d,g=1-g);e=1-d-g;f.copy(a);f.multiplyScalar(d);h.copy(c);h.multiplyScalar(g);f.addSelf(h);h.copy(b);h.multiplyScalar(e);f.addSelf(h);return f},randomPointInFace:function(a,c,b){var d,g,e;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,g=c.vertices[a.b].position,
e=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,g,e);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;g=c.vertices[a.b].position;e=c.vertices[a.c].position;var c=c.vertices[a.d].position,f;b?a._area1&&a._area2?(b=a._area1,f=a._area2):(b=THREE.GeometryUtils.triangleArea(d,g,c),f=THREE.GeometryUtils.triangleArea(g,e,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(d,g,c),f=THREE.GeometryUtils.triangleArea(g,e,c));return THREE.GeometryUtils.random()*(b+
A
alteredq 已提交
358 359
f)<b?THREE.GeometryUtils.randomPointInTriangle(d,g,c):THREE.GeometryUtils.randomPointInTriangle(g,e,c)}},randomPointsInGeometry:function(a,c){function b(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return k[e]>a?b(c,e-1):k[e]<a?b(e+1,d):e}return b(0,k.length-1)}var d,g,e=a.faces,f=a.vertices,h=e.length,i=0,k=[],l,o,p,n;for(g=0;g<h;g++){d=e[g];if(d instanceof THREE.Face3)l=f[d.a].position,o=f[d.b].position,p=f[d.c].position,d._area=THREE.GeometryUtils.triangleArea(l,o,p);else if(d instanceof
THREE.Face4)l=f[d.a].position,o=f[d.b].position,p=f[d.c].position,n=f[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(l,o,n),d._area2=THREE.GeometryUtils.triangleArea(o,p,n),d._area=d._area1+d._area2;i+=d._area;k[g]=i}d=[];f={};for(g=0;g<c;g++)h=THREE.GeometryUtils.random()*i,h=b(h),d[g]=THREE.GeometryUtils.randomPointInFace(e[h],a,!0),f[h]?f[h]+=1:f[h]=1;return d},triangleArea:function(a,c,b){var d,g=THREE.GeometryUtils.__v1;g.sub(a,c);d=g.length();g.sub(a,b);a=g.length();g.sub(c,b);b=g.length();
A
alteredq 已提交
360 361
c=0.5*(d+a+b);return Math.sqrt(c*(c-d)*(c-a)*(c-b))},center:function(a){a.computeBoundingBox();var c=new THREE.Matrix4;c.setTranslation(-0.5*(a.boundingBox.x[1]+a.boundingBox.x[0]),-0.5*(a.boundingBox.y[1]+a.boundingBox.y[0]),-0.5*(a.boundingBox.z[1]+a.boundingBox.z[0]));a.applyMatrix(c);a.computeBoundingBox()}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
THREE.ImageUtils={loadTexture:function(a,c,b){var d=new Image,g=new THREE.Texture(d,c);d.onload=function(){g.needsUpdate=!0;b&&b(this)};d.crossOrigin="";d.src=a;return g},loadTextureCube:function(a,c,b){var d,g=[],e=new THREE.Texture(g,c),c=g.loadCount=0;for(d=a.length;c<d;++c)g[c]=new Image,g[c].onload=function(){g.loadCount+=1;if(g.loadCount===6)e.needsUpdate=!0;b&&b(this)},g[c].crossOrigin="",g[c].src=a[c];return e},getNormalMap:function(a,c){var b=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+
A
alteredq 已提交
362 363 364
a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};c|=1;var d=a.width,g=a.height,e=document.createElement("canvas");e.width=d;e.height=g;var f=e.getContext("2d");f.drawImage(a,0,0);for(var h=f.getImageData(0,0,d,g).data,i=f.createImageData(d,g),k=i.data,l=0;l<d;l++)for(var o=1;o<g;o++){var p=o-1<0?g-1:o-1,n=(o+1)%g,r=l-1<0?d-1:l-1,m=(l+1)%d,s=[],u=[0,0,h[(o*d+l)*4]/255*c];s.push([-1,0,h[(o*d+r)*4]/255*c]);s.push([-1,-1,h[(p*d+r)*4]/255*c]);s.push([0,-1,h[(p*d+l)*4]/255*c]);s.push([1,-1,h[(p*d+m)*4]/255*c]);
s.push([1,0,h[(o*d+m)*4]/255*c]);s.push([1,1,h[(n*d+m)*4]/255*c]);s.push([0,1,h[(n*d+l)*4]/255*c]);s.push([-1,1,h[(n*d+r)*4]/255*c]);p=[];r=s.length;for(n=0;n<r;n++){var m=s[n],t=s[(n+1)%r],m=[m[0]-u[0],m[1]-u[1],m[2]-u[2]],t=[t[0]-u[0],t[1]-u[1],t[2]-u[2]];p.push(b([m[1]*t[2]-m[2]*t[1],m[2]*t[0]-m[0]*t[2],m[0]*t[1]-m[1]*t[0]]))}s=[0,0,0];for(n=0;n<p.length;n++)s[0]+=p[n][0],s[1]+=p[n][1],s[2]+=p[n][2];s[0]/=p.length;s[1]/=p.length;s[2]/=p.length;u=(o*d+l)*4;k[u]=(s[0]+1)/2*255|0;k[u+1]=(s[1]+0.5)*
255|0;k[u+2]=s[2]*255|0;k[u+3]=255}f.putImageData(i,0,0);return e}};THREE.SceneUtils={showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=c})},traverseHierarchy:function(a,c){var b,d,g=a.children.length;for(d=0;d<g;d++)b=a.children[d],c(b),THREE.SceneUtils.traverseHierarchy(b,c)},createMultiMaterialObject:function(a,c){var b,d=c.length,g=new THREE.Object3D;for(b=0;b<d;b++){var e=new THREE.Mesh(a,c[b]);g.add(e)}return g}};
A
alteredq 已提交
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
if(THREE.WebGLRenderer)THREE.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}",
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}"},
normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tCube:{type:"t",value:1,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},tDisplacement:{type:"t",value:5,texture:null},uNormalScale:{type:"f",
value:1},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},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},uOpacity:{type:"f",value:1},uReflectivity:{type:"f",value:0.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,1)}}]),fragmentShader:["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform float uNormalScale;\nuniform float uReflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\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 ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 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 + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor) + totalSpecular;\nif ( enableReflection ) {\nvec3 wPos = cameraPosition - vViewPosition;\nvec3 vReflect = reflect( normalize( wPos ), normal );\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, uReflectivity );\n}",
THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\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;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\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",
THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},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;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPoint(c/a));return b};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b};
THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var c=[],b,d=this.getPoint(0),g,e=0;c.push(0);for(g=1;g<=a;g++)b=this.getPoint(g/a),e+=b.distanceTo(d),c.push(e),d=b;return this.cacheArcLengths=c};
THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),d=0,g=b.length,e;e=c?c:a*b[g-1];Date.now();for(var f=0,h=g-1,i;f<=h;)if(d=Math.floor(f+(h-f)/2),i=b[d]-e,i<0)f=d+1;else if(i>0)h=d-1;else{h=d;break}d=h;if(b[d]==e)return d/(g-1);f=b[d];return b=(d+(e-f)/(b[d+1]-f))/(g-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
THREE.Curve.prototype.getTangent=function(a){var c=a-1.0E-4;a+=1.0E-4;c<0&&(c=0);a>1&&(a=1);var c=this.getPoint(c),a=this.getPoint(a),b=new THREE.Vector2;b.sub(a,c);return b.unit()};THREE.LineCurve=function(a,c){a instanceof THREE.Vector2?(this.v1=a,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,c,b,d){this.constructor(new THREE.Vector2(a,c),new THREE.Vector2(b,d))};THREE.LineCurve.prototype=new THREE.Curve;
THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(a).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a};
THREE.QuadraticBezierCurve=function(a,c,b){if(!(c instanceof THREE.Vector2))var d=Array.prototype.slice.call(arguments),a=new THREE.Vector2(d[0],d[1]),c=new THREE.Vector2(d[2],d[3]),b=new THREE.Vector2(d[4],d[5]);this.v0=a;this.v1=c;this.v2=b};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;
THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(c,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);c=new THREE.Vector2(c,a);c.normalize();return c};
THREE.CubicBezierCurve=function(a,c,b,d){if(!(c instanceof THREE.Vector2))var g=Array.prototype.slice.call(arguments),a=new THREE.Vector2(g[0],g[1]),c=new THREE.Vector2(g[2],g[3]),b=new THREE.Vector2(g[4],g[5]),d=new THREE.Vector2(g[6],g[7]);this.v0=a;this.v1=c;this.v2=b;this.v3=d};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;
THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(c,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);c=new THREE.Vector2(c,a);c.normalize();return c};
THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
THREE.SplineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2,b=[],d=this.points,g;g=(d.length-1)*a;a=Math.floor(g);g-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,g);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,g);return c};THREE.ArcCurve=function(a,c,b,d,g,e){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=d;this.aEndAngle=g;this.aClockwise=e};
THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))};
THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,d){return 2*(1-a)*(b-c)+2*a*(d-b)},tangentCubicBezier:function(a,c,b,d,g){return-3*c*(1-a)*(1-a)+3*b*(1-a)*(1-a)-6*a*b*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*g},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,c,b,d,g){var a=(b-a)*0.5,d=(d-c)*0.5,e=g*g;return(2*c-2*b+a+d)*g*e+(-3*c+3*b-2*a-d)*e+a*g+c}};
THREE.Curve.create=function(a,c){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=c;return a};THREE.LineCurve3=THREE.Curve.create(function(a,c){this.v1=a;this.v2=c},function(a){var c=new THREE.Vector3;c.sub(this.v2,this.v1);c.multiplyScalar(a);c.addSelf(this.v1);return c});
THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,c,b){this.v0=a;this.v1=c;this.v2=b},function(a){var c,b;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,b,a)});
THREE.CubicBezierCurve3=THREE.Curve.create(function(a,c,b,d){this.v0=a;this.v1=c;this.v2=b;this.v3=d},function(a){var c,b;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(c,b,a)});
THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a},function(a){var c=new THREE.Vector3,b=[],d=this.points,g;g=(d.length-1)*a;a=Math.floor(g);g-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,g);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,g);c.z=THREE.Curve.Utils.interpolate(d[b[0]].z,d[b[1]].z,d[b[2]].z,d[b[3]].z,g);return c});
THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){};
THREE.CurvePath.prototype.getPoint=function(a){for(var c=a*this.getLength(),b=this.getCurveLengths(),a=0;a<b.length;){if(b[a]>=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],c=0,b,d=this.curves.length;for(b=0;b<d;b++)c+=this.curves[b].getLength(),a.push(c);return this.cacheLengths=a};
THREE.CurvePath.prototype.getBoundingBox=function(){var a=this.getPoints(),c,b,d,g;c=b=Number.NEGATIVE_INFINITY;d=g=Number.POSITIVE_INFINITY;var e,f,h,i;i=new THREE.Vector2;f=0;for(h=a.length;f<h;f++){e=a[f];if(e.x>c)c=e.x;else if(e.x<d)d=e.x;if(e.y>b)b=e.y;else if(e.y<b)g=e.y;i.addSelf(e.x,e.y)}return{minX:d,minY:g,maxX:c,maxY:b,centroid:i.divideScalar(h)}};THREE.CurvePath.prototype.createPointsGeometry=function(a){return this.createGeometry(this.getPoints(a,!0))};
THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){return this.createGeometry(this.getSpacedPoints(a,!0))};THREE.CurvePath.prototype.createGeometry=function(a){for(var c=new THREE.Geometry,b=0;b<a.length;b++)c.vertices.push(new THREE.Vertex(new THREE.Vector3(a[b].x,a[b].y,0)));return c};THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)};
THREE.CurvePath.prototype.getTransformedPoints=function(a,c){var b=this.getPoints(a),d,g;if(!c)c=this.bends;d=0;for(g=c.length;d<g;d++)b=this.getWrapPoints(b,c[d]);return b};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,c){var b=this.getSpacedPoints(a),d,g;if(!c)c=this.bends;d=0;for(g=c.length;d<g;d++)b=this.getWrapPoints(b,c[d]);return b};
THREE.CurvePath.prototype.getWrapPoints=function(a,c){var b=this.getBoundingBox(),d,g,e,f,h,i;d=0;for(g=a.length;d<g;d++)e=a[d],f=e.x,h=e.y,i=f/b.maxX,i=c.getUtoTmapping(i,f),f=c.getPoint(i),h=c.getNormalVector(i).multiplyScalar(h),e.x=f.x+h.x,e.y=f.y+h.y;return a};THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;
THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"};THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);var c,b=a.length;for(c=1;c<b;c++)this.lineTo(a[c].x,a[c].y)};THREE.Path.prototype.moveTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:a})};
THREE.Path.prototype.lineTo=function(a,c){var b=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args;this.curves.push(new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,c)));this.actions.push({action:THREE.PathActions.LINE_TO,args:b})};
THREE.Path.prototype.quadraticCurveTo=function(a,c,b,d){var g=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args;this.curves.push(new THREE.QuadraticBezierCurve(new THREE.Vector2(e[e.length-2],e[e.length-1]),new THREE.Vector2(a,c),new THREE.Vector2(b,d)));this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:g})};
THREE.Path.prototype.bezierCurveTo=function(a,c,b,d,g,e){var f=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,c),new THREE.Vector2(b,d),new THREE.Vector2(g,e)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:f})};
THREE.Path.prototype.splineThru=function(a){var c=Array.prototype.slice.call(arguments),b=this.actions[this.actions.length-1].args,b=[new THREE.Vector2(b[b.length-2],b[b.length-1])];Array.prototype.push.apply(b,a);this.curves.push(new THREE.SplineCurve(b));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c})};
THREE.Path.prototype.arc=function(a,c,b,d,g,e){var f=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,c,b,d,g,e));this.actions.push({action:THREE.PathActions.ARC,args:f})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var c=[],b=0;b<a;b++)c.push(this.getPoint(b/a));return c};
A
alteredq 已提交
403 404 405 406
THREE.Path.prototype.getPoints=function(a,c){var a=a||12,b=[],d,g,e,f,h,i,k,l,o,p,n,r,m;d=0;for(g=this.actions.length;d<g;d++)switch(e=this.actions[d],f=e.action,e=e.args,f){case THREE.PathActions.LINE_TO:b.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=e[2];i=e[3];o=e[0];p=e[1];b.length>0?(f=b[b.length-1],n=f.x,r=f.y):(f=this.actions[d-1].args,n=f[f.length-2],r=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,e=THREE.Shape.Utils.b2(m,n,o,h),m=THREE.Shape.Utils.b2(m,r,p,
i),b.push(new THREE.Vector2(e,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];o=e[0];p=e[1];k=e[2];l=e[3];b.length>0?(f=b[b.length-1],n=f.x,r=f.y):(f=this.actions[d-1].args,n=f[f.length-2],r=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,e=THREE.Shape.Utils.b3(m,n,o,k,h),m=THREE.Shape.Utils.b3(m,r,p,l,i),b.push(new THREE.Vector2(e,m));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];m=a*e[0].length;f=f.concat(e[0]);e=new THREE.SplineCurve(f);
for(f=1;f<=m;f++)b.push(e.getPointAt(f/m));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=e[0];i=e[1];k=e[2];o=e[3];m=e[4];p=!!e[5];l=f[f.length-2];n=f[f.length-1];f.length==0&&(l=n=0);r=m-o;var s=a*2;for(f=1;f<=s;f++)m=f/s,p||(m=1-m),m=o+m*r,e=l+h+k*Math.cos(m),m=n+i+k*Math.sin(m),b.push(new THREE.Vector2(e,m))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)};
THREE.Path.prototype.nltransform=function(a,c,b,d,g,e){var f=this.getPoints(),h,i,k,l,o;h=0;for(i=f.length;h<i;h++)k=f[h],l=k.x,o=k.y,k.x=a*l+c*o+b,k.y=d*o+g*l+e;return f};
A
alteredq 已提交
407 408 409 410 411 412
THREE.Path.prototype.debug=function(a){var c=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",c.maxX+100),a.setAttribute("height",c.maxY+100),document.body.appendChild(a));c=a.getContext("2d");c.fillStyle="white";c.fillRect(0,0,a.width,a.height);c.strokeStyle="black";c.beginPath();var b,d,g,a=0;for(b=this.actions.length;a<b;a++)d=this.actions[a],g=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&c[d].apply(c,g);c.stroke();c.closePath();c.strokeStyle="red";d=
this.getPoints();a=0;for(b=d.length;a<b;a++)g=d[a],c.beginPath(),c.arc(g.x,g.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
THREE.Path.prototype.toShapes=function(){var a,c,b,d,g=[],e=new THREE.Path;a=0;for(c=this.actions.length;a<c;a++)b=this.actions[a],d=b.args,b=b.action,b==THREE.PathActions.MOVE_TO&&e.actions.length!=0&&(g.push(e),e=new THREE.Path),e[b].apply(e,d);e.actions.length!=0&&g.push(e);if(g.length==0)return[];var f,e=[];if(THREE.Shape.Utils.isClockWise(g[0].getPoints())){a=0;for(c=g.length;a<c;a++)d=g[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(f&&e.push(f),f=new THREE.Shape,f.actions=d.actions,f.curves=
d.curves):f.holes.push(d);e.push(f)}else{f=new THREE.Shape;a=0;for(c=g.length;a<c;a++)d=g[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(f.actions=d.actions,f.curves=d.curves,e.push(f),f=new THREE.Shape):f.holes.push(d)}return e};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};
THREE.Shape.prototype.getPointsHoles=function(a){var c,b=this.holes.length,d=[];for(c=0;c<b;c++)d[c]=this.holes[c].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var c,b=this.holes.length,d=[];for(c=0;c<b;c++)d[c]=this.holes[c].getTransformedSpacedPoints(a,this.bends);return d};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};
THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
A
alteredq 已提交
413 414 415
THREE.Shape.Utils={removeHoles:function(a,c){var b=a.concat(),d=b.concat(),g,e,f,h,i,k,l,o,p,n,r=[];for(i=0;i<c.length;i++){k=c[i];Array.prototype.push.apply(d,k);e=Number.POSITIVE_INFINITY;for(g=0;g<k.length;g++){p=k[g];n=[];for(o=0;o<b.length;o++)l=b[o],l=p.distanceToSquared(l),n.push(l),l<e&&(e=l,f=g,h=o)}g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:k.length-1;var m=[k[f],b[h],b[g]];o=THREE.FontUtils.Triangulate.area(m);var s=[k[f],k[e],b[h]];p=THREE.FontUtils.Triangulate.area(s);n=h;l=f;h+=1;f+=-1;h<
0&&(h+=b.length);h%=b.length;f<0&&(f+=k.length);f%=k.length;g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:k.length-1;m=[k[f],b[h],b[g]];m=THREE.FontUtils.Triangulate.area(m);s=[k[f],k[e],b[h]];s=THREE.FontUtils.Triangulate.area(s);o+p>m+s&&(h=n,f=l,h<0&&(h+=b.length),h%=b.length,f<0&&(f+=k.length),f%=k.length,g=h-1>=0?h-1:b.length-1,e=f-1>=0?f-1:k.length-1);o=b.slice(0,h);p=b.slice(h);n=k.slice(f);l=k.slice(0,f);e=[k[f],k[e],b[h]];r.push([k[f],b[h],b[g]]);r.push(e);b=o.concat(n).concat(l).concat(p)}return{shape:b,
isolatedPts:r,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),e,f,h,i,k={};e=0;for(f=d.length;e<f;e++)i=d[e].x+":"+d[e].y,k[i]!==void 0&&console.log("Duplicate point",i),k[i]=e;e=0;for(f=b.length;e<f;e++){h=b[e];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=k[i],i!==void 0&&(h[d]=i)}e=0;for(f=g.length;e<f;e++){h=g[e];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=k[i],i!==void 0&&(h[d]=i)}return b.concat(g)},
A
alteredq 已提交
416 417 418 419
isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,d){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,d)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*(1-a)*a*a*c},b3p3:function(a,c){return a*a*a*c},b3:function(a,c,b,d,g){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,d)+
this.b3p3(a,g)}};THREE.TextPath=function(a,c){THREE.Path.call(this);this.parameters=c||{};this.set(a)};THREE.TextPath.prototype.set=function(a,c){this.text=a;var c=c||this.parameters,b=c.curveSegments!==void 0?c.curveSegments:4,d=c.font!==void 0?c.font:"helvetiker",g=c.weight!==void 0?c.weight:"normal",e=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=b;THREE.FontUtils.face=d;THREE.FontUtils.weight=g;THREE.FontUtils.style=e};
THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,c=[],b=0,d=a.length;b<d;b++)Array.prototype.push.apply(c,a[b].toShapes());return c};
THREE.AnimationHandler=function(){var a=[],c={},b={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){c[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");c[a.name]=a;if(a.initialized!==!0){for(var b=0;b<a.hierarchy.length;b++){for(var d=0;d<a.hierarchy[b].keys.length;d++){if(a.hierarchy[b].keys[d].time<
A
alteredq 已提交
420 421
0)a.hierarchy[b].keys[d].time=0;if(a.hierarchy[b].keys[d].rot!==void 0&&!(a.hierarchy[b].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[b].keys[d].rot;a.hierarchy[b].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[b].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[b].keys.length;d++)for(var i=0;i<a.hierarchy[b].keys[d].morphTargets.length;i++){var k=a.hierarchy[b].keys[d].morphTargets[i];h[k]=-1}a.hierarchy[b].usedMorphTargets=h;for(d=0;d<a.hierarchy[b].keys.length;d++){var l=
{};for(k in h){for(i=0;i<a.hierarchy[b].keys[d].morphTargets.length;i++)if(a.hierarchy[b].keys[d].morphTargets[i]===k){l[k]=a.hierarchy[b].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[b].keys[d].morphTargets.length&&(l[k]=0)}a.hierarchy[b].keys[d].morphTargetsInfluences=l}}for(d=1;d<a.hierarchy[b].keys.length;d++)a.hierarchy[b].keys[d].time===a.hierarchy[b].keys[d-1].time&&(a.hierarchy[b].keys.splice(d,1),d--);for(d=1;d<a.hierarchy[b].keys.length;d++)a.hierarchy[b].keys[d].index=d}d=parseInt(a.length*
A
alteredq 已提交
422 423 424 425 426 427
a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(b=0;b<a.hierarchy.length;b++)a.JIT.hierarchy.push(Array(d));a.initialized=!0}},get:function(a){if(typeof a==="string")return c[a]?c[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};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.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=b!==void 0?b:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==void 0?d:!0;this.points=[];this.target=new THREE.Vector3};
THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=c!==void 0?c:0;var b,d=this.hierarchy.length,g;for(b=0;b<d;b++){g=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===void 0)g.animationCache={},g.animationCache.prevKey={pos:0,rot:0,scl:0},g.animationCache.nextKey={pos:0,rot:0,scl:0},g.animationCache.originalMatrix=g instanceof
THREE.Bone?g.skinMatrix:g.matrix;var e=g.animationCache.prevKey;g=g.animationCache.nextKey;e.pos=this.data.hierarchy[b].keys[0];e.rot=this.data.hierarchy[b].keys[0];e.scl=this.data.hierarchy[b].keys[0];g.pos=this.getNextKeyWith("pos",b,1);g.rot=this.getNextKeyWith("rot",b,1);g.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
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.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
A
alteredq 已提交
428 429 430
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,g,e,f,h,i,k,l=this.data.JIT.hierarchy,o,p;this.currentTime+=a*this.timeScale;p=this.currentTime;o=this.currentTime%=this.data.length;k=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,r=this.hierarchy.length;n<r;n++)if(a=this.hierarchy[n],i=a.animationCache,this.JITCompile&&l[n][k]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=l[n][k],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
!1):(a.matrix=l[n][k],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var m=0;m<3;m++){b=c[m];f=i.prevKey[b];h=i.nextKey[b];if(h.time<=p){if(o<p)if(this.loop){f=this.data.hierarchy[n].keys[0];for(h=this.getNextKeyWith(b,n,1);h.time<o;)f=h,h=this.getNextKeyWith(b,n,h.index+1)}else{this.stop();return}else{do f=h,h=this.getNextKeyWith(b,n,h.index+1);while(h.time<
o)}i.prevKey[b]=f;i.nextKey[b]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(o-f.time)/(h.time-f.time);g=f[b];e=h[b];if(d<0||d>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
M
Mr.doob 已提交
431
this.getPrevKeyWith("pos",n,f.index-1).pos,this.points[1]=g,this.points[2]=e,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b===
A
alteredq 已提交
432 433
"rot")THREE.Quaternion.slerp(g,e,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].update(null,!0);for(n=0;n<this.hierarchy.length;n++)l[n][k]=this.hierarchy[n]instanceof THREE.Bone?this.hierarchy[n].skinMatrix.clone():this.hierarchy[n].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],g,e,f,h,i,k;g=(a.length-1)*c;e=Math.floor(g);g-=e;b[0]=e===0?e:e-1;b[1]=e;b[2]=e>a.length-2?e:e+1;b[3]=e>a.length-3?e:e+2;e=a[b[0]];h=a[b[1]];i=a[b[2]];k=a[b[3]];b=g*g;f=g*b;d[0]=this.interpolate(e[0],h[0],i[0],k[0],g,b,f);d[1]=this.interpolate(e[1],h[1],i[1],k[1],g,b,f);d[2]=this.interpolate(e[2],h[2],i[2],k[2],g,b,f);return d};
A
alteredq 已提交
434 435 436 437 438 439 440 441 442 443 444 445 446
THREE.Animation.prototype.interpolate=function(a,c,b,d,g,e,f){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*f+(-3*(c-b)-2*a-d)*e+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<d.length-1?b:d.length-1:b%=d.length;b<d.length;b++)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[0]};
THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var d=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[d.length-1]};
THREE.CubeCamera=function(a,c,b,d){this.heightOffset=b;this.position=new THREE.Vector3(0,b,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=
this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ=
new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+=
1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var c=this.renderTarget;c.activeCubeFace=0;a.render(b,this.cameraPX,c);c.activeCubeFace=1;a.render(b,this.cameraNX,c);c.activeCubeFace=2;a.render(b,this.cameraPY,c);c.activeCubeFace=3;a.render(b,
this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")};
THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,c,b,d,g,e,f){THREE.Camera.call(this);this.fov=b;this.left=-a/2;this.right=a/2;this.top=c/2;this.bottom=-c/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,e,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,d,g);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1};
THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov/2)*((this.cameraP.near+this.cameraP.far)/2),c=2*a*this.cameraP.aspect/2;a/=this.zoom;c/=this.zoom;this.cameraO.left=-c;this.cameraO.right=c;this.cameraO.top=a;this.cameraO.bottom=-a;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0};
THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
A
alteredq 已提交
447
THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
A
alteredq 已提交
448 449 450 451 452 453 454
0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
function(a){switch(a.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;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.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;break;case 82:this.moveUp=
!1;break;case 70:this.moveDown=!1}};this.update=function(a){if(!this.freeze){if(this.heightSpeed){var b=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*b*this.heightCoef}else this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&&this.object.translateX(b);
this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);b=a*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);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 a=this.target,c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&&
(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b*a);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;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);
this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};
A
alteredq 已提交
455
THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),s=g.length,u=0;f=s-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<s-1;f++)u=d*h.chunks[f]/h.total,b.keys[f]={time:u,pos:g[f]};e.hierarchy[0]=
A
alteredq 已提交
456
b;THREE.AnimationHandler.add(e);return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}this.object=a;this.domElement=c!==void 0?c:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=
A
alteredq 已提交
457
new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
A
alteredq 已提交
458 459 460 461
this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var f=Math.PI*2,h=Math.PI/180;this.update=function(a){var c;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%f;this.phi=a>=0?a:a+f;c=this.verticalAngleMap.srcRange;
a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var d=a[1]-a[0];this.phi=b((c-a[0])/d)*d+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);d=a[1]-a[0];this.theta=b((c-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=g(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
M
Mr.doob 已提交
462
this.debugPath,b=this.spline,f=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),n=0;n<b.points.length;n++)c=new THREE.Mesh(f,h),c.position.copy(b.points[n]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
A
alteredq 已提交
463
!1)}};THREE.PathControlsIdCounter=0;
A
alteredq 已提交
464
THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=c!==void 0?c:document;c&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
A
alteredq 已提交
465 466 467 468 469 470 471 472
0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
!0;break;case 2:this.object.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),c=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=
!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion);
this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,
this.mouseup),!1);this.domElement.addEventListener("keydown",b(this,this.keydown),!1);this.domElement.addEventListener("keyup",b(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};
A
alteredq 已提交
473 474
THREE.RollControls=function(a,c){this.object=a;this.domElement=c!==void 0?c:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var b=new THREE.Vector3,d=new THREE.Vector3,g=new THREE.Vector3,e=new THREE.Matrix4,f=!1,h=1,i=0,k=0,l=0,o=0,p=0,n=window.innerWidth/2,r=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed;
this.rotateHorizontally(c*o);this.rotateVertically(c*p)}c=a*this.movementSpeed;this.object.translateZ(-c*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*k);this.object.translateY(c*l);f&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();g.copy(this.forward);d.set(0,1,0);b.cross(d,
A
alteredq 已提交
475 476 477
g).normalize();d.cross(g,b).normalize();this.object.matrix.n11=b.x;this.object.matrix.n12=d.x;this.object.matrix.n13=g.x;this.object.matrix.n21=b.y;this.object.matrix.n22=d.y;this.object.matrix.n23=g.y;this.object.matrix.n31=b.z;this.object.matrix.n32=d.z;this.object.matrix.n33=g.z;e.identity();e.n11=Math.cos(this.roll);e.n12=-Math.sin(this.roll);e.n21=Math.sin(this.roll);e.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(e);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){b.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);b.multiplyScalar(a);this.forward.subSelf(b);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
A
alteredq 已提交
478 479
function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){o=(a.clientX-n)/window.innerWidth;p=(a.clientY-r)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
function(a){switch(a.keyCode){case 38:case 87:i=1;break;case 37:case 65:k=-1;break;case 40:case 83:i=-1;break;case 39:case 68:k=1;break;case 81:f=!0;h=1;break;case 69:f=!0;h=-1;break;case 82:l=1;break;case 70:l=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:k=0;break;case 40:case 83:i=0;break;case 39:case 68:k=0;break;case 81:f=!1;break;case 69:f=!1;break;case 82:l=0;break;case 70:l=0}},!1)};
A
alteredq 已提交
480
THREE.TrackballControls=function(a,c){var b=this,d={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};this.object=a;this.domElement=c!==void 0?c:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=
A
alteredq 已提交
481
new THREE.Vector3(0,0,0);var g=!1,e=d.NONE,f=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector2,l=new THREE.Vector2,o=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a-b.screen.offsetLeft)/b.radius*0.5,(c-b.screen.offsetTop)/b.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var d=new THREE.Vector3((a-b.screen.width*0.5-b.screen.offsetLeft)/
A
alteredq 已提交
482
b.radius,(b.screen.height*0.5+b.screen.offsetTop-c)/b.radius,0),e=d.length();e>1?d.normalize():d.z=Math.sqrt(1-e*e);f.copy(b.object.position).subSelf(b.target);e=b.object.up.clone().setLength(d.y);e.addSelf(b.object.up.clone().crossSelf(f).setLength(d.x));e.addSelf(f.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var c=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=b.rotateSpeed;d.setFromAxisAngle(c,-a);d.multiplyVector3(f);
A
alteredq 已提交
483 484 485 486
d.multiplyVector3(b.object.up);d.multiplyVector3(i);b.staticMoving?h=i:(d.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(l.y-k.y)*b.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),b.staticMoving?k=l:k.y+=(l.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(f.length()*b.panSpeed);var c=f.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y));
b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?o=p:o.addSelf(a.sub(p,o).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),f.lengthSq()<b.minDistance*b.minDistance&&b.object.position.add(b.target,f.setLength(b.minDistance))};this.update=function(){f.copy(b.object.position).subSelf(this.target);b.rotateCamera();b.noZoom||b.zoomCamera();b.noPan||
b.panCamera();b.object.position.add(b.target,f);b.checkDistances();b.object.lookAt(b.target)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){b.enabled&&(g&&(h=i=b.getMouseProjectionOnBall(a.clientX,a.clientY),k=l=b.getMouseOnScreen(a.clientX,a.clientY),o=p=b.getMouseOnScreen(a.clientX,a.clientY),g=!1),e!==d.NONE&&(e===d.ROTATE?i=b.getMouseProjectionOnBall(a.clientX,a.clientY):e===d.ZOOM&&!b.noZoom?l=b.getMouseOnScreen(a.clientX,
a.clientY):e===d.PAN&&!b.noPan&&(p=b.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(b.enabled&&(a.preventDefault(),a.stopPropagation(),e===d.NONE))e=a.button,e===d.ROTATE?h=i=b.getMouseProjectionOnBall(a.clientX,a.clientY):e===d.ZOOM&&!b.noZoom?k=l=b.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(o=p=b.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",function(a){if(b.enabled)a.preventDefault(),a.stopPropagation(),
A
alteredq 已提交
487
e=d.NONE},!1);window.addEventListener("keydown",function(a){if(b.enabled&&e===d.NONE){if(a.keyCode===b.keys[d.ROTATE])e=d.ROTATE;else if(a.keyCode===b.keys[d.ZOOM]&&!b.noZoom)e=d.ZOOM;else if(a.keyCode===b.keys[d.PAN]&&!b.noPan)e=d.PAN;e!==d.NONE&&(g=!0)}},!1);window.addEventListener("keyup",function(){if(b.enabled&&e!==d.NONE)e=d.NONE},!1)};
A
alteredq 已提交
488 489 490 491 492 493 494
THREE.CubeGeometry=function(a,c,b,d,g,e,f,h){function i(a,b,c,f,h,i,l,m){var n,o,p=d||1,r=g||1,s=h/2,q=i/2,u=k.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x")n="y",r=e||1;else if(a==="z"&&b==="y"||a==="y"&&b==="z")n="x",p=e||1;var t=p+1,H=r+1;h/=p;var z=i/r;for(o=0;o<H;o++)for(i=0;i<t;i++){var L=new THREE.Vector3;L[a]=(i*h-s)*c;L[b]=(o*z-q)*f;L[n]=l;k.vertices.push(new THREE.Vertex(L))}for(o=0;o<r;o++)for(i=0;i<p;i++)k.faces.push(new THREE.Face4(i+
t*o+u,i+t*(o+1)+u,i+1+t*(o+1)+u,i+1+t*o+u,null,null,m)),k.faceVertexUvs[0].push([new THREE.UV(i/p,o/r),new THREE.UV(i/p,(o+1)/r),new THREE.UV((i+1)/p,(o+1)/r),new THREE.UV((i+1)/p,o/r)])}THREE.Geometry.call(this);var k=this,l=a/2,o=c/2,p=b/2,n,r,m,s,u,t;if(f!==void 0){if(f instanceof Array)this.materials=f;else{this.materials=[];for(n=0;n<6;n++)this.materials.push(f)}n=0;s=1;r=2;u=3;m=4;t=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=void 0)for(var q in h)this.sides[q]!=
void 0&&(this.sides[q]=h[q]);this.sides.px&&i("z","y",-1,-1,b,c,l,n);this.sides.nx&&i("z","y",1,-1,b,c,-l,s);this.sides.py&&i("x","z",1,1,a,b,o,r);this.sides.ny&&i("x","z",1,-1,a,b,-o,u);this.sides.pz&&i("x","y",1,-1,a,c,p,m);this.sides.nz&&i("x","y",-1,-1,a,c,-p,t);this.mergeVertices();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
THREE.CylinderGeometry=function(a,c,b,d,g,e){THREE.Geometry.call(this);var a=a!=null?a:20,c=c!=null?c:20,b=b||100,f=b/2,d=d||8,g=g||1,h,i,k=[],l=[];for(i=0;i<=g;i++){var o=[],p=[],n=i/g,r=n*(c-a)+a;for(h=0;h<=d;h++){var m=h/d;this.vertices.push(new THREE.Vertex(new THREE.Vector3(r*Math.sin(m*Math.PI*2),-n*b+f,r*Math.cos(m*Math.PI*2))));o.push(this.vertices.length-1);p.push(new THREE.UV(m,n))}k.push(o);l.push(p)}for(i=0;i<g;i++)for(h=0;h<d;h++){var b=k[i][h],o=k[i+1][h],p=k[i+1][h+1],n=k[i][h+1],r=
this.vertices[b].position.clone().setY(0).normalize(),m=this.vertices[o].position.clone().setY(0).normalize(),s=this.vertices[p].position.clone().setY(0).normalize(),u=this.vertices[n].position.clone().setY(0).normalize(),t=l[i][h].clone(),q=l[i+1][h].clone(),A=l[i+1][h+1].clone(),w=l[i][h+1].clone();this.faces.push(new THREE.Face4(b,o,p,n,[r,m,s,u]));this.faceVertexUvs[0].push([t,q,A,w])}if(!e&&a>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h<d;h++)b=k[0][h],o=k[0][h+
1],p=this.vertices.length-1,r=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,1,0),t=l[0][h].clone(),q=l[0][h+1].clone(),A=new THREE.UV(q.u,0),this.faces.push(new THREE.Face3(b,o,p,[r,m,s])),this.faceVertexUvs[0].push([t,q,A])}if(!e&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h<d;h++)b=k[i][h+1],o=k[i][h],p=this.vertices.length-1,r=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),s=new THREE.Vector3(0,-1,0),t=l[i][h+1].clone(),q=l[i][h].clone(),
A=new THREE.UV(q.u,1),this.faces.push(new THREE.Face3(b,o,p,[r,m,s])),this.faceVertexUvs[0].push([t,q,A])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
A
alteredq 已提交
495 496
THREE.ExtrudeGeometry=function(a,c){if(typeof a!=="undefined"){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],b,d=a.length,g;this.shapebb=a[d-1].getBoundingBox();for(b=0;b<d;b++)g=a[b],this.addShape(g,c);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
THREE.ExtrudeGeometry.prototype.addShape=function(a,c){function b(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
A
alteredq 已提交
497 498 499 500 501 502 503
h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);f===0&&(console.log("Either infinite or no solutions!"),g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;if(g<0)return b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(F=a.length;--F>=0;){j=F;aa=F-1;aa<0&&(aa=a.length-1);for(var b=
0,c=n+l*2,b=0;b<c;b++){var d=V*b,e=V*(b+1),f=ga+j+d,g=ga+j+e,k=f,d=ga+aa+d,e=ga+aa+e,m=g;k+=D;d+=D;e+=D;m+=D;M.faces.push(new THREE.Face4(k,d,e,m,null,null,A));A&&(k=b/c,d=(b+1)/c,e=h+i*2,f=(M.vertices[f].position.z+i)/e,g=(M.vertices[g].position.z+i)/e,M.faceVertexUvs[0].push([new THREE.UV(f,k),new THREE.UV(g,k),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function e(a,b,c){M.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=D;b+=D;c+=D;M.faces.push(new THREE.Face3(a,b,c,
null,null,q));if(q){var d=w.maxY,e=w.maxX,f=M.vertices[b].position.x,b=M.vertices[b].position.y,g=M.vertices[c].position.x,c=M.vertices[c].position.y;M.faceVertexUvs[0].push([new THREE.UV(M.vertices[a].position.x/e,M.vertices[a].position.y/d),new THREE.UV(f/e,b/d),new THREE.UV(g/e,c/d)])}}var h=c.amount!==void 0?c.amount:100,i=c.bevelThickness!==void 0?c.bevelThickness:6,k=c.bevelSize!==void 0?c.bevelSize:i-2,l=c.bevelSegments!==void 0?c.bevelSegments:3,o=c.bevelEnabled!==void 0?c.bevelEnabled:!0,
p=c.curveSegments!==void 0?c.curveSegments:12,n=c.steps!==void 0?c.steps:1,r=c.bendPath,m=c.extrudePath,s,u=!1,t=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,q=c.material,A=c.extrudeMaterial,w=this.shapebb;if(m)s=m.getPoints(p),n=s.length,u=!0,o=!1;o||(k=i=l=0);var E,x,I,M=this,D=this.vertices.length;r&&a.addWrapPath(r);p=t?a.extractAllSpacedPoints(p):a.extractAllPoints(p);r=p.shape;p=p.holes;if(m=!THREE.Shape.Utils.isClockWise(r)){r=r.reverse();x=0;for(I=p.length;x<I;x++)E=p[x],THREE.Shape.Utils.isClockWise(E)&&
(p[x]=E.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(r,p);t=r;x=0;for(I=p.length;x<I;x++)E=p[x],r=r.concat(E);var F,P,K,$,S,R,V=r.length,ja=m.length,y=[];F=0;P=t.length;j=P-1;for(aa=F+1;F<P;F++,j++,aa++)j===P&&(j=0),aa===P&&(aa=0),y[F]=d(t[F],t[j],t[aa]);var H=[],z,L=y.concat();x=0;for(I=p.length;x<I;x++){E=p[x];z=[];F=0;P=E.length;j=P-1;for(aa=F+1;F<P;F++,j++,aa++)j===P&&(j=0),aa===P&&(aa=0),z[F]=d(E[F],E[j],E[aa]);H.push(z);L=L.concat(z)}for(K=0;K<l;K++){$=K/l;S=i*(1-$);$=k*Math.sin($*Math.PI/
2);F=0;for(P=t.length;F<P;F++)R=b(t[F],y[F],$),e(R.x,R.y,-S);x=0;for(I=p.length;x<I;x++){E=p[x];z=H[x];F=0;for(P=E.length;F<P;F++)R=b(E[F],z[F],$),e(R.x,R.y,-S)}}$=k;for(F=0;F<V;F++)R=o?b(r[F],L[F],$):r[F],u?e(R.x,R.y+s[0].y,s[0].x):e(R.x,R.y,0);for(K=1;K<=n;K++)for(F=0;F<V;F++)R=o?b(r[F],L[F],$):r[F],u?e(R.x,R.y+s[K-1].y,s[K-1].x):e(R.x,R.y,h/n*K);for(K=l-1;K>=0;K--){$=K/l;S=i*(1-$);$=k*Math.sin($*Math.PI/2);F=0;for(P=t.length;F<P;F++)R=b(t[F],y[F],$),e(R.x,R.y,h+S);x=0;for(I=p.length;x<I;x++){E=
p[x];z=H[x];F=0;for(P=E.length;F<P;F++)R=b(E[F],z[F],$),u?e(R.x,R.y+s[n-1].y,s[n-1].x+S):e(R.x,R.y,h+S)}}if(o){o=V*0;for(F=0;F<ja;F++)k=m[F],f(k[2]+o,k[1]+o,k[0]+o);o=V*(n+l*2);for(F=0;F<ja;F++)k=m[F],f(k[0]+o,k[1]+o,k[2]+o)}else{for(F=0;F<ja;F++)k=m[F],f(k[2],k[1],k[0]);for(F=0;F<ja;F++)k=m[F],f(k[0]+V*n,k[1]+V*n,k[2]+V*n)}var j,aa,ga=0;g(t);ga+=t.length;x=0;for(I=p.length;x<I;x++)E=p[x],g(E),ga+=E.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
A
alteredq 已提交
504 505
THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
THREE.IcosahedronGeometry=function(a){function c(a,b,c){var d=Math.sqrt(a*a+b*b+c*c);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(a/d,b/d,c/d)))-1}function b(a,b,c,d){d.faces.push(new THREE.Face3(a,b,c))}function d(a,b){var d=g.vertices[a].position,e=g.vertices[b].position;return c((d.x+e.x)/2,(d.y+e.y)/2,(d.z+e.z)/2)}var g=this,e=new THREE.Geometry;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
alteredq 已提交
506 507
-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,e);b(0,5,1,e);b(0,1,7,e);b(0,7,10,e);b(0,10,11,e);b(1,5,9,e);b(5,11,4,e);b(11,10,2,e);b(10,7,6,e);b(7,1,8,e);b(3,9,4,e);b(3,4,2,e);b(3,2,6,e);b(3,6,8,e);b(3,8,9,e);b(4,9,5,e);b(2,4,11,e);b(6,2,10,e);b(8,6,7,e);b(9,8,1,e);for(var f=0;f<this.subdivisions;f++){var a=new THREE.Geometry,h;for(h in e.faces){var i=d(e.faces[h].a,e.faces[h].b),k=d(e.faces[h].b,e.faces[h].c),l=d(e.faces[h].c,e.faces[h].a);b(e.faces[h].a,i,l,a);b(e.faces[h].b,k,
i,a);b(e.faces[h].c,l,k,a);b(i,k,l,a)}e.faces=a.faces}g.faces=e.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
A
alteredq 已提交
508
THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],d=[],g=[],e=[],f=(new THREE.Matrix4).setRotationZ(c),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),b[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.0010;i+=c){for(h=0;h<b.length;h++)i<this.angle?(b[h]=f.multiplyVector3(b[h].clone()),this.vertices.push(new THREE.Vertex(b[h])),g[h]=this.vertices.length-1):g=e;i==0&&(e=d);
A
alteredq 已提交
509 510 511 512 513
for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(g[h],g[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-i/this.angle,h/a.length),new THREE.UV(1-i/this.angle,(h+1)/a.length),new THREE.UV(1-(i-c)/this.angle,(h+1)/a.length),new THREE.UV(1-(i-c)/this.angle,h/a.length)]);d=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
THREE.OctahedronGeometry=function(a,c){function b(b){var c=b.clone().normalize(),c=new THREE.Vertex(c.clone().multiplyScalar(a));c.index=f.vertices.push(c)-1;c.uv=new THREE.UV(Math.atan2(b.z,-b.x)/2/Math.PI+0.5,Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))/Math.PI+0.5);return c}function d(a,b,c,h){h<1?(h=new THREE.Face3(a.index,b.index,c.index,[a.position,b.position,c.position]),h.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),h.normal=h.centroid.clone().normalize(),
f.faces.push(h),h=Math.atan2(h.centroid.z,-h.centroid.x),f.faceVertexUvs[0].push([e(a.uv,a.position,h),e(b.uv,b.position,h),e(c.uv,c.position,h)])):(h-=1,d(a,g(a,b),g(a,c),h),d(g(a,b),b,g(b,c),h),d(g(a,c),g(b,c),c,h),d(g(a,b),g(b,c),g(a,c),h))}function g(a,c){h[a.index]||(h[a.index]=[]);h[c.index]||(h[c.index]=[]);var d=h[a.index][c.index];d===void 0&&(h[a.index][c.index]=h[c.index][a.index]=d=b((new THREE.Vector3).add(a.position,c.position).divideScalar(2)));return d}function e(a,b,c){c<0&&a.u===
1&&(a=new THREE.UV(a.u-1,a.v));b.x===0&&b.z===0&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);var c=c||0,f=this;b(new THREE.Vector3(1,0,0));b(new THREE.Vector3(-1,0,0));b(new THREE.Vector3(0,1,0));b(new THREE.Vector3(0,-1,0));b(new THREE.Vector3(0,0,1));b(new THREE.Vector3(0,0,-1));var h=[],i=this.vertices;d(i[0],i[2],i[4],c);d(i[0],i[4],i[3],c);d(i[0],i[3],i[5],c);d(i[0],i[5],i[2],c);d(i[1],i[2],i[5],c);d(i[1],i[5],i[3],c);d(i[1],i[3],i[4],c);d(i[1],i[4],i[2],c);this.boundingSphere=
{radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
A
alteredq 已提交
514
THREE.PlaneGeometry=function(a,c,b,d){THREE.Geometry.call(this);var g,e=a/2,f=c/2,b=b||1,d=d||1,h=b+1,i=d+1;a/=b;var k=c/d;for(g=0;g<i;g++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-e,-(g*k-f),0)));for(g=0;g<d;g++)for(c=0;c<b;c++)this.faces.push(new THREE.Face4(c+h*g,c+h*(g+1),c+1+h*(g+1),c+1+h*g)),this.faceVertexUvs[0].push([new THREE.UV(c/b,g/d),new THREE.UV(c/b,(g+1)/d),new THREE.UV((c+1)/b,(g+1)/d),new THREE.UV((c+1)/b,g/d)]);this.computeCentroids();this.computeFaceNormals()};
A
alteredq 已提交
515
THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
A
alteredq 已提交
516 517 518
THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,d,g=Math.PI,e=Math.max(3,c||8),f=Math.max(2,b||6),c=[],b=0;b<f+1;b++){d=b/f;var h=a*Math.cos(d*g),i=a*Math.sin(d*g),k=[],l=0;for(d=0;d<e;d++){var o=2*d/e,p=i*Math.sin(o*g),o=i*Math.cos(o*g);(b==0||b==f)&&d>0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,h,p)))-1);k.push(l)}c.push(k)}for(var n,r,m,g=c.length,b=0;b<g;b++)if(e=c[b].length,b>0)for(d=0;d<e;d++){k=d==e-1;f=c[b][k?0:d+1];h=c[b][k?e-1:d];i=c[b-1][k?
e-1:d];k=c[b-1][k?0:d+1];p=b/(g-1);n=(b-1)/(g-1);r=(d+1)/e;var o=d/e,l=new THREE.UV(1-r,p),p=new THREE.UV(1-o,p),o=new THREE.UV(1-o,n),s=new THREE.UV(1-r,n);b<c.length-1&&(n=this.vertices[f].position.clone(),r=this.vertices[h].position.clone(),m=this.vertices[i].position.clone(),n.normalize(),r.normalize(),m.normalize(),this.faces.push(new THREE.Face3(f,h,i,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([l,p,o]));b>1&&(n=
this.vertices[f].position.clone(),r=this.vertices[i].position.clone(),m=this.vertices[k].position.clone(),n.normalize(),r.normalize(),m.normalize(),this.faces.push(new THREE.Face3(f,i,k,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([l,o,s]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
A
alteredq 已提交
519 520 521
THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var d=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
A
alteredq 已提交
522
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var c=this.getFace(),b=this.size/c.resolution,d=
A
alteredq 已提交
523 524 525 526 527 528
0,g=String(a).split(""),e=g.length,f=[],a=0;a<e;a++){var h=new THREE.Path,h=this.extractGlyphPoints(g[a],c,b,d,h);d+=h.offset;f.push(h.path)}return{paths:f,offset:d/2}},extractGlyphPoints:function(a,c,b,d,g){var e=[],f,h,i,k,l,o,p,n,r,m,s,u=c.glyphs[a]||c.glyphs["?"];if(u){if(u.o){c=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=c.length;for(a=0;a<k;)switch(i=c[a++],i){case "m":i=c[a++]*b+d;l=c[a++]*b;e.push(new THREE.Vector2(i,l));g.moveTo(i,l);break;case "l":i=c[a++]*b+d;l=c[a++]*b;e.push(new THREE.Vector2(i,
l));g.lineTo(i,l);break;case "q":i=c[a++]*b+d;l=c[a++]*b;n=c[a++]*b+d;r=c[a++]*b;g.quadraticCurveTo(n,r,i,l);if(f=e[e.length-1]){o=f.x;p=f.y;f=1;for(h=this.divisions;f<=h;f++){var t=f/h,q=THREE.Shape.Utils.b2(t,o,n,i),t=THREE.Shape.Utils.b2(t,p,r,l);e.push(new THREE.Vector2(q,t))}}break;case "b":if(i=c[a++]*b+d,l=c[a++]*b,n=c[a++]*b+d,r=c[a++]*-b,m=c[a++]*b+d,s=c[a++]*-b,g.bezierCurveTo(i,l,n,r,m,s),f=e[e.length-1]){o=f.x;p=f.y;f=1;for(h=this.divisions;f<=h;f++)t=f/h,q=THREE.Shape.Utils.b3(t,o,n,
m,i),t=THREE.Shape.Utils.b3(t,p,r,s,l),e.push(new THREE.Vector2(q,t))}}}return{offset:u.ha*b,points:e,path:g}}}};
(function(a){var c=function(a){for(var c=a.length,g=0,e=c-1,f=0;f<c;e=f++)g+=a[e].x*a[f].y-a[f].x*a[e].y;return g*0.5};a.Triangulate=function(a,d){var g=a.length;if(g<3)return null;var e=[],f=[],h=[],i,k,l;if(c(a)>0)for(k=0;k<g;k++)f[k]=k;else for(k=0;k<g;k++)f[k]=g-1-k;var o=2*g;for(k=g-1;g>2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return e}i=k;g<=i&&(i=0);k=i+1;g<=k&&(k=0);l=k+1;g<=l&&(l=0);var p;a:{p=a;var n=i,r=k,m=l,s=g,u=f,t=void 0,q=void 0,A=void 0,
w=void 0,E=void 0,x=void 0,I=void 0,M=void 0,D=void 0,q=p[u[n]].x,A=p[u[n]].y,w=p[u[r]].x,E=p[u[r]].y,x=p[u[m]].x,I=p[u[m]].y;if(1.0E-10>(w-q)*(I-A)-(E-A)*(x-q))p=!1;else{for(t=0;t<s;t++)if(!(t==n||t==r||t==m)){var M=p[u[t]].x,D=p[u[t]].y,F=void 0,P=void 0,K=void 0,$=void 0,S=void 0,R=void 0,V=void 0,ja=void 0,y=void 0,H=void 0,z=void 0,L=void 0,F=K=S=void 0,F=x-w,P=I-E,K=q-x,$=A-I,S=w-q,R=E-A,V=M-q,ja=D-A,y=M-w,H=D-E,z=M-x,L=D-I,F=F*H-P*y,S=S*ja-R*V,K=K*L-$*z;if(F>=0&&K>=0&&S>=0){p=!1;break a}}p=
!0}}if(p){e.push([a[f[i]],a[f[k]],a[f[l]]]);h.push([f[i],f[k],f[l]]);i=k;for(l=k+1;l<g;i++,l++)f[i]=f[l];g--;o=2*g}}if(d)return h;return e};a.Triangulate.area=c;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
A
alteredq 已提交
529 530 531 532 533
THREE.TorusGeometry=function(a,c,b,d,g){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;this.arc=g||Math.PI*2;g=new THREE.Vector3;a=[];c=[];for(b=0;b<=this.segmentsR;b++)for(d=0;d<=this.segmentsT;d++){var e=d/this.segmentsT*this.arc,f=b/this.segmentsR*Math.PI*2;g.x=this.radius*Math.cos(e);g.y=this.radius*Math.sin(e);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(f))*Math.cos(e);h.y=(this.radius+this.tube*Math.cos(f))*Math.sin(e);h.z=
this.tube*Math.sin(f);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-b/this.segmentsR));c.push(h.clone().subSelf(g).normalize())}for(b=1;b<=this.segmentsR;b++)for(d=1;d<=this.segmentsT;d++){var g=(this.segmentsT+1)*b+d-1,e=(this.segmentsT+1)*(b-1)+d-1,f=(this.segmentsT+1)*(b-1)+d,h=(this.segmentsT+1)*b+d,i=new THREE.Face4(g,e,f,h,[c[g],c[e],c[f],c[h]]);i.normal.addSelf(c[g]);i.normal.addSelf(c[e]);i.normal.addSelf(c[f]);i.normal.addSelf(c[h]);i.normal.normalize();this.faces.push(i);
this.faceVertexUvs[0].push([a[g].clone(),a[e].clone(),a[f].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
THREE.TorusKnotGeometry=function(a,c,b,d,g,e,f){function h(a,b,c,d,e,f){b=c/d*a;c=Math.cos(b);return new THREE.Vector3(e*(2+c)*0.5*Math.cos(a),e*(2+c)*Math.sin(a)*0.5,f*e*Math.sin(b)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=g||2;this.q=e||3;this.heightScale=f||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<
this.segmentsT;++c){var i=a/this.segmentsR*2*this.p*Math.PI,f=c/this.segmentsT*2*Math.PI,g=h(i,f,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,f,this.q,this.p,this.radius,this.heightScale);b.x=i.x-g.x;b.y=i.y-g.y;b.z=i.z-g.z;d.x=i.x+g.x;d.y=i.y+g.y;d.z=i.z+g.z;e.cross(b,d);d.cross(e,b);e.normalize();d.normalize();i=-this.tube*Math.cos(f);f=this.tube*Math.sin(f);g.x+=i*d.x+f*e.x;g.y+=i*d.y+f*e.y;g.z+=i*d.z+f*e.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,
A
alteredq 已提交
534
g.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=0;c<this.segmentsT;++c){var d=(a+1)%this.segmentsR,e=(c+1)%this.segmentsT,g=this.grid[a][c],b=this.grid[d][c],d=this.grid[d][e],e=this.grid[a][e],f=new THREE.UV(a/this.segmentsR,c/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT),k=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),l=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,b,d,e));this.faceVertexUvs[0].push([f,i,k,l])}this.computeCentroids();
A
alteredq 已提交
535
this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var c=this.subdivisions;c-- >0;)this.smooth(a)};
A
alteredq 已提交
536 537 538 539 540 541 542
THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){k.vertexColors=[];for(var j,l,m,n=0;n<4;n++){m=i[n];j=new THREE.Color;j.setRGB(0,0,0);for(var o=0;o<m.length;o++)l=h.vertexColors[m[o]-1],j.r+=l.r,j.g+=l.g,j.b+=l.b;j.r/=m.length;j.g/=m.length;j.b/=m.length;k.vertexColors[n]=j}}g.push(k);(!f.supportUVs||p.length!=0)&&e.push([p[a],p[b],p[c],p[d]])}function b(a,b){return Math.min(a,b)+"_"+Math.max(a,
b)}var d=[],g=[],e=[],f=this,h=a.vertices,d=a.faces,i=h.concat(),k=[],l={},o={},p=[],n,r,m,s,u,t=a.faceVertexUvs[0];n=0;for(r=t.length;n<r;n++){m=0;for(s=t[n].length;m<s;m++)u=d[n]["abcd".charAt(m)],p[u]||(p[u]=t[n][m])}var q;n=0;for(r=d.length;n<r;n++)if(u=d[n],k.push(u.centroid),i.push(new THREE.Vertex(u.centroid)),f.supportUVs&&p.length!=0){q=new THREE.UV;if(u instanceof THREE.Face3)q.u=p[u.a].u+p[u.b].u+p[u.c].u,q.v=p[u.a].v+p[u.b].v+p[u.c].v,q.u/=3,q.v/=3;else if(u instanceof THREE.Face4)q.u=
p[u.a].u+p[u.b].u+p[u.c].u+p[u.d].u,q.v=p[u.a].v+p[u.b].v+p[u.c].v+p[u.d].v,q.u/=4,q.v/=4;p.push(q)}r=function(a){function c(a,b,d){a[b]===void 0&&(a[b]=[]);a[b].push(d)}var d,e,f,g,h={};d=0;for(e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=b(f.a,f.b),c(h,g,d),g=b(f.b,f.c),c(h,g,d),g=b(f.c,f.a),c(h,g,d)):f instanceof THREE.Face4&&(g=b(f.a,f.b),c(h,g,d),g=b(f.b,f.c),c(h,g,d),g=b(f.c,f.d),c(h,g,d),g=b(f.d,f.a),c(h,g,d));return h}(a);var A=0,t=h.length,w,E,x={},I={},M=function(a,
b){x[a]===void 0&&(x[a]=[]);x[a].push(b)},D=function(a,b){I[a]===void 0&&(I[a]={});I[a][b]=null};for(n in r){q=r[n];w=n.split("_");E=w[0];w=w[1];M(E,[E,w]);M(w,[E,w]);m=0;for(s=q.length;m<s;m++)u=q[m],D(E,u,n),D(w,u,n);q.length<2&&(o[n]=!0)}for(n in r)if(q=r[n],u=q[0],q=q[1],w=n.split("_"),E=w[0],w=w[1],s=new THREE.Vector3,o[n]?(s.addSelf(h[E].position),s.addSelf(h[w].position),s.multiplyScalar(0.5)):(s.addSelf(k[u]),s.addSelf(k[q]),s.addSelf(h[E].position),s.addSelf(h[w].position),s.multiplyScalar(0.25)),
l[n]=t+d.length+A,i.push(new THREE.Vertex(s)),A++,f.supportUVs&&p.length!=0)q=new THREE.UV,q.u=p[E].u+p[w].u,q.v=p[E].v+p[w].v,q.u/=2,q.v/=2,p.push(q);var F,P;w=["123","12","2","23"];s=["123","23","3","31"];var M=["123","31","1","12"],D=["1234","12","2","23"],K=["1234","23","3","34"],$=["1234","34","4","41"],S=["1234","41","1","12"];n=0;for(r=k.length;n<r;n++)u=d[n],q=t+n,u instanceof THREE.Face3?(A=b(u.a,u.b),E=b(u.b,u.c),F=b(u.c,u.a),c(q,l[A],u.b,l[E],u,w),c(q,l[E],u.c,l[F],u,s),c(q,l[F],u.a,l[A],
u,M)):u instanceof THREE.Face4?(A=b(u.a,u.b),E=b(u.b,u.c),F=b(u.c,u.d),P=b(u.d,u.a),c(q,l[A],u.b,l[E],u,D),c(q,l[E],u.c,l[F],u,K),c(q,l[F],u.d,l[P],u,$),c(q,l[P],u.a,l[A],u,S)):console.log("face should be a face!",u);d=i;i=new THREE.Vector3;l=new THREE.Vector3;n=0;for(r=h.length;n<r;n++)if(x[n]!==void 0){i.set(0,0,0);l.set(0,0,0);u=new THREE.Vector3(0,0,0);q=0;for(m in I[n])i.addSelf(k[m]),q++;A=0;t=x[n].length;for(m=0;m<t;m++)o[b(x[n][m][0],x[n][m][1])]&&A++;if(A!=2){i.divideScalar(q);for(m=0;m<
t;m++)q=x[n][m],q=h[q[0]].position.clone().addSelf(h[q[1]].position).divideScalar(2),l.addSelf(q);l.divideScalar(t);u.addSelf(h[n].position);u.multiplyScalar(t-3);u.addSelf(i);u.addSelf(l.multiplyScalar(2));u.divideScalar(t);d[n].position=u}}a.vertices=d;a.faces=g;a.faceVertexUvs[0]=e;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
A
alteredq 已提交
543 544 545 546 547 548 549
THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
THREE.Loader.prototype={constructor:THREE.Loader,addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";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},extractUrlbase:function(a){a=a.split("/");a.pop();return a.length<1?"":a.join("/")+"/"},initMaterials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(c[d],b)},hasNormals:function(a){var c,b,d=a.materials.length;for(b=0;b<d;b++)if(c=a.materials[b],c instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,c){function b(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==
a}function d(a,c){var d=new Image;d.onload=function(){if(!b(this.width)||!b(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),d=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));a.image.width=c;a.image.height=d;a.image.getContext("2d").drawImage(this,0,0,c,d)}else a.image=this;a.needsUpdate=!0};d.src=c}function g(a,b,e,f,g,h){var i=document.createElement("canvas");a[b]=new THREE.Texture(i);a[b].sourceFile=e;if(f){a[b].repeat.set(f[0],f[1]);if(f[0]!=1)a[b].wrapS=THREE.RepeatWrapping;
if(f[1]!=1)a[b].wrapT=THREE.RepeatWrapping}g&&a[b].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[h[0]]!==void 0)a[b].wrapS=f[h[0]];if(f[h[1]]!==void 0)a[b].wrapT=f[h[1]]}d(a[b],c+"/"+e)}function e(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var f,h,i;h="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?h="MeshPhongMaterial":a.shading=="Basic"&&(h="MeshBasicMaterial"));
if(a.blending)if(a.blending=="Additive")f.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")f.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")f.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)f.transparent=a.transparent;if(a.depthTest!==void 0)f.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")f.vertexColors=THREE.FaceColors;else if(a.vertexColors)f.vertexColors=THREE.VertexColors;if(a.colorDiffuse)f.color=e(a.colorDiffuse);
else if(a.DbgColor)f.color=a.DbgColor;if(a.colorSpecular)f.specular=e(a.colorSpecular);if(a.colorAmbient)f.ambient=e(a.colorAmbient);if(a.transparency)f.opacity=a.transparency;if(a.specularCoef)f.shininess=a.specularCoef;a.mapDiffuse&&c&&g(f,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&c&&g(f,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&c&&g(f,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);
A
alteredq 已提交
550 551
a.mapSpecular&&c&&g(f,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var k=THREE.ShaderUtils.lib.normal,l=THREE.UniformsUtils.clone(k.uniforms),o=f.color;h=f.specular;i=f.ambient;var p=f.shininess;l.tNormal.texture=f.normalMap;if(a.mapNormalFactor)l.uNormalScale.value=a.mapNormalFactor;if(f.map)l.tDiffuse.texture=f.map,l.enableDiffuse.value=!0;if(f.specularMap)l.tSpecular.texture=f.specularMap,l.enableSpecular.value=!0;if(f.lightMap)l.tAO.texture=
f.lightMap,l.enableAO.value=!0;l.uDiffuseColor.value.setHex(o);l.uSpecularColor.value.setHex(h);l.uAmbientColor.value.setHex(i);l.uShininess.value=p;if(f.opacity)l.uOpacity.value=f.opacity;f=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:l,lights:!0,fog:!0})}else f=new THREE[h](f);return f}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
552 553 554 555 556
THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;THREE.BinaryLoader.prototype.load=function(a,c,b,d){if(a instanceof Object)console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath )."),d=a,a=d.model,c=d.callback,b=d.texture_path,d=d.bin_path;var b=b?b:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),g=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,c,b,d,g)};
THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,c,b,d,g,e){var f=new XMLHttpRequest;f.onreadystatechange=function(){if(f.readyState==4)if(f.status==200||f.status==0)try{var h=JSON.parse(f.responseText);h.metadata===void 0||h.metadata.formatVersion===void 0||h.metadata.formatVersion!==3?console.error("Deprecated file format."):a.loadAjaxBuffers(h,b,g,d,e)}catch(i){console.error(i),console.warn("DEPRECATED: ["+c+"] seems to be using old model format")}else console.error("Couldn't load ["+c+"] ["+
f.status+"]")};f.open("GET",c,!0);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,c,b,d,g){var e=new XMLHttpRequest,f=b+"/"+a.buffers,h=0;e.onreadystatechange=function(){e.readyState==4?e.status==200||e.status==0?THREE.BinaryLoader.prototype.createBinModel(e.responseText,c,d,a.materials):console.error("Couldn't load ["+f+"] ["+e.status+"]"):e.readyState==3?g&&(h==0&&(h=e.getResponseHeader("Content-Length")),g({total:h,loaded:e.responseText.length})):e.readyState==2&&(h=e.getResponseHeader("Content-Length"))};e.open("GET",
f,!0);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
A
alteredq 已提交
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
THREE.BinaryLoader.prototype.createBinModel=function(a,c,b,d){var g=function(b){function c(a,b){var d=l(a,b),e=l(a,b+1),f=l(a,b+2),g=l(a,b+3),h=(g<<1&255|f>>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&h==-127)return 0;return(1-2*(g>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,h)}function g(a,b){var c=l(a,b),d=l(a,b+1),e=l(a,b+2);return(l(a,b+3)<<24)+(e<<16)+(d<<8)+c}function i(a,b){var c=l(a,b);return(l(a,b+1)<<8)+c}function k(a,b){var c=l(a,b);return c>127?c-256:c}function l(a,b){return a.charCodeAt(b)&255}function o(b){var c,
d,e;c=g(a,b);d=g(a,b+E);e=g(a,b+x);b=i(a,b+I);u.faces.push(new THREE.Face3(c,d,e,null,null,b))}function p(b){var c,d,e,f,j,k,l;c=g(a,b);d=g(a,b+E);e=g(a,b+x);f=i(a,b+I);j=g(a,b+M);k=g(a,b+D);l=g(a,b+F);var b=A[k*3],m=A[k*3+1];k=A[k*3+2];var n=A[l*3],o=A[l*3+1];l=A[l*3+2];u.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(A[j*3],A[j*3+1],A[j*3+2]),new THREE.Vector3(b,m,k),new THREE.Vector3(n,o,l)],null,f))}function n(b){var c,d,e,f;c=g(a,b);d=g(a,b+P);e=g(a,b+K);f=g(a,b+$);b=i(a,b+S);u.faces.push(new THREE.Face4(c,
d,e,f,null,null,b))}function r(b){var c,d,e,f,j,k,l,m,n;c=g(a,b);d=g(a,b+P);e=g(a,b+K);f=g(a,b+$);j=i(a,b+S);k=g(a,b+R);l=g(a,b+V);m=g(a,b+ja);n=g(a,b+y);var b=A[l*3],o=A[l*3+1];l=A[l*3+2];var p=A[m*3],v=A[m*3+1];m=A[m*3+2];var J=A[n*3],r=A[n*3+1];n=A[n*3+2];u.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(A[k*3],A[k*3+1],A[k*3+2]),new THREE.Vector3(b,o,l),new THREE.Vector3(p,v,m),new THREE.Vector3(J,r,n)],null,j))}function m(b){var c,d,e,f;c=g(a,b);d=g(a,b+H);e=g(a,b+z);b=w[c*2];f=w[c*2+1];
c=w[d*2];var i=u.faceVertexUvs[0];d=w[d*2+1];var j=w[e*2];e=w[e*2+1];var k=[];k.push(new THREE.UV(b,f));k.push(new THREE.UV(c,d));k.push(new THREE.UV(j,e));i.push(k)}function s(b){var c,d,e,f,i,k;c=g(a,b);d=g(a,b+L);e=g(a,b+j);f=g(a,b+aa);b=w[c*2];i=w[c*2+1];c=w[d*2];k=w[d*2+1];d=w[e*2];var l=u.faceVertexUvs[0];e=w[e*2+1];var m=w[f*2];f=w[f*2+1];var n=[];n.push(new THREE.UV(b,i));n.push(new THREE.UV(c,k));n.push(new THREE.UV(d,e));n.push(new THREE.UV(m,f));l.push(n)}var u=this,t=0,q,A=[],w=[],E,x,
I,M,D,F,P,K,$,S,R,V,ja,y,H,z,L,j,aa,ga,N,W,T,ca,Q;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(u,d,b);q={signature:a.substr(t,8),header_bytes:l(a,t+8),vertex_coordinate_bytes:l(a,t+9),normal_coordinate_bytes:l(a,t+10),uv_coordinate_bytes:l(a,t+11),vertex_index_bytes:l(a,t+12),normal_index_bytes:l(a,t+13),uv_index_bytes:l(a,t+14),material_index_bytes:l(a,t+15),nvertices:g(a,t+16),nnormals:g(a,t+16+4),nuvs:g(a,t+16+8),ntri_flat:g(a,t+16+12),ntri_smooth:g(a,t+16+16),ntri_flat_uv:g(a,
t+16+20),ntri_smooth_uv:g(a,t+16+24),nquad_flat:g(a,t+16+28),nquad_smooth:g(a,t+16+32),nquad_flat_uv:g(a,t+16+36),nquad_smooth_uv:g(a,t+16+40)};t+=q.header_bytes;E=q.vertex_index_bytes;x=q.vertex_index_bytes*2;I=q.vertex_index_bytes*3;M=q.vertex_index_bytes*3+q.material_index_bytes;D=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;F=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;P=q.vertex_index_bytes;K=q.vertex_index_bytes*2;$=q.vertex_index_bytes*3;S=q.vertex_index_bytes*
4;R=q.vertex_index_bytes*4+q.material_index_bytes;V=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes;ja=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*2;y=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;H=q.uv_index_bytes;z=q.uv_index_bytes*2;L=q.uv_index_bytes;j=q.uv_index_bytes*2;aa=q.uv_index_bytes*3;b=q.vertex_index_bytes*3+q.material_index_bytes;Q=q.vertex_index_bytes*4+q.material_index_bytes;ga=q.ntri_flat*b;N=q.ntri_smooth*(b+q.normal_index_bytes*
3);W=q.ntri_flat_uv*(b+q.uv_index_bytes*3);T=q.ntri_smooth_uv*(b+q.normal_index_bytes*3+q.uv_index_bytes*3);ca=q.nquad_flat*Q;b=q.nquad_smooth*(Q+q.normal_index_bytes*4);Q=q.nquad_flat_uv*(Q+q.uv_index_bytes*4);t+=function(b){for(var d,e,g,h=q.vertex_coordinate_bytes*3,i=b+q.nvertices*h;b<i;b+=h)d=c(a,b),e=c(a,b+q.vertex_coordinate_bytes),g=c(a,b+q.vertex_coordinate_bytes*2),u.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,g)));return q.nvertices*h}(t);t+=function(b){for(var c,d,e,f=q.normal_coordinate_bytes*
3,g=b+q.nnormals*f;b<g;b+=f)c=k(a,b),d=k(a,b+q.normal_coordinate_bytes),e=k(a,b+q.normal_coordinate_bytes*2),A.push(c/127,d/127,e/127);return q.nnormals*f}(t);t+=function(b){for(var d,e,g=q.uv_coordinate_bytes*2,h=b+q.nuvs*g;b<h;b+=g)d=c(a,b),e=c(a,b+q.uv_coordinate_bytes),w.push(d,e);return q.nuvs*g}(t);ga=t+ga;N=ga+N;W=N+W;T=W+T;ca=T+ca;b=ca+b;Q=b+Q;(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes,d=c+q.uv_index_bytes*3,e=a+q.ntri_flat_uv*d;for(b=a;b<e;b+=d)o(b),m(b+c);return e-
a})(N);(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,d=c+q.uv_index_bytes*3,e=a+q.ntri_smooth_uv*d;for(b=a;b<e;b+=d)p(b),m(b+c);return e-a})(W);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes,d=c+q.uv_index_bytes*4,e=a+q.nquad_flat_uv*d;for(b=a;b<e;b+=d)n(b),s(b+c);return e-a})(b);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,d=c+q.uv_index_bytes*4,e=a+q.nquad_smooth_uv*d;for(b=a;b<e;b+=d)r(b),
s(b+c);return e-a})(Q);(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes,d=a+q.ntri_flat*c;for(b=a;b<d;b+=c)o(b);return d-a})(t);(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,d=a+q.ntri_smooth*c;for(b=a;b<d;b+=c)p(b);return d-a})(ga);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes,d=a+q.nquad_flat*c;for(b=a;b<d;b+=c)n(b);return d-a})(T);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*
4,d=a+q.nquad_smooth*c;for(b=a;b<d;b+=c)r(b);return d-a})(ca);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(b))};
THREE.ColladaLoader=function(){function a(a,d,g){N=a;d=d||ca;g!==void 0&&(a=g.split("/"),a.pop(),ta=a.length<1?"":a.join("/")+"/");C=c("//dae:library_images/dae:image",f,"image");oa=c("//dae:library_materials/dae:material",I,"material");la=c("//dae:library_effects/dae:effect",K,"effect");X=c("//dae:library_geometries/dae:geometry",s,"geometry");da=c("//dae:library_controllers/dae:controller",h,"controller");ka=c("//dae:library_animations/dae:animation",S,"animation");ra=c(".//dae:library_visual_scenes/dae:visual_scene",
l,"visual_scene");pa=[];qa=[];(a=N.evaluate(".//dae:scene/dae:instance_visual_scene",N,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),T=ra[a]):T=null;W=new THREE.Object3D;for(a=0;a<T.nodes.length;a++)W.add(e(T.nodes[a]));b();for(var i in ka);i={scene:W,morphs:pa,skins:qa,dae:{images:C,materials:oa,effects:la,geometries:X,controllers:da,animations:ka,visualScenes:ra,scene:T}};d&&d(i);return i}function c(a,b,c){for(var a=N.evaluate(a,N,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(e.id.length==0)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function b(){var a=1E6,b=-a,c=0,d;for(d in ka)for(var e=ka[d],f=0;f<e.sampler.length;f++){var g=e.sampler[f];g.create();a=Math.min(a,g.startTime);b=Math.max(b,g.endTime);c=Math.max(c,g.input.length)}return{start:a,end:b,frames:c}}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=a.channels[0].sampler.output[c];
f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function g(a,c,e){var f=da[c.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!c.skeleton||!c.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var g=b(),c=T.getChildById(c.skeleton[0],!0)||T.getChildBySid(c.skeleton[0],!0),h,i,j,k,l=new THREE.Vector3,m;for(h=0;h<a.vertices.length;h++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[h].position);
M
Mr.doob 已提交
573
for(e=0;e<g.frames;e++){var n=[],o=[];for(h=0;h<a.vertices.length;h++)o.push(new THREE.Vertex(new THREE.Vector3));d(c,n,e);h=n;i=f.skin;for(k=0;k<h.length;k++)if(j=h[k],m=-1,j.type=="JOINT"){for(var p=0;p<i.joints.length;p++)if(j.sid==i.joints[p]){m=p;break}if(m>=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p<i.weights.length;p++)for(var r=0;r<i.weights[p].length;r++){var q=i.weights[p][r];q.joint==m&&j.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
A
alteredq 已提交
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
j.sid+"'.";}for(h=0;h<n.length;h++)if(n[h].type=="JOINT")for(i=0;i<n[h].weights.length;i++)j=n[h].weights[i],k=j.index,j=j.weight,m=a.vertices[k],k=o[k],l.x=m.position.x,l.y=m.position.y,l.z=m.position.z,n[h].skinningMatrix.multiplyVector3(l),k.position.x+=l.x*j,k.position.y+=l.y*j,k.position.z+=l.z*j;a.morphTargets.push({name:"target_"+e,vertices:o})}}}function e(a){var b=new THREE.Object3D,c,d,f,h;for(f=0;f<a.controllers.length;f++){var i=da[a.controllers[f].url];switch(i.type){case "skin":if(X[i.skin.source]){var j=
new m;j.url=i.skin.source;j.instance_material=a.controllers[f].instance_material;a.geometries.push(j);c=a.controllers[f]}else if(da[i.skin.source]&&(d=i=da[i.skin.source],i.morph&&X[i.morph.source]))j=new m,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j);break;case "morph":if(X[i.morph.source])j=new m,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j),d=a.controllers[f];console.log("ColladaLoader: Morph-controller partially supported.")}}for(f=
0;f<a.geometries.length;f++){var i=a.geometries[f],j=i.instance_material,i=X[i.url],k={},l=0,o;if(i&&i.mesh&&i.mesh.primitives){if(b.name.length==0)b.name=i.id;if(j)for(h=0;h<j.length;h++){o=j[h];var p=la[oa[o.target].instance_effect.url].shader;p.material.opacity=!p.material.opacity?1:p.material.opacity;o=k[o.symbol]=p.material;l++}j=o||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(l>1){j=new THREE.MeshFaceMaterial;for(h=0;h<i.faces.length;h++)l=
i.faces[h],l.materials=[k[l.daeMaterial]]}if(c!==void 0)g(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=da[c.url],j.skinInstanceController=c,j.name="skin_"+qa.length,qa.push(j);else if(d!==void 0){h=i;k=d instanceof n?da[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(p=X[k.targets[l]],p.mesh&&p.mesh.primitives&&p.mesh.primitives.length)p=p.mesh.primitives[0].geometry,p.vertices.length===
h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:p.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+pa.length;pa.push(j)}else j=new THREE.Mesh(i,j);a.geometries.length>1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f<a.nodes.length;f++)b.add(e(a.nodes[f],a));return b}function f(){this.init_from=this.id=""}function h(){this.type=this.name=this.id="";this.morph=this.skin=
null}function i(){this.weights=this.targets=this.source=this.method=null}function k(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function l(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function o(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function p(){this.type=this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function n(){this.url=
"";this.skeleton=[];this.instance_material=[]}function r(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function s(){this.id="";this.mesh=null}function u(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function t(){}function q(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function A(){this.source="";this.stride=this.count=0;this.params=[]}function w(){this.input={}}function E(){this.semantic=
"";this.offset=0;this.source="";this.set=0}function x(a){this.id=a;this.type=null}function I(){this.name=this.id="";this.instance_effect=null}function M(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function D(a,b){this.type=a;this.effect=b;this.material=null}function F(a){this.effect=a;this.format=this.init_from=null}function P(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=
this.source=null}function K(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function $(){this.url=""}function S(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function R(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=null}function V(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ja(a){var b=a.getAttribute("id");
if(Q[b]!=void 0)return Q[b];Q[b]=(new x(b)).parse(a);return Q[b]}function y(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function H(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function z(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],10));return b}function L(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function j(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function aa(a,b){if(a===
void 0){for(var c="0.";c.length<b+2;)c+="0";return c}b=b||2;c=a.toString().split(".");for(c[1]=c.length>1?c[1].substr(0,b):"0";c[1].length<b;)c[1]+="0";return c.join(".")}function ga(a,b){var c="";c+=aa(a.x,b)+",";c+=aa(a.y,b)+",";c+=aa(a.z,b);return c}var N=null,W=null,T,ca=null,Q={},C={},ka={},da={},X={},oa={},la={},ra,ta,pa,qa,wa=THREE.SmoothShading;f.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="init_from")this.init_from=
c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new k).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new i).parse(c),this.type=c.nodeName}}return this};i.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,"");for(d=
0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==1)switch(e.nodeName){case "source":e=(new x).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};i.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":b.push((new E).parse(d))}}return b};
k.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=H(f.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12],f[13],f[14],f[15]);break;case "source":f=(new x).parse(f);b[f.id]=f;break;case "joints":c=
f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,b);return this};k.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":var d=(new E).parse(d),e=b[d.source];if(d.semantic=="JOINT")this.joints=e.read();else if(d.semantic=="INV_BIND_MATRIX")this.invBindMatrices=e.read()}}};k.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=
a.childNodes[f];if(g.nodeType==1)switch(g.nodeName){case "input":e.push((new E).parse(g));break;case "v":c=z(g.textContent);break;case "vcount":d=z(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var k={},l=0;l<e.length;l++){var m=e[l],n=c[g+m.offset];switch(m.semantic){case "JOINT":k.joint=n;break;case "WEIGHT":k.weight=b[m.source].data[n]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};l.prototype.getChildById=function(a,b){for(var c=
0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};l.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};l.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new o).parse(c))}}return this};o.prototype.getChannelForTransform=
function(a){for(var b=0;b<this.channels.length;b++){var c=this.channels[b],d=c.target.split("/");d.shift();var e=d.shift(),f=e.indexOf(".")>=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;d<h.length;d++)h[d]=parseInt(h[d].replace(/\)/,""))}if(e==a)return c.info={sid:e,dotSyntax:f,arrSyntax:g,arrIndices:h},c}return null};o.prototype.getChildById=function(a,b){if(this.id==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,
b);if(d)return d}return null};o.prototype.getChildBySid=function(a,b){if(this.sid==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};o.prototype.getTransformBySid=function(a){for(var b=0;b<this.transforms.length;b++)if(this.transforms[b].sid==a)return this.transforms[b];return null};o.prototype.parse=function(a){var b;this.id=a.getAttribute("id");this.sid=a.getAttribute("sid");this.name=a.getAttribute("name");this.type=a.getAttribute("type");
this.type=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],b.nodeType==1)switch(b.nodeName){case "node":this.nodes.push((new o).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new n).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;case "instance_node":b=
b.getAttribute("url").replace(/^#/,"");(b=N.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",N,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new o).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new p).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in ka)for(var e=ka[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];
595
if(d==this.id)h.create(),g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=1E7;for(a=0;a<this.channels.length;a++){c=this.channels[a].sampler;for(b=0;b<c.input.length-1;b++)d=Math.min(d,c.input[b+1]-c.input[b])}c=[];for(a=this.startTime;a<this.endTime;a+=d){b=a;for(var e={},i=f=void 0,f=0;f<this.channels.length;f++)i=this.channels[f],e[i.sid]=i;g=new THREE.Matrix4;for(f=0;f<this.transforms.length;f++)if(h=
A
alteredq 已提交
596 597
this.transforms[f],i=e[h.sid],i!==void 0){for(var j=i.sampler,k,i=0;i<j.input.length-1;i++)if(j.input[i+1]>b){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.matrix.multiply(this.matrix,
this.transforms[a].matrix)};p.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=H(a.textContent);this.updateMatrix();return this};p.prototype.updateMatrix=function(){var a=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],this.data[1],this.data[2],this.data[3],this.data[4],this.data[5],this.data[6],this.data[7],this.data[8],this.data[9],this.data[10],this.data[11],this.data[12],this.data[13],this.data[14],this.data[15]);break;
M
Mr.doob 已提交
598
case "translate":this.matrix.setTranslation(this.data[0],this.data[1],this.data[2]);break;case "rotate":a=this.data[3]*(Math.PI/180);this.matrix.setRotationAxis(new THREE.Vector3(this.data[0],this.data[1],this.data[2]),a);break;case "scale":this.matrix.setScale(this.data[0],this.data[1],this.data[2])}return this.matrix};n.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
A
alteredq 已提交
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
if(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=N.evaluate(".//dae:instance_material",c,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new r).parse(d)),d=c.iterateNext()}}return this};r.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,"");return this};m.prototype.parse=function(a){this.url=
a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1&&c.nodeName=="bind_material"){if(a=N.evaluate(".//dae:instance_material",c,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new r).parse(b)),b=a.iterateNext();break}}return this};s.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=
(new u(this)).parse(c)}}return this};u.prototype.parse=function(a){function b(a,c){var d=ga(a.position);e[d]===void 0&&(e[d]={v:a,index:c});return e[d]}this.primitives=[];var c;for(c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];switch(d.nodeName){case "source":ja(d);break;case "vertices":this.vertices=(new w).parse(d);break;case "triangles":this.primitives.push((new q).parse(d));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new t).parse(d))}}var e=
{};this.geometry3js=new THREE.Geometry;d=Q[this.vertices.input.POSITION.source].data;for(a=c=0;c<d.length;c+=3,a++){var f=new THREE.Vertex(new THREE.Vector3(d[c],d[c+1],d[c+2]));b(f,a);this.geometry3js.vertices.push(f)}for(c=0;c<this.primitives.length;c++)a=this.primitives[c],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js,e);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();
return this};u.prototype.handlePrimitive=function(a,b,c){var d=0,e,f,g=a.p,h=a.inputs,i,j,k,l,m=0,n=3,o=[];for(e=0;e<h.length;e++)switch(i=h[e],i.semantic){case "TEXCOORD":o.push(i.set)}for(;d<g.length;){var p=[],r=[],q={},s=[];a.vcount&&(n=a.vcount[m++]);for(e=0;e<n;e++)for(f=0;f<h.length;f++)switch(i=h[f],l=Q[i.source],j=g[d+e*h.length+i.offset],k=l.accessor.params.length,k*=j,i.semantic){case "VERTEX":i=ga(b.vertices[j].position);p.push(c[i].index);break;case "NORMAL":r.push(new THREE.Vector3(l.data[k],
l.data[k+1],l.data[k+2]));break;case "TEXCOORD":q[i.set]===void 0&&(q[i.set]=[]);q[i.set].push(new THREE.UV(l.data[k],l.data[k+1]));break;case "COLOR":s.push((new THREE.Color).setRGB(l.data[k],l.data[k+1],l.data[k+2]))}var u;n==3?u=new THREE.Face3(p[0],p[1],p[2],[r[0],r[1],r[2]],s.length?s:new THREE.Color):n==4&&(u=new THREE.Face4(p[0],p[1],p[2],p[3],[r[0],r[1],r[2],r[3]],s.length?s:new THREE.Color));u.daeMaterial=a.material;b.faces.push(u);for(f=0;f<o.length;f++)e=q[o[f]],b.faceVertexUvs[f].push([e[0],
e[1],e[2]]);d+=h.length*n}};t.prototype=new q;t.prototype.constructor=t;q.prototype.setVertices=function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=a.input.POSITION.source};q.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=j(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new E).parse(a.childNodes[b]));break;case "vcount":this.vcount=
z(c.textContent);break;case "p":this.p=z(c.textContent)}}return this};A.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=j(a,"count",0);this.stride=j(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};w.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName==
"input"){var c=(new E).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};E.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=j(a,"set",-1);this.offset=j(a,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};x.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=L(c.textContent),
e=[],f=0;f<d.length;f++)e.push(d[f]=="true"||d[f]=="1"?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=H(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=z(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=L(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeName=="accessor"){this.accessor=(new A).parse(c.childNodes[d]);break}}}return this};
x.prototype.read=function(){var a=[],b=this.accessor.params[0];switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=this.data.slice(b,b+16),d=new THREE.Matrix4;d.set(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15]);a.push(d)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};I.prototype.parse=function(a){this.id=a.getAttribute("id");
this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="instance_effect"){this.instance_effect=(new $).parse(a.childNodes[b]);break}return this};M.prototype.isColor=function(){return this.texture==null};M.prototype.isTexture=function(){return this.texture!=null};M.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "color":c=H(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],
c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord")}}return this};D.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new M).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=N.evaluate(".//dae:float",c,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};D.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof M)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=C[this.effect.surface.init_from]))a.map=
THREE.ImageUtils.loadTexture(ta+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=wa;return this.material=new THREE.MeshLambertMaterial(a)};F.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
614
if(c.nodeType==1)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+c.nodeName)}}return this};P.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=c.textContent;break;case "mipfilter":this.mipfilter=
A
alteredq 已提交
615 616 617 618 619 620
c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};K.prototype.create=function(){if(this.shader==null)return null};K.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};
K.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "surface":this.surface=(new F(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new P(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};K.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);
break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};K.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new D(c.nodeName,this)).parse(c)}}};$.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};S.prototype.parse=function(a){this.id=a.getAttribute("id");
this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":c=(new x).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new V(this)).parse(c));break;case "channel":this.channel.push((new R(this)).parse(c))}}return this};R.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");b.shift();var a=
b.shift(),c=a.indexOf(".")>=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b<e.length;b++)e[b]=parseInt(e[b].replace(/\)/,""))}this.sid=a;this.dotSyntax=c;this.arrSyntax=d;this.arrIndices=e;this.member=f;return this};V.prototype.parse=function(a){this.id=a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new E).parse(c))}}return this};
V.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=this.inputs[a],c=this.animation.source[b.source];switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=0;a<this.input.length;a++)this.startTime=
621
Math.min(this.startTime,this.input[a]),this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};return{load:function(b,c){if(document.implementation&&document.implementation.createDocument){document.implementation.createDocument("http://www.collada.org/2005/11/COLLADASchema","COLLADA",null);b+="?rnd="+Math.random();var d=new XMLHttpRequest;d.overrideMimeType&&d.overrideMimeType("text/xml");d.onreadystatechange=function(){if(d.readyState==4&&(d.status==0||d.status==
A
alteredq 已提交
622
200))ca=c,a(d.responseXML,void 0,b)};d.open("GET",b,!0);d.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){wa=a},applySkin:g,geometries:X}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
623 624 625
THREE.JSONLoader.prototype.load=function(a,c,b){if(a instanceof Object)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),b=a,a=b.model,c=b.callback,b=b.texture_path;b=b?b:this.extractUrlbase(a);this.onLoadStart();this.loadAjaxJSON(this,a,c,b)};
THREE.JSONLoader.prototype.loadAjaxJSON=function(a,c,b,d,g){var e=new XMLHttpRequest,f=0;e.onreadystatechange=function(){if(e.readyState==4)if(e.status==200||e.status==0)try{var h=JSON.parse(e.responseText);a.createModel(h,b,d);a.onLoadComplete()}catch(i){console.error(i),console.warn("DEPRECATED: ["+c+"] seems to be using old model format")}else console.error("Couldn't load ["+c+"] ["+e.status+"]");else e.readyState==3?g&&(f==0&&(f=e.getResponseHeader("Content-Length")),g({total:f,loaded:e.responseText.length})):
e.readyState==2&&(f=e.getResponseHeader("Content-Length"))};e.open("GET",c,!0);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
A
alteredq 已提交
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
THREE.JSONLoader.prototype.createModel=function(a,c,b){var d=new THREE.Geometry,g=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,b);(function(b){if(a.metadata===void 0||a.metadata.formatVersion===void 0||a.metadata.formatVersion!==3)console.error("Deprecated file format.");else{var c,g,i,k,l,o,p,n,r,m,s,u,t,q,A=a.faces;o=a.vertices;var w=a.normals,E=a.colors,x=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&x++;for(c=0;c<x;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];k=0;for(l=o.length;k<
l;)p=new THREE.Vertex,p.position.x=o[k++]*b,p.position.y=o[k++]*b,p.position.z=o[k++]*b,d.vertices.push(p);k=0;for(l=A.length;k<l;){b=A[k++];o=b&1;i=b&2;c=b&4;g=b&8;n=b&16;p=b&32;m=b&64;b&=128;o?(s=new THREE.Face4,s.a=A[k++],s.b=A[k++],s.c=A[k++],s.d=A[k++],o=4):(s=new THREE.Face3,s.a=A[k++],s.b=A[k++],s.c=A[k++],o=3);if(i)i=A[k++],s.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<x;c++)u=a.uvs[c],r=A[k++],q=u[r*2],r=u[r*2+1],d.faceUvs[c][i]=new THREE.UV(q,r);if(g)for(c=0;c<x;c++){u=a.uvs[c];t=[];
for(g=0;g<o;g++)r=A[k++],q=u[r*2],r=u[r*2+1],t[g]=new THREE.UV(q,r);d.faceVertexUvs[c][i]=t}if(n)n=A[k++]*3,g=new THREE.Vector3,g.x=w[n++],g.y=w[n++],g.z=w[n],s.normal=g;if(p)for(c=0;c<o;c++)n=A[k++]*3,g=new THREE.Vector3,g.x=w[n++],g.y=w[n++],g.z=w[n],s.vertexNormals.push(g);if(m)p=A[k++],p=new THREE.Color(E[p]),s.color=p;if(b)for(c=0;c<o;c++)p=A[k++],p=new THREE.Color(E[p]),s.vertexColors.push(p);d.faces.push(s)}}})(g);(function(){var b,c,g,i;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=
2)g=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(g,i,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)g=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(g,i,0,0))}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,g,i,k,l,o,p,n,r;c=0;for(g=a.morphTargets.length;c<g;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];n=d.morphTargets[c].vertices;
r=a.morphTargets[c].vertices;i=0;for(k=r.length;i<k;i+=3)l=r[i]*b,o=r[i+1]*b,p=r[i+2]*b,n.push(new THREE.Vertex(new THREE.Vector3(l,o,p)))}}if(a.morphColors!==void 0){c=0;for(g=a.morphColors.length;c<g;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];k=d.morphColors[c].colors;l=a.morphColors[c].colors;b=0;for(i=l.length;b<i;b+=3)o=new THREE.Color(16755200),o.setRGB(l[b],l[b+1],l[b+2]),k.push(o)}}})(g);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
d.computeTangents();c(d)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
THREE.SceneLoader.prototype.load=function(a,c){var b=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState==4)if(d.status==200||d.status==0)try{var g=JSON.parse(d.responseText);g.metadata===void 0||g.metadata.formatVersion===void 0||g.metadata.formatVersion!==3?console.error("Deprecated file format."):b.createScene(g,c,a)}catch(e){console.error(e),console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}else console.error("Couldn't load ["+a+"] ["+d.status+"]")};
d.open("GET",a,!0);d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
THREE.SceneLoader.prototype.createScene=function(a,c,b){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function g(){var a;for(p in K.objects)if(!y.objects[p])if(u=K.objects[p],u.geometry!==void 0){if(M=y.geometries[u.geometry]){a=!1;for(z=0;z<u.materials.length;z++)P=y.materials[u.materials[z]],a=P instanceof THREE.ShaderMaterial;a&&M.computeTangents();A=u.position;w=u.rotation;E=u.quaternion;x=u.scale;E=0;P.length==0&&(P=new THREE.MeshFaceMaterial);P.length>1&&(P=new THREE.MeshFaceMaterial);
a=new THREE.Mesh(M,P);a.name=p;a.position.set(A[0],A[1],A[2]);E?(a.quaternion.set(E[0],E[1],E[2],E[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]);a.scale.set(x[0],x[1],x[2]);a.visible=u.visible;y.scene.add(a);y.objects[p]=a;if(u.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);y.scene.collisions.colliders.push(b)}if(u.castsShadow)b=new THREE.ShadowVolume(M),y.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;u.trigger&&u.trigger.toLowerCase()!="none"&&(b=
{type:u.trigger,object:u},y.triggers[a.name]=b)}}else A=u.position,w=u.rotation,E=u.quaternion,x=u.scale,E=0,a=new THREE.Object3D,a.name=p,a.position.set(A[0],A[1],A[2]),E?(a.quaternion.set(E[0],E[1],E[2],E[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]),a.scale.set(x[0],x[1],x[2]),a.visible=u.visible!==void 0?u.visible:!1,y.scene.add(a),y.objects[p]=a,y.empties[p]=a,u.trigger&&u.trigger.toLowerCase()!="none"&&(b={type:u.trigger,object:u},y.triggers[a.name]=b)}function e(a){return function(b){y.geometries[a]=
b;g();S-=1;i.onLoadComplete();h()}}function f(a){return function(b){y.geometries[a]=b}}function h(){i.callbackProgress({totalModels:V,totalTextures:ja,loadedModels:V-S,loadedTextures:ja-R},y);i.onLoadProgress();S==0&&R==0&&c(y)}var i=this,k=THREE.Loader.prototype.extractUrlbase(b),l,o,p,n,r,m,s,u,t,q,A,w,E,x,I,M,D,F,P,K,$,S,R,V,ja,y;K=a;b=new THREE.BinaryLoader;$=new THREE.JSONLoader;R=S=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
empties:{}};a=!1;for(p in K.objects)if(u=K.objects[p],u.meshCollider){a=!0;break}if(a)y.scene.collisions=new THREE.CollisionSystem;if(K.transform){a=K.transform.position;t=K.transform.rotation;var H=K.transform.scale;a&&y.scene.position.set(a[0],a[1],a[2]);t&&y.scene.rotation.set(t[0],t[1],t[2]);H&&y.scene.scale.set(H[0],H[1],H[2]);(a||t||H)&&y.scene.updateMatrix()}a=function(){R-=1;h();i.onLoadComplete()};for(r in K.cameras)t=K.cameras[r],t.type=="perspective"?D=new THREE.PerspectiveCamera(t.fov,
t.aspect,t.near,t.far):t.type=="ortho"&&(D=new THREE.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far)),A=t.position,t=t.target,D.position.set(A[0],A[1],A[2]),D.target=new THREE.Vector3(t[0],t[1],t[2]),y.cameras[r]=D;for(n in K.lights)t=K.lights[n],r=t.color!==void 0?t.color:16777215,D=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(A=t.direction,q=new THREE.DirectionalLight(r,D),q.position.set(A[0],A[1],A[2]),q.position.normalize()):t.type=="point"?(A=t.position,q=t.distance,
q=new THREE.PointLight(r,D,q),q.position.set(A[0],A[1],A[2])):t.type=="ambient"&&(q=new THREE.AmbientLight(r)),y.scene.add(q),y.lights[n]=q;for(m in K.fogs)n=K.fogs[m],n.type=="linear"?F=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(F=new THREE.FogExp2(0,n.density)),t=n.color,F.color.setRGB(t[0],t[1],t[2]),y.fogs[m]=F;if(y.cameras&&K.defaults.camera)y.currentCamera=y.cameras[K.defaults.camera];if(y.fogs&&K.defaults.fog)y.scene.fog=y.fogs[K.defaults.fog];t=K.defaults.bgcolor;y.bgColor=new THREE.Color;
y.bgColor.setRGB(t[0],t[1],t[2]);y.bgColorAlpha=K.defaults.bgalpha;for(l in K.geometries)if(m=K.geometries[l],m.type=="bin_mesh"||m.type=="ascii_mesh")S+=1,i.onLoadStart();V=S;for(l in K.geometries)m=K.geometries[l],m.type=="cube"?(M=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),y.geometries[l]=M):m.type=="plane"?(M=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),y.geometries[l]=M):m.type=="sphere"?
(M=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),y.geometries[l]=M):m.type=="cylinder"?(M=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),y.geometries[l]=M):m.type=="torus"?(M=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),y.geometries[l]=M):m.type=="icosahedron"?(M=new THREE.IcosahedronGeometry(m.subdivisions),y.geometries[l]=M):m.type=="bin_mesh"?b.load(d(m.url,K.urlBaseType),e(l)):m.type=="ascii_mesh"?$.load(d(m.url,K.urlBaseType),
e(l)):m.type=="embedded_mesh"&&(m=K.embeds[m.id])&&$.createModel(m,f(l),"");for(s in K.textures)if(l=K.textures[s],l.url instanceof Array){R+=l.url.length;for(m=0;m<l.url.length;m++)i.onLoadStart()}else R+=1,i.onLoadStart();ja=R;for(s in K.textures){l=K.textures[s];if(l.mapping!=void 0&&THREE[l.mapping]!=void 0)l.mapping=new THREE[l.mapping];if(l.url instanceof Array){m=[];for(var z=0;z<l.url.length;z++)m[z]=d(l.url[z],K.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,l.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(l.url,
K.urlBaseType),l.mapping,a);if(THREE[l.minFilter]!=void 0)m.minFilter=THREE[l.minFilter];if(THREE[l.magFilter]!=void 0)m.magFilter=THREE[l.magFilter];if(l.repeat){m.repeat.set(l.repeat[0],l.repeat[1]);if(l.repeat[0]!=1)m.wrapS=THREE.RepeatWrapping;if(l.repeat[1]!=1)m.wrapT=THREE.RepeatWrapping}l.offset&&m.offset.set(l.offset[0],l.offset[1]);if(l.wrap){F={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(F[l.wrap[0]]!==void 0)m.wrapS=F[l.wrap[0]];if(F[l.wrap[1]]!==void 0)m.wrapT=
F[l.wrap[1]]}}y.textures[s]=m}for(o in K.materials){s=K.materials[o];for(I in s.parameters)if(I=="envMap"||I=="map"||I=="lightMap")s.parameters[I]=y.textures[s.parameters[I]];else if(I=="shading")s.parameters[I]=s.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")s.parameters[I]=THREE[s.parameters[I]]?THREE[s.parameters[I]]:THREE.NormalBlending;else if(I=="combine")s.parameters[I]=s.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(I==
"vertexColors")if(s.parameters[I]=="face")s.parameters[I]=THREE.FaceColors;else if(s.parameters[I])s.parameters[I]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=!0;if(s.parameters.normalMap){l=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(l.uniforms);m=s.parameters.color;F=s.parameters.specular;b=s.parameters.ambient;$=s.parameters.shininess;a.tNormal.texture=y.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=
s.parameters.normalMapFactor;if(s.parameters.map)a.tDiffuse.texture=s.parameters.map,a.enableDiffuse.value=!0;if(s.parameters.lightMap)a.tAO.texture=s.parameters.lightMap,a.enableAO.value=!0;if(s.parameters.specularMap)a.tSpecular.texture=y.textures[s.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(F);a.uAmbientColor.value.setHex(b);a.uShininess.value=$;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;s=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader,
vertexShader:l.vertexShader,uniforms:a,lights:!0,fog:!0})}else s=new THREE[s.type](s.parameters);y.materials[o]=s}g();i.callbackSync(y);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
A
alteredq 已提交
649 650
THREE.UTF8Loader.prototype.load=function(a,c,b){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),b=a,a=b.model,c=b.callback,b={scale:b.scale,offsetX:b.offsetX,offsetY:b.offsetY,offsetZ:b.offsetZ};var d=new XMLHttpRequest,g=b.scale!==void 0?b.scale:1,e=b.offsetX!==void 0?b.offsetX:0,f=b.offsetY!==void 0?b.offsetY:0,h=b.offsetZ!==void 0?b.offsetZ:0;d.onreadystatechange=function(){d.readyState==4?d.status==200||d.status==0?THREE.UTF8Loader.prototype.createModel(d.responseText,
c,g,e,f,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):d.readyState!=3&&d.readyState==2&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var c=a.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,g=0;g<8;g++){for(var e=0,f=0;f<c;++f){var h=a.charCodeAt(f+d);e+=h>>1^-(h&1);b[8*f+g]=e}d+=c}c=a.length-d;e=new Uint16Array(c);for(g=f=0;g<c;g++)h=a.charCodeAt(g+d),e[g]=f-h,h==0&&f++;return[b,e]};
A
alteredq 已提交
651 652 653
THREE.UTF8Loader.prototype.createModel=function(a,c,b,d,g,e){var f=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var f=THREE.UTF8Loader.prototype.decompressMesh(a),k=[],l=[];(function(a,f,i){for(var k,l,s,u=a.length;i<u;i+=f)k=a[i],l=a[i+1],s=a[i+2],k=k/16383*b,l=l/16383*b,s=s/16383*b,k+=d,l+=g,s+=e,c.vertices.push(new THREE.Vertex(new THREE.Vector3(k,l,s)))})(f[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,l.push(d,1-e)})(f[0],8,3);(function(a,
b,c){for(var d,e,f,g=a.length;c<g;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,k.push(d,e,f)})(f[0],8,5);(function(a){var b,d,e,f,g,i,t,q,A,w=a.length;for(b=0;b<w;b+=3){d=a[b];e=a[b+1];f=a[b+2];g=c;q=d;A=e;i=f;t=d;var E=e,x=f,I=g.materials[0],M=k[E*3],D=k[E*3+1],E=k[E*3+2],F=k[x*3],P=k[x*3+1],x=k[x*3+2];t=new THREE.Vector3(k[t*3],k[t*3+1],k[t*3+2]);E=new THREE.Vector3(M,D,E);x=new THREE.Vector3(F,P,x);g.faces.push(new THREE.Face3(q,A,i,[t,E,x],null,I));g=l[d*2];d=l[d*2+
1];i=l[e*2];t=l[e*2+1];q=l[f*2];A=l[f*2+1];f=c.faceVertexUvs[0];e=i;i=t;t=[];t.push(new THREE.UV(g,d));t.push(new THREE.UV(e,i));t.push(new THREE.UV(q,A));f.push(t)}})(f[1]);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f)};
A
alteredq 已提交
654 655 656
THREE.Axes=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var c=new THREE.CylinderGeometry(0,5,25,5,1),b=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));b.rotation.z=-Math.PI/2;this.add(b);b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:16711680}));b.position.x=100;b.rotation.z=-Math.PI/2;this.add(b);b=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(b);
b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:65280}));b.position.y=100;this.add(b);b=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));b.rotation.x=Math.PI/2;this.add(b);b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:255}));b.position.z=100;b.rotation.x=Math.PI/2;this.add(b)};THREE.Axes.prototype=new THREE.Object3D;THREE.Axes.prototype.constructor=THREE.Axes;
THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(a){this.isolation=80;this.size=a;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=
A
alteredq 已提交
657 658 659 660 661 662
0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,c,g){return a+(c-a)*g};this.VIntX=function(a,c,g,e,f,h,i,k,l,o){f=(f-l)/(o-l);l=this.normal_cache;c[e]=h+f*this.delta;c[e+1]=i;c[e+2]=k;g[e]=this.lerp(l[a],l[a+3],f);g[e+1]=this.lerp(l[a+1],l[a+4],f);g[e+2]=this.lerp(l[a+2],l[a+5],f)};this.VIntY=function(a,c,g,e,f,h,i,k,l,o){f=(f-l)/(o-l);l=this.normal_cache;c[e]=h;c[e+1]=i+f*this.delta;c[e+
2]=k;c=a+this.yd*3;g[e]=this.lerp(l[a],l[c],f);g[e+1]=this.lerp(l[a+1],l[c+1],f);g[e+2]=this.lerp(l[a+2],l[c+2],f)};this.VIntZ=function(a,c,g,e,f,h,i,k,l,o){f=(f-l)/(o-l);l=this.normal_cache;c[e]=h;c[e+1]=i;c[e+2]=k+f*this.delta;c=a+this.zd*3;g[e]=this.lerp(l[a],l[c],f);g[e+1]=this.lerp(l[a+1],l[c+1],f);g[e+2]=this.lerp(l[a+2],l[c+2],f)};this.compNorm=function(a){var c=a*3;this.normal_cache[c]===0&&(this.normal_cache[c]=this.field[a-1]-this.field[a+1],this.normal_cache[c+1]=this.field[a-this.yd]-
this.field[a+this.yd],this.normal_cache[c+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,c,g,e,f,h){var i=e+1,k=e+this.yd,l=e+this.zd,o=i+this.yd,p=i+this.zd,n=e+this.yd+this.zd,r=i+this.yd+this.zd,m=0,s=this.field[e],u=this.field[i],t=this.field[k],q=this.field[o],A=this.field[l],w=this.field[p],E=this.field[n],x=this.field[r];s<f&&(m|=1);u<f&&(m|=2);t<f&&(m|=8);q<f&&(m|=4);A<f&&(m|=16);w<f&&(m|=32);E<f&&(m|=128);x<f&&(m|=64);var I=THREE.edgeTable[m];if(I===0)return 0;
var M=this.delta,D=a+M,F=c+M,M=g+M;I&1&&(this.compNorm(e),this.compNorm(i),this.VIntX(e*3,this.vlist,this.nlist,0,f,a,c,g,s,u));I&2&&(this.compNorm(i),this.compNorm(o),this.VIntY(i*3,this.vlist,this.nlist,3,f,D,c,g,u,q));I&4&&(this.compNorm(k),this.compNorm(o),this.VIntX(k*3,this.vlist,this.nlist,6,f,a,F,g,t,q));I&8&&(this.compNorm(e),this.compNorm(k),this.VIntY(e*3,this.vlist,this.nlist,9,f,a,c,g,s,t));I&16&&(this.compNorm(l),this.compNorm(p),this.VIntX(l*3,this.vlist,this.nlist,12,f,a,c,M,A,w));
I&32&&(this.compNorm(p),this.compNorm(r),this.VIntY(p*3,this.vlist,this.nlist,15,f,D,c,M,w,x));I&64&&(this.compNorm(n),this.compNorm(r),this.VIntX(n*3,this.vlist,this.nlist,18,f,a,F,M,E,x));I&128&&(this.compNorm(l),this.compNorm(n),this.VIntY(l*3,this.vlist,this.nlist,21,f,a,c,M,A,E));I&256&&(this.compNorm(e),this.compNorm(l),this.VIntZ(e*3,this.vlist,this.nlist,24,f,a,c,g,s,A));I&512&&(this.compNorm(i),this.compNorm(p),this.VIntZ(i*3,this.vlist,this.nlist,27,f,D,c,g,u,w));I&1024&&(this.compNorm(o),
this.compNorm(r),this.VIntZ(o*3,this.vlist,this.nlist,30,f,D,F,g,q,x));I&2048&&(this.compNorm(k),this.compNorm(n),this.VIntZ(k*3,this.vlist,this.nlist,33,f,a,F,g,t,E));m<<=4;for(f=e=0;THREE.triTable[m+f]!=-1;)a=m+f,c=a+1,g=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[c],3*THREE.triTable[g],h),f+=3,e++;return e};this.posnormtriv=function(a,c,g,e,f,h){var i=this.count*3;this.positionArray[i]=a[g];this.positionArray[i+1]=a[g+1];this.positionArray[i+2]=a[g+2];this.positionArray[i+
A
alteredq 已提交
663
3]=a[e];this.positionArray[i+4]=a[e+1];this.positionArray[i+5]=a[e+2];this.positionArray[i+6]=a[f];this.positionArray[i+7]=a[f+1];this.positionArray[i+8]=a[f+2];this.normalArray[i]=c[g];this.normalArray[i+1]=c[g+1];this.normalArray[i+2]=c[g+2];this.normalArray[i+3]=c[e];this.normalArray[i+4]=c[e+1];this.normalArray[i+5]=c[e+2];this.normalArray[i+6]=c[f];this.normalArray[i+7]=c[f+1];this.normalArray[i+8]=c[f+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
A
alteredq 已提交
664 665 666 667 668
function(){this.count=0;this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;a(this)}};this.addBall=function(a,c,g,e,f){var h=this.size*Math.sqrt(e/f),i=g*this.size,k=c*this.size,l=a*this.size,o=Math.floor(i-h);o<1&&(o=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var n=Math.floor(l-h);n<1&&(n=1);h=Math.floor(l+h);
h>this.size-1&&(h=this.size-1);for(var r,m,s,u,t,q;o<i;o++){l=this.size2*o;m=o/this.size-g;t=m*m;for(m=p;m<k;m++){s=l+this.size*m;r=m/this.size-c;q=r*r;for(r=n;r<h;r++)u=r/this.size-a,u=e/(1.0E-6+u*u+q+t)-f,u>0&&(this.field[s+r]+=u)}}};this.addPlaneX=function(a,c){var g,e,f,h,i,k=this.size,l=this.yd,o=this.zd,p=this.field,n=k*Math.sqrt(a/c);n>k&&(n=k);for(g=0;g<n;g++)if(e=g/k,e*=e,h=a/(1.0E-4+e)-c,h>0)for(e=0;e<k;e++){i=g+e*l;for(f=0;f<k;f++)p[o*f+i]+=h}};this.addPlaneY=function(a,c){var g,e,f,h,
i,k,l=this.size,o=this.yd,p=this.zd,n=this.field,r=l*Math.sqrt(a/c);r>l&&(r=l);for(e=0;e<r;e++)if(g=e/l,g*=g,h=a/(1.0E-4+g)-c,h>0){i=e*o;for(g=0;g<l;g++){k=i+g;for(f=0;f<l;f++)n[p*f+k]+=h}}};this.addPlaneZ=function(a,c){var g,e,f,h,i,k,l=this.size,o=this.yd,p=this.zd,n=this.field,r=l*Math.sqrt(a/c);r>l&&(r=l);for(f=0;f<r;f++)if(g=f/l,g*=g,h=a/(1.0E-4+g)-c,h>0){i=p*f;for(e=0;e<l;e++){k=i+e*o;for(g=0;g<l;g++)n[k+g]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*3]=0,
this.field[a]=0};this.render=function(a){this.begin();var c,g,e,f,h,i,k,l,o,p=this.size-2;for(f=1;f<p;f++){o=this.size2*f;k=(f-this.halfsize)/this.halfsize;for(e=1;e<p;e++){l=o+this.size*e;i=(e-this.halfsize)/this.halfsize;for(g=1;g<p;g++)h=(g-this.halfsize)/this.halfsize,c=l+g,this.polygonize(h,i,k,c,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,c=new THREE.Geometry,g=[];this.render(function(e){var f,h,i,k,l,o,p,n;for(f=0;f<e.count;f++)p=f*3,l=p+1,n=p+2,h=e.positionArray[p],
i=e.positionArray[l],k=e.positionArray[n],o=new THREE.Vector3(h,i,k),h=e.normalArray[p],i=e.normalArray[l],k=e.normalArray[n],p=new THREE.Vector3(h,i,k),p.normalize(),l=new THREE.Vertex(o),c.vertices.push(l),g.push(p);o=e.count/3;for(f=0;f<o;f++)p=(a+f)*3,l=p+1,n=p+2,h=g[p],i=g[l],k=g[n],p=new THREE.Face3(p,l,n,[h,i,k]),c.faces.push(p);a+=o;e.count=0});return c};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
A
alteredq 已提交
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,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.PlaneCollider=function(a,c){this.point=a;this.normal=c};THREE.SphereCollider=function(a,c){this.center=a;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(a,c){this.min=a;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
THREE.MeshCollider=function(a,c){this.mesh=a;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){Array.prototype.push.apply(this.colliders,a.colliders);Array.prototype.push.apply(this.hits,a.hits)};
THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,d,g,e=0;c=0;for(b=this.colliders.length;c<b;c++)if(g=this.colliders[c],d=this.rayCast(a,g),d<Number.MAX_VALUE)g.distance=d,d>e?this.hits.push(g):this.hits.unshift(g),e=d;return this.hits};
THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var d=this.rayMesh(a,c[b]);if(d.dist<Number.MAX_VALUE){c[b].distance=d.dist;c[b].faceIndex=d.faceIndex;break}b++}if(b>c.length)return null;return c[b]};
THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)};
A
alteredq 已提交
697 698
THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),d=Number.MAX_VALUE,g,e=0;e<c.numFaces;e++){var f=c.mesh.geometry.faces[e],h=c.mesh.geometry.vertices[f.a].position,i=c.mesh.geometry.vertices[f.b].position,k=c.mesh.geometry.vertices[f.c].position,l=f instanceof THREE.Face4?c.mesh.geometry.vertices[f.d].position:null;f instanceof THREE.Face3?(f=this.rayTriangle(b,h,i,k,d,this.collisionNormal,c.mesh),f<d&&(d=f,g=e,c.normal.copy(this.collisionNormal),c.normal.normalize())):
f instanceof THREE.Face4&&(f=this.rayTriangle(b,h,i,l,d,this.collisionNormal,c.mesh),f<d&&(d=f,g=e,c.normal.copy(this.collisionNormal),c.normal.normalize()),f=this.rayTriangle(b,i,k,l,d,this.collisionNormal,c.mesh),f<d&&(d=f,g=e,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:d,faceIndex:g}};
A
alteredq 已提交
699 700 701
THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,d,g,e,f){var h=THREE.CollisionSystem.__v1,i=THREE.CollisionSystem.__v2;e.set(0,0,0);h.sub(b,c);i.sub(d,b);e.cross(h,i);h=e.dot(a.direction);if(!(h<0))if(f.doubleSided||f.flipSided)e.multiplyScalar(-1),h*=-1;else return Number.MAX_VALUE;f=e.dot(c)-e.dot(a.origin);if(!(f<=0))return Number.MAX_VALUE;if(!(f>=h*g))return Number.MAX_VALUE;f/=h;h=THREE.CollisionSystem.__v3;h.copy(a.direction);h.multiplyScalar(f);h.addSelf(a.origin);Math.abs(e.x)>
Math.abs(e.y)?Math.abs(e.x)>Math.abs(e.z)?(a=h.y-c.y,e=b.y-c.y,g=d.y-c.y,h=h.z-c.z,b=b.z-c.z,d=d.z-c.z):(a=h.x-c.x,e=b.x-c.x,g=d.x-c.x,h=h.y-c.y,b=b.y-c.y,d=d.y-c.y):Math.abs(e.y)>Math.abs(e.z)?(a=h.x-c.x,e=b.x-c.x,g=d.x-c.x,h=h.z-c.z,b=b.z-c.z,d=d.z-c.z):(a=h.x-c.x,e=b.x-c.x,g=d.x-c.x,h=h.y-c.y,b=b.y-c.y,d=d.y-c.y);c=e*d-b*g;if(c==0)return Number.MAX_VALUE;c=1/c;d=(a*d-h*g)*c;if(!(d>=0))return Number.MAX_VALUE;c*=e*h-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-d-c>=0))return Number.MAX_VALUE;return f};
THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;b.getInverse(c.matrixWorld);var d=THREE.CollisionSystem.__r;d.origin.copy(a.origin);d.direction.copy(a.direction);b.multiplyVector3(d.origin);b.rotateAxis(d.direction);d.direction.normalize();return d};
A
alteredq 已提交
702 703
THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;c.dynamic&&c.mesh&&c.mesh.matrixWorld?b=this.makeRayLocal(a,c.mesh):(b=THREE.CollisionSystem.__r,b.origin.copy(a.origin),b.direction.copy(a.direction));var d=0,g=0,e=0,f=0,h=0,i=0,k=!0;b.origin.x<c.min.x?(d=c.min.x-b.origin.x,d/=b.direction.x,k=!1,f=-1):b.origin.x>c.max.x&&(d=c.max.x-b.origin.x,d/=b.direction.x,k=!1,f=1);b.origin.y<c.min.y?(g=c.min.y-b.origin.y,g/=b.direction.y,k=!1,h=-1):b.origin.y>c.max.y&&(g=c.max.y-b.origin.y,g/=b.direction.y,
k=!1,h=1);b.origin.z<c.min.z?(e=c.min.z-b.origin.z,e/=b.direction.z,k=!1,i=-1):b.origin.z>c.max.z&&(e=c.max.z-b.origin.z,e/=b.direction.z,k=!1,i=1);if(k)return-1;k=0;g>d&&(k=1,d=g);e>d&&(k=2,d=e);switch(k){case 0:h=b.origin.y+b.direction.y*d;if(h<c.min.y||h>c.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*d;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(f,0,0);break;case 1:f=b.origin.x+b.direction.x*d;if(f<c.min.x||f>c.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*
A
alteredq 已提交
704 705 706 707
d;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,h,0);break;case 2:f=b.origin.x+b.direction.x*d;if(f<c.min.x||f>c.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*d;if(h<c.min.y||h>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,i)}return d};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),d=c.point.dot(c.normal);if(b<0)b=(d-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE};
THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq<c.radiusSq)return-1;var d=b.dot(a.direction.clone());if(d<=0)return Number.MAX_VALUE;b=c.radiusSq-(b.lengthSq()-d*d);if(b>=0)return Math.abs(d)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c};
THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};
A
alteredq 已提交
708 709 710 711
if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,e=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,k,l,o;g.matrixAutoUpdate=e.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),r=new THREE.PerspectiveCamera(53,
1,1,1E4);r.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},mapRight:{type:"t",value:1,texture:n}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}),
m=new THREE.Scene;m.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));m.add(r);this.setSize=function(a,d){b.call(c,a,d);p.width=a;p.height=d;n.width=a;n.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||k!==b.near||l!==b.far||o!==b.fov){i=b.aspect;k=b.near;l=b.far;o=b.fov;var t=b.projectionMatrix.clone(),q=125/30*0.5,A=q*k/125,w=k*Math.tan(o*Math.PI/360),E;f.n14=q;h.n14=-q;q=-w*i+A;E=w*i+A;t.n11=2*k/(E-q);t.n13=(E+q)/(E-q);g.projectionMatrix.copy(t);q=-w*i-A;E=w*i-A;t.n11=
2*k/(E-q);t.n13=(E+q)/(E-q);e.projectionMatrix.copy(t)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,p,!0);e.matrixWorld.copy(b.matrixWorld).multiplySelf(f);e.position.copy(b.position);e.near=b.near;e.far=b.far;d.call(c,a,e,n,!0);m.updateMatrixWorld();d.call(c,m,r)}};
A
alteredq 已提交
712 713
if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,d=this.render,g,e,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,d){b.call(c,a,d);g=a/2;e=d};this.render=function(a,b){this.clear();f.fov=b.fov;f.aspect=0.5*b.aspect;f.near=b.near;f.far=
b.far;f.updateProjectionMatrix();f.position.copy(b.position);f.target.copy(b.target);f.translateX(c.separation);f.lookAt(f.target);h.projectionMatrix=f.projectionMatrix;h.position.copy(b.position);h.target.copy(b.target);h.translateX(-c.separation);h.lookAt(h.target);this.setViewport(0,0,g,e);d.call(c,a,f);this.setViewport(g,0,g,e);d.call(c,a,h,!1)}};