|
@@ -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,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,k,m,r,b,n;if(d==0)f=k=m=0;else{r=Math.floor(a*6);b=a*6-r;a=d*(1-c);n=d*(1-c*b);c=d*(1-c*(1-b));switch(r){case 1:f=n;k=d;m=a;break;case 2:f=a;k=d;m=c;break;case 3:f=a;k=n;m=d;break;case 4:f=c;k=a;m=d;break;case 5:f=d;k=a;m=n;break;case 6:case 0:f=d;k=c;m=a}}this.r=f;this.g=k;this.b=m;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
|
|
|
+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()}},
|
|
|
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,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)},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;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,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;
|
|
|
+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;
|
|
|
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,d,f=a.objects,k=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)k=k.concat(this.intersectObject(d))}k.sort(function(m,r){return m.distance-r.distance});return k},intersectObject:function(a){function c(K,u,S,F){F=F.clone().subSelf(u);S=S.clone().subSelf(u);var P=K.clone().subSelf(u);K=F.dot(F);u=F.dot(S);F=F.dot(P);var e=S.dot(S);S=S.dot(P);P=1/(K*e-u*u);e=(e*F-u*S)*P;K=(K*S-u*F)*P;return e>0&&K>0&&e+K<1}var d,f,k,m,r,b,n,o,B,A,
|
|
|
-x,y=a.geometry,w=y.vertices,I=[];d=0;for(f=y.faces.length;d<f;d++){k=y.faces[d];A=this.origin.clone();x=this.direction.clone();m=a.matrix.multiplyVector3(w[k.a].position.clone());r=a.matrix.multiplyVector3(w[k.b].position.clone());b=a.matrix.multiplyVector3(w[k.c].position.clone());n=k instanceof THREE.Face4?a.matrix.multiplyVector3(w[k.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(k.normal.clone());B=x.dot(o);if(B<0){o=o.dot((new THREE.Vector3).sub(m,A))/B;A=A.addSelf(x.multiplyScalar(o));
|
|
|
-if(k instanceof THREE.Face3){if(c(A,m,r,b)){k={distance:this.origin.distanceTo(A),point:A,face:k,object:a};I.push(k)}}else if(k instanceof THREE.Face4)if(c(A,m,r,n)||c(A,r,b,n)){k={distance:this.origin.distanceTo(A),point:A,face:k,object:a};I.push(k)}}}return I}};
|
|
|
-THREE.Rectangle=function(){function a(){m=f-c;r=k-d}var c,d,f,k,m,r,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return m};this.getHeight=function(){return r};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return k};this.set=function(n,o,B,A){b=false;c=n;d=o;f=B;k=A;a()};this.addPoint=function(n,o){if(b){b=false;c=n;d=o;f=n;k=o}else{c=c<n?c:n;d=d<o?d:o;f=f>n?f:n;k=k>o?
|
|
|
-k:o}a()};this.add3Points=function(n,o,B,A,x,y){if(b){b=false;c=n<B?n<x?n:x:B<x?B:x;d=o<A?o<y?o:y:A<y?A:y;f=n>B?n>x?n:x:B>x?B:x;k=o>A?o>y?o:y:A>y?A:y}else{c=n<B?n<x?n<c?n:c:x<c?x:c:B<x?B<c?B:c:x<c?x:c;d=o<A?o<y?o<d?o:d:y<d?y:d:A<y?A<d?A:d:y<d?y:d;f=n>B?n>x?n>f?n:f:x>f?x:f:B>x?B>f?B:f:x>f?x:f;k=o>A?o>y?o>k?o:k:y>k?y:k:A>y?A>k?A:k:y>k?y:k}a()};this.addRectangle=function(n){if(b){b=false;c=n.getLeft();d=n.getTop();f=n.getRight();k=n.getBottom()}else{c=c<n.getLeft()?c:n.getLeft();d=d<n.getTop()?d:n.getTop();
|
|
|
-f=f>n.getRight()?f:n.getRight();k=k>n.getBottom()?k:n.getBottom()}a()};this.inflate=function(n){c-=n;d-=n;f+=n;k+=n;a()};this.minSelf=function(n){c=c>n.getLeft()?c:n.getLeft();d=d>n.getTop()?d:n.getTop();f=f<n.getRight()?f:n.getRight();k=k<n.getBottom()?k:n.getBottom();a()};this.instersects=function(n){return Math.min(f,n.getRight())-Math.max(c,n.getLeft())>=0&&Math.min(k,n.getBottom())-Math.max(d,n.getTop())>=0};this.empty=function(){b=true;k=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
|
|
|
-function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+k+", width: "+m+", height: "+r+" )"}};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,k,m,r,b,n,o,B,A,x,y,w,I){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=k||0;this.n22=m||1;this.n23=r||0;this.n24=b||0;this.n31=n||0;this.n32=o||0;this.n33=B||1;this.n34=A||0;this.n41=x||0;this.n42=y||0;this.n43=w||0;this.n44=I||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,k,m,r,b,n,o,B,A,x,y,w,I){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=k;this.n22=m;this.n23=r;this.n24=b;this.n31=n;this.n32=o;this.n33=B;this.n34=A;this.n41=x;this.n42=y;this.n43=w;this.n44=I;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,k=THREE.Matrix4.__tmpVec2,m=THREE.Matrix4.__tmpVec3;m.sub(a,c).normalize();f.cross(d,m).normalize();k.cross(m,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=m.x;this.n32=m.y;this.n33=m.z;this.n34=-m.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,k=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)*k;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*k;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*k;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,k=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*k;a.y=this.n21*c+this.n22*d+this.n23*
|
|
|
-f+this.n24*k;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*k;a.w=this.n41*c+this.n42*d+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 d=a.n11,f=a.n12,k=a.n13,m=a.n14,r=a.n21,b=a.n22,n=a.n23,o=a.n24,B=a.n31,
|
|
|
-A=a.n32,x=a.n33,y=a.n34,w=a.n41,I=a.n42,K=a.n43,u=a.n44,S=c.n11,F=c.n12,P=c.n13,e=c.n14,q=c.n21,h=c.n22,g=c.n23,p=c.n24,i=c.n31,t=c.n32,j=c.n33,l=c.n34,s=c.n41,z=c.n42,v=c.n43,N=c.n44;this.n11=d*S+f*q+k*i+m*s;this.n12=d*F+f*h+k*t+m*z;this.n13=d*P+f*g+k*j+m*v;this.n14=d*e+f*p+k*l+m*N;this.n21=r*S+b*q+n*i+o*s;this.n22=r*F+b*h+n*t+o*z;this.n23=r*P+b*g+n*j+o*v;this.n24=r*e+b*p+n*l+o*N;this.n31=B*S+A*q+x*i+y*s;this.n32=B*F+A*h+x*t+y*z;this.n33=B*P+A*g+x*j+y*v;this.n34=B*e+A*p+x*l+y*N;this.n41=w*S+I*q+
|
|
|
-K*i+u*s;this.n42=w*F+I*h+K*t+u*z;this.n43=w*P+I*g+K*j+u*v;this.n44=w*e+I*p+K*l+u*N;return this},multiplyToArray:function(a,c,d){var f=a.n11,k=a.n12,m=a.n13,r=a.n14,b=a.n21,n=a.n22,o=a.n23,B=a.n24,A=a.n31,x=a.n32,y=a.n33,w=a.n34,I=a.n41,K=a.n42,u=a.n43;a=a.n44;var S=c.n11,F=c.n12,P=c.n13,e=c.n14,q=c.n21,h=c.n22,g=c.n23,p=c.n24,i=c.n31,t=c.n32,j=c.n33,l=c.n34,s=c.n41,z=c.n42,v=c.n43;c=c.n44;this.n11=f*S+k*q+m*i+r*s;this.n12=f*F+k*h+m*t+r*z;this.n13=f*P+k*g+m*j+r*v;this.n14=f*e+k*p+m*l+r*c;this.n21=
|
|
|
-b*S+n*q+o*i+B*s;this.n22=b*F+n*h+o*t+B*z;this.n23=b*P+n*g+o*j+B*v;this.n24=b*e+n*p+o*l+B*c;this.n31=A*S+x*q+y*i+w*s;this.n32=A*F+x*h+y*t+w*z;this.n33=A*P+x*g+y*j+w*v;this.n34=A*e+x*p+y*l+w*c;this.n41=I*S+K*q+u*i+a*s;this.n42=I*F+K*h+u*t+a*z;this.n43=I*P+K*g+u*j+a*v;this.n44=I*e+K*p+u*l+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,k=this.n14,m=this.n21,r=this.n22,b=this.n23,n=this.n24,o=this.n31,B=this.n32,A=this.n33,x=this.n34,y=this.n41,w=this.n42,I=this.n43,K=this.n44,u=a.n11,S=a.n21,F=a.n31,P=a.n41,e=a.n12,q=a.n22,h=a.n32,g=a.n42,p=a.n13,i=a.n23,t=a.n33,j=a.n43,l=a.n14,s=a.n24,z=a.n34;a=a.n44;this.n11=c*u+d*S+f*F+k*P;this.n12=c*e+d*q+f*h+k*g;this.n13=c*p+d*i+f*t+k*j;this.n14=c*l+d*s+f*z+k*a;this.n21=m*u+r*S+b*F+n*P;this.n22=m*e+r*
|
|
|
-q+b*h+n*g;this.n23=m*p+r*i+b*t+n*j;this.n24=m*l+r*s+b*z+n*a;this.n31=o*u+B*S+A*F+x*P;this.n32=o*e+B*q+A*h+x*g;this.n33=o*p+B*i+A*t+x*j;this.n34=o*l+B*s+A*z+x*a;this.n41=y*u+w*S+I*F+K*P;this.n42=y*e+w*q+I*h+K*g;this.n43=y*p+w*i+I*t+K*j;this.n44=y*l+w*s+I*z+K*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,k=this.n21,m=this.n22,r=this.n23,b=this.n24,n=this.n31,o=this.n32,B=this.n33,A=this.n34,x=this.n41,y=this.n42,w=this.n43,I=this.n44;return f*r*o*x-d*b*o*x-f*m*B*x+c*b*B*x+d*m*A*x-c*r*A*x-f*r*n*y+d*b*n*y+f*k*B*y-a*b*B*y-d*k*A*y+a*r*A*y+f*m*n*w-c*b*n*w-f*k*o*w+a*b*o*w+c*k*A*w-a*m*A*w-d*m*n*I+c*r*n*I+d*k*o*I-a*r*o*I-c*k*B*I+a*m*B*I},transpose:function(){function a(c,d,f){var k=c[d];c[d]=c[f];c[f]=k}a(this,"n21","n12");a(this,"n31",
|
|
|
+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,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),k=1-d,m=a.x,r=a.y,b=a.z,
|
|
|
-n=k*m,o=k*r;this.set(n*m+d,n*r-f*b,n*b+f*r,0,n*r+f*b,o*r+d,o*b-f*m,0,n*b-f*r,o*b+f*m,k*b*b+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,k=a.n14,m=a.n21,r=a.n22,b=a.n23,n=a.n24,o=a.n31,B=a.n32,A=a.n33,x=a.n34,y=a.n41,w=a.n42,I=a.n43,K=a.n44,u=new THREE.Matrix4;u.n11=b*x*w-n*A*w+n*B*I-r*x*I-b*B*K+r*A*K;u.n12=k*A*w-f*x*w-k*B*I+d*x*I+f*B*K-d*A*K;u.n13=f*n*w-k*b*w+k*r*I-d*n*I-f*r*K+d*b*K;u.n14=k*b*B-f*n*B-k*r*A+d*n*A+f*r*x-d*b*x;u.n21=n*A*y-b*x*y-n*o*I+m*x*I+b*o*K-m*A*K;u.n22=f*x*y-k*A*y+k*o*I-c*x*I-f*o*K+c*A*K;u.n23=k*b*y-f*n*y-k*m*I+c*n*I+f*m*K-c*b*K;u.n24=f*n*o-k*b*o+
|
|
|
-k*m*A-c*n*A-f*m*x+c*b*x;u.n31=r*x*y-n*B*y+n*o*w-m*x*w-r*o*K+m*B*K;u.n32=k*B*y-d*x*y-k*o*w+c*x*w+d*o*K-c*B*K;u.n33=f*n*y-k*r*y+k*m*w-c*n*w-d*m*K+c*r*K;u.n34=k*r*o-d*n*o-k*m*B+c*n*B+d*m*x-c*r*x;u.n41=b*B*y-r*A*y-b*o*w+m*A*w+r*o*I-m*B*I;u.n42=d*A*y-f*B*y+f*o*w-c*A*w-d*o*I+c*B*I;u.n43=f*r*y-d*b*y-f*m*w+c*b*w+d*m*I-c*r*I;u.n44=d*b*o-f*r*o+f*m*B-c*b*B-d*m*A+c*r*A;u.multiplyScalar(1/a.determinant());return u};
|
|
|
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,k=-a.n33*a.n21+a.n31*a.n23,m=a.n32*a.n21-a.n31*a.n22,r=-a.n33*a.n12+a.n32*a.n13,b=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,B=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*r+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*k;d[2]=a*m;d[3]=a*r;d[4]=a*b;d[5]=a*n;d[6]=a*o;d[7]=a*B;d[8]=a*A;return c};
|
|
|
-THREE.Matrix4.makeFrustum=function(a,c,d,f,k,m){var r,b,n;r=new THREE.Matrix4;b=2*k/(c-a);n=2*k/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(m+k)/(m-k);k=-2*m*k/(m-k);r.n11=b;r.n12=0;r.n13=a;r.n14=0;r.n21=0;r.n22=n;r.n23=d;r.n24=0;r.n31=0;r.n32=0;r.n33=f;r.n34=k;r.n41=0;r.n42=0;r.n43=-1;r.n44=0;return r};THREE.Matrix4.makePerspective=function(a,c,d,f){var k;a=d*Math.tan(a*Math.PI/360);k=-a;return THREE.Matrix4.makeFrustum(k*c,a*c,k,a,d,f)};
|
|
|
-THREE.Matrix4.makeOrtho=function(a,c,d,f,k,m){var r,b,n,o;r=new THREE.Matrix4;b=c-a;n=d-f;o=m-k;a=(c+a)/b;d=(d+f)/n;k=(m+k)/o;r.n11=2/b;r.n12=0;r.n13=0;r.n14=-a;r.n21=0;r.n22=2/n;r.n23=0;r.n24=-d;r.n31=0;r.n32=0;r.n33=-2/o;r.n34=-k;r.n41=0;r.n42=0;r.n43=0;r.n44=1;return r};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
|
|
+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.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,d,f,k){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=k instanceof Array?k:[k]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
-THREE.Face4=function(a,c,d,f,k,m){this.a=a;this.b=c;this.c=d;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=m instanceof Array?m:[m]};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,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.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,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,k,m,r,b=new THREE.Vector3,n=new THREE.Vector3;f=0;for(k=this.vertices.length;f<k;f++){m=this.vertices[f];m.normal.set(0,0,0)}f=0;for(k=this.faces.length;f<k;f++){m=this.faces[f];if(a&&m.vertexNormals.length){b.set(0,0,0);c=0;for(d=m.normal.length;c<d;c++)b.addSelf(m.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[m.a];d=this.vertices[m.b];r=this.vertices[m.c];b.sub(r.position,
|
|
|
-d.position);n.sub(c.position,d.position);b.crossSelf(n)}b.isZero()||b.normalize();m.normal.copy(b)}},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(l,s,z,v,N,J,E){m=l.vertices[s].position;r=l.vertices[z].position;b=l.vertices[v].position;n=k[N];o=k[J];B=k[E];A=r.x-m.x;x=b.x-m.x;y=r.y-m.y;w=b.y-m.y;
|
|
|
-I=r.z-m.z;K=b.z-m.z;u=o.u-n.u;S=B.u-n.u;F=o.v-n.v;P=B.v-n.v;e=1/(u*P-S*F);g.set((P*A-F*x)*e,(P*y-F*w)*e,(P*I-F*K)*e);p.set((u*x-S*A)*e,(u*w-S*y)*e,(u*K-S*I)*e);q[s].addSelf(g);q[z].addSelf(g);q[v].addSelf(g);h[s].addSelf(p);h[z].addSelf(p);h[v].addSelf(p)}var c,d,f,k,m,r,b,n,o,B,A,x,y,w,I,K,u,S,F,P,e,q=[],h=[],g=new THREE.Vector3,p=new THREE.Vector3,i=new THREE.Vector3,t=new THREE.Vector3,j=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){q[c]=new THREE.Vector3;h[c]=new THREE.Vector3}c=0;
|
|
|
-for(d=this.faces.length;c<d;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(d=this.vertices.length;c<d;c++){j.copy(this.vertices[c].normal);f=q[c];i.copy(f);i.subSelf(j.multiplyScalar(j.dot(f))).normalize();t.cross(this.vertices[c].normal,f);f=t.dot(h[c]);f=f<0?-1:1;this.vertices[c].tangent.set(i.x,i.y,i.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(B){var A=[];c=0;for(d=B.length;c<d;c++)B[c]==undefined?A.push("undefined"):A.push(B[c].toString());return A.join("_")}var c,d,f,k,m,r,b,n,o={};f=0;for(k=this.faces.length;f<k;f++){m=this.faces[f];
|
|
|
-r=m.materials;b=a(r);if(o[b]==undefined)o[b]={hash:b,counter:0};n=o[b].hash+"_"+o[b].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],materials:r,vertices:0};m=m instanceof THREE.Face3?3:4;if(this.geometryChunks[n].vertices+m>65535){o[b].counter+=1;n=o[b].hash+"_"+o[b].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],materials:r,vertices:0}}this.geometryChunks[n].faces.push(f);this.geometryChunks[n].vertices+=m}},toString:function(){return"THREE.Geometry ( vertices: "+
|
|
|
+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: "+
|
|
|
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
-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(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)};
|
|
|
+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.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,d=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(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
|
|
|
+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,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.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.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,119 +96,120 @@ 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,d,f,k,m){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=k!==undefined?k:THREE.LinearFilter;this.min_filter=m!==undefined?m: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,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.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,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,k={};for(c in a){k[c]={};for(d in a[c]){f=a[c][d];k[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return k},merge:function(a){var c,d,f,k={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)k[d]=f[d]}return k}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
|
|
+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.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,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(h,g){return g.z-h.z}function c(h,g){var p=0,i=1,t=h.z+h.w,j=g.z+g.w,l=-h.z+h.w,s=-g.z+g.w;if(t>=0&&j>=0&&l>=0&&s>=0)return true;else if(t<0&&j<0||l<0&&s<0)return false;else{if(t<0)p=Math.max(p,t/(t-j));else if(j<0)i=Math.min(i,t/(t-j));if(l<0)p=Math.max(p,l/(l-s));else if(s<0)i=Math.min(i,l/(l-s));if(i<p)return false;else{h.lerpSelf(g,p);g.lerpSelf(h,1-i);return true}}}var d,f,k=[],m,r,b,n=[],o,B,A=[],x,y,w=[],I=new THREE.Vector4,K=new THREE.Vector4,u=new THREE.Matrix4,
|
|
|
-S=new THREE.Matrix4,F=[],P=new THREE.Vector4,e=new THREE.Vector4,q;this.projectObjects=function(h,g,p){var i=[],t,j;f=0;u.multiply(g.projectionMatrix,g.matrix);F[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);F[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);F[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);F[3]=new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);F[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-
|
|
|
-u.n33,u.n44-u.n34);F[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);g=0;for(t=F.length;g<t;g++){j=F[g];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z*j.z))}t=h.objects;h=0;for(g=t.length;h<g;h++){j=t[h];var l;if(!(l=!j.visible)){if(l=j instanceof THREE.Mesh){a:{l=void 0;for(var s=j.position,z=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),v=0;v<6;v++){l=F[v].x*s.x+F[v].y*s.y+F[v].z*s.z+F[v].w;if(l<=z){l=false;break a}}l=true}l=!l}l=l}if(!l){d=
|
|
|
-k[f]=k[f]||new THREE.RenderableObject;I.copy(j.position);u.multiplyVector3(I);d.object=j;d.z=I.z;i.push(d);f++}}p&&i.sort(a);return i};this.projectScene=function(h,g,p){var i=[],t=g.near,j=g.far,l,s,z,v,N,J,E,U,X,O,H,L,Q,C,M,W;b=B=y=0;g.autoUpdateMatrix&&g.updateMatrix();u.multiply(g.projectionMatrix,g.matrix);J=this.projectObjects(h,g,true);h=0;for(l=J.length;h<l;h++){E=J[h].object;if(E.visible){E.autoUpdateMatrix&&E.updateMatrix();U=E.matrix;X=E.rotationMatrix;O=E.materials;H=E.overdraw;if(E instanceof
|
|
|
-THREE.Mesh){L=E.geometry;Q=L.vertices;s=0;for(z=Q.length;s<z;s++){C=Q[s];C.positionWorld.copy(C.position);U.multiplyVector3(C.positionWorld);v=C.positionScreen;v.copy(C.positionWorld);u.multiplyVector4(v);v.x/=v.w;v.y/=v.w;C.__visible=v.z>t&&v.z<j}L=L.faces;s=0;for(z=L.length;s<z;s++){C=L[s];if(C instanceof THREE.Face3){v=Q[C.a];N=Q[C.b];M=Q[C.c];if(v.__visible&&N.__visible&&M.__visible)if(E.doubleSided||E.flipSided!=(M.positionScreen.x-v.positionScreen.x)*(N.positionScreen.y-v.positionScreen.y)-
|
|
|
-(M.positionScreen.y-v.positionScreen.y)*(N.positionScreen.x-v.positionScreen.x)<0){m=n[b]=n[b]||new THREE.RenderableFace3;m.v1.positionWorld.copy(v.positionWorld);m.v2.positionWorld.copy(N.positionWorld);m.v3.positionWorld.copy(M.positionWorld);m.v1.positionScreen.copy(v.positionScreen);m.v2.positionScreen.copy(N.positionScreen);m.v3.positionScreen.copy(M.positionScreen);m.normalWorld.copy(C.normal);X.multiplyVector3(m.normalWorld);m.centroidWorld.copy(C.centroid);U.multiplyVector3(m.centroidWorld);
|
|
|
-m.centroidScreen.copy(m.centroidWorld);u.multiplyVector3(m.centroidScreen);M=C.vertexNormals;q=m.vertexNormalsWorld;v=0;for(N=M.length;v<N;v++){W=q[v]=q[v]||new THREE.Vector3;W.copy(M[v]);X.multiplyVector3(W)}m.z=m.centroidScreen.z;m.meshMaterials=O;m.faceMaterials=C.materials;m.overdraw=H;if(E.geometry.uvs[s]){m.uvs[0]=E.geometry.uvs[s][0];m.uvs[1]=E.geometry.uvs[s][1];m.uvs[2]=E.geometry.uvs[s][2]}i.push(m);b++}}else if(C instanceof THREE.Face4){v=Q[C.a];N=Q[C.b];M=Q[C.c];W=Q[C.d];if(v.__visible&&
|
|
|
-N.__visible&&M.__visible&&W.__visible)if(E.doubleSided||E.flipSided!=((W.positionScreen.x-v.positionScreen.x)*(N.positionScreen.y-v.positionScreen.y)-(W.positionScreen.y-v.positionScreen.y)*(N.positionScreen.x-v.positionScreen.x)<0||(N.positionScreen.x-M.positionScreen.x)*(W.positionScreen.y-M.positionScreen.y)-(N.positionScreen.y-M.positionScreen.y)*(W.positionScreen.x-M.positionScreen.x)<0)){m=n[b]=n[b]||new THREE.RenderableFace3;m.v1.positionWorld.copy(v.positionWorld);m.v2.positionWorld.copy(N.positionWorld);
|
|
|
-m.v3.positionWorld.copy(W.positionWorld);m.v1.positionScreen.copy(v.positionScreen);m.v2.positionScreen.copy(N.positionScreen);m.v3.positionScreen.copy(W.positionScreen);m.normalWorld.copy(C.normal);X.multiplyVector3(m.normalWorld);m.centroidWorld.copy(C.centroid);U.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);u.multiplyVector3(m.centroidScreen);m.z=m.centroidScreen.z;m.meshMaterials=O;m.faceMaterials=C.materials;m.overdraw=H;if(E.geometry.uvs[s]){m.uvs[0]=E.geometry.uvs[s][0];
|
|
|
-m.uvs[1]=E.geometry.uvs[s][1];m.uvs[2]=E.geometry.uvs[s][3]}i.push(m);b++;r=n[b]=n[b]||new THREE.RenderableFace3;r.v1.positionWorld.copy(N.positionWorld);r.v2.positionWorld.copy(M.positionWorld);r.v3.positionWorld.copy(W.positionWorld);r.v1.positionScreen.copy(N.positionScreen);r.v2.positionScreen.copy(M.positionScreen);r.v3.positionScreen.copy(W.positionScreen);r.normalWorld.copy(m.normalWorld);r.centroidWorld.copy(m.centroidWorld);r.centroidScreen.copy(m.centroidScreen);r.z=r.centroidScreen.z;r.meshMaterials=
|
|
|
-O;r.faceMaterials=C.materials;r.overdraw=H;if(E.geometry.uvs[s]){r.uvs[0]=E.geometry.uvs[s][1];r.uvs[1]=E.geometry.uvs[s][2];r.uvs[2]=E.geometry.uvs[s][3]}i.push(r);b++}}}}else if(E instanceof THREE.Line){S.multiply(u,U);Q=E.geometry.vertices;C=Q[0];C.positionScreen.copy(C.position);S.multiplyVector4(C.positionScreen);s=1;for(z=Q.length;s<z;s++){v=Q[s];v.positionScreen.copy(v.position);S.multiplyVector4(v.positionScreen);N=Q[s-1];P.copy(v.positionScreen);e.copy(N.positionScreen);if(c(P,e)){P.multiplyScalar(1/
|
|
|
-P.w);e.multiplyScalar(1/e.w);o=A[B]=A[B]||new THREE.RenderableLine;o.v1.positionScreen.copy(P);o.v2.positionScreen.copy(e);o.z=Math.max(P.z,e.z);o.materials=E.materials;i.push(o);B++}}}else if(E instanceof THREE.Particle){K.set(E.position.x,E.position.y,E.position.z,1);u.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){x=w[y]=w[y]||new THREE.RenderableParticle;x.x=K.x/K.w;x.y=K.y/K.w;x.z=K.z;x.rotation=E.rotation.z;x.scale.x=E.scale.x*Math.abs(x.x-(K.x+g.projectionMatrix.n11)/(K.w+g.projectionMatrix.n14));
|
|
|
-x.scale.y=E.scale.y*Math.abs(x.y-(K.y+g.projectionMatrix.n22)/(K.w+g.projectionMatrix.n24));x.materials=E.materials;i.push(x);y++}}}}p&&i.sort(a);return i};this.unprojectVector=function(h,g){var p=THREE.Matrix4.makeInvert(g.matrix);p.multiplySelf(THREE.Matrix4.makeInvert(g.projectionMatrix));p.multiplyVector3(h);return h}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,k,m;this.domElement=document.createElement("div");this.setSize=function(r,b){d=r;f=b;k=d/2;m=f/2};this.render=function(r,b){var n,o,B,A,x,y,w,I;a=c.projectScene(r,b);n=0;for(o=a.length;n<o;n++){x=a[n];if(x instanceof THREE.RenderableParticle){w=x.x*k+k;I=x.y*m+m;B=0;for(A=x.material.length;B<A;B++){y=x.material[B];if(y instanceof THREE.ParticleDOMMaterial){y=y.domElement;y.style.left=w+"px";y.style.top=I+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a(aa){if(x!=aa)o.globalAlpha=x=aa}function c(aa){if(y!=aa){switch(aa){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}y=aa}}var d=null,f=new THREE.Projector,k=document.createElement("canvas"),m,r,b,n,o=k.getContext("2d"),B=new THREE.Color(0),A=0,x=1,y=0,w=null,I=null,K=1,u,S,F,P,e,q,h,g,p,i=new THREE.Color,
|
|
|
-t=new THREE.Color,j=new THREE.Color,l=new THREE.Color,s=new THREE.Color,z,v,N,J,E,U,X,O,H,L=new THREE.Rectangle,Q=new THREE.Rectangle,C=new THREE.Rectangle,M=false,W=new THREE.Color,ga=new THREE.Color,da=new THREE.Color,Y=new THREE.Color,ba=Math.PI*2,Z=new THREE.Vector3,ea,xa,ha,ia,ta,pa,qa=16;ea=document.createElement("canvas");ea.width=ea.height=2;xa=ea.getContext("2d");xa.fillStyle="rgba(0,0,0,1)";xa.fillRect(0,0,2,2);ha=xa.getImageData(0,0,2,2);ia=ha.data;ta=document.createElement("canvas");ta.width=
|
|
|
-ta.height=qa;pa=ta.getContext("2d");pa.translate(-qa/2,-qa/2);pa.scale(qa,qa);qa--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(aa,na){m=aa;r=na;b=m/2;n=r/2;k.width=m;k.height=r;L.set(-b,-n,b,n);x=1;y=0;I=w=null;K=1};this.setClearColor=function(aa,na){B=aa;A=na;Q.set(-b,-n,b,n);o.setTransform(1,0,0,-1,b,n);this.clear()};this.setClearColorHex=function(aa,na){B.setHex(aa);A=na;Q.set(-b,-n,b,n);o.setTransform(1,0,0,-1,b,n);this.clear()};this.clear=function(){o.setTransform(1,
|
|
|
-0,0,-1,b,n);if(!Q.isEmpty()){Q.inflate(1);Q.minSelf(L);if(B.hex==0&&A==0)o.clearRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());else{c(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+A+")";o.fillRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight())}Q.empty()}};this.render=function(aa,na){function ka(D){var V,T,G,R=D.lights;ga.setRGB(0,0,0);da.setRGB(0,0,0);Y.setRGB(0,0,0);D=0;for(V=R.length;D<V;D++){T=R[D];G=T.color;if(T instanceof
|
|
|
-THREE.AmbientLight){ga.r+=G.r;ga.g+=G.g;ga.b+=G.b}else if(T instanceof THREE.DirectionalLight){da.r+=G.r;da.g+=G.g;da.b+=G.b}else if(T instanceof THREE.PointLight){Y.r+=G.r;Y.g+=G.g;Y.b+=G.b}}}function ya(D,V,T,G){var R,$,fa,ja,la=D.lights;D=0;for(R=la.length;D<R;D++){$=la[D];fa=$.color;ja=$.intensity;if($ instanceof THREE.DirectionalLight){$=T.dot($.position)*ja;if($>0){G.r+=fa.r*$;G.g+=fa.g*$;G.b+=fa.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,V);Z.normalize();$=T.dot(Z)*ja;if($>
|
|
|
-0){G.r+=fa.r*$;G.g+=fa.g*$;G.b+=fa.b*$}}}}function Ga(D,V,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var G,R,$,fa,ja,la;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){fa=T.map.image;ja=fa.width>>1;la=fa.height>>1;R=V.scale.x*b;$=V.scale.y*n;T=R*ja;G=$*la;C.set(D.x-T,D.y-G,D.x+T,D.y+G);if(!L.instersects(C))return;o.save();o.translate(D.x,D.y);o.rotate(-V.rotation);o.scale(R,-$);o.translate(-ja,-la);o.drawImage(fa,0,0);o.restore()}o.beginPath();o.moveTo(D.x-10,D.y);o.lineTo(D.x+
|
|
|
-10,D.y);o.moveTo(D.x,D.y-10);o.lineTo(D.x,D.y+10);o.closePath();o.strokeStyle="rgb(255,255,0)";o.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(M){W.r=ga.r+da.r+Y.r;W.g=ga.g+da.g+Y.g;W.b=ga.b+da.b+Y.b;i.r=T.color.r*W.r;i.g=T.color.g*W.g;i.b=T.color.b*W.b;i.updateStyleString()}else i.__styleString=T.color.__styleString;T=V.scale.x*b;G=V.scale.y*n;C.set(D.x-T,D.y-G,D.x+T,D.y+G);if(L.instersects(C)){R=i.__styleString;if(I!=R)o.fillStyle=I=R;o.save();o.translate(D.x,D.y);o.rotate(-V.rotation);
|
|
|
-o.scale(T,G);o.beginPath();o.arc(0,0,1,0,ba,true);o.closePath();o.fill();o.restore()}}}}function Ha(D,V,T,G){if(G.opacity!=0){a(G.opacity);c(G.blending);o.beginPath();o.moveTo(D.positionScreen.x,D.positionScreen.y);o.lineTo(V.positionScreen.x,V.positionScreen.y);o.closePath();if(G instanceof THREE.LineBasicMaterial){i.__styleString=G.color.__styleString;D=G.linewidth;if(K!=D)o.lineWidth=K=D;D=i.__styleString;if(w!=D)o.strokeStyle=w=D;o.stroke();C.inflate(G.linewidth*2)}}}function Da(D,V,T,G,R,$){if(R.opacity!=
|
|
|
-0){a(R.opacity);c(R.blending);P=D.positionScreen.x;e=D.positionScreen.y;q=V.positionScreen.x;h=V.positionScreen.y;g=T.positionScreen.x;p=T.positionScreen.y;o.beginPath();o.moveTo(P,e);o.lineTo(q,h);o.lineTo(g,p);o.lineTo(P,e);o.closePath();if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.image.loaded&&R.map.mapping instanceof THREE.UVMapping&&Aa(P,e,q,h,g,p,R.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(R.env_map){if(R.env_map.image.loaded)if(R.env_map.mapping instanceof
|
|
|
-THREE.SphericalReflectionMapping){D=na.matrix;Z.copy(G.vertexNormalsWorld[0]);J=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;E=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(G.vertexNormalsWorld[1]);U=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;X=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(G.vertexNormalsWorld[2]);O=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;H=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Aa(P,e,q,h,g,p,R.env_map.image,J,E,U,X,O,H)}}else R.wireframe?ma(R.color.__styleString,R.wireframe_linewidth):
|
|
|
-Ea(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){R.map.mapping instanceof THREE.UVMapping&&Aa(P,e,q,h,g,p,R.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(M)if(!R.wireframe&&R.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==3){t.r=j.r=l.r=ga.r;t.g=j.g=l.g=ga.g;t.b=j.b=l.b=ga.b;ya($,G.v1.positionWorld,G.vertexNormalsWorld[0],t);ya($,G.v2.positionWorld,G.vertexNormalsWorld[1],j);
|
|
|
-ya($,G.v3.positionWorld,G.vertexNormalsWorld[2],l);s.r=(j.r+l.r)*0.5;s.g=(j.g+l.g)*0.5;s.b=(j.b+l.b)*0.5;N=Ma(t,j,l,s);Aa(P,e,q,h,g,p,N,0,0,1,0,0,1)}else{W.r=ga.r;W.g=ga.g;W.b=ga.b;ya($,G.centroidWorld,G.normalWorld,W);i.r=R.color.r*W.r;i.g=R.color.g*W.g;i.b=R.color.b*W.b;i.updateStyleString();R.wireframe?ma(i.__styleString,R.wireframe_linewidth):Ea(i.__styleString)}else R.wireframe?ma(R.color.__styleString,R.wireframe_linewidth):Ea(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){z=
|
|
|
-na.near;v=na.far;t.r=t.g=t.b=1-Ia(D.positionScreen.z,z,v);j.r=j.g=j.b=1-Ia(V.positionScreen.z,z,v);l.r=l.g=l.b=1-Ia(T.positionScreen.z,z,v);s.r=(j.r+l.r)*0.5;s.g=(j.g+l.g)*0.5;s.b=(j.b+l.b)*0.5;N=Ma(t,j,l,s);Aa(P,e,q,h,g,p,N,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){i.r=Ja(G.normalWorld.x);i.g=Ja(G.normalWorld.y);i.b=Ja(G.normalWorld.z);i.updateStyleString();R.wireframe?ma(i.__styleString,R.wireframe_linewidth):Ea(i.__styleString)}}}function ma(D,V){if(w!=D)o.strokeStyle=w=D;if(K!=
|
|
|
-V)o.lineWidth=K=V;o.stroke();C.inflate(V*2)}function Ea(D){if(I!=D)o.fillStyle=I=D;o.fill()}function Aa(D,V,T,G,R,$,fa,ja,la,ua,oa,va,Ba){var ra,wa;ra=fa.width-1;wa=fa.height-1;ja*=ra;la*=wa;ua*=ra;oa*=wa;va*=ra;Ba*=wa;T-=D;G-=V;R-=D;$-=V;ua-=ja;oa-=la;va-=ja;Ba-=la;ra=ua*Ba-va*oa;if(ra!=0){wa=1/ra;ra=(Ba*T-oa*R)*wa;oa=(Ba*G-oa*$)*wa;T=(ua*R-va*T)*wa;G=(ua*$-va*G)*wa;D=D-ra*ja-T*la;V=V-oa*ja-G*la;o.save();o.transform(ra,oa,T,G,D,V);o.clip();o.drawImage(fa,0,0);o.restore()}}function Ma(D,V,T,G){var R=
|
|
|
-~~(D.r*255),$=~~(D.g*255);D=~~(D.b*255);var fa=~~(V.r*255),ja=~~(V.g*255);V=~~(V.b*255);var la=~~(T.r*255),ua=~~(T.g*255);T=~~(T.b*255);var oa=~~(G.r*255),va=~~(G.g*255);G=~~(G.b*255);ia[0]=R<0?0:R>255?255:R;ia[1]=$<0?0:$>255?255:$;ia[2]=D<0?0:D>255?255:D;ia[4]=fa<0?0:fa>255?255:fa;ia[5]=ja<0?0:ja>255?255:ja;ia[6]=V<0?0:V>255?255:V;ia[8]=la<0?0:la>255?255:la;ia[9]=ua<0?0:ua>255?255:ua;ia[10]=T<0?0:T>255?255:T;ia[12]=oa<0?0:oa>255?255:oa;ia[13]=va<0?0:va>255?255:va;ia[14]=G<0?0:G>255?255:G;xa.putImageData(ha,
|
|
|
-0,0);pa.drawImage(ea,0,0);return ta}function Ia(D,V,T){D=(D-V)/(T-V);return D*D*(3-2*D)}function Ja(D){D=(D+1)*0.5;return D<0?0:D>1?1:D}function Ka(D,V){var T=V.x-D.x,G=V.y-D.y,R=1/Math.sqrt(T*T+G*G);T*=R;G*=R;V.x+=T;V.y+=G;D.x-=T;D.y-=G}var Fa,Na,ca,sa,za,La,Oa,Ca;this.autoClear?this.clear():o.setTransform(1,0,0,-1,b,n);d=f.projectScene(aa,na,this.sortElements);o.fillStyle="rgba( 0, 255, 255, 0.5 )";o.fillRect(L.getX(),L.getY(),L.getWidth(),L.getHeight());(M=aa.lights.length>0)&&ka(aa);Fa=0;for(Na=
|
|
|
-d.length;Fa<Na;Fa++){ca=d[Fa];C.empty();if(ca instanceof THREE.RenderableParticle){u=ca;u.x*=b;u.y*=n;sa=0;for(za=ca.materials.length;sa<za;sa++)Ga(u,ca,ca.materials[sa],aa)}else if(ca instanceof THREE.RenderableLine){u=ca.v1;S=ca.v2;u.positionScreen.x*=b;u.positionScreen.y*=n;S.positionScreen.x*=b;S.positionScreen.y*=n;C.addPoint(u.positionScreen.x,u.positionScreen.y);C.addPoint(S.positionScreen.x,S.positionScreen.y);if(L.instersects(C)){sa=0;for(za=ca.materials.length;sa<za;)Ha(u,S,ca,ca.materials[sa++],
|
|
|
-aa)}}else if(ca instanceof THREE.RenderableFace3){u=ca.v1;S=ca.v2;F=ca.v3;u.positionScreen.x*=b;u.positionScreen.y*=n;S.positionScreen.x*=b;S.positionScreen.y*=n;F.positionScreen.x*=b;F.positionScreen.y*=n;if(ca.overdraw){Ka(u.positionScreen,S.positionScreen);Ka(S.positionScreen,F.positionScreen);Ka(F.positionScreen,u.positionScreen)}C.add3Points(u.positionScreen.x,u.positionScreen.y,S.positionScreen.x,S.positionScreen.y,F.positionScreen.x,F.positionScreen.y);if(L.instersects(C)){sa=0;for(za=ca.meshMaterials.length;sa<
|
|
|
-za;){Ca=ca.meshMaterials[sa++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Oa=ca.faceMaterials.length;La<Oa;)(Ca=ca.faceMaterials[La++])&&Da(u,S,F,ca,Ca,aa)}else Da(u,S,F,ca,Ca,aa)}}}Q.addRectangle(C)}o.lineWidth=1;o.strokeStyle="rgba( 255, 0, 0, 0.5 )";o.strokeRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());o.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(J,E,U){var X,O,H,L;X=0;for(O=J.lights.length;X<O;X++){H=J.lights[X];if(H instanceof THREE.DirectionalLight){L=E.normalWorld.dot(H.position)*H.intensity;if(L>0){U.r+=H.color.r*L;U.g+=H.color.g*L;U.b+=H.color.b*L}}else if(H instanceof THREE.PointLight){p.sub(H.position,E.centroidWorld);p.normalize();L=E.normalWorld.dot(p)*H.intensity;if(L>0){U.r+=H.color.r*L;U.g+=H.color.g*L;U.b+=H.color.b*L}}}}function c(J,E,U,X,O,H){l=f(s++);l.setAttribute("d","M "+J.positionScreen.x+
|
|
|
-" "+J.positionScreen.y+" L "+E.positionScreen.x+" "+E.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)F.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(S){P.r=e.r;P.g=e.g;P.b=e.b;a(H,X,P);F.r=O.color.r*P.r;F.g=O.color.g*P.g;F.b=O.color.b*P.b;F.updateStyleString()}else F.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){g=1-O.__2near/(O.__farPlusNear-X.z*O.__farMinusNear);
|
|
|
-F.setRGB(g,g,g)}else O instanceof THREE.MeshNormalMaterial&&F.setRGB(k(X.normalWorld.x),k(X.normalWorld.y),k(X.normalWorld.z));O.wireframe?l.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):l.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+O.opacity);b.appendChild(l)}function d(J,E,U,X,O,H,L){l=f(s++);l.setAttribute("d",
|
|
|
-"M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+E.positionScreen.x+" "+E.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)F.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(S){P.r=e.r;P.g=e.g;P.b=e.b;a(L,O,P);F.r=H.color.r*P.r;F.g=H.color.g*P.g;F.b=H.color.b*P.b;F.updateStyleString()}else F.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){g=
|
|
|
-1-H.__2near/(H.__farPlusNear-O.z*H.__farMinusNear);F.setRGB(g,g,g)}else H instanceof THREE.MeshNormalMaterial&&F.setRGB(k(O.normalWorld.x),k(O.normalWorld.y),k(O.normalWorld.z));H.wireframe?l.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):l.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+H.opacity);b.appendChild(l)}
|
|
|
-function f(J){if(i[J]==null){i[J]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&i[J].setAttribute("shape-rendering","crispEdges");return i[J]}return i[J]}function k(J){return J<0?Math.min((1+J)*0.5,0.5):0.5+Math.min(J*0.5,0.5)}var m=null,r=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,o,B,A,x,y,w,I,K=new THREE.Rectangle,u=new THREE.Rectangle,S=false,F=new THREE.Color(16777215),P=new THREE.Color(16777215),e=new THREE.Color(0),q=new THREE.Color(0),
|
|
|
-h=new THREE.Color(0),g,p=new THREE.Vector3,i=[],t=[],j=[],l,s,z,v,N=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(J){switch(J){case "high":N=1;break;case "low":N=0}};this.setSize=function(J,E){n=J;o=E;B=n/2;A=o/2;b.setAttribute("viewBox",-B+" "+-A+" "+n+" "+o);b.setAttribute("width",n);b.setAttribute("height",o);K.set(-B,-A,B,A)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(J,E){var U,X,
|
|
|
-O,H,L,Q,C,M;this.autoClear&&this.clear();m=r.projectScene(J,E,this.sortElements);v=z=s=0;if(S=J.lights.length>0){C=J.lights;e.setRGB(0,0,0);q.setRGB(0,0,0);h.setRGB(0,0,0);U=0;for(X=C.length;U<X;U++){O=C[U];H=O.color;if(O instanceof THREE.AmbientLight){e.r+=H.r;e.g+=H.g;e.b+=H.b}else if(O instanceof THREE.DirectionalLight){q.r+=H.r;q.g+=H.g;q.b+=H.b}else if(O instanceof THREE.PointLight){h.r+=H.r;h.g+=H.g;h.b+=H.b}}}U=0;for(X=m.length;U<X;U++){C=m[U];u.empty();if(C instanceof THREE.RenderableParticle){x=
|
|
|
-C;x.x*=B;x.y*=-A;O=0;for(H=C.materials.length;O<H;O++)if(M=C.materials[O]){L=x;Q=C;M=M;var W=z++;if(t[W]==null){t[W]=document.createElementNS("http://www.w3.org/2000/svg","circle");N==0&&t[W].setAttribute("shape-rendering","crispEdges")}l=t[W];l.setAttribute("cx",L.x);l.setAttribute("cy",L.y);l.setAttribute("r",Q.scale.x*B);if(M instanceof THREE.ParticleCircleMaterial){if(S){P.r=e.r+q.r+h.r;P.g=e.g+q.g+h.g;P.b=e.b+q.b+h.b;F.r=M.color.r*P.r;F.g=M.color.g*P.g;F.b=M.color.b*P.b;F.updateStyleString()}else F=
|
|
|
-M.color;l.setAttribute("style","fill: "+F.__styleString)}b.appendChild(l)}}else if(C instanceof THREE.RenderableLine){x=C.v1;y=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-A;y.positionScreen.x*=B;y.positionScreen.y*=-A;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(y.positionScreen.x,y.positionScreen.y);if(K.instersects(u)){O=0;for(H=C.materials.length;O<H;)if(M=C.materials[O++]){L=x;Q=y;M=M;W=v++;if(j[W]==null){j[W]=document.createElementNS("http://www.w3.org/2000/svg","line");N==
|
|
|
-0&&j[W].setAttribute("shape-rendering","crispEdges")}l=j[W];l.setAttribute("x1",L.positionScreen.x);l.setAttribute("y1",L.positionScreen.y);l.setAttribute("x2",Q.positionScreen.x);l.setAttribute("y2",Q.positionScreen.y);if(M instanceof THREE.LineBasicMaterial){F.__styleString=M.color.__styleString;l.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+M.linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.linecap+"; stroke-linejoin: "+M.linejoin);b.appendChild(l)}}}}else if(C instanceof
|
|
|
-THREE.RenderableFace3){x=C.v1;y=C.v2;w=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-A;y.positionScreen.x*=B;y.positionScreen.y*=-A;w.positionScreen.x*=B;w.positionScreen.y*=-A;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);if(K.instersects(u)){O=0;for(H=C.meshMaterials.length;O<H;){M=C.meshMaterials[O++];if(M instanceof THREE.MeshFaceMaterial){L=0;for(Q=C.faceMaterials.length;L<Q;)(M=C.faceMaterials[L++])&&
|
|
|
-c(x,y,w,C,M,J)}else M&&c(x,y,w,C,M,J)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;y=C.v2;w=C.v3;I=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-A;y.positionScreen.x*=B;y.positionScreen.y*=-A;w.positionScreen.x*=B;w.positionScreen.y*=-A;I.positionScreen.x*=B;I.positionScreen.y*=-A;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(I.positionScreen.x,I.positionScreen.y);if(K.instersects(u)){O=
|
|
|
-0;for(H=C.meshMaterials.length;O<H;){M=C.meshMaterials[O++];if(M instanceof THREE.MeshFaceMaterial){L=0;for(Q=C.faceMaterials.length;L<Q;)(M=C.faceMaterials[L++])&&d(x,y,w,I,C,M,J)}else M&&d(x,y,w,I,C,M,J)}}}}}};
|
|
|
-THREE.WebGLRenderer=function(a){function c(e,q){e.fragment_shader=q.fragment_shader;e.vertex_shader=q.vertex_shader;e.uniforms=Uniforms.clone(q.uniforms)}function d(e){if(B!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);B=e.doubleSided}if(A!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);A=e.flipSided}}function f(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 k(e,q){var h;if(e=="fragment")h=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")h=b.createShader(b.VERTEX_SHADER);b.shaderSource(h,q);b.compileShader(h);if(!b.getShaderParameter(h,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(h));return null}return h}function m(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 r=document.createElement("canvas"),
|
|
|
-b,n=null,o=null,B=null,A=null,x=null,y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],w=new THREE.Matrix4,I=new Float32Array(16),K=new Float32Array(16),u=new THREE.Vector4,S=true,F=new THREE.Color(0),P=0;if(a){if(a.antialias!==undefined)S=a.antialias;a.clearColor!==undefined&&F.setHex(a.clearColor);if(a.clearAlpha!==undefined)P=a.clearAlpha}this.domElement=r;this.autoClear=true;(function(e,q,h){try{b=r.getContext("experimental-webgl",
|
|
|
-{antialias:e})}catch(g){console.log(g)}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(q.r,q.g,q.b,h);_cullEnabled=true})(S,F,P);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=
|
|
|
-function(e,q){r.width=e;r.height=q;b.viewport(0,0,r.width,r.height)};this.setClearColorHex=function(e,q){var h=new THREE.Color(e);b.clearColor(h.r,h.g,h.b,q)};this.setClearColor=function(e,q){b.clearColor(e.r,e.g,e.b,q)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,q){var h,g,p,i=0,t=0,j=0,l,s,z,v=this.lights,N=v.directional.colors,J=v.directional.positions,E=v.point.colors,U=v.point.positions,X=0,O=0;h=p=p=0;for(g=q.length;h<g;h++){p=q[h];l=p.color;
|
|
|
-s=p.position;z=p.intensity;if(p instanceof THREE.AmbientLight){i+=l.r;t+=l.g;j+=l.b}else if(p instanceof THREE.DirectionalLight){p=X*3;N[p]=l.r*z;N[p+1]=l.g*z;N[p+2]=l.b*z;J[p]=s.x;J[p+1]=s.y;J[p+2]=s.z;X+=1}else if(p instanceof THREE.PointLight){p=O*3;E[p]=l.r*z;E[p+1]=l.g*z;E[p+2]=l.b*z;U[p]=s.x;U[p+1]=s.y;U[p+2]=s.z;O+=1}}for(h=X*3;h<N.length;h++)N[h]=0;for(h=O*3;h<E.length;h++)E[h]=0;v.point.length=O;v.directional.length=X;v.ambient[0]=i;v.ambient[1]=t;v.ambient[2]=j};this.createParticleBuffers=
|
|
|
-function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLNormalBuffer=b.createBuffer();e.__webGLTangentBuffer=b.createBuffer();e.__webGLColorBuffer=b.createBuffer();e.__webGLUVBuffer=b.createBuffer();e.__webGLUV2Buffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer();
|
|
|
-e.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(e){var q=e.vertices.length;e.__vertexArray=new Float32Array(q*3);e.__colorArray=new Float32Array(q*3);e.__webGLLineCount=q};this.initParticleBuffers=function(e){var q=e.vertices.length;e.__vertexArray=new Float32Array(q*3);e.__colorArray=new Float32Array(q*3);e.__sortArray=[];e.__webGLParticleCount=q};this.initMeshBuffers=function(e,q){var h,g,p=0,i=0,t=0,j=q.geometry.faces,l=e.faces;h=0;for(g=l.length;h<g;h++){fi=l[h];face=j[fi];
|
|
|
-if(face instanceof THREE.Face3){p+=3;i+=1;t+=3}else if(face instanceof THREE.Face4){p+=4;i+=2;t+=4}}e.__vertexArray=new Float32Array(p*3);e.__normalArray=new Float32Array(p*3);e.__tangentArray=new Float32Array(p*4);e.__colorArray=new Float32Array(p*3);e.__uvArray=new Float32Array(p*2);e.__uv2Array=new Float32Array(p*2);e.__faceArray=new Uint16Array(i*3);e.__lineArray=new Uint16Array(t*2);p=false;h=0;for(g=q.materials.length;h<g;h++){j=q.materials[h];if(j instanceof THREE.MeshFaceMaterial){j=0;for(l=
|
|
|
-e.materials.length;j<l;j++)if(e.materials[j]&&e.materials[j].shading!=undefined&&e.materials[j].shading==THREE.SmoothShading){p=true;break}}else if(j&&j.shading!=undefined&&j.shading==THREE.SmoothShading){p=true;break}if(p)break}e.__needsSmoothNormals=p;e.__webGLFaceCount=i*3;e.__webGLLineCount=t*2};this.setMeshBuffers=function(e,q,h){var g,p,i,t,j,l,s,z,v,N,J=0,E=0,U=0,X=0,O=0,H=0,L=0,Q=0,C=0,M=e.__vertexArray,W=e.__uvArray,ga=e.__uv2Array,da=e.__normalArray,Y=e.__tangentArray,ba=e.__colorArray,
|
|
|
-Z=e.__faceArray,ea=e.__lineArray,xa=e.__needsSmoothNormals,ha=q.geometry,ia=ha.__dirtyVertices,ta=ha.__dirtyElements,pa=ha.__dirtyUvs,qa=ha.__dirtyNormals,aa=ha.__dirtyTangents,na=ha.__dirtyColors,ka=ha.vertices,ya=e.faces,Ga=ha.faces,Ha=ha.uvs,Da=ha.uvs2,ma=ha.colors;q=0;for(g=ya.length;q<g;q++){p=ya[q];i=Ga[p];l=Ha[p];p=Da[p];t=i.vertexNormals;j=i.normal;if(i instanceof THREE.Face3){if(ia){s=ka[i.a].position;z=ka[i.b].position;v=ka[i.c].position;M[E]=s.x;M[E+1]=s.y;M[E+2]=s.z;M[E+3]=z.x;M[E+4]=
|
|
|
-z.y;M[E+5]=z.z;M[E+6]=v.x;M[E+7]=v.y;M[E+8]=v.z;E+=9}if(na&&ma.length){s=ma[i.a];z=ma[i.b];v=ma[i.c];ba[C]=s.r;ba[C+1]=s.g;ba[C+2]=s.b;ba[C+3]=z.r;ba[C+4]=z.g;ba[C+5]=z.b;ba[C+6]=v.r;ba[C+7]=v.g;ba[C+8]=v.b;C+=9}if(aa&&ha.hasTangents){s=ka[i.a].tangent;z=ka[i.b].tangent;v=ka[i.c].tangent;Y[L]=s.x;Y[L+1]=s.y;Y[L+2]=s.z;Y[L+3]=s.w;Y[L+4]=z.x;Y[L+5]=z.y;Y[L+6]=z.z;Y[L+7]=z.w;Y[L+8]=v.x;Y[L+9]=v.y;Y[L+10]=v.z;Y[L+11]=v.w;L+=12}if(qa)if(t.length==3&&xa)for(i=0;i<3;i++){j=t[i];da[H]=j.x;da[H+1]=j.y;da[H+
|
|
|
-2]=j.z;H+=3}else for(i=0;i<3;i++){da[H]=j.x;da[H+1]=j.y;da[H+2]=j.z;H+=3}if(pa&&l)for(i=0;i<3;i++){t=l[i];W[U]=t.u;W[U+1]=t.v;U+=2}if(pa&&p)for(i=0;i<3;i++){l=p[i];ga[X]=l.u;ga[X+1]=l.v;X+=2}if(ta){Z[O]=J;Z[O+1]=J+1;Z[O+2]=J+2;O+=3;ea[Q]=J;ea[Q+1]=J+1;ea[Q+2]=J;ea[Q+3]=J+2;ea[Q+4]=J+1;ea[Q+5]=J+2;Q+=6;J+=3}}else if(i instanceof THREE.Face4){if(ia){s=ka[i.a].position;z=ka[i.b].position;v=ka[i.c].position;N=ka[i.d].position;M[E]=s.x;M[E+1]=s.y;M[E+2]=s.z;M[E+3]=z.x;M[E+4]=z.y;M[E+5]=z.z;M[E+6]=v.x;
|
|
|
-M[E+7]=v.y;M[E+8]=v.z;M[E+9]=N.x;M[E+10]=N.y;M[E+11]=N.z;E+=12}if(na&&ma.length){s=ma[i.a];z=ma[i.b];v=ma[i.c];N=ma[i.d];ba[C]=s.r;ba[C+1]=s.g;ba[C+2]=s.b;ba[C+3]=z.r;ba[C+4]=z.g;ba[C+5]=z.b;ba[C+6]=v.r;ba[C+7]=v.g;ba[C+8]=v.b;ba[C+9]=N.r;ba[C+10]=N.g;ba[C+11]=N.b;C+=12}if(aa&&ha.hasTangents){s=ka[i.a].tangent;z=ka[i.b].tangent;v=ka[i.c].tangent;i=ka[i.d].tangent;Y[L]=s.x;Y[L+1]=s.y;Y[L+2]=s.z;Y[L+3]=s.w;Y[L+4]=z.x;Y[L+5]=z.y;Y[L+6]=z.z;Y[L+7]=z.w;Y[L+8]=v.x;Y[L+9]=v.y;Y[L+10]=v.z;Y[L+11]=v.w;Y[L+
|
|
|
-12]=i.x;Y[L+13]=i.y;Y[L+14]=i.z;Y[L+15]=i.w;L+=16}if(qa)if(t.length==4&&xa)for(i=0;i<4;i++){j=t[i];da[H]=j.x;da[H+1]=j.y;da[H+2]=j.z;H+=3}else for(i=0;i<4;i++){da[H]=j.x;da[H+1]=j.y;da[H+2]=j.z;H+=3}if(pa&&l)for(i=0;i<4;i++){t=l[i];W[U]=t.u;W[U+1]=t.v;U+=2}if(pa&&p)for(i=0;i<4;i++){l=p[i];ga[X]=l.u;ga[X+1]=l.v;X+=2}if(ta){Z[O]=J;Z[O+1]=J+1;Z[O+2]=J+2;Z[O+3]=J;Z[O+4]=J+2;Z[O+5]=J+3;O+=6;ea[Q]=J;ea[Q+1]=J+1;ea[Q+2]=J;ea[Q+3]=J+3;ea[Q+4]=J+1;ea[Q+5]=J+2;ea[Q+6]=J+2;ea[Q+7]=J+3;Q+=8;J+=4}}}if(ia){b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
-e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,M,h)}if(na&&ma.length){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ba,h)}if(qa){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,da,h)}if(aa&&ha.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Y,h)}if(pa&&U>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,W,h)}if(pa&&X>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUV2Buffer);
|
|
|
-b.bufferData(b.ARRAY_BUFFER,ga,h)}if(ta){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Z,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ea,h)}};this.setLineBuffers=function(e,q){var h,g,p,i=e.vertices,t=e.colors,j=i.length,l=t.length,s=e.__vertexArray,z=e.__colorArray,v=e.__dirtyColors;if(e.__dirtyVertices){for(h=0;h<j;h++){g=i[h].position;p=h*3;s[p]=g.x;s[p+1]=g.y;s[p+2]=g.z}b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
-e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,s,q)}if(v){for(h=0;h<l;h++){color=t[h];p=h*3;z[p]=color.r;z[p+1]=color.g;z[p+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,z,q)}};this.setParticleBuffers=function(e,q,h){var g,p,i,t=e.vertices,j=t.length,l=e.colors,s=l.length,z=e.__vertexArray,v=e.__colorArray,N=e.__sortArray,J=e.__dirtyVertices,E=e.__dirtyColors;if(h.sortParticles){w.multiplySelf(h.matrix);for(g=0;g<j;g++){p=t[g].position;u.copy(p);w.multiplyVector3(u);
|
|
|
-N[g]=[u.z,g]}N.sort(function(U,X){return X[0]-U[0]});for(g=0;g<j;g++){p=t[N[g][1]].position;i=g*3;z[i]=p.x;z[i+1]=p.y;z[i+2]=p.z}for(g=0;g<s;g++){i=g*3;color=l[N[g][1]];v[i]=color.r;v[i+1]=color.g;v[i+2]=color.b}}else{if(J)for(g=0;g<j;g++){p=t[g].position;i=g*3;z[i]=p.x;z[i+1]=p.y;z[i+2]=p.z}if(E)for(g=0;g<s;g++){color=l[g];i=g*3;v[i]=color.r;v[i+1]=color.g;v[i+2]=color.b}}if(J||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,q)}if(E||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
-e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,v,q)}};this.initMaterial=function(e,q,h){var g,p;if(e instanceof THREE.MeshDepthMaterial)c(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)c(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)c(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)c(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)c(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)c(e,
|
|
|
-THREE.ShaderLib.basic);else e instanceof THREE.ParticleBasicMaterial&&c(e,THREE.ShaderLib.particle_basic);var i,t,j,l;p=j=l=0;for(i=q.length;p<i;p++){t=q[p];t instanceof THREE.DirectionalLight&&j++;t instanceof THREE.PointLight&&l++}if(l+j<=4){q=j;l=l}else{q=Math.ceil(4*j/(l+j));l=4-q}p={directional:q,point:l};l=e.fragment_shader;q=e.vertex_shader;i={fog:h,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,maxDirLights:p.directional,maxPointLights:p.point};h=b.createProgram();
|
|
|
-p=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+i.maxDirLights,"#define MAX_POINT_LIGHTS "+i.maxPointLights,i.fog?"#define USE_FOG":"",i.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.env_map?"#define USE_ENVMAP":"",i.light_map?"#define USE_LIGHTMAP":"",i.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");i=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":
|
|
|
-"","#define MAX_DIR_LIGHTS "+i.maxDirLights,"#define MAX_POINT_LIGHTS "+i.maxPointLights,i.map?"#define USE_MAP":"",i.env_map?"#define USE_ENVMAP":"",i.light_map?"#define USE_LIGHTMAP":"",i.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(h,k("fragment",p+l));b.attachShader(h,k("vertex",i+q));b.linkProgram(h);b.getProgramParameter(h,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(h,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");h.uniforms={};h.attributes={};e.program=h;h=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(g in e.uniforms)h.push(g);g=e.program;l=0;for(q=h.length;l<q;l++){p=h[l];g.uniforms[p]=b.getUniformLocation(g,
|
|
|
-p)}e=e.program;g=["position","normal","uv","uv2","tangent","color"];h=0;for(l=g.length;h<l;h++){q=g[h];e.attributes[q]=b.getAttribLocation(e,q)}};this.setProgram=function(e,q,h,g,p){g.program||this.initMaterial(g,q,h);var i=g.program,t=i.uniforms,j=g.uniforms;if(i!=n){b.useProgram(i);n=i;b.uniformMatrix4fv(t.projectionMatrix,false,I)}if(h&&(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial||g instanceof THREE.LineBasicMaterial||g instanceof
|
|
|
-THREE.ParticleBasicMaterial)){j.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){j.fogNear.value=h.near;j.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)j.fogDensity.value=h.density}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial){this.setupLights(i,q);q=this.lights;j.enableLighting.value=q.directional.length+q.point.length;j.ambientLightColor.value=q.ambient;j.directionalLightColor.value=q.directional.colors;j.directionalLightDirection.value=q.directional.positions;
|
|
|
-j.pointLightColor.value=q.point.colors;j.pointLightPosition.value=q.point.positions}if(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial){j.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);j.opacity.value=g.opacity;j.map.texture=g.map;j.light_map.texture=g.light_map;j.env_map.texture=g.env_map;j.reflectivity.value=g.reflectivity;j.refraction_ratio.value=g.refraction_ratio;j.combine.value=g.combine;j.useRefract.value=
|
|
|
-g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping}if(g instanceof THREE.LineBasicMaterial){j.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);j.opacity.value=g.opacity}else if(g instanceof THREE.ParticleBasicMaterial){j.psColor.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);j.opacity.value=g.opacity;j.size.value=g.size;j.map.texture=g.map}else if(g instanceof THREE.MeshPhongMaterial){j.ambient.value.setRGB(g.ambient.r,g.ambient.g,
|
|
|
-g.ambient.b);j.specular.value.setRGB(g.specular.r,g.specular.g,g.specular.b);j.shininess.value=g.shininess}else if(g instanceof THREE.MeshDepthMaterial){j.mNear.value=e.near;j.mFar.value=e.far;j.opacity.value=g.opacity}else if(g instanceof THREE.MeshNormalMaterial)j.opacity.value=g.opacity;var l,s,z;for(l in j)if(z=i.uniforms[l]){h=j[l];s=h.type;q=h.value;if(s=="i")b.uniform1i(z,q);else if(s=="f")b.uniform1f(z,q);else if(s=="fv1")b.uniform1fv(z,q);else if(s=="fv")b.uniform3fv(z,q);else if(s=="v2")b.uniform2f(z,
|
|
|
-q.x,q.y);else if(s=="v3")b.uniform3f(z,q.x,q.y,q.z);else if(s=="c")b.uniform3f(z,q.r,q.g,q.b);else if(s=="t"){b.uniform1i(z,q);if(h=h.texture)if(h.image instanceof Array&&h.image.length==6){h=h;q=q;if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,h.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(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,h.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+q);b.bindTexture(b.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}else{h=h;q=q;if(!h.__webGLTexture&&
|
|
|
-h.image.loaded){h.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,h.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,m(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,m(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,m(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,m(h.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
|
|
|
-q);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture)}}}b.uniformMatrix4fv(t.modelViewMatrix,false,p._modelViewMatrixArray);b.uniformMatrix3fv(t.normalMatrix,false,p._normalMatrixArray);if(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshPhongMaterial||g.env_map)b.uniform3f(t.cameraPosition,e.position.x,e.position.y,e.position.z);if(g instanceof THREE.MeshShaderMaterial||g.env_map)b.uniformMatrix4fv(t.objectMatrix,false,p._objectMatrixArray);if(g instanceof THREE.MeshPhongMaterial||g instanceof
|
|
|
-THREE.MeshLambertMaterial||g instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(t.viewMatrix,false,K);return i};this.renderBuffer=function(e,q,h,g,p,i){e=this.setProgram(e,q,h,g,i).attributes;b.bindBuffer(b.ARRAY_BUFFER,p.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.position);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=
|
|
|
-0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(p.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,p.__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(p.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(i instanceof THREE.Mesh)if(g.wireframe){b.lineWidth(g.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);b.drawElements(b.LINES,p.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,p.__webGLFaceCount,b.UNSIGNED_SHORT,
|
|
|
-0)}else if(i instanceof THREE.Line){i=i.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(g.linewidth);b.drawArrays(i,0,p.__webGLLineCount)}else i instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,p.__webGLParticleCount)};this.renderPass=function(e,q,h,g,p,i,t){var j,l,s,z,v;s=0;for(z=g.materials.length;s<z;s++){j=g.materials[s];if(j instanceof THREE.MeshFaceMaterial){j=0;for(l=p.materials.length;j<l;j++)if((v=p.materials[j])&&v.blending==i&&v.opacity<1==t){f(v.blending);this.setDepthTest(v.depth_test);
|
|
|
-this.renderBuffer(e,q,h,v,p,g)}}else if((v=j)&&v.blending==i&&v.opacity<1==t){f(v.blending);this.setDepthTest(v.depth_test);this.renderBuffer(e,q,h,v,p,g)}}};this.renderPassImmediate=function(e,q,h,g,p,i){var t,j,l,s;t=0;for(j=g.materials.length;t<j;t++)if((l=g.materials[t])&&l.blending==p&&l.opacity<1==i){f(l.blending);this.setDepthTest(l.depth_test);s=this.setProgram(e,q,h,l,g);g.render(function(z){var v=s;if(!z.__webGLVertexBuffer)z.__webGLVertexBuffer=b.createBuffer();if(!z.__webGLNormalBuffer)z.__webGLNormalBuffer=
|
|
|
-b.createBuffer();if(z.hasPos){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(v.attributes.position);b.vertexAttribPointer(v.attributes.position,3,b.FLOAT,false,0,0)}if(z.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,z.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(v.attributes.normal);b.vertexAttribPointer(v.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,
|
|
|
-0,z.count);z.count=0})}};this.render=function(e,q,h,g){var p,i,t,j,l=e.lights,s=e.fog;q.autoUpdateMatrix&&q.updateMatrix();q.matrix.flattenToArray(K);q.projectionMatrix.flattenToArray(I);w.multiply(q.projectionMatrix,q.matrix);y[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);y[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);y[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);y[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);y[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-w.n33,
|
|
|
-w.n44-w.n34);y[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(p=0;p<5;p++){j=y[p];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z*j.z))}this.initWebGLObjects(e,q);g=g!==undefined?g:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,h.width,h.height);b.bindTexture(b.TEXTURE_2D,
|
|
|
-h.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,m(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,m(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,m(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,m(h.min_filter));b.texImage2D(b.TEXTURE_2D,0,m(h.format),h.width,h.height,0,m(h.format),m(h.type),null);b.bindFramebuffer(b.FRAMEBUFFER,h.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,h.__webGLTexture,0);
|
|
|
-b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){p=h.__webGLFramebuffer;j=h.width;t=h.height}else{p=null;j=r.width;t=r.height}if(p!=o){b.bindFramebuffer(b.FRAMEBUFFER,p);b.viewport(0,0,j,t);g&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);o=p}this.autoClear&&this.clear();p=e.__webGLObjects.length;for(g=0;g<p;g++){t=e.__webGLObjects[g];
|
|
|
-j=t.object;if(i=j.visible){if(!(i=!(j instanceof THREE.Mesh)))a:{i=void 0;for(var z=j.matrix,v=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),N=0;N<6;N++){i=y[N].x*z.n14+y[N].y*z.n24+y[N].z*z.n34+y[N].w;if(i<=v){i=false;break a}}i=true}i=i}if(i){if(j.autoUpdateMatrix){j.updateMatrix();j.matrix.flattenToArray(j._objectMatrixArray)}this.setupMatrices(j,q);t.render=true}else t.render=false}i=e.__webGLObjectsImmediate.length;for(g=0;g<i;g++){j=e.__webGLObjectsImmediate[g].object;
|
|
|
-if(j.visible){if(j.autoUpdateMatrix){j.updateMatrix();j.matrix.flattenToArray(j._objectMatrixArray)}this.setupMatrices(j,q)}}for(g=0;g<p;g++){t=e.__webGLObjects[g];if(t.render){j=t.object;t=t.buffer;d(j);this.renderPass(q,l,s,j,t,THREE.NormalBlending,false)}}for(g=0;g<i;g++){j=e.__webGLObjectsImmediate[g].object;if(j.visible){d(j);this.renderPassImmediate(q,l,s,j,THREE.NormalBlending,false)}}for(g=0;g<p;g++){t=e.__webGLObjects[g];if(t.render){j=t.object;t=t.buffer;d(j);this.renderPass(q,l,s,j,t,THREE.AdditiveBlending,
|
|
|
-false);this.renderPass(q,l,s,j,t,THREE.SubtractiveBlending,false);this.renderPass(q,l,s,j,t,THREE.AdditiveBlending,true);this.renderPass(q,l,s,j,t,THREE.SubtractiveBlending,true);this.renderPass(q,l,s,j,t,THREE.NormalBlending,true);this.renderPass(q,l,s,j,t,THREE.BillboardBlending,false)}}for(g=0;g<i;g++){j=e.__webGLObjectsImmediate[g].object;if(j.visible){d(j);this.renderPassImmediate(q,l,s,j,THREE.NormalBlending,true)}}if(h&&h.min_filter!==THREE.NearestFilter&&h.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,
|
|
|
-h.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e,q){function h(v,N,J,E){if(v[N]==undefined){e.__webGLObjects.push({buffer:J,object:E});v[N]=1}}function g(v,N,J){if(v[N]==undefined){e.__webGLObjectsImmediate.push({object:J});v[N]=1}}var p,i,t,j,l,s,z;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}p=0;for(i=e.objects.length;p<i;p++){t=e.objects[p];l=t.geometry;if(e.__webGLObjectsMap[t.id]==
|
|
|
-undefined){e.__webGLObjectsMap[t.id]={};t._modelViewMatrix=new THREE.Matrix4;t._normalMatrixArray=new Float32Array(9);t._modelViewMatrixArray=new Float32Array(16);t._objectMatrixArray=new Float32Array(16);t.matrix.flattenToArray(t._objectMatrixArray)}z=e.__webGLObjectsMap[t.id];if(t instanceof THREE.Mesh){for(j in l.geometryChunks){s=l.geometryChunks[j];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);this.initMeshBuffers(s,t);l.__dirtyVertices=true;l.__dirtyElements=true;l.__dirtyUvs=true;l.__dirtyNormals=
|
|
|
-true;l.__dirtyTangents=true;l.__dirtyColors=true}if(l.__dirtyVertices||l.__dirtyElements||l.__dirtyUvs||l.__dirtyNormals||l.__dirtyColors||l.__dirtyTangents)this.setMeshBuffers(s,t,b.DYNAMIC_DRAW);h(z,j,s,t)}l.__dirtyVertices=false;l.__dirtyElements=false;l.__dirtyUvs=false;l.__dirtyNormals=false;l.__dirtyTangents=false;l.__dirtyColors=false}else if(t instanceof THREE.Line){if(!l.__webGLVertexBuffer){this.createLineBuffers(l);this.initLineBuffers(l);l.__dirtyVertices=true;l.__dirtyColors=true}if(l.__dirtyVertices||
|
|
|
-l.__dirtyColors)this.setLineBuffers(l,b.DYNAMIC_DRAW);h(z,0,l,t);l.__dirtyVertices=false;l.__dirtyColors=false}else if(t instanceof THREE.ParticleSystem){if(!l.__webGLVertexBuffer){this.createParticleBuffers(l);this.initParticleBuffers(l);l.__dirtyVertices=true;l.__dirtyColors=true}if(l.__dirtyVertices||l.__dirtyColors||t.sortParticles)this.setParticleBuffers(l,b.DYNAMIC_DRAW,t,q);h(z,0,l,t);l.__dirtyVertices=false;l.__dirtyColors=false}else t instanceof THREE.MarchingCubes&&g(z,0,t)}};this.removeObject=
|
|
|
-function(e,q){var h,g;for(h=e.__webGLObjects.length-1;h>=0;h--){g=e.__webGLObjects[h].object;q==g&&e.__webGLObjects.splice(h,1)}};this.setupMatrices=function(e,q){e._modelViewMatrix.multiplyToArray(q.matrix,e.matrix,e._modelViewMatrixArray);e._normalMatrix=THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(e,q){if(e){!q||q=="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",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
|
|
|
-lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
|
|
|
+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.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",
|
|
|
+map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
|
|
|
+lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
|
|
|
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
|
|
|
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
|
|
|
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};
|