|
@@ -1,70 +1,70 @@
|
|
|
// ThreeDebug.js r32 - http://github.com/mrdoob/three.js
|
|
|
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
|
|
-THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var f,k,l,p,q,m;if(e==0)f=k=l=0;else{p=Math.floor(a*6);q=a*6-p;a=e*(1-c);m=e*(1-c*q);c=e*(1-c*(1-q));switch(p){case 1:f=m;k=e;l=a;break;case 2:f=a;k=e;l=c;break;case 3:f=a;k=m;l=e;break;case 4:f=c;k=a;l=e;break;case 5:f=e;k=a;l=m;break;case 6:case 0:f=e;k=c;l=a}}this.r=f;this.g=k;this.b=l;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
|
|
|
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
|
|
|
setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
|
|
|
this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
|
|
|
THREE.Vector2.prototype={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},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add: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},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
|
|
|
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,e){this.x=a||0;this.y=c||0;this.z=e||0};
|
|
|
-THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,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},
|
|
|
-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,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-e*a.x;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},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
|
|
|
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
|
|
|
+THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},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},
|
|
|
+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,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;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},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
|
|
|
-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
|
|
|
-THREE.Vector4=function(a,c,e,f){this.x=a||0;this.y=c||0;this.z=e||0;this.w=f||1};
|
|
|
-THREE.Vector4.prototype={set:function(a,c,e,f){this.x=a;this.y=c;this.z=e;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,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;
|
|
|
+THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
|
|
|
+THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,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){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},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},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
|
THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
|
|
-THREE.Ray.prototype={intersectScene:function(a){var c,e,f=a.objects,k=[];a=0;for(c=f.length;a<c;a++){e=f[a];if(e instanceof THREE.Mesh)k=k.concat(this.intersectObject(e))}k.sort(function(l,p){return l.distance-p.distance});return k},intersectObject:function(a){function c(I,s,R,F){F=F.clone().subSelf(s);R=R.clone().subSelf(s);var J=I.clone().subSelf(s);I=F.dot(F);s=F.dot(R);F=F.dot(J);var O=R.dot(R);R=R.dot(J);J=1/(I*O-s*s);O=(O*F-s*R)*J;I=(I*R-s*F)*J;return O>0&&I>0&&O+I<1}var e,f,k,l,p,q,m,n,C,B,
|
|
|
-u,x=a.geometry,b=x.vertices,H=[];e=0;for(f=x.faces.length;e<f;e++){k=x.faces[e];B=this.origin.clone();u=this.direction.clone();l=a.matrix.multiplyVector3(b[k.a].position.clone());p=a.matrix.multiplyVector3(b[k.b].position.clone());q=a.matrix.multiplyVector3(b[k.c].position.clone());m=k instanceof THREE.Face4?a.matrix.multiplyVector3(b[k.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(k.normal.clone());C=u.dot(n);if(C<0){n=n.dot((new THREE.Vector3).sub(l,B))/C;B=B.addSelf(u.multiplyScalar(n));
|
|
|
-if(k instanceof THREE.Face3){if(c(B,l,p,q)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}else if(k instanceof THREE.Face4)if(c(B,l,p,m)||c(B,p,q,m)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}}return H}};
|
|
|
-THREE.Rectangle=function(){function a(){l=f-c;p=k-e}var c,e,f,k,l,p,q=true;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return l};this.getHeight=function(){return p};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return k};this.set=function(m,n,C,B){q=false;c=m;e=n;f=C;k=B;a()};this.addPoint=function(m,n){if(q){q=false;c=m;e=n;f=m;k=n}else{c=c<m?c:m;e=e<n?e:n;f=f>m?f:m;k=k>n?
|
|
|
-k:n}a()};this.add3Points=function(m,n,C,B,u,x){if(q){q=false;c=m<C?m<u?m:u:C<u?C:u;e=n<B?n<x?n:x:B<x?B:x;f=m>C?m>u?m:u:C>u?C:u;k=n>B?n>x?n:x:B>x?B:x}else{c=m<C?m<u?m<c?m:c:u<c?u:c:C<u?C<c?C:c:u<c?u:c;e=n<B?n<x?n<e?n:e:x<e?x:e:B<x?B<e?B:e:x<e?x:e;f=m>C?m>u?m>f?m:f:u>f?u:f:C>u?C>f?C:f:u>f?u:f;k=n>B?n>x?n>k?n:k:x>k?x:k:B>x?B>k?B:k:x>k?x:k}a()};this.addRectangle=function(m){if(q){q=false;c=m.getLeft();e=m.getTop();f=m.getRight();k=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();e=e<m.getTop()?e:m.getTop();
|
|
|
-f=f>m.getRight()?f:m.getRight();k=k>m.getBottom()?k:m.getBottom()}a()};this.inflate=function(m){c-=m;e-=m;f+=m;k+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();e=e>m.getTop()?e:m.getTop();f=f<m.getRight()?f:m.getRight();k=k<m.getBottom()?k:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(k,m.getBottom())-Math.max(e,m.getTop())>=0};this.empty=function(){q=true;k=f=e=c=0;a()};this.isEmpty=function(){return q};this.toString=
|
|
|
-function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+e+", bottom: "+k+", width: "+l+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
|
|
|
-THREE.Matrix4=function(a,c,e,f,k,l,p,q,m,n,C,B,u,x,b,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=f||0;this.n21=k||0;this.n22=l||1;this.n23=p||0;this.n24=q||0;this.n31=m||0;this.n32=n||0;this.n33=C||1;this.n34=B||0;this.n41=u||0;this.n42=x||0;this.n43=b||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
|
|
|
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,e,f,k,l,p,q,m,n,C,B,u,x,b,H){this.n11=a;this.n12=c;this.n13=e;this.n14=f;this.n21=k;this.n22=l;this.n23=p;this.n24=q;this.n31=m;this.n32=n;this.n33=C;this.n34=B;this.n41=u;this.n42=x;this.n43=b;this.n44=H;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,e){var f=THREE.Matrix4.__tmpVec1,k=THREE.Matrix4.__tmpVec2,l=THREE.Matrix4.__tmpVec3;l.sub(a,c).normalize();f.cross(e,l).normalize();k.cross(l,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=k.x;this.n22=k.y;this.n23=k.z;this.n24=-k.dot(a);
|
|
|
-this.n31=l.x;this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,f=a.z,k=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*k;a.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*k;a.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*k;return a},multiplyVector4:function(a){var c=a.x,e=a.y,f=a.z,k=a.w;a.x=this.n11*c+this.n12*e+this.n13*f+this.n14*k;a.y=this.n21*c+this.n22*e+this.n23*
|
|
|
-f+this.n24*k;a.z=this.n31*c+this.n32*e+this.n33*f+this.n34*k;a.w=this.n41*c+this.n42*e+this.n43*f+this.n44*k;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var e=a.n11,f=a.n12,k=a.n13,l=a.n14,p=a.n21,q=a.n22,m=a.n23,n=a.n24,C=a.n31,
|
|
|
-B=a.n32,u=a.n33,x=a.n34,b=a.n41,H=a.n42,I=a.n43,s=a.n44,R=c.n11,F=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,L=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43,o=c.n44;this.n11=e*R+f*Y+k*M+l*i;this.n12=e*F+f*P+k*U+l*j;this.n13=e*J+f*L+k*d+l*g;this.n14=e*O+f*V+k*h+l*o;this.n21=p*R+q*Y+m*M+n*i;this.n22=p*F+q*P+m*U+n*j;this.n23=p*J+q*L+m*d+n*g;this.n24=p*O+q*V+m*h+n*o;this.n31=C*R+B*Y+u*M+x*i;this.n32=C*F+B*P+u*U+x*j;this.n33=C*J+B*L+u*d+x*g;this.n34=C*O+B*V+u*h+x*o;this.n41=b*R+H*Y+
|
|
|
-I*M+s*i;this.n42=b*F+H*P+I*U+s*j;this.n43=b*J+H*L+I*d+s*g;this.n44=b*O+H*V+I*h+s*o;return this},multiplyToArray:function(a,c,e){var f=a.n11,k=a.n12,l=a.n13,p=a.n14,q=a.n21,m=a.n22,n=a.n23,C=a.n24,B=a.n31,u=a.n32,x=a.n33,b=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var R=c.n11,F=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,L=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43;c=c.n44;this.n11=f*R+k*Y+l*M+p*i;this.n12=f*F+k*P+l*U+p*j;this.n13=f*J+k*L+l*d+p*g;this.n14=f*O+k*V+l*h+p*c;this.n21=
|
|
|
-q*R+m*Y+n*M+C*i;this.n22=q*F+m*P+n*U+C*j;this.n23=q*J+m*L+n*d+C*g;this.n24=q*O+m*V+n*h+C*c;this.n31=B*R+u*Y+x*M+b*i;this.n32=B*F+u*P+x*U+b*j;this.n33=B*J+u*L+x*d+b*g;this.n34=B*O+u*V+x*h+b*c;this.n41=H*R+I*Y+s*M+a*i;this.n42=H*F+I*P+s*U+a*j;this.n43=H*J+I*L+s*d+a*g;this.n44=H*O+I*V+s*h+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;
|
|
|
-e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,f=this.n13,k=this.n14,l=this.n21,p=this.n22,q=this.n23,m=this.n24,n=this.n31,C=this.n32,B=this.n33,u=this.n34,x=this.n41,b=this.n42,H=this.n43,I=this.n44,s=a.n11,R=a.n21,F=a.n31,J=a.n41,O=a.n12,Y=a.n22,P=a.n32,L=a.n42,V=a.n13,M=a.n23,U=a.n33,d=a.n43,h=a.n14,i=a.n24,j=a.n34;a=a.n44;this.n11=c*s+e*R+f*F+k*J;this.n12=c*O+e*Y+f*P+k*L;this.n13=c*V+e*M+f*U+k*d;this.n14=c*h+e*i+f*j+k*a;this.n21=l*s+p*R+q*F+m*J;this.n22=l*O+p*
|
|
|
-Y+q*P+m*L;this.n23=l*V+p*M+q*U+m*d;this.n24=l*h+p*i+q*j+m*a;this.n31=n*s+C*R+B*F+u*J;this.n32=n*O+C*Y+B*P+u*L;this.n33=n*V+C*M+B*U+u*d;this.n34=n*h+C*i+B*j+u*a;this.n41=x*s+b*R+H*F+I*J;this.n42=x*O+b*Y+H*P+I*L;this.n43=x*V+b*M+H*U+I*d;this.n44=x*h+b*i+H*j+I*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},
|
|
|
-determinant:function(){var a=this.n11,c=this.n12,e=this.n13,f=this.n14,k=this.n21,l=this.n22,p=this.n23,q=this.n24,m=this.n31,n=this.n32,C=this.n33,B=this.n34,u=this.n41,x=this.n42,b=this.n43,H=this.n44;return f*p*n*u-e*q*n*u-f*l*C*u+c*q*C*u+e*l*B*u-c*p*B*u-f*p*m*x+e*q*m*x+f*k*C*x-a*q*C*x-e*k*B*x+a*p*B*x+f*l*m*b-c*q*m*b-f*k*n*b+a*q*n*b+c*k*B*b-a*l*B*b-e*l*m*H+c*p*m*H+e*k*n*H-a*p*n*H-c*k*C*H+a*l*C*H},transpose:function(){function a(c,e,f){var k=c[e];c[e]=c[f];c[f]=k}a(this,"n21","n12");a(this,"n31",
|
|
|
-"n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;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},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},setTranslation:function(a,c,e){this.set(1,0,0,a,0,1,0,c,0,0,1,e,0,0,0,
|
|
|
-1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var e=Math.cos(c),f=Math.sin(c),k=1-e,l=a.x,p=a.y,q=a.z,
|
|
|
-m=k*l,n=k*p;this.set(m*l+e,m*p-f*q,m*q+f*p,0,m*p+f*q,n*p+e,n*q-f*l,0,m*q-f*p,n*q+f*l,k*q*q+e,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,e){var f=new THREE.Matrix4;f.setTranslation(a,c,e);return f};
|
|
|
-THREE.Matrix4.scaleMatrix=function(a,c,e){var f=new THREE.Matrix4;f.setScale(a,c,e);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e};
|
|
|
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,f=a.n13,k=a.n14,l=a.n21,p=a.n22,q=a.n23,m=a.n24,n=a.n31,C=a.n32,B=a.n33,u=a.n34,x=a.n41,b=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=q*u*b-m*B*b+m*C*H-p*u*H-q*C*I+p*B*I;s.n12=k*B*b-f*u*b-k*C*H+e*u*H+f*C*I-e*B*I;s.n13=f*m*b-k*q*b+k*p*H-e*m*H-f*p*I+e*q*I;s.n14=k*q*C-f*m*C-k*p*B+e*m*B+f*p*u-e*q*u;s.n21=m*B*x-q*u*x-m*n*H+l*u*H+q*n*I-l*B*I;s.n22=f*u*x-k*B*x+k*n*H-c*u*H-f*n*I+c*B*I;s.n23=k*q*x-f*m*x-k*l*H+c*m*H+f*l*I-c*q*I;s.n24=f*m*n-k*q*n+
|
|
|
-k*l*B-c*m*B-f*l*u+c*q*u;s.n31=p*u*x-m*C*x+m*n*b-l*u*b-p*n*I+l*C*I;s.n32=k*C*x-e*u*x-k*n*b+c*u*b+e*n*I-c*C*I;s.n33=f*m*x-k*p*x+k*l*b-c*m*b-e*l*I+c*p*I;s.n34=k*p*n-e*m*n-k*l*C+c*m*C+e*l*u-c*p*u;s.n41=q*C*x-p*B*x-q*n*b+l*B*b+p*n*H-l*C*H;s.n42=e*B*x-f*C*x+f*n*b-c*B*b-e*n*H+c*C*H;s.n43=f*p*x-e*q*x-f*l*b+c*q*b+e*l*H-c*p*H;s.n44=e*q*n-f*p*n+f*l*C-c*q*C-e*l*B+c*p*B;s.multiplyScalar(1/a.determinant());return s};
|
|
|
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,f=a.n33*a.n22-a.n32*a.n23,k=-a.n33*a.n21+a.n31*a.n23,l=a.n32*a.n21-a.n31*a.n22,p=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,C=-a.n23*a.n11+a.n21*a.n13,B=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*p+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*f;e[1]=a*k;e[2]=a*l;e[3]=a*p;e[4]=a*q;e[5]=a*m;e[6]=a*n;e[7]=a*C;e[8]=a*B;return c};
|
|
|
-THREE.Matrix4.makeFrustum=function(a,c,e,f,k,l){var p,q,m;p=new THREE.Matrix4;q=2*k/(c-a);m=2*k/(f-e);a=(c+a)/(c-a);e=(f+e)/(f-e);f=-(l+k)/(l-k);k=-2*l*k/(l-k);p.n11=q;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=m;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=k;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,c,e,f){var k;a=e*Math.tan(a*Math.PI/360);k=-a;return THREE.Matrix4.makeFrustum(k*c,a*c,k,a,e,f)};
|
|
|
-THREE.Matrix4.makeOrtho=function(a,c,e,f,k,l){var p,q,m,n;p=new THREE.Matrix4;q=c-a;m=e-f;n=l-k;a=(c+a)/q;e=(e+f)/m;k=(l+k)/n;p.n11=2/q;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/m;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/n;p.n34=-k;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function c(I,s,O,C){C=C.clone().subSelf(s);O=O.clone().subSelf(s);var b=I.clone().subSelf(s);I=C.dot(C);s=C.dot(O);C=C.dot(b);var R=O.dot(O);O=O.dot(b);b=1/(I*R-s*s);R=(R*C-s*O)*b;I=(I*O-s*C)*b;return R>0&&I>0&&R+I<1}var d,f,j,k,q,o,l,m,z,y,
|
|
|
+v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;d<f;d++){j=x.faces[d];y=this.origin.clone();v=this.direction.clone();k=a.matrix.multiplyVector3(F[j.a].position.clone());q=a.matrix.multiplyVector3(F[j.b].position.clone());o=a.matrix.multiplyVector3(F[j.c].position.clone());l=j instanceof THREE.Face4?a.matrix.multiplyVector3(F[j.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(j.normal.clone());z=v.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(k,y))/z;y=y.addSelf(v.multiplyScalar(m));
|
|
|
+if(j instanceof THREE.Face3){if(c(y,k,q,o)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}else if(j instanceof THREE.Face4)if(c(y,k,q,l)||c(y,q,o,l)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}}return H}};
|
|
|
+THREE.Rectangle=function(){function a(){k=f-c;q=j-d}var c,d,f,j,k,q,o=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(l,m,z,y){o=false;c=l;d=m;f=z;j=y;a()};this.addPoint=function(l,m){if(o){o=false;c=l;d=m;f=l;j=m}else{c=c<l?c:l;d=d<m?d:m;f=f>l?f:l;j=j>m?
|
|
|
+j:m}a()};this.add3Points=function(l,m,z,y,v,x){if(o){o=false;c=l<z?l<v?l:v:z<v?z:v;d=m<y?m<x?m:x:y<x?y:x;f=l>z?l>v?l:v:z>v?z:v;j=m>y?m>x?m:x:y>x?y:x}else{c=l<z?l<v?l<c?l:c:v<c?v:c:z<v?z<c?z:c:v<c?v:c;d=m<y?m<x?m<d?m:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=m>y?m>x?m>j?m:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
|
|
|
+f=f>l.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();j=j<l.getBottom()?j:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=
|
|
|
+function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
|
|
|
+THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
|
|
|
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
+a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
|
|
|
+this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
|
|
|
+f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,m=a.n24,z=a.n31,
|
|
|
+y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+m*K;this.n22=q*C+o*Q+l*U+m*ca;this.n23=q*b+o*J+l*M+m*N;this.n24=q*R+o*X+l*D+m*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41=
|
|
|
+F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,m=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q*
|
|
|
+c;this.n21=o*O+l*$+m*G+z*K;this.n22=o*C+l*Q+m*U+z*ca;this.n23=o*b+l*J+m*M+z*N;this.n24=o*R+l*X+m*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;
|
|
|
+d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l*
|
|
|
+b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=m*s+z*O+y*C+v*b;this.n32=m*R+z*$+y*Q+v*J;this.n33=m*X+z*G+y*U+v*M;this.n34=m*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=
|
|
|
+a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*m*v-d*o*m*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*m*F+a*o*m*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*m*H-a*q*m*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}a(this,"n21","n12");
|
|
|
+a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;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},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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,
|
|
|
+0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y,
|
|
|
+o=a.z,l=j*k,m=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,m*q+d,m*o-f*k,0,l*o-f*q,m*o+f*k,j*o*o+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};
|
|
|
+THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
|
|
|
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*m*H+k*v*H+o*m*I-k*y*I;s.n22=f*v*x-j*y*x+j*m*H-c*v*H-f*m*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*m-j*o*m+
|
|
|
+j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*m*F-k*v*F-q*m*I+k*z*I;s.n32=j*z*x-d*v*x-j*m*F+c*v*F+d*m*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*m-d*l*m-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*m*F+k*y*F+q*m*H-k*z*H;s.n42=d*y*x-f*z*x+f*m*F-c*y*F-d*m*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*m-f*q*m+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
|
|
|
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*m;d[7]=a*z;d[8]=a*y;return c};
|
|
|
+THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)};
|
|
|
+THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,m;q=new THREE.Matrix4;o=c-a;l=d-f;m=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/m;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
|
|
THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
|
|
|
-THREE.Face3=function(a,c,e,f,k){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=k instanceof Array?k:[k]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
-THREE.Face4=function(a,c,e,f,k,l){this.a=a;this.b=c;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=k instanceof THREE.Vector3?k:new THREE.Vector3;this.vertexNormals=k instanceof Array?k:[];this.materials=l instanceof Array?l:[l]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
|
|
|
+THREE.Face3=function(a,c,d,f,j){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
+THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
|
|
|
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
|
|
|
-THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
|
|
|
-e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,e,f,k,l,p,q=new THREE.Vector3,m=new THREE.Vector3;f=0;for(k=this.vertices.length;f<k;f++){l=this.vertices[f];l.normal.set(0,0,0)}f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];if(a&&l.vertexNormals.length){q.set(0,0,0);c=0;for(e=l.normal.length;c<e;c++)q.addSelf(l.vertexNormals[c]);q.divideScalar(3)}else{c=this.vertices[l.a];e=this.vertices[l.b];p=this.vertices[l.c];q.sub(p.position,
|
|
|
-e.position);m.sub(c.position,e.position);q.crossSelf(m)}q.isZero()||q.normalize();l.normal.copy(q)}},computeVertexNormals:function(){var a,c,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
|
|
|
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
|
|
|
-c;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(h,i,j,g,o,z,r){l=h.vertices[i].position;p=h.vertices[j].position;q=h.vertices[g].position;m=k[o];n=k[z];C=k[r];B=p.x-l.x;u=q.x-l.x;x=p.y-l.y;b=q.y-l.y;
|
|
|
-H=p.z-l.z;I=q.z-l.z;s=n.u-m.u;R=C.u-m.u;F=n.v-m.v;J=C.v-m.v;O=1/(s*J-R*F);L.set((J*B-F*u)*O,(J*x-F*b)*O,(J*H-F*I)*O);V.set((s*u-R*B)*O,(s*b-R*x)*O,(s*I-R*H)*O);Y[i].addSelf(L);Y[j].addSelf(L);Y[g].addSelf(L);P[i].addSelf(V);P[j].addSelf(V);P[g].addSelf(V)}var c,e,f,k,l,p,q,m,n,C,B,u,x,b,H,I,s,R,F,J,O,Y=[],P=[],L=new THREE.Vector3,V=new THREE.Vector3,M=new THREE.Vector3,U=new THREE.Vector3,d=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++){Y[c]=new THREE.Vector3;P[c]=new THREE.Vector3}c=0;
|
|
|
-for(e=this.faces.length;c<e;c++){f=this.faces[c];k=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
|
|
|
-this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(e=this.vertices.length;c<e;c++){d.copy(this.vertices[c].normal);f=Y[c];M.copy(f);M.subSelf(d.multiplyScalar(d.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(P[c]);f=f<0?-1:1;this.vertices[c].tangent.set(M.x,M.y,M.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
|
|
-z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,e=this.vertices.length;c<e;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
|
|
|
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c<e;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(C){var B=[];c=0;for(e=C.length;c<e;c++)C[c]==undefined?B.push("undefined"):B.push(C[c].toString());return B.join("_")}var c,e,f,k,l,p,q,m,n={};f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];
|
|
|
-p=l.materials;q=a(p);if(n[q]==undefined)n[q]={hash:q,counter:0};m=n[q].hash+"_"+n[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0};l=l instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+l>65535){n[q].counter+=1;m=n[q].hash+"_"+n[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0}}this.geometryChunks[m].faces.push(f);this.geometryChunks[m].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+
|
|
|
+THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
|
|
|
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,j,k,q,o=new THREE.Vector3,l=new THREE.Vector3;f=0;for(j=this.vertices.length;f<j;f++){k=this.vertices[f];k.normal.set(0,0,0)}f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];if(a&&k.vertexNormals.length){o.set(0,0,0);c=0;for(d=k.normal.length;c<d;c++)o.addSelf(k.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[k.a];d=this.vertices[k.b];q=this.vertices[k.c];o.sub(q.position,
|
|
|
+d.position);l.sub(c.position,d.position);o.crossSelf(l)}o.isZero()||o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
|
|
|
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
|
|
|
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(D,K,ca,N,aa,e,i){k=D.vertices[K].position;q=D.vertices[ca].position;o=D.vertices[N].position;l=j[aa];m=j[e];z=j[i];y=q.x-k.x;v=o.x-k.x;x=q.y-k.y;F=o.y-
|
|
|
+k.y;H=q.z-k.z;I=o.z-k.z;s=m.u-l.u;O=z.u-l.u;C=m.v-l.v;b=z.v-l.v;R=1/(s*b-O*C);J.set((b*y-C*v)*R,(b*x-C*F)*R,(b*H-C*I)*R);X.set((s*v-O*y)*R,(s*F-O*x)*R,(s*I-O*H)*R);$[K].addSelf(J);$[ca].addSelf(J);$[N].addSelf(J);Q[K].addSelf(X);Q[ca].addSelf(X);Q[N].addSelf(X)}var c,d,f,j,k,q,o,l,m,z,y,v,x,F,H,I,s,O,C,b,R,$=[],Q=[],J=new THREE.Vector3,X=new THREE.Vector3,G=new THREE.Vector3,U=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){$[c]=new THREE.Vector3;Q[c]=new THREE.Vector3}c=
|
|
|
+0;for(d=this.faces.length;c<d;c++){f=this.faces[c];j=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
|
|
|
+this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){M.copy(this.vertices[c].normal);f=$[c];G.copy(f);G.subSelf(M.multiplyScalar(M.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(Q[c]);f=f<0?-1:1;this.vertices[c].tangent.set(G.x,G.y,G.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
|
|
+z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
|
|
|
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,j,k,q,o,l,m={};f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];
|
|
|
+q=k.materials;o=a(q);if(m[o]==undefined)m[o]={hash:o,counter:0};l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){m[o].counter+=1;l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
|
|
|
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
-THREE.Camera=function(a,c,e,f){this.fov=a;this.aspect=c;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
|
|
-this.translateZ=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
|
|
|
+THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
|
|
+this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
|
|
|
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
|
|
|
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
|
|
|
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
|
|
|
-THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
|
|
|
-THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
|
|
|
-THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
|
|
|
+THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
|
|
|
+THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x,
|
|
|
+d.y,d.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
|
|
|
+THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
|
|
|
THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
|
|
|
THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
|
|
|
a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
|
|
@@ -96,115 +96,116 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
|
|
|
THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
|
|
|
if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
|
|
|
THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
|
-THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,f,k,l){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=k!==undefined?k:THREE.LinearFilter;this.min_filter=l!==undefined?l:THREE.LinearMipMapLinearFilter};
|
|
|
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
|
|
|
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
|
|
|
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.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.RenderTarget=function(a,c,e){this.width=a;this.height=c;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
|
|
|
-var Uniforms={clone:function(a){var c,e,f,k={};for(c in a){k[c]={};for(e in a[c]){f=a[c][e];k[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return k},merge:function(a){var c,e,f,k={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(e in f)k[e]=f[e]}return k}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
|
|
+THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
|
|
|
+var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)j[d]=f[d]}return j}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
|
|
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
|
-THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
|
|
|
-THREE.Projector=function(){function a(P,L){return L.z-P.z}function c(P,L){var V=0,M=1,U=P.z+P.w,d=L.z+L.w,h=-P.z+P.w,i=-L.z+L.w;if(U>=0&&d>=0&&h>=0&&i>=0)return true;else if(U<0&&d<0||h<0&&i<0)return false;else{if(U<0)V=Math.max(V,U/(U-d));else if(d<0)M=Math.min(M,U/(U-d));if(h<0)V=Math.max(V,h/(h-i));else if(i<0)M=Math.min(M,h/(h-i));if(M<V)return false;else{P.lerpSelf(L,V);L.lerpSelf(P,1-M);return true}}}var e,f,k=[],l,p,q,m=[],n,C,B=[],u,x,b=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
|
|
|
-R=new THREE.Matrix4,F=[],J=new THREE.Vector4,O=new THREE.Vector4,Y;this.projectObjects=function(P,L,V){var M=[],U,d;f=0;s.multiply(L.projectionMatrix,L.matrix);F[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);F[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);F[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);F[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);F[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
|
|
|
-s.n33,s.n44-s.n34);F[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);L=0;for(U=F.length;L<U;L++){d=F[L];d.divideScalar(Math.sqrt(d.x*d.x+d.y*d.y+d.z*d.z))}U=P.objects;P=0;for(L=U.length;P<L;P++){d=U[P];var h;if(!(h=!d.visible)){if(h=d instanceof THREE.Mesh){a:{h=void 0;for(var i=d.position,j=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,Math.max(d.scale.y,d.scale.z)),g=0;g<6;g++){h=F[g].x*i.x+F[g].y*i.y+F[g].z*i.z+F[g].w;if(h<=j){h=false;break a}}h=true}h=!h}h=h}if(!h){e=
|
|
|
-k[f]=k[f]||new THREE.RenderableObject;H.copy(d.position);s.multiplyVector3(H);e.object=d;e.z=H.z;M.push(e);f++}}V&&M.sort(a);return M};this.projectScene=function(P,L,V){var M=[],U=L.near,d=L.far,h,i,j,g,o,z,r,t,v,w,y,K,E,A,N,T;q=C=x=0;L.autoUpdateMatrix&&L.updateMatrix();s.multiply(L.projectionMatrix,L.matrix);z=this.projectObjects(P,L,true);P=0;for(h=z.length;P<h;P++){r=z[P].object;if(r.visible){r.autoUpdateMatrix&&r.updateMatrix();t=r.matrix;v=r.rotationMatrix;w=r.materials;y=r.overdraw;if(r instanceof
|
|
|
-THREE.Mesh){K=r.geometry;E=K.vertices;i=0;for(j=E.length;i<j;i++){A=E[i];A.positionWorld.copy(A.position);t.multiplyVector3(A.positionWorld);g=A.positionScreen;g.copy(A.positionWorld);s.multiplyVector4(g);g.x/=g.w;g.y/=g.w;A.__visible=g.z>U&&g.z<d}K=K.faces;i=0;for(j=K.length;i<j;i++){A=K[i];if(A instanceof THREE.Face3){g=E[A.a];o=E[A.b];N=E[A.c];if(g.__visible&&o.__visible&&N.__visible)if(r.doubleSided||r.flipSided!=(N.positionScreen.x-g.positionScreen.x)*(o.positionScreen.y-g.positionScreen.y)-
|
|
|
-(N.positionScreen.y-g.positionScreen.y)*(o.positionScreen.x-g.positionScreen.x)<0){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(o.positionWorld);l.v3.positionWorld.copy(N.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(o.positionScreen);l.v3.positionScreen.copy(N.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);
|
|
|
-l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);N=A.vertexNormals;Y=l.vertexNormalsWorld;g=0;for(o=N.length;g<o;g++){T=Y[g]=Y[g]||new THREE.Vector3;T.copy(N[g]);v.multiplyVector3(T)}l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][2]}M.push(l);q++}}else if(A instanceof THREE.Face4){g=E[A.a];o=E[A.b];N=E[A.c];T=E[A.d];if(g.__visible&&
|
|
|
-o.__visible&&N.__visible&&T.__visible)if(r.doubleSided||r.flipSided!=((T.positionScreen.x-g.positionScreen.x)*(o.positionScreen.y-g.positionScreen.y)-(T.positionScreen.y-g.positionScreen.y)*(o.positionScreen.x-g.positionScreen.x)<0||(o.positionScreen.x-N.positionScreen.x)*(T.positionScreen.y-N.positionScreen.y)-(o.positionScreen.y-N.positionScreen.y)*(T.positionScreen.x-N.positionScreen.x)<0)){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(o.positionWorld);
|
|
|
-l.v3.positionWorld.copy(T.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(o.positionScreen);l.v3.positionScreen.copy(T.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];
|
|
|
-l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][3]}M.push(l);q++;p=m[q]=m[q]||new THREE.RenderableFace3;p.v1.positionWorld.copy(o.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(T.positionWorld);p.v1.positionScreen.copy(o.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(T.positionScreen);p.normalWorld.copy(l.normalWorld);p.centroidWorld.copy(l.centroidWorld);p.centroidScreen.copy(l.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
|
|
|
-w;p.faceMaterials=A.materials;p.overdraw=y;if(r.geometry.uvs[i]){p.uvs[0]=r.geometry.uvs[i][1];p.uvs[1]=r.geometry.uvs[i][2];p.uvs[2]=r.geometry.uvs[i][3]}M.push(p);q++}}}}else if(r instanceof THREE.Line){R.multiply(s,t);E=r.geometry.vertices;A=E[0];A.positionScreen.copy(A.position);R.multiplyVector4(A.positionScreen);i=1;for(j=E.length;i<j;i++){g=E[i];g.positionScreen.copy(g.position);R.multiplyVector4(g.positionScreen);o=E[i-1];J.copy(g.positionScreen);O.copy(o.positionScreen);if(c(J,O)){J.multiplyScalar(1/
|
|
|
-J.w);O.multiplyScalar(1/O.w);n=B[C]=B[C]||new THREE.RenderableLine;n.v1.positionScreen.copy(J);n.v2.positionScreen.copy(O);n.z=Math.max(J.z,O.z);n.materials=r.materials;M.push(n);C++}}}else if(r instanceof THREE.Particle){I.set(r.position.x,r.position.y,r.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){u=b[x]=b[x]||new THREE.RenderableParticle;u.x=I.x/I.w;u.y=I.y/I.w;u.z=I.z;u.rotation=r.rotation.z;u.scale.x=r.scale.x*Math.abs(u.x-(I.x+L.projectionMatrix.n11)/(I.w+L.projectionMatrix.n14));
|
|
|
-u.scale.y=r.scale.y*Math.abs(u.y-(I.y+L.projectionMatrix.n22)/(I.w+L.projectionMatrix.n24));u.materials=r.materials;M.push(u);x++}}}}V&&M.sort(a);return M};this.unprojectVector=function(P,L){var V=THREE.Matrix4.makeInvert(L.matrix);V.multiplySelf(THREE.Matrix4.makeInvert(L.projectionMatrix));V.multiplyVector3(P);return P}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,f,k,l;this.domElement=document.createElement("div");this.setSize=function(p,q){e=p;f=q;k=e/2;l=f/2};this.render=function(p,q){var m,n,C,B,u,x,b,H;a=c.projectScene(p,q);m=0;for(n=a.length;m<n;m++){u=a[m];if(u instanceof THREE.RenderableParticle){b=u.x*k+k;H=u.y*l+l;C=0;for(B=u.material.length;C<B;C++){x=u.material[C];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=b+"px";x.style.top=H+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a($){if(u!=$)n.globalAlpha=u=$}function c($){if(x!=$){switch($){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}x=$}}var e=null,f=new THREE.Projector,k=document.createElement("canvas"),l,p,q,m,n=k.getContext("2d"),C=new THREE.Color(0),B=0,u=1,x=0,b=null,H=null,I=1,s,R,F,J,O,Y,P,L,V,M=new THREE.Color,
|
|
|
-U=new THREE.Color,d=new THREE.Color,h=new THREE.Color,i=new THREE.Color,j,g,o,z,r,t,v,w,y,K=new THREE.Rectangle,E=new THREE.Rectangle,A=new THREE.Rectangle,N=false,T=new THREE.Color,ca=new THREE.Color,ga=new THREE.Color,Z=new THREE.Color,ka=Math.PI*2,W=new THREE.Vector3,da,sa,va,ea,aa,fa,la=16;da=document.createElement("canvas");da.width=da.height=2;sa=da.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);va=sa.getImageData(0,0,2,2);ea=va.data;aa=document.createElement("canvas");aa.width=
|
|
|
-aa.height=la;fa=aa.getContext("2d");fa.translate(-la/2,-la/2);fa.scale(la,la);la--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function($,qa){l=$;p=qa;q=l/2;m=p/2;k.width=l;k.height=p;K.set(-q,-m,q,m);u=1;x=0;H=b=null;I=1};this.setClearColor=function($,qa){C=$;B=qa;E.set(-q,-m,q,m);n.setTransform(1,0,0,-1,q,m);this.clear()};this.setClearColorHex=function($,qa){C.setHex($);B=qa;E.set(-q,-m,q,m);n.setTransform(1,0,0,-1,q,m);this.clear()};this.clear=function(){n.setTransform(1,
|
|
|
-0,0,-1,q,m);if(!E.isEmpty()){E.inflate(1);E.minSelf(K);if(C.hex==0&&B==0)n.clearRect(E.getX(),E.getY(),E.getWidth(),E.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*255)+","+B+")";n.fillRect(E.getX(),E.getY(),E.getWidth(),E.getHeight())}E.empty()}};this.render=function($,qa){function na(D){var X,S,G,Q=D.lights;ca.setRGB(0,0,0);ga.setRGB(0,0,0);Z.setRGB(0,0,0);D=0;for(X=Q.length;D<X;D++){S=Q[D];G=S.color;if(S instanceof
|
|
|
-THREE.AmbientLight){ca.r+=G.r;ca.g+=G.g;ca.b+=G.b}else if(S instanceof THREE.DirectionalLight){ga.r+=G.r;ga.g+=G.g;ga.b+=G.b}else if(S instanceof THREE.PointLight){Z.r+=G.r;Z.g+=G.g;Z.b+=G.b}}}function za(D,X,S,G){var Q,ba,ia,ma,oa=D.lights;D=0;for(Q=oa.length;D<Q;D++){ba=oa[D];ia=ba.color;ma=ba.intensity;if(ba instanceof THREE.DirectionalLight){ba=S.dot(ba.position)*ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}else if(ba instanceof THREE.PointLight){W.sub(ba.position,X);W.normalize();ba=S.dot(W)*
|
|
|
-ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}}}function Fa(D,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);var G,Q,ba,ia,ma,oa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){ia=S.map.image;ma=ia.width>>1;oa=ia.height>>1;Q=X.scale.x*q;ba=X.scale.y*m;S=Q*ma;G=ba*oa;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(!K.instersects(A))return;n.save();n.translate(D.x,D.y);n.rotate(-X.rotation);n.scale(Q,-ba);n.translate(-ma,-oa);n.drawImage(ia,0,0);n.restore()}n.beginPath();n.moveTo(D.x-
|
|
|
-10,D.y);n.lineTo(D.x+10,D.y);n.moveTo(D.x,D.y-10);n.lineTo(D.x,D.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(N){T.r=ca.r+ga.r+Z.r;T.g=ca.g+ga.g+Z.g;T.b=ca.b+ga.b+Z.b;M.r=S.color.r*T.r;M.g=S.color.g*T.g;M.b=S.color.b*T.b;M.updateStyleString()}else M.__styleString=S.color.__styleString;S=X.scale.x*q;G=X.scale.y*m;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(K.instersects(A)){Q=M.__styleString;if(H!=Q)n.fillStyle=H=Q;n.save();n.translate(D.x,
|
|
|
-D.y);n.rotate(-X.rotation);n.scale(S,G);n.beginPath();n.arc(0,0,1,0,ka,true);n.closePath();n.fill();n.restore()}}}}function Aa(D,X,S,G){if(G.opacity!=0){a(G.opacity);c(G.blending);n.beginPath();n.moveTo(D.positionScreen.x,D.positionScreen.y);n.lineTo(X.positionScreen.x,X.positionScreen.y);n.closePath();if(G instanceof THREE.LineBasicMaterial){M.__styleString=G.color.__styleString;D=G.linewidth;if(I!=D)n.lineWidth=I=D;D=M.__styleString;if(b!=D)n.strokeStyle=b=D;n.stroke();A.inflate(G.linewidth*2)}}}
|
|
|
-function Da(D,X,S,G,Q,ba){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);J=D.positionScreen.x;O=D.positionScreen.y;Y=X.positionScreen.x;P=X.positionScreen.y;L=S.positionScreen.x;V=S.positionScreen.y;n.beginPath();n.moveTo(J,O);n.lineTo(Y,P);n.lineTo(L,V);n.lineTo(J,O);n.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&ja(J,O,Y,P,L,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
|
|
|
-THREE.SphericalReflectionMapping){D=qa.matrix;W.copy(G.vertexNormalsWorld[0]);z=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;r=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[1]);t=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;v=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[2]);w=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;y=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;ja(J,O,Y,P,L,V,Q.env_map.image,z,r,t,v,w,y)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):
|
|
|
-Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&ja(J,O,Y,P,L,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);c(THREE.SubtractiveBlending)}if(N)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==3){U.r=d.r=h.r=ca.r;U.g=d.g=h.g=ca.g;U.b=d.b=h.b=ca.b;za(ba,G.v1.positionWorld,G.vertexNormalsWorld[0],U);za(ba,G.v2.positionWorld,G.vertexNormalsWorld[1],
|
|
|
-d);za(ba,G.v3.positionWorld,G.vertexNormalsWorld[2],h);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;o=Ga(U,d,h,i);ja(J,O,Y,P,L,V,o,0,0,1,0,0,1)}else{T.r=ca.r;T.g=ca.g;T.b=ca.b;za(ba,G.centroidWorld,G.normalWorld,T);M.r=Q.color.r*T.r;M.g=Q.color.g*T.g;M.b=Q.color.b*T.b;M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){j=
|
|
|
-qa.near;g=qa.far;U.r=U.g=U.b=1-Ha(D.positionScreen.z,j,g);d.r=d.g=d.b=1-Ha(X.positionScreen.z,j,g);h.r=h.g=h.b=1-Ha(S.positionScreen.z,j,g);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;o=Ga(U,d,h,i);ja(J,O,Y,P,L,V,o,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Ia(G.normalWorld.x);M.g=Ia(G.normalWorld.y);M.b=Ia(G.normalWorld.z);M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}}}function Ba(D,X){if(b!=D)n.strokeStyle=b=D;if(I!=
|
|
|
-X)n.lineWidth=I=X;n.stroke();A.inflate(X*2)}function Ca(D){if(H!=D)n.fillStyle=H=D;n.fill()}function ja(D,X,S,G,Q,ba,ia,ma,oa,wa,ra,xa,Ja){var ta,ya;ta=ia.width-1;ya=ia.height-1;ma*=ta;oa*=ya;wa*=ta;ra*=ya;xa*=ta;Ja*=ya;S-=D;G-=X;Q-=D;ba-=X;wa-=ma;ra-=oa;xa-=ma;Ja-=oa;ta=wa*Ja-xa*ra;if(ta!=0){ya=1/ta;ta=(Ja*S-ra*Q)*ya;ra=(Ja*G-ra*ba)*ya;S=(wa*Q-xa*S)*ya;G=(wa*ba-xa*G)*ya;D=D-ta*ma-S*oa;X=X-ra*ma-G*oa;n.save();n.transform(ta,ra,S,G,D,X);n.clip();n.drawImage(ia,0,0);n.restore()}}function Ga(D,X,S,G){var Q=
|
|
|
-~~(D.r*255),ba=~~(D.g*255);D=~~(D.b*255);var ia=~~(X.r*255),ma=~~(X.g*255);X=~~(X.b*255);var oa=~~(S.r*255),wa=~~(S.g*255);S=~~(S.b*255);var ra=~~(G.r*255),xa=~~(G.g*255);G=~~(G.b*255);ea[0]=Q<0?0:Q>255?255:Q;ea[1]=ba<0?0:ba>255?255:ba;ea[2]=D<0?0:D>255?255:D;ea[4]=ia<0?0:ia>255?255:ia;ea[5]=ma<0?0:ma>255?255:ma;ea[6]=X<0?0:X>255?255:X;ea[8]=oa<0?0:oa>255?255:oa;ea[9]=wa<0?0:wa>255?255:wa;ea[10]=S<0?0:S>255?255:S;ea[12]=ra<0?0:ra>255?255:ra;ea[13]=xa<0?0:xa>255?255:xa;ea[14]=G<0?0:G>255?255:G;sa.putImageData(va,
|
|
|
-0,0);fa.drawImage(da,0,0);return aa}function Ha(D,X,S){D=(D-X)/(S-X);return D*D*(3-2*D)}function Ia(D){D=(D+1)*0.5;return D<0?0:D>1?1:D}function Ka(D,X){var S=X.x-D.x,G=X.y-D.y,Q=1/Math.sqrt(S*S+G*G);S*=Q;G*=Q;X.x+=S;X.y+=G;D.x-=S;D.y-=G}var pa,Na,ha,ua,Ea,Ma,Oa,La;this.autoClear?this.clear():n.setTransform(1,0,0,-1,q,m);e=f.projectScene($,qa,this.sortElements);n.fillStyle="rgba( 0, 255, 255, 0.5 )";n.fillRect(K.getX(),K.getY(),K.getWidth(),K.getHeight());(N=$.lights.length>0)&&na($);pa=0;for(Na=
|
|
|
-e.length;pa<Na;pa++){ha=e[pa];A.empty();if(ha instanceof THREE.RenderableParticle){s=ha;s.x*=q;s.y*=m;ua=0;for(Ea=ha.materials.length;ua<Ea;ua++)Fa(s,ha,ha.materials[ua],$)}else if(ha instanceof THREE.RenderableLine){s=ha.v1;R=ha.v2;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;A.addPoint(s.positionScreen.x,s.positionScreen.y);A.addPoint(R.positionScreen.x,R.positionScreen.y);if(K.instersects(A)){ua=0;for(Ea=ha.materials.length;ua<Ea;)Aa(s,R,ha,ha.materials[ua++],
|
|
|
-$)}}else if(ha instanceof THREE.RenderableFace3){s=ha.v1;R=ha.v2;F=ha.v3;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;F.positionScreen.x*=q;F.positionScreen.y*=m;if(ha.overdraw){Ka(s.positionScreen,R.positionScreen);Ka(R.positionScreen,F.positionScreen);Ka(F.positionScreen,s.positionScreen)}A.add3Points(s.positionScreen.x,s.positionScreen.y,R.positionScreen.x,R.positionScreen.y,F.positionScreen.x,F.positionScreen.y);if(K.instersects(A)){ua=0;for(Ea=ha.meshMaterials.length;ua<
|
|
|
-Ea;){La=ha.meshMaterials[ua++];if(La instanceof THREE.MeshFaceMaterial){Ma=0;for(Oa=ha.faceMaterials.length;Ma<Oa;)(La=ha.faceMaterials[Ma++])&&Da(s,R,F,ha,La,$)}else Da(s,R,F,ha,La,$)}}}E.addRectangle(A)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(E.getX(),E.getY(),E.getWidth(),E.getHeight());n.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(z,r,t){var v,w,y,K;v=0;for(w=z.lights.length;v<w;v++){y=z.lights[v];if(y instanceof THREE.DirectionalLight){K=r.normalWorld.dot(y.position)*y.intensity;if(K>0){t.r+=y.color.r*K;t.g+=y.color.g*K;t.b+=y.color.b*K}}else if(y instanceof THREE.PointLight){V.sub(y.position,r.centroidWorld);V.normalize();K=r.normalWorld.dot(V)*y.intensity;if(K>0){t.r+=y.color.r*K;t.g+=y.color.g*K;t.b+=y.color.b*K}}}}function c(z,r,t,v,w,y){h=f(i++);h.setAttribute("d","M "+z.positionScreen.x+
|
|
|
-" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(y,v,J);F.r=w.color.r*J.r;F.g=w.color.g*J.g;F.b=w.color.b*J.b;F.updateStyleString()}else F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){L=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear);
|
|
|
-F.setRGB(L,L,L)}else w instanceof THREE.MeshNormalMaterial&&F.setRGB(k(v.normalWorld.x),k(v.normalWorld.y),k(v.normalWorld.z));w.wireframe?h.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):h.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+w.opacity);q.appendChild(h)}function e(z,r,t,v,w,y,K){h=f(i++);h.setAttribute("d",
|
|
|
-"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)F.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(K,w,J);F.r=y.color.r*J.r;F.g=y.color.g*J.g;F.b=y.color.b*J.b;F.updateStyleString()}else F.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){L=
|
|
|
-1-y.__2near/(y.__farPlusNear-w.z*y.__farMinusNear);F.setRGB(L,L,L)}else y instanceof THREE.MeshNormalMaterial&&F.setRGB(k(w.normalWorld.x),k(w.normalWorld.y),k(w.normalWorld.z));y.wireframe?h.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):h.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+y.opacity);q.appendChild(h)}
|
|
|
-function f(z){if(M[z]==null){M[z]=document.createElementNS("http://www.w3.org/2000/svg","path");o==0&&M[z].setAttribute("shape-rendering","crispEdges");return M[z]}return M[z]}function k(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var l=null,p=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,C,B,u,x,b,H,I=new THREE.Rectangle,s=new THREE.Rectangle,R=false,F=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0),Y=new THREE.Color(0),
|
|
|
-P=new THREE.Color(0),L,V=new THREE.Vector3,M=[],U=[],d=[],h,i,j,g,o=1;this.domElement=q;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":o=1;break;case "low":o=0}};this.setSize=function(z,r){m=z;n=r;C=m/2;B=n/2;q.setAttribute("viewBox",-C+" "+-B+" "+m+" "+n);q.setAttribute("width",m);q.setAttribute("height",n);I.set(-C,-B,C,B)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(z,r){var t,v,
|
|
|
-w,y,K,E,A,N;this.autoClear&&this.clear();l=p.projectScene(z,r,this.sortElements);g=j=i=0;if(R=z.lights.length>0){A=z.lights;O.setRGB(0,0,0);Y.setRGB(0,0,0);P.setRGB(0,0,0);t=0;for(v=A.length;t<v;t++){w=A[t];y=w.color;if(w instanceof THREE.AmbientLight){O.r+=y.r;O.g+=y.g;O.b+=y.b}else if(w instanceof THREE.DirectionalLight){Y.r+=y.r;Y.g+=y.g;Y.b+=y.b}else if(w instanceof THREE.PointLight){P.r+=y.r;P.g+=y.g;P.b+=y.b}}}t=0;for(v=l.length;t<v;t++){A=l[t];s.empty();if(A instanceof THREE.RenderableParticle){u=
|
|
|
-A;u.x*=C;u.y*=-B;w=0;for(y=A.materials.length;w<y;w++)if(N=A.materials[w]){K=u;E=A;N=N;var T=j++;if(U[T]==null){U[T]=document.createElementNS("http://www.w3.org/2000/svg","circle");o==0&&U[T].setAttribute("shape-rendering","crispEdges")}h=U[T];h.setAttribute("cx",K.x);h.setAttribute("cy",K.y);h.setAttribute("r",E.scale.x*C);if(N instanceof THREE.ParticleCircleMaterial){if(R){J.r=O.r+Y.r+P.r;J.g=O.g+Y.g+P.g;J.b=O.b+Y.b+P.b;F.r=N.color.r*J.r;F.g=N.color.g*J.g;F.b=N.color.b*J.b;F.updateStyleString()}else F=
|
|
|
-N.color;h.setAttribute("style","fill: "+F.__styleString)}q.appendChild(h)}}else if(A instanceof THREE.RenderableLine){u=A.v1;x=A.v2;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.materials.length;w<y;)if(N=A.materials[w++]){K=u;E=x;N=N;T=g++;if(d[T]==null){d[T]=document.createElementNS("http://www.w3.org/2000/svg","line");o==
|
|
|
-0&&d[T].setAttribute("shape-rendering","crispEdges")}h=d[T];h.setAttribute("x1",K.positionScreen.x);h.setAttribute("y1",K.positionScreen.y);h.setAttribute("x2",E.positionScreen.x);h.setAttribute("y2",E.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){F.__styleString=N.color.__styleString;h.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);q.appendChild(h)}}}}else if(A instanceof
|
|
|
-THREE.RenderableFace3){u=A.v1;x=A.v2;b=A.v3;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){K=0;for(E=A.faceMaterials.length;K<E;)(N=A.faceMaterials[K++])&&
|
|
|
-c(u,x,b,A,N,z)}else N&&c(u,x,b,A,N,z)}}}else if(A instanceof THREE.RenderableFace4){u=A.v1;x=A.v2;b=A.v3;H=A.v4;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;H.positionScreen.x*=C;H.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){w=
|
|
|
-0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){K=0;for(E=A.faceMaterials.length;K<E;)(N=A.faceMaterials[K++])&&e(u,x,b,H,A,N,z)}else N&&e(u,x,b,H,A,N,z)}}}}}};
|
|
|
-THREE.WebGLRenderer=function(a){function c(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function e(d,h){if(!d.__webGLVertexBuffer)d.__webGLVertexBuffer=b.createBuffer();if(!d.__webGLNormalBuffer)d.__webGLNormalBuffer=b.createBuffer();if(d.hasPos){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.position);b.vertexAttribPointer(h.attributes.position,
|
|
|
-3,b.FLOAT,false,0,0)}if(d.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,d.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.normal);b.vertexAttribPointer(h.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,d.count);d.count=0}function f(d){if(s!=d.doubleSided){d.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);s=d.doubleSided}if(R!=d.flipSided){d.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);R=d.flipSided}}function k(d){J[0].set(d.n41-
|
|
|
-d.n11,d.n42-d.n12,d.n43-d.n13,d.n44-d.n14);J[1].set(d.n41+d.n11,d.n42+d.n12,d.n43+d.n13,d.n44+d.n14);J[2].set(d.n41+d.n21,d.n42+d.n22,d.n43+d.n23,d.n44+d.n24);J[3].set(d.n41-d.n21,d.n42-d.n22,d.n43-d.n23,d.n44-d.n24);J[4].set(d.n41-d.n31,d.n42-d.n32,d.n43-d.n33,d.n44-d.n34);J[5].set(d.n41+d.n31,d.n42+d.n32,d.n43+d.n33,d.n44+d.n34);var h;for(d=0;d<5;d++){h=J[d];h.divideScalar(Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z))}}function l(d){for(var h=d.matrix,i=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,
|
|
|
-Math.max(d.scale.y,d.scale.z)),j=0;j<6;j++){d=J[j].x*h.n14+J[j].y*h.n24+J[j].z*h.n34+J[j].w;if(d<=i)return false}return true}function p(d,h){d.list[d.count]=h;d.count+=1}function q(d){var h,i,j=d.object,g=d.opaque,o=d.transparent;o.count=0;d=g.count=0;for(h=j.materials.length;d<h;d++){i=j.materials[d];i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?p(o,i):p(g,i)}}function m(d){var h,i,j,g,o=d.object,z=d.buffer,r=d.opaque,t=d.transparent;t.count=0;d=r.count=0;for(j=o.materials.length;d<j;d++){h=
|
|
|
-o.materials[d];if(h instanceof THREE.MeshFaceMaterial){h=0;for(i=z.materials.length;h<i;h++)if(g=z.materials[h])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}else{g=h;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}}}function n(d){if(d!=F){switch(d){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
|
|
|
-b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}F=d}}function C(d,h){if(d&&!d.__webGLFramebuffer){d.__webGLFramebuffer=b.createFramebuffer();d.__webGLRenderbuffer=b.createRenderbuffer();d.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,d.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,d.width,d.height);b.bindTexture(b.TEXTURE_2D,d.__webGLTexture);b.texParameteri(b.TEXTURE_2D,
|
|
|
-b.TEXTURE_WRAP_S,u(d.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(d.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(d.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(d.min_filter));b.texImage2D(b.TEXTURE_2D,0,u(d.format),d.width,d.height,0,u(d.format),u(d.type),null);b.bindFramebuffer(b.FRAMEBUFFER,d.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,d.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,
|
|
|
-b.RENDERBUFFER,d.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var i,j,g;if(d){i=d.__webGLFramebuffer;j=d.width;g=d.height}else{i=null;j=x.width;g=x.height}if(i!=I){b.bindFramebuffer(b.FRAMEBUFFER,i);b.viewport(0,0,j,g);h&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);I=i}}function B(d,h){var i;if(d=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(d=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,
|
|
|
-h);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function u(d){switch(d){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;
|
|
|
-case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;
|
|
|
-case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var x=document.createElement("canvas"),b,H=null,I=null,s=null,R=null,F=null,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Matrix4,Y=new Float32Array(16),P=new Float32Array(16),L=new THREE.Vector4,V=true,M=new THREE.Color(0),U=0;if(a){if(a.antialias!==undefined)V=a.antialias;a.clearColor!==undefined&&M.setHex(a.clearColor);
|
|
|
-if(a.clearAlpha!==undefined)U=a.clearAlpha}this.domElement=x;this.autoClear=true;(function(d,h,i){try{b=x.getContext("experimental-webgl",{antialias:d})}catch(j){console.log(j)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,i);_cullEnabled=true})(V,
|
|
|
-M,U);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(d,h){x.width=d;x.height=h;b.viewport(0,0,x.width,x.height)};this.setClearColorHex=function(d,h){var i=new THREE.Color(d);b.clearColor(i.r,i.g,i.b,h)};this.setClearColor=function(d,h){b.clearColor(d.r,d.g,d.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var i,j,g,o=0,z=0,r=0,t,v,w,y=
|
|
|
-this.lights,K=y.directional.colors,E=y.directional.positions,A=y.point.colors,N=y.point.positions,T=0,ca=0;i=g=g=0;for(j=h.length;i<j;i++){g=h[i];t=g.color;v=g.position;w=g.intensity;if(g instanceof THREE.AmbientLight){o+=t.r;z+=t.g;r+=t.b}else if(g instanceof THREE.DirectionalLight){g=T*3;K[g]=t.r*w;K[g+1]=t.g*w;K[g+2]=t.b*w;E[g]=v.x;E[g+1]=v.y;E[g+2]=v.z;T+=1}else if(g instanceof THREE.PointLight){g=ca*3;A[g]=t.r*w;A[g+1]=t.g*w;A[g+2]=t.b*w;N[g]=v.x;N[g+1]=v.y;N[g+2]=v.z;ca+=1}}for(i=T*3;i<K.length;i++)K[i]=
|
|
|
-0;for(i=ca*3;i<A.length;i++)A[i]=0;y.point.length=ca;y.directional.length=T;y.ambient[0]=o;y.ambient[1]=z;y.ambient[2]=r};this.createParticleBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLNormalBuffer=b.createBuffer();d.__webGLTangentBuffer=b.createBuffer();
|
|
|
-d.__webGLColorBuffer=b.createBuffer();d.__webGLUVBuffer=b.createBuffer();d.__webGLUV2Buffer=b.createBuffer();d.__webGLFaceBuffer=b.createBuffer();d.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__webGLLineCount=h};this.initParticleBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__sortArray=[];d.__webGLParticleCount=
|
|
|
-h};this.initMeshBuffers=function(d,h){var i,j,g=0,o=0,z=0,r=h.geometry.faces,t=d.faces;i=0;for(j=t.length;i<j;i++){fi=t[i];face=r[fi];if(face instanceof THREE.Face3){g+=3;o+=1;z+=3}else if(face instanceof THREE.Face4){g+=4;o+=2;z+=4}}d.__vertexArray=new Float32Array(g*3);d.__normalArray=new Float32Array(g*3);d.__tangentArray=new Float32Array(g*4);d.__colorArray=new Float32Array(g*3);d.__uvArray=new Float32Array(g*2);d.__uv2Array=new Float32Array(g*2);d.__faceArray=new Uint16Array(o*3);d.__lineArray=
|
|
|
-new Uint16Array(z*2);g=false;i=0;for(j=h.materials.length;i<j;i++){r=h.materials[i];if(r instanceof THREE.MeshFaceMaterial){r=0;for(t=d.materials.length;r<t;r++)if(d.materials[r]&&d.materials[r].shading!=undefined&&d.materials[r].shading==THREE.SmoothShading){g=true;break}}else if(r&&r.shading!=undefined&&r.shading==THREE.SmoothShading){g=true;break}if(g)break}d.__needsSmoothNormals=g;d.__webGLFaceCount=o*3;d.__webGLLineCount=z*2};this.setMeshBuffers=function(d,h,i){var j,g,o,z,r,t,v,w,y,K,E=0,A=
|
|
|
-0,N=0,T=0,ca=0,ga=0,Z=0,ka=0,W=0,da=d.__vertexArray,sa=d.__uvArray,va=d.__uv2Array,ea=d.__normalArray,aa=d.__tangentArray,fa=d.__colorArray,la=d.__faceArray,$=d.__lineArray,qa=d.__needsSmoothNormals,na=h.geometry,za=na.__dirtyVertices,Fa=na.__dirtyElements,Aa=na.__dirtyUvs,Da=na.__dirtyNormals,Ba=na.__dirtyTangents,Ca=na.__dirtyColors,ja=na.vertices,Ga=d.faces,Ha=na.faces,Ia=na.uvs,Ka=na.uvs2,pa=na.colors;h=0;for(j=Ga.length;h<j;h++){g=Ga[h];o=Ha[g];t=Ia[g];g=Ka[g];z=o.vertexNormals;r=o.normal;if(o instanceof
|
|
|
-THREE.Face3){if(za){v=ja[o.a].position;w=ja[o.b].position;y=ja[o.c].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;A+=9}if(Ca&&pa.length){v=pa[o.a];w=pa[o.b];y=pa[o.c];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;W+=9}if(Ba&&na.hasTangents){v=ja[o.a].tangent;w=ja[o.b].tangent;y=ja[o.c].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=
|
|
|
-w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;Z+=12}if(Da)if(z.length==3&&qa)for(o=0;o<3;o++){r=z[o];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(o=0;o<3;o++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(o=0;o<3;o++){z=t[o];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(o=0;o<3;o++){t=g[o];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=E;la[ca+1]=E+1;la[ca+2]=E+2;ca+=3;$[ka]=E;$[ka+1]=E+1;$[ka+2]=E;$[ka+3]=E+2;$[ka+4]=E+1;$[ka+5]=E+2;ka+=6;E+=3}}else if(o instanceof THREE.Face4){if(za){v=
|
|
|
-ja[o.a].position;w=ja[o.b].position;y=ja[o.c].position;K=ja[o.d].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;da[A+9]=K.x;da[A+10]=K.y;da[A+11]=K.z;A+=12}if(Ca&&pa.length){v=pa[o.a];w=pa[o.b];y=pa[o.c];K=pa[o.d];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;fa[W+9]=K.r;fa[W+10]=K.g;fa[W+11]=K.b;W+=12}if(Ba&&na.hasTangents){v=ja[o.a].tangent;w=ja[o.b].tangent;y=ja[o.c].tangent;
|
|
|
-o=ja[o.d].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;aa[Z+12]=o.x;aa[Z+13]=o.y;aa[Z+14]=o.z;aa[Z+15]=o.w;Z+=16}if(Da)if(z.length==4&&qa)for(o=0;o<4;o++){r=z[o];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(o=0;o<4;o++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(o=0;o<4;o++){z=t[o];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(o=0;o<4;o++){t=g[o];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=
|
|
|
-E;la[ca+1]=E+1;la[ca+2]=E+2;la[ca+3]=E;la[ca+4]=E+2;la[ca+5]=E+3;ca+=6;$[ka]=E;$[ka+1]=E+1;$[ka+2]=E;$[ka+3]=E+3;$[ka+4]=E+1;$[ka+5]=E+2;$[ka+6]=E+2;$[ka+7]=E+3;ka+=8;E+=4}}}if(za){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,da,i)}if(Ca&&pa.length){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,fa,i)}if(Da){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ea,i)}if(Ba&&na.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
-d.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,aa,i)}if(Aa&&N>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,sa,i)}if(Aa&&T>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,va,i)}if(Fa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,la,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,$,i)}};this.setLineBuffers=function(d,h){var i,j,g,o=d.vertices,
|
|
|
-z=d.colors,r=o.length,t=z.length,v=d.__vertexArray,w=d.__colorArray,y=d.__dirtyColors;if(d.__dirtyVertices){for(i=0;i<r;i++){j=o[i].position;g=i*3;v[g]=j.x;v[g+1]=j.y;v[g+2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,h)}if(y){for(i=0;i<t;i++){color=z[i];g=i*3;w[g]=color.r;w[g+1]=color.g;w[g+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}};this.setParticleBuffers=function(d,h,i){var j,g,o,z=d.vertices,r=z.length,
|
|
|
-t=d.colors,v=t.length,w=d.__vertexArray,y=d.__colorArray,K=d.__sortArray,E=d.__dirtyVertices,A=d.__dirtyColors;if(i.sortParticles){O.multiplySelf(i.matrix);for(j=0;j<r;j++){g=z[j].position;L.copy(g);O.multiplyVector3(L);K[j]=[L.z,j]}K.sort(function(N,T){return T[0]-N[0]});for(j=0;j<r;j++){g=z[K[j][1]].position;o=j*3;w[o]=g.x;w[o+1]=g.y;w[o+2]=g.z}for(j=0;j<v;j++){o=j*3;color=t[K[j][1]];y[o]=color.r;y[o+1]=color.g;y[o+2]=color.b}}else{if(E)for(j=0;j<r;j++){g=z[j].position;o=j*3;w[o]=g.x;w[o+1]=g.y;
|
|
|
-w[o+2]=g.z}if(A)for(j=0;j<v;j++){color=t[j];o=j*3;y[o]=color.r;y[o+1]=color.g;y[o+2]=color.b}}if(E||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}if(A||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,y,h)}};this.initMaterial=function(d,h,i){var j,g;if(d instanceof THREE.MeshDepthMaterial)c(d,THREE.ShaderLib.depth);else if(d instanceof THREE.MeshNormalMaterial)c(d,THREE.ShaderLib.normal);else if(d instanceof
|
|
|
-THREE.MeshBasicMaterial)c(d,THREE.ShaderLib.basic);else if(d instanceof THREE.MeshLambertMaterial)c(d,THREE.ShaderLib.lambert);else if(d instanceof THREE.MeshPhongMaterial)c(d,THREE.ShaderLib.phong);else if(d instanceof THREE.LineBasicMaterial)c(d,THREE.ShaderLib.basic);else d instanceof THREE.ParticleBasicMaterial&&c(d,THREE.ShaderLib.particle_basic);var o,z,r,t;g=r=t=0;for(o=h.length;g<o;g++){z=h[g];z instanceof THREE.DirectionalLight&&r++;z instanceof THREE.PointLight&&t++}if(t+r<=4){h=r;t=t}else{h=
|
|
|
-Math.ceil(4*r/(t+r));t=4-h}g={directional:h,point:t};t=d.fragment_shader;h=d.vertex_shader;o={fog:i,map:d.map,env_map:d.env_map,light_map:d.light_map,vertex_colors:d.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};i=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+o.maxDirLights,"#define MAX_POINT_LIGHTS "+o.maxPointLights,o.fog?"#define USE_FOG":"",o.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.env_map?
|
|
|
-"#define USE_ENVMAP":"",o.light_map?"#define USE_LIGHTMAP":"",o.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");o=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+o.maxDirLights,"#define MAX_POINT_LIGHTS "+o.maxPointLights,o.map?"#define USE_MAP":"",o.env_map?"#define USE_ENVMAP":"",o.light_map?"#define USE_LIGHTMAP":"",o.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
|
|
|
-b.attachShader(i,B("fragment",g+t));b.attachShader(i,B("vertex",o+h));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};d.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in d.uniforms)i.push(j);j=d.program;t=0;for(h=i.length;t<h;t++){g=i[t];j.uniforms[g]=b.getUniformLocation(j,
|
|
|
-g)}d=d.program;j=["position","normal","uv","uv2","tangent","color"];i=0;for(t=j.length;i<t;i++){h=j[i];d.attributes[h]=b.getAttribLocation(d,h)}};this.setProgram=function(d,h,i,j,g){j.program||this.initMaterial(j,h,i);var o=j.program,z=o.uniforms,r=j.uniforms;if(o!=H){b.useProgram(o);H=o;b.uniformMatrix4fv(z.projectionMatrix,false,Y)}if(i&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof
|
|
|
-THREE.ParticleBasicMaterial)){r.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){r.fogNear.value=i.near;r.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)r.fogDensity.value=i.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(o,h);h=this.lights;r.enableLighting.value=h.directional.length+h.point.length;r.ambientLightColor.value=h.ambient;r.directionalLightColor.value=h.directional.colors;r.directionalLightDirection.value=h.directional.positions;
|
|
|
-r.pointLightColor.value=h.point.colors;r.pointLightPosition.value=h.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.map.texture=j.map;r.light_map.texture=j.light_map;r.env_map.texture=j.env_map;r.reflectivity.value=j.reflectivity;r.refraction_ratio.value=j.refraction_ratio;r.combine.value=j.combine;r.useRefract.value=
|
|
|
-j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){r.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.size.value=j.size;r.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){r.ambient.value.setRGB(j.ambient.r,j.ambient.g,
|
|
|
-j.ambient.b);r.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);r.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){r.mNear.value=d.near;r.mFar.value=d.far;r.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)r.opacity.value=j.opacity;var t,v,w;for(t in r)if(w=o.uniforms[t]){i=r[t];v=i.type;h=i.value;if(v=="i")b.uniform1i(w,h);else if(v=="f")b.uniform1f(w,h);else if(v=="fv1")b.uniform1fv(w,h);else if(v=="fv")b.uniform3fv(w,h);else if(v=="v2")b.uniform2f(w,
|
|
|
-h.x,h.y);else if(v=="v3")b.uniform3f(w,h.x,h.y,h.z);else if(v=="c")b.uniform3f(w,h.r,h.g,h.b);else if(v=="t"){b.uniform1i(w,h);if(i=i.texture)if(i.image instanceof Array&&i.image.length==6){i=i;h=h;if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
|
|
|
-b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(v=0;v<6;++v)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image[v]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}else{i=i;h=h;if(!i.__webGLTexture&&
|
|
|
-i.image.loaded){i.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,u(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(i.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
|
|
|
-h);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture)}}}b.uniformMatrix4fv(z.modelViewMatrix,false,g._modelViewMatrixArray);b.uniformMatrix3fv(z.normalMatrix,false,g._normalMatrixArray);if(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)b.uniform3f(z.cameraPosition,d.position.x,d.position.y,d.position.z);if(j instanceof THREE.MeshShaderMaterial||j.env_map)b.uniformMatrix4fv(z.objectMatrix,false,g._objectMatrixArray);if(j instanceof THREE.MeshPhongMaterial||j instanceof
|
|
|
-THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(z.viewMatrix,false,P);return o};this.renderBuffer=function(d,h,i,j,g,o){d=this.setProgram(d,h,i,j,o).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=
|
|
|
-0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=
|
|
|
-0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(o instanceof THREE.Mesh)if(j.wireframe){b.lineWidth(j.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,
|
|
|
-0)}else if(o instanceof THREE.Line){o=o.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(j.linewidth);b.drawArrays(o,0,g.__webGLLineCount)}else o instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(d,h,i,j){var g,o,z,r,t,v,w,y=d.lights,K=d.fog;h.autoUpdateMatrix&&h.updateMatrix();h.matrix.flattenToArray(P);h.projectionMatrix.flattenToArray(Y);O.multiply(h.projectionMatrix,h.matrix);k(O);this.initWebGLObjects(d,h);C(i,j!==undefined?j:true);this.autoClear&&
|
|
|
-this.clear();r=d.__webGLObjects.length;for(j=0;j<r;j++){g=d.__webGLObjects[j];v=g.object;if(v.visible&&(!(v instanceof THREE.Mesh)||l(v))){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,h);m(g);g.render=true}else g.render=false}t=d.__webGLObjectsImmediate.length;for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,
|
|
|
-h);q(g)}}n(THREE.NormalBlending);for(j=0;j<r;j++){g=d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(h,y,K,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);o=this.setProgram(h,y,K,material,v);v.render(function(E){e(E,o)})}}}for(j=0;j<r;j++){g=
|
|
|
-d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];n(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(h,y,K,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];n(material.blending);this.setDepthTest(material.depth_test);o=this.setProgram(h,y,K,material,v);v.render(function(E){e(E,o)})}}}if(i&&i.min_filter!==
|
|
|
-THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d,h){function i(y,K,E,A){if(y[K]==undefined){d.__webGLObjects.push({buffer:E,object:A,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[K]=1}}function j(y,K,E){if(y[K]==undefined){d.__webGLObjectsImmediate.push({object:E,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[K]=1}}var g,o,
|
|
|
-z,r,t,v,w;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}g=0;for(o=d.objects.length;g<o;g++){z=d.objects[g];t=z.geometry;if(d.__webGLObjectsMap[z.id]==undefined){d.__webGLObjectsMap[z.id]={};z._modelViewMatrix=new THREE.Matrix4;z._normalMatrixArray=new Float32Array(9);z._modelViewMatrixArray=new Float32Array(16);z._objectMatrixArray=new Float32Array(16);z.matrix.flattenToArray(z._objectMatrixArray)}w=d.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(r in t.geometryChunks){v=
|
|
|
-t.geometryChunks[r];if(!v.__webGLVertexBuffer){this.createMeshBuffers(v);this.initMeshBuffers(v,z);t.__dirtyVertices=true;t.__dirtyElements=true;t.__dirtyUvs=true;t.__dirtyNormals=true;t.__dirtyTangents=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyElements||t.__dirtyUvs||t.__dirtyNormals||t.__dirtyColors||t.__dirtyTangents)this.setMeshBuffers(v,z,b.DYNAMIC_DRAW);i(w,r,v,z)}t.__dirtyVertices=false;t.__dirtyElements=false;t.__dirtyUvs=false;t.__dirtyNormals=false;t.__dirtyTangents=false;
|
|
|
-t.__dirtyColors=false}else if(z instanceof THREE.Line){if(!t.__webGLVertexBuffer){this.createLineBuffers(t);this.initLineBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyColors)this.setLineBuffers(t,b.DYNAMIC_DRAW);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else if(z instanceof THREE.ParticleSystem){if(!t.__webGLVertexBuffer){this.createParticleBuffers(t);this.initParticleBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||
|
|
|
-t.__dirtyColors||z.sortParticles)this.setParticleBuffers(t,b.DYNAMIC_DRAW,z,h);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else z instanceof THREE.MarchingCubes&&j(w,0,z)}};this.removeObject=function(d,h){var i,j;for(i=d.__webGLObjects.length-1;i>=0;i--){j=d.__webGLObjects[i].object;h==j&&d.__webGLObjects.splice(i,1)}};this.setupMatrices=function(d,h){d._modelViewMatrix.multiplyToArray(h.matrix,d.matrix,d._modelViewMatrixArray);d._normalMatrix=THREE.Matrix4.makeInvert3x3(d._modelViewMatrix).transposeIntoArray(d._normalMatrixArray)};
|
|
|
-this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
|
|
+THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
|
|
|
+THREE.Projector=function(){function a(Q,J){return J.z-Q.z}function c(Q,J){var X=0,G=1,U=Q.z+Q.w,M=J.z+J.w,D=-Q.z+Q.w,K=-J.z+J.w;if(U>=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(G<X)return false;else{Q.lerpSelf(J,X);J.lerpSelf(Q,1-G);return true}}}var d,f,j=[],k,q,o,l=[],m,z,y=[],v,x,F=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
|
|
|
+O=new THREE.Matrix4,C=[],b=new THREE.Vector4,R=new THREE.Vector4,$;this.projectObjects=function(Q,J,X){var G=[],U,M;f=0;s.multiply(J.projectionMatrix,J.matrix);C[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);C[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);C[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);C[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);C[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
|
|
|
+s.n33,s.n44-s.n34);C[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);J=0;for(U=C.length;J<U;J++){M=C[J];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}U=Q.objects;Q=0;for(J=U.length;Q<J;Q++){M=U[Q];var D;if(!(D=!M.visible)){if(D=M instanceof THREE.Mesh){a:{D=void 0;for(var K=M.position,ca=-M.geometry.boundingSphere.radius*Math.max(M.scale.x,Math.max(M.scale.y,M.scale.z)),N=0;N<6;N++){D=C[N].x*K.x+C[N].y*K.y+C[N].z*K.z+C[N].w;if(D<=ca){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
|
|
|
+j[f]=j[f]||new THREE.RenderableObject;H.copy(M.position);s.multiplyVector3(H);d.object=M;d.z=H.z;G.push(d);f++}}X&&G.sort(a);return G};this.projectScene=function(Q,J,X){var G=[],U=J.near,M=J.far,D,K,ca,N,aa,e,i,n,h,g,t,w,u,r,p,B;o=z=x=0;J.autoUpdateMatrix&&J.updateMatrix();s.multiply(J.projectionMatrix,J.matrix);e=this.projectObjects(Q,J,true);Q=0;for(D=e.length;Q<D;Q++){i=e[Q].object;if(i.visible){i.autoUpdateMatrix&&i.updateMatrix();n=i.matrix;h=i.rotationMatrix;g=i.materials;t=i.overdraw;if(i instanceof
|
|
|
+THREE.Mesh){w=i.geometry;u=w.vertices;K=0;for(ca=u.length;K<ca;K++){r=u[K];r.positionWorld.copy(r.position);n.multiplyVector3(r.positionWorld);N=r.positionScreen;N.copy(r.positionWorld);s.multiplyVector4(N);N.x/=N.w;N.y/=N.w;r.__visible=N.z>U&&N.z<M}w=w.faces;K=0;for(ca=w.length;K<ca;K++){r=w[K];if(r instanceof THREE.Face3){N=u[r.a];aa=u[r.b];p=u[r.c];if(N.__visible&&aa.__visible&&p.__visible)if(i.doubleSided||i.flipSided!=(p.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-
|
|
|
+(p.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);k.v3.positionWorld.copy(p.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(p.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);n.multiplyVector3(k.centroidWorld);
|
|
|
+k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);p=r.vertexNormals;$=k.vertexNormalsWorld;N=0;for(aa=p.length;N<aa;N++){B=$[N]=$[N]||new THREE.Vector3;B.copy(p[N]);h.multiplyVector3(B)}k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][2]}G.push(k);o++}}else if(r instanceof THREE.Face4){N=u[r.a];aa=u[r.b];p=u[r.c];B=u[r.d];if(N.__visible&&
|
|
|
+aa.__visible&&p.__visible&&B.__visible)if(i.doubleSided||i.flipSided!=((B.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-(B.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0||(aa.positionScreen.x-p.positionScreen.x)*(B.positionScreen.y-p.positionScreen.y)-(aa.positionScreen.y-p.positionScreen.y)*(B.positionScreen.x-p.positionScreen.x)<0)){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);
|
|
|
+k.v3.positionWorld.copy(B.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(B.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);n.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];
|
|
|
+k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][3]}G.push(k);o++;q=l[o]=l[o]||new THREE.RenderableFace3;q.v1.positionWorld.copy(aa.positionWorld);q.v2.positionWorld.copy(p.positionWorld);q.v3.positionWorld.copy(B.positionWorld);q.v1.positionScreen.copy(aa.positionScreen);q.v2.positionScreen.copy(p.positionScreen);q.v3.positionScreen.copy(B.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
|
|
|
+q.meshMaterials=g;q.faceMaterials=r.materials;q.overdraw=t;if(i.geometry.uvs[K]){q.uvs[0]=i.geometry.uvs[K][1];q.uvs[1]=i.geometry.uvs[K][2];q.uvs[2]=i.geometry.uvs[K][3]}G.push(q);o++}}}}else if(i instanceof THREE.Line){O.multiply(s,n);u=i.geometry.vertices;r=u[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);K=1;for(ca=u.length;K<ca;K++){N=u[K];N.positionScreen.copy(N.position);O.multiplyVector4(N.positionScreen);aa=u[K-1];b.copy(N.positionScreen);R.copy(aa.positionScreen);
|
|
|
+if(c(b,R)){b.multiplyScalar(1/b.w);R.multiplyScalar(1/R.w);m=y[z]=y[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(b);m.v2.positionScreen.copy(R);m.z=Math.max(b.z,R.z);m.materials=i.materials;G.push(m);z++}}}else if(i instanceof THREE.Particle){I.set(i.position.x,i.position.y,i.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/
|
|
|
+(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}};
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,m,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(m=a.length;l<m;l++){v=a[l];if(v instanceof THREE.RenderableParticle){F=v.x*j+j;H=v.y*k+k;z=0;for(y=v.material.length;z<y;z++){x=v.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
|
|
|
+THREE.CanvasRenderer=function(){function a(W){if(v!=W)m.globalAlpha=v=W}function c(W){if(x!=W){switch(W){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=W}}var d=null,f=new THREE.Projector,j=document.createElement("canvas"),k,q,o,l,m=j.getContext("2d"),z=new THREE.Color(0),y=0,v=1,x=0,F=null,H=null,I=1,s,O,C,b,R,$,Q,J,X,G=new THREE.Color,
|
|
|
+U=new THREE.Color,M=new THREE.Color,D=new THREE.Color,K=new THREE.Color,ca,N,aa,e,i,n,h,g,t,w=new THREE.Rectangle,u=new THREE.Rectangle,r=new THREE.Rectangle,p=false,B=new THREE.Color,V=new THREE.Color,da=new THREE.Color,ea=new THREE.Color,ia=Math.PI*2,S=new THREE.Vector3,Y,pa,P,ka,oa,wa,fa=16;Y=document.createElement("canvas");Y.width=Y.height=2;pa=Y.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);P=pa.getImageData(0,0,2,2);ka=P.data;oa=document.createElement("canvas");oa.width=
|
|
|
+oa.height=fa;wa=oa.getContext("2d");wa.translate(-fa/2,-fa/2);wa.scale(fa,fa);fa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(W,ba){k=W;q=ba;o=k/2;l=q/2;j.width=k;j.height=q;w.set(-o,-l,o,l);v=1;x=0;H=F=null;I=1};this.setClearColor=function(W,ba){z=W;y=ba;u.set(-o,-l,o,l);m.setTransform(1,0,0,-1,o,l);this.clear()};this.setClearColorHex=function(W,ba){z.setHex(W);y=ba;u.set(-o,-l,o,l);m.setTransform(1,0,0,-1,o,l);this.clear()};this.clear=function(){m.setTransform(1,
|
|
|
+0,0,-1,o,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(w);if(z.hex==0&&y==0)m.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";m.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(W,ba){function Ca(A){var Z,T,E,L=A.lights;V.setRGB(0,0,0);da.setRGB(0,0,0);ea.setRGB(0,0,0);A=0;for(Z=L.length;A<Z;A++){T=L[A];E=T.color;if(T instanceof
|
|
|
+THREE.AmbientLight){V.r+=E.r;V.g+=E.g;V.b+=E.b}else if(T instanceof THREE.DirectionalLight){da.r+=E.r;da.g+=E.g;da.b+=E.b}else if(T instanceof THREE.PointLight){ea.r+=E.r;ea.g+=E.g;ea.b+=E.b}}}function qa(A,Z,T,E){var L,ha,ra,xa,za=A.lights;A=0;for(L=za.length;A<L;A++){ha=za[A];ra=ha.color;xa=ha.intensity;if(ha instanceof THREE.DirectionalLight){ha=T.dot(ha.position)*xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)*
|
|
|
+xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(!w.instersects(r))return;m.save();m.translate(A.x,A.y);m.rotate(-Z.rotation);m.scale(L,-ha);m.translate(-xa,-za);m.drawImage(ra,0,0);m.restore()}m.beginPath();m.moveTo(A.x-
|
|
|
+10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r=V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)m.fillStyle=H=L;m.save();m.translate(A.x,
|
|
|
+A.y);m.rotate(-Z.rotation);m.scale(T,E);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(Z.positionScreen.x,Z.positionScreen.y);m.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)m.lineWidth=I=A;A=G.__styleString;if(F!=A)m.strokeStyle=F=A;m.stroke();r.inflate(E.linewidth*2)}}}
|
|
|
+function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y;m.beginPath();m.moveTo(b,R);m.lineTo($,Q);m.lineTo(J,X);m.lineTo(b,R);m.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof
|
|
|
+THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);n=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,n,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):
|
|
|
+va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M);
|
|
|
+qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca=
|
|
|
+ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z,ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)m.strokeStyle=F=
|
|
|
+A;if(I!=Z)m.lineWidth=I=Z;m.stroke();r.inflate(Z*2)}function va(A){if(H!=A)m.fillStyle=H=A;m.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga,Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;m.save();m.transform(Ea,Ba,T,E,A,Z);m.clip();m.drawImage(ra,0,0);m.restore()}}function ma(A,
|
|
|
+Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255);T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E>
|
|
|
+255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());(p=W.lights.length>
|
|
|
+0)&&Ca(W);ua=0;for(Ma=d.length;ua<Ma;ua++){ja=d[ua];r.empty();if(ja instanceof THREE.RenderableParticle){s=ja;s.x*=o;s.y*=l;ya=0;for(Fa=ja.materials.length;ya<Fa;ya++)la(s,ja,ja.materials[ya],W)}else if(ja instanceof THREE.RenderableLine){s=ja.v1;O=ja.v2;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;r.addPoint(s.positionScreen.x,s.positionScreen.y);r.addPoint(O.positionScreen.x,O.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.materials.length;ya<Fa;)na(s,
|
|
|
+O,ja,ja.materials[ya++],W)}}else if(ja instanceof THREE.RenderableFace3){s=ja.v1;O=ja.v2;C=ja.v3;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;C.positionScreen.x*=o;C.positionScreen.y*=l;if(ja.overdraw){La(s.positionScreen,O.positionScreen);La(O.positionScreen,C.positionScreen);La(C.positionScreen,s.positionScreen)}r.add3Points(s.positionScreen.x,s.positionScreen.y,O.positionScreen.x,O.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if(w.instersects(r)){ya=
|
|
|
+0;for(Fa=ja.meshMaterials.length;ya<Fa;){sa=ja.meshMaterials[ya++];if(sa instanceof THREE.MeshFaceMaterial){Ka=0;for(Na=ja.faceMaterials.length;Ka<Na;)(sa=ja.faceMaterials[Ka++])&&Ja(s,O,C,ja,sa,W)}else Ja(s,O,C,ja,sa,W)}}}u.addRectangle(r)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());m.setTransform(1,0,0,1,0,0)}};
|
|
|
+THREE.SVGRenderer=function(){function a(e,i,n){var h,g,t,w;h=0;for(g=e.lights.length;h<g;h++){t=e.lights[h];if(t instanceof THREE.DirectionalLight){w=i.normalWorld.dot(t.position)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}}}function c(e,i,n,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+
|
|
|
+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear);
|
|
|
+C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,n,h,g,t,w){D=f(K++);D.setAttribute("d",
|
|
|
+"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J=
|
|
|
+1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)}
|
|
|
+function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0),
|
|
|
+Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;m=i;z=l/2;y=m/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);o.setAttribute("width",l);o.setAttribute("height",m);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var n,
|
|
|
+h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);n=0;for(h=r.length;n<h;n++){g=r[n];t=g.color;if(g instanceof THREE.AmbientLight){R.r+=t.r;R.g+=t.g;R.b+=t.b}else if(g instanceof THREE.DirectionalLight){$.r+=t.r;$.g+=t.g;$.b+=t.b}else if(g instanceof THREE.PointLight){Q.r+=t.r;Q.g+=t.g;Q.b+=t.b}}}n=0;for(h=k.length;n<h;n++){r=k[n];s.empty();if(r instanceof THREE.RenderableParticle){v=
|
|
|
+r;v.x*=z;v.y*=-y;g=0;for(t=r.materials.length;g<t;g++)if(p=r.materials[g]){w=v;u=r;p=p;var B=ca++;if(U[B]==null){U[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");aa==0&&U[B].setAttribute("shape-rendering","crispEdges")}D=U[B];D.setAttribute("cx",w.x);D.setAttribute("cy",w.y);D.setAttribute("r",u.scale.x*z);if(p instanceof THREE.ParticleCircleMaterial){if(O){b.r=R.r+$.r+Q.r;b.g=R.g+$.g+Q.g;b.b=R.b+$.b+Q.b;C.r=p.color.r*b.r;C.g=p.color.g*b.g;C.b=p.color.b*b.b;C.updateStyleString()}else C=
|
|
|
+p.color;D.setAttribute("style","fill: "+C.__styleString)}o.appendChild(D)}}else if(r instanceof THREE.RenderableLine){v=r.v1;x=r.v2;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.materials.length;g<t;)if(p=r.materials[g++]){w=v;u=x;p=p;B=N++;if(M[B]==null){M[B]=document.createElementNS("http://www.w3.org/2000/svg","line");aa==
|
|
|
+0&&M[B].setAttribute("shape-rendering","crispEdges")}D=M[B];D.setAttribute("x1",w.positionScreen.x);D.setAttribute("y1",w.positionScreen.y);D.setAttribute("x2",u.positionScreen.x);D.setAttribute("y2",u.positionScreen.y);if(p instanceof THREE.LineBasicMaterial){C.__styleString=p.color.__styleString;D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+p.linewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.linecap+"; stroke-linejoin: "+p.linejoin);o.appendChild(D)}}}}else if(r instanceof
|
|
|
+THREE.RenderableFace3){v=r.v1;x=r.v2;F=r.v3;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&
|
|
|
+c(v,x,F,r,p,e)}else p&&c(v,x,F,r,p,e)}}}else if(r instanceof THREE.RenderableFace4){v=r.v1;x=r.v2;F=r.v3;H=r.v4;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){g=
|
|
|
+0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&d(v,x,F,H,r,p,e)}else p&&d(v,x,F,H,r,p,e)}}}}}};
|
|
|
+THREE.WebGLRenderer=function(a){function c(e,i,n){var h,g,t,w=e.vertices,u=w.length,r=e.colors,p=r.length,B=e.__vertexArray,V=e.__colorArray,da=e.__sortArray,ea=e.__dirtyVertices,ia=e.__dirtyColors;if(n.sortParticles){U.multiplySelf(n.matrixWorld);for(h=0;h<u;h++){g=w[h].position;K.copy(g);U.multiplyVector3(K);da[h]=[K.z,h]}da.sort(function(S,Y){return Y[0]-S[0]});for(h=0;h<u;h++){g=w[da[h][1]].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}for(h=0;h<p;h++){t=h*3;color=r[da[h][1]];V[t]=color.r;V[t+
|
|
|
+1]=color.g;V[t+2]=color.b}}else{if(ea)for(h=0;h<u;h++){g=w[h].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}if(ia)for(h=0;h<p;h++){color=r[h];t=h*3;V[t]=color.r;V[t+1]=color.g;V[t+2]=color.b}}if(ea||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,i)}if(ia||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,V,i)}}function d(e,i){e.fragment_shader=i.fragment_shader;e.vertex_shader=i.vertex_shader;e.uniforms=
|
|
|
+Uniforms.clone(i.uniforms)}function f(e,i){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.position);b.vertexAttribPointer(i.attributes.position,3,b.FLOAT,false,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
|
|
|
+e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.normal);b.vertexAttribPointer(i.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function j(e){if(Q!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);Q=e.doubleSided}if(J!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);J=e.flipSided}}function k(e){G[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);G[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+
|
|
|
+e.n14);G[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);G[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);G[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);G[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var i;for(e=0;e<5;e++){i=G[e];i.divideScalar(Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z))}}function q(e){for(var i=e.matrix,n=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=G[h].x*i.n14+G[h].y*i.n24+G[h].z*i.n34+G[h].w;
|
|
|
+if(e<=n)return false}return true}function o(e,i){e.list[e.count]=i;e.count+=1}function l(e){var i,n,h=e.object,g=e.opaque,t=e.transparent;t.count=0;e=g.count=0;for(i=h.materials.length;e<i;e++){n=h.materials[e];n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?o(t,n):o(g,n)}}function m(e){var i,n,h,g,t=e.object,w=e.buffer,u=e.opaque,r=e.transparent;r.count=0;e=u.count=0;for(h=t.materials.length;e<h;e++){i=t.materials[e];if(i instanceof THREE.MeshFaceMaterial){i=0;for(n=w.materials.length;i<
|
|
|
+n;i++)if(g=w.materials[i])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}else{g=i;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}}}function z(e){var i,n,h,g=e.children;i=0;for(n=g.length;i<n;i++){h=g[i];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(e.matrixWorld,h.matrix);z(h)}}function y(e,i){var n,h,g=i.children;n=0;for(h=g.length;n<h;n++){child=g[n];v(e,child,false);y(e,child)}}function v(e,i,n){var h,g,t;g=i.geometry;if(e.__webGLObjectsMap[i.id]==
|
|
|
+undefined){e.__webGLObjectsMap[i.id]={};i._modelViewMatrix=new THREE.Matrix4;i._normalMatrixArray=new Float32Array(9);i._modelViewMatrixArray=new Float32Array(16);i._objectMatrixArray=new Float32Array(16);i.matrix.flattenToArray(i._objectMatrixArray)}t=e.__webGLObjectsMap[i.id];objlist=e.__webGLObjects;if(i instanceof THREE.Mesh){for(h in g.geometryChunks){e=g.geometryChunks[h];if(!e.__webGLVertexBuffer){var w=e;w.__webGLVertexBuffer=b.createBuffer();w.__webGLNormalBuffer=b.createBuffer();w.__webGLTangentBuffer=
|
|
|
+b.createBuffer();w.__webGLColorBuffer=b.createBuffer();w.__webGLUVBuffer=b.createBuffer();w.__webGLUV2Buffer=b.createBuffer();w.__webGLFaceBuffer=b.createBuffer();w.__webGLLineBuffer=b.createBuffer();w=e;var u=i,r=void 0,p=void 0,B=0,V=0,da=0,ea=u.geometry.faces,ia=w.faces;r=0;for(p=ia.length;r<p;r++){fi=ia[r];face=ea[fi];if(face instanceof THREE.Face3){B+=3;V+=1;da+=3}else if(face instanceof THREE.Face4){B+=4;V+=2;da+=4}}w.__vertexArray=new Float32Array(B*3);w.__normalArray=new Float32Array(B*3);
|
|
|
+w.__tangentArray=new Float32Array(B*4);w.__colorArray=new Float32Array(B*3);w.__uvArray=new Float32Array(B*2);w.__uv2Array=new Float32Array(B*2);w.__faceArray=new Uint16Array(V*3);w.__lineArray=new Uint16Array(da*2);p=r=w;u=u;B=void 0;ea=void 0;var S=void 0,Y=void 0;S=void 0;ia=false;B=0;for(ea=u.materials.length;B<ea;B++){S=u.materials[B];if(S instanceof THREE.MeshFaceMaterial){S=0;for(Y=p.materials.length;S<Y;S++)if(p.materials[S]&&p.materials[S].shading!=undefined&&p.materials[S].shading==THREE.SmoothShading){ia=
|
|
|
+true;break}}else if(S&&S.shading!=undefined&&S.shading==THREE.SmoothShading){ia=true;break}if(ia)break}r.__needsSmoothNormals=ia;w.__webGLFaceCount=V*3;w.__webGLLineCount=da*2;g.__dirtyVertices=true;g.__dirtyElements=true;g.__dirtyUvs=true;g.__dirtyNormals=true;g.__dirtyTangents=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyElements||g.__dirtyUvs||g.__dirtyNormals||g.__dirtyColors||g.__dirtyTangents){w=e;V=b.DYNAMIC_DRAW;da=void 0;r=void 0;var pa=void 0,P=void 0,ka=void 0,oa=void 0,wa=
|
|
|
+void 0;pa=void 0;var fa=void 0,W=void 0,ba=void 0,Ca=void 0;fa=void 0;W=void 0;ba=void 0;P=void 0;fa=void 0;W=void 0;ba=void 0;Ca=void 0;P=void 0;oa=void 0;ka=void 0;wa=void 0;var qa=Y=S=ia=ea=B=u=p=0,la=0,na=w.__vertexArray,Ja=w.__uvArray,Da=w.__uv2Array,va=w.__normalArray,ga=w.__tangentArray,ma=w.__colorArray,Aa=w.__faceArray,ta=w.__lineArray,La=w.__needsSmoothNormals,ua=i.geometry,Ma=ua.__dirtyVertices,ja=ua.__dirtyElements,ya=ua.__dirtyUvs,Fa=ua.__dirtyNormals,Ka=ua.__dirtyTangents,Na=ua.__dirtyColors,
|
|
|
+sa=ua.vertices,A=w.faces,Z=ua.faces,T=ua.uvs,E=ua.uvs2,L=ua.colors;da=0;for(r=A.length;da<r;da++){pa=A[da];P=Z[pa];wa=T[pa];pa=E[pa];ka=P.vertexNormals;oa=P.normal;if(P instanceof THREE.Face3){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;u+=9}if(Na&&L.length){fa=L[P.a];W=L[P.b];ba=L[P.c];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;
|
|
|
+ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;la+=9}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;Y+=12}if(Fa)if(ka.length==3&&La)for(P=0;P<3;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<3;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<3;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;
|
|
|
+B+=2}if(ya&&pa)for(P=0;P<3;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;ia+=3;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+2;ta[qa+4]=p+1;ta[qa+5]=p+2;qa+=6;p+=3}}else if(P instanceof THREE.Face4){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;Ca=sa[P.d].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;na[u+9]=Ca.x;na[u+10]=Ca.y;na[u+11]=Ca.z;u+=12}if(Na&&L.length){fa=
|
|
|
+L[P.a];W=L[P.b];ba=L[P.c];Ca=L[P.d];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;ma[la+9]=Ca.r;ma[la+10]=Ca.g;ma[la+11]=Ca.b;la+=12}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;P=sa[P.d].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;ga[Y+12]=P.x;ga[Y+13]=P.y;ga[Y+14]=P.z;ga[Y+
|
|
|
+15]=P.w;Y+=16}if(Fa)if(ka.length==4&&La)for(P=0;P<4;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<4;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<4;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;B+=2}if(ya&&pa)for(P=0;P<4;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;Aa[ia+3]=p;Aa[ia+4]=p+2;Aa[ia+5]=p+3;ia+=6;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+3;ta[qa+4]=p+1;ta[qa+5]=p+2;ta[qa+6]=p+2;ta[qa+7]=p+3;qa+=8;p+=4}}}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
+w.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,V)}if(Na&&L.length){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ma,V)}if(Fa){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,va,V)}if(Ka&&ua.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ga,V)}if(ya&&B>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer);
|
|
|
+b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,n)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=
|
|
|
+b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r<B;r++){p=u[r].position;e=r*3;ea[e]=p.x;ea[e+1]=p.y;ea[e+2]=p.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
|
|
|
+ea,h)}if(ia){for(r=0;r<V;r++){color=w[r];e=r*3;da[e]=color.r;da[e+1]=color.g;da[e+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,da,h)}}x(objlist,t,0,g,i,n);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.ParticleSystem){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__sortArray=
|
|
|
+[];g.__webGLParticleCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors||i.sortParticles)c(g,b.DYNAMIC_DRAW,i,camera);x(objlist,t,0,g,i,n);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.MarchingCubes)if(t[0]==undefined){e.__webGLObjectsImmediate.push({object:i,opaque:{list:[],count:0},transparent:{list:[],count:0},root:n});t[0]=1}}function x(e,i,n,h,g,t){if(i[n]==undefined){e.push({buffer:h,object:g,opaque:{list:[],count:0},transparent:{list:[],
|
|
|
+count:0},root:t});i[n]=1}}function F(e,i){e._modelViewMatrix.multiplyToArray(i.matrix,e.matrixWorld,e._modelViewMatrixArray);e._normalMatrix=THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function H(e){if(e!=X){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
|
|
|
+break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}X=e}}function I(e,i){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(e.wrap_s));b.texParameteri(b.TEXTURE_2D,
|
|
|
+b.TEXTURE_WRAP_T,O(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,O(e.format),e.width,e.height,0,O(e.format),O(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
|
|
|
+null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var n,h,g;if(e){n=e.__webGLFramebuffer;h=e.width;g=e.height}else{n=null;h=C.width;g=C.height}if(n!=$){b.bindFramebuffer(b.FRAMEBUFFER,n);b.viewport(0,0,h,g);i&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);$=n}}function s(e,i){var n;if(e=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,i);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));
|
|
|
+return null}return n}function O(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;
|
|
|
+case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}
|
|
|
+var C=document.createElement("canvas"),b,R=null,$=null,Q=null,J=null,X=null,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],U=new THREE.Matrix4,M=new Float32Array(16),D=new Float32Array(16),K=new THREE.Vector4,ca=true,N=new THREE.Color(0),aa=0;if(a){if(a.antialias!==undefined)ca=a.antialias;a.clearColor!==undefined&&N.setHex(a.clearColor);if(a.clearAlpha!==undefined)aa=a.clearAlpha}this.domElement=C;this.autoClear=true;(function(e,i,
|
|
|
+n){try{b=C.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(i.r,i.g,i.b,n);_cullEnabled=true})(ca,N,aa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},
|
|
|
+point:{length:0,colors:[],positions:[]}};this.setSize=function(e,i){C.width=e;C.height=i;b.viewport(0,0,C.width,C.height)};this.setClearColorHex=function(e,i){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,i)};this.setClearColor=function(e,i){b.clearColor(e.r,e.g,e.b,i)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,i){var n,h,g,t=0,w=0,u=0,r,p,B,V=this.lights,da=V.directional.colors,ea=V.directional.positions,ia=V.point.colors,S=V.point.positions,
|
|
|
+Y=0,pa=0;n=g=g=0;for(h=i.length;n<h;n++){g=i[n];r=g.color;p=g.position;B=g.intensity;if(g instanceof THREE.AmbientLight){t+=r.r;w+=r.g;u+=r.b}else if(g instanceof THREE.DirectionalLight){g=Y*3;da[g]=r.r*B;da[g+1]=r.g*B;da[g+2]=r.b*B;ea[g]=p.x;ea[g+1]=p.y;ea[g+2]=p.z;Y+=1}else if(g instanceof THREE.PointLight){g=pa*3;ia[g]=r.r*B;ia[g+1]=r.g*B;ia[g+2]=r.b*B;S[g]=p.x;S[g+1]=p.y;S[g+2]=p.z;pa+=1}}for(n=Y*3;n<da.length;n++)da[n]=0;for(n=pa*3;n<ia.length;n++)ia[n]=0;V.point.length=pa;V.directional.length=
|
|
|
+Y;V.ambient[0]=t;V.ambient[1]=w;V.ambient[2]=u};this.initMaterial=function(e,i,n){var h,g;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);
|
|
|
+else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var t,w,u,r;g=u=r=0;for(t=i.length;g<t;g++){w=i[g];w instanceof THREE.DirectionalLight&&u++;w instanceof THREE.PointLight&&r++}if(r+u<=4){i=u;r=r}else{i=Math.ceil(4*u/(r+u));r=4-i}g={directional:i,point:r};r=e.fragment_shader;i=e.vertex_shader;t={fog:n,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};n=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
|
|
|
+"#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+
|
|
|
+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,s("fragment",g+r));b.attachShader(n,
|
|
|
+s("vertex",t+i));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};e.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)n.push(h);h=e.program;r=0;for(i=n.length;r<i;r++){g=n[r];h.uniforms[g]=b.getUniformLocation(h,g)}e=e.program;h=["position","normal",
|
|
|
+"uv","uv2","tangent","color"];n=0;for(r=h.length;n<r;n++){i=h[n];e.attributes[i]=b.getAttribLocation(e,i)}};this.setProgram=function(e,i,n,h,g){h.program||this.initMaterial(h,i,n);var t=h.program,w=t.uniforms,u=h.uniforms;if(t!=R){b.useProgram(t);R=t;b.uniformMatrix4fv(w.projectionMatrix,false,M)}if(n&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){u.fogColor.value.setHex(n.color.hex);
|
|
|
+if(n instanceof THREE.Fog){u.fogNear.value=n.near;u.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)u.fogDensity.value=n.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(t,i);i=this.lights;u.enableLighting.value=i.directional.length+i.point.length;u.ambientLightColor.value=i.ambient;u.directionalLightColor.value=i.directional.colors;u.directionalLightDirection.value=i.directional.positions;u.pointLightColor.value=i.point.colors;u.pointLightPosition.value=
|
|
|
+i.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.map.texture=h.map;u.light_map.texture=h.light_map;u.env_map.texture=h.env_map;u.reflectivity.value=h.reflectivity;u.refraction_ratio.value=h.refraction_ratio;u.combine.value=h.combine;u.useRefract.value=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof
|
|
|
+THREE.LineBasicMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.size.value=h.size;u.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(h.ambient.r,h.ambient.g,h.ambient.b);u.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);
|
|
|
+u.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){u.mNear.value=e.near;u.mFar.value=e.far;u.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)u.opacity.value=h.opacity;var r,p,B;for(r in u)if(B=t.uniforms[r]){n=u[r];p=n.type;i=n.value;if(p=="i")b.uniform1i(B,i);else if(p=="f")b.uniform1f(B,i);else if(p=="fv1")b.uniform1fv(B,i);else if(p=="fv")b.uniform3fv(B,i);else if(p=="v2")b.uniform2f(B,i.x,i.y);else if(p=="v3")b.uniform3f(B,i.x,i.y,i.z);else if(p==
|
|
|
+"c")b.uniform3f(B,i.r,i.g,i.b);else if(p=="t"){b.uniform1i(B,i);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;i=i;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
|
|
|
+b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(p=0;p<6;++p)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;i=i;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=b.createTexture();
|
|
|
+b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(n.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture)}}}b.uniformMatrix4fv(w.modelViewMatrix,
|
|
|
+false,g._modelViewMatrixArray);b.uniformMatrix3fv(w.normalMatrix,false,g._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(w.cameraPosition,e.position.x,e.position.y,e.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(w.objectMatrix,false,g._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(w.viewMatrix,
|
|
|
+false,D);return t};this.renderBuffer=function(e,i,n,h,g,t){e=this.setProgram(e,i,n,h,t).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.position);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,
|
|
|
+false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,
|
|
|
+2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);
|
|
|
+b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,n,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(n,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h<u;h++){g=e.__webGLObjects[h];p=g.object;if(p.visible){if(g.root){p.autoUpdateMatrix&&
|
|
|
+p.updateMatrix();p.matrixWorld.copy(p.matrix);z(p)}if(!(p instanceof THREE.Mesh)||q(p)){p.matrixWorld.flattenToArray(p._objectMatrixArray);F(p,i);m(g);g.render=true}else g.render=false}else g.render=false}r=e.__webGLObjectsImmediate.length;for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){if(p.autoUpdateMatrix){p.updateMatrix();p.matrixWorld.copy(p.matrix);p.matrixWorld.flattenToArray(p._objectMatrixArray)}F(p,i);l(g)}}H(THREE.NormalBlending);for(h=0;h<u;h++){g=e.__webGLObjects[h];
|
|
|
+if(g.render){p=g.object;B=g.buffer;w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}for(h=0;h<u;h++){g=e.__webGLObjects[h];if(g.render){p=g.object;B=g.buffer;w=g.transparent;
|
|
|
+j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.transparent;j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,
|
|
|
+n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e){var i,n,h;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}i=0;for(n=e.objects.length;i<n;i++){h=e.objects[i];v(e,h,true);y(e,h)}};this.removeObject=function(e,i){var n,h;for(n=e.__webGLObjects.length-1;n>=0;n--){h=e.__webGLObjects[n].object;i==h&&e.__webGLObjects.splice(n,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};
|
|
|
+this.setFaceCulling=function(e,i){if(e){!i||i=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
|
|
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
|
|
|
envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\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 ), refraction_ratio );\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",
|