|
@@ -1,61 +1,61 @@
|
|
// ThreeDebug.js r31 - http://github.com/mrdoob/three.js
|
|
// ThreeDebug.js r31 - http://github.com/mrdoob/three.js
|
|
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
|
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
|
-THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;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)+
|
|
|
|
|
|
+THREE.Color.prototype={setRGB:function(a,b,g){this.r=a;this.g=b;this.b=g;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)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
|
|
","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
|
|
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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*
|
|
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
|
|
|
|
-THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
|
|
|
|
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.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},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 b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
|
|
|
|
|
|
+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,b,g){this.x=a||0;this.y=b||0;this.z=g||0};
|
|
|
|
+THREE.Vector3.prototype={set:function(a,b,g){this.x=a;this.y=b;this.z=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
|
|
|
|
+cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,g=this.y,d=this.z;this.x=g*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-g*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.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},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 b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+g*g+a*a)},distanceToSquared:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return b*b+g*g+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+" )"}};
|
|
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,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
|
|
|
|
-THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.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,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1};
|
|
|
|
+THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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+")"}};
|
|
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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,j=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(n,o){return n.distance-o.distance});return j},intersectObject:function(a){function b(P,J,K,w){w=w.clone().subSelf(J);K=K.clone().subSelf(J);var g=P.clone().subSelf(J);P=w.dot(w);J=w.dot(K);w=w.dot(g);var l=K.dot(K);K=K.dot(g);g=1/(P*l-J*J);l=(l*w-J*K)*g;P=(P*K-J*w)*g;return l>0&&P>0&&l+P<1}var d,e,j,n,o,k,m,c,A,y,
|
|
|
|
-s,r=a.geometry,E=r.vertices,M=[];d=0;for(e=r.faces.length;d<e;d++){j=r.faces[d];y=this.origin.clone();s=this.direction.clone();n=a.matrix.multiplyVector3(E[j.a].position.clone());o=a.matrix.multiplyVector3(E[j.b].position.clone());k=a.matrix.multiplyVector3(E[j.c].position.clone());m=j instanceof THREE.Face4?a.matrix.multiplyVector3(E[j.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(j.normal.clone());A=s.dot(c);if(A<0){c=c.dot((new THREE.Vector3).sub(n,y))/A;y=y.addSelf(s.multiplyScalar(c));
|
|
|
|
-if(j instanceof THREE.Face3){if(b(y,n,o,k)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};M.push(j)}}else if(j instanceof THREE.Face4)if(b(y,n,o,m)||b(y,o,k,m)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};M.push(j)}}}return M}};
|
|
|
|
-THREE.Rectangle=function(){function a(){n=e-b;o=j-d}var b,d,e,j,n,o,k=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return n};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return j};this.set=function(m,c,A,y){k=false;b=m;d=c;e=A;j=y;a()};this.addPoint=function(m,c){if(k){k=false;b=m;d=c;e=m;j=c}else{b=b<m?b:m;d=d<c?d:c;e=e>m?e:m;j=j>c?
|
|
|
|
-j:c}a()};this.add3Points=function(m,c,A,y,s,r){if(k){k=false;b=m<A?m<s?m:s:A<s?A:s;d=c<y?c<r?c:r:y<r?y:r;e=m>A?m>s?m:s:A>s?A:s;j=c>y?c>r?c:r:y>r?y:r}else{b=m<A?m<s?m<b?m:b:s<b?s:b:A<s?A<b?A:b:s<b?s:b;d=c<y?c<r?c<d?c:d:r<d?r:d:y<r?y<d?y:d:r<d?r:d;e=m>A?m>s?m>e?m:e:s>e?s:e:A>s?A>e?A:e:s>e?s:e;j=c>y?c>r?c>j?c:j:r>j?r:j:y>r?y>j?y:j:r>j?r:j}a()};this.addRectangle=function(m){if(k){k=false;b=m.getLeft();d=m.getTop();e=m.getRight();j=m.getBottom()}else{b=b<m.getLeft()?b:m.getLeft();d=d<m.getTop()?d:m.getTop();
|
|
|
|
-e=e>m.getRight()?e:m.getRight();j=j>m.getBottom()?j:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;j+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e<m.getRight()?e:m.getRight();j=j<m.getBottom()?j:m.getBottom();a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=0&&Math.min(j,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){k=true;j=e=d=b=0;a()};this.isEmpty=function(){return k};this.toString=
|
|
|
|
-function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+j+", width: "+n+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
|
|
|
|
-THREE.Matrix4=function(a,b,d,e,j,n,o,k,m,c,A,y,s,r,E,M){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=j||0;this.n22=n||1;this.n23=o||0;this.n24=k||0;this.n31=m||0;this.n32=c||0;this.n33=A||1;this.n34=y||0;this.n41=s||0;this.n42=r||0;this.n43=E||0;this.n44=M||1};
|
|
|
|
-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,b,d,e,j,n,o,k,m,c,A,y,s,r,E,M){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=j;this.n22=n;this.n23=o;this.n24=k;this.n31=m;this.n32=c;this.n33=A;this.n34=y;this.n41=s;this.n42=r;this.n43=E;this.n44=M;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,b,d){var e=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();j.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=n.x;
|
|
|
|
-this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,j=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
|
|
|
|
-j;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*j;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,j=a.n13,n=a.n14,o=a.n21,k=a.n22,m=a.n23,c=a.n24,A=a.n31,y=a.n32,
|
|
|
|
-s=a.n33,r=a.n34,E=a.n41,M=a.n42,P=a.n43,J=a.n44,K=b.n11,w=b.n12,g=b.n13,l=b.n14,f=b.n21,p=b.n22,h=b.n23,i=b.n24,u=b.n31,t=b.n32,G=b.n33,z=b.n34,H=b.n41,Q=b.n42,C=b.n43,O=b.n44;this.n11=d*K+e*f+j*u+n*H;this.n12=d*w+e*p+j*t+n*Q;this.n13=d*g+e*h+j*G+n*C;this.n14=d*l+e*i+j*z+n*O;this.n21=o*K+k*f+m*u+c*H;this.n22=o*w+k*p+m*t+c*Q;this.n23=o*g+k*h+m*G+c*C;this.n24=o*l+k*i+m*z+c*O;this.n31=A*K+y*f+s*u+r*H;this.n32=A*w+y*p+s*t+r*Q;this.n33=A*g+y*h+s*G+r*C;this.n34=A*l+y*i+s*z+r*O;this.n41=E*K+M*f+P*u+J*H;
|
|
|
|
-this.n42=E*w+M*p+P*t+J*Q;this.n43=E*g+M*h+P*G+J*C;this.n44=E*l+M*i+P*z+J*O;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,j=this.n14,n=this.n21,o=this.n22,k=this.n23,m=this.n24,c=this.n31,A=this.n32,y=this.n33,s=this.n34,r=this.n41,E=this.n42,M=this.n43,P=this.n44,J=a.n11,K=a.n21,w=a.n31,g=a.n41,l=a.n12,f=a.n22,p=a.n32,h=a.n42,i=a.n13,u=a.n23,t=a.n33,G=a.n43,z=a.n14,H=a.n24,Q=a.n34;a=a.n44;this.n11=b*J+d*K+e*w+j*g;this.n12=b*l+d*f+e*p+j*h;this.n13=b*i+d*u+e*t+j*G;this.n14=
|
|
|
|
-b*z+d*H+e*Q+j*a;this.n21=n*J+o*K+k*w+m*g;this.n22=n*l+o*f+k*p+m*h;this.n23=n*i+o*u+k*t+m*G;this.n24=n*z+o*H+k*Q+m*a;this.n31=c*J+A*K+y*w+s*g;this.n32=c*l+A*f+y*p+s*h;this.n33=c*i+A*u+y*t+s*G;this.n34=c*z+A*H+y*Q+s*a;this.n41=r*J+E*K+M*w+P*g;this.n42=r*l+E*f+M*p+P*h;this.n43=r*i+E*u+M*t+P*G;this.n44=r*z+E*H+M*Q+P*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*=
|
|
|
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,i=[];a=0;for(b=d.length;a<b;a++){g=d[a];if(g instanceof THREE.Mesh)i=i.concat(this.intersectObject(g))}i.sort(function(q,k){return q.distance-k.distance});return i},intersectObject:function(a){function b(K,J,O,E){E=E.clone().subSelf(J);O=O.clone().subSelf(J);var e=K.clone().subSelf(J);K=E.dot(E);J=E.dot(O);E=E.dot(e);var m=O.dot(O);O=O.dot(e);e=1/(K*m-J*J);m=(m*E-J*O)*e;K=(K*O-J*E)*e;return m>0&&K>0&&m+K<1}var g,d,i,q,k,h,n,c,A,y,
|
|
|
|
+x,s=a.geometry,G=s.vertices,N=[];g=0;for(d=s.faces.length;g<d;g++){i=s.faces[g];y=this.origin.clone();x=this.direction.clone();q=a.matrix.multiplyVector3(G[i.a].position.clone());k=a.matrix.multiplyVector3(G[i.b].position.clone());h=a.matrix.multiplyVector3(G[i.c].position.clone());n=i instanceof THREE.Face4?a.matrix.multiplyVector3(G[i.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(i.normal.clone());A=x.dot(c);if(A<0){c=c.dot((new THREE.Vector3).sub(q,y))/A;y=y.addSelf(x.multiplyScalar(c));
|
|
|
|
+if(i instanceof THREE.Face3){if(b(y,q,k,h)){i={distance:this.origin.distanceTo(y),point:y,face:i,object:a};N.push(i)}}else if(i instanceof THREE.Face4)if(b(y,q,k,n)||b(y,k,h,n)){i={distance:this.origin.distanceTo(y),point:y,face:i,object:a};N.push(i)}}}return N}};
|
|
|
|
+THREE.Rectangle=function(){function a(){q=d-b;k=i-g}var b,g,d,i,q,k,h=true;this.getX=function(){return b};this.getY=function(){return g};this.getWidth=function(){return q};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return g};this.getRight=function(){return d};this.getBottom=function(){return i};this.set=function(n,c,A,y){h=false;b=n;g=c;d=A;i=y;a()};this.addPoint=function(n,c){if(h){h=false;b=n;g=c;d=n;i=c}else{b=b<n?b:n;g=g<c?g:c;d=d>n?d:n;i=i>c?
|
|
|
|
+i:c}a()};this.add3Points=function(n,c,A,y,x,s){if(h){h=false;b=n<A?n<x?n:x:A<x?A:x;g=c<y?c<s?c:s:y<s?y:s;d=n>A?n>x?n:x:A>x?A:x;i=c>y?c>s?c:s:y>s?y:s}else{b=n<A?n<x?n<b?n:b:x<b?x:b:A<x?A<b?A:b:x<b?x:b;g=c<y?c<s?c<g?c:g:s<g?s:g:y<s?y<g?y:g:s<g?s:g;d=n>A?n>x?n>d?n:d:x>d?x:d:A>x?A>d?A:d:x>d?x:d;i=c>y?c>s?c>i?c:i:s>i?s:i:y>s?y>i?y:i:s>i?s:i}a()};this.addRectangle=function(n){if(h){h=false;b=n.getLeft();g=n.getTop();d=n.getRight();i=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();g=g<n.getTop()?g:n.getTop();
|
|
|
|
+d=d>n.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d<n.getRight()?d:n.getRight();i=i<n.getBottom()?i:n.getBottom();a()};this.instersects=function(n){return Math.min(d,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(i,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){h=true;i=d=g=b=0;a()};this.isEmpty=function(){return h};this.toString=
|
|
|
|
+function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+i+", width: "+q+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
|
|
|
|
+THREE.Matrix4=function(a,b,g,d,i,q,k,h,n,c,A,y,x,s,G,N){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=i||0;this.n22=q||1;this.n23=k||0;this.n24=h||0;this.n31=n||0;this.n32=c||0;this.n33=A||1;this.n34=y||0;this.n41=x||0;this.n42=s||0;this.n43=G||0;this.n44=N||1};
|
|
|
|
+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,b,g,d,i,q,k,h,n,c,A,y,x,s,G,N){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=i;this.n22=q;this.n23=k;this.n24=h;this.n31=n;this.n32=c;this.n33=A;this.n34=y;this.n41=x;this.n42=s;this.n43=G;this.n44=N;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,b,g){var d=new THREE.Vector3,i=new THREE.Vector3,q=new THREE.Vector3;q.sub(a,b).normalize();d.cross(g,q).normalize();i.cross(q,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=q.x;
|
|
|
|
+this.n32=q.y;this.n33=q.z;this.n34=-q.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,i=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24*
|
|
|
|
+i;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*i;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var g=a.n11,d=a.n12,i=a.n13,q=a.n14,k=a.n21,h=a.n22,n=a.n23,c=a.n24,A=a.n31,y=a.n32,
|
|
|
|
+x=a.n33,s=a.n34,G=a.n41,N=a.n42,K=a.n43,J=a.n44,O=b.n11,E=b.n12,e=b.n13,m=b.n14,f=b.n21,p=b.n22,l=b.n23,j=b.n24,o=b.n31,C=b.n32,v=b.n33,t=b.n34,I=b.n41,B=b.n42,F=b.n43,U=b.n44;this.n11=g*O+d*f+i*o+q*I;this.n12=g*E+d*p+i*C+q*B;this.n13=g*e+d*l+i*v+q*F;this.n14=g*m+d*j+i*t+q*U;this.n21=k*O+h*f+n*o+c*I;this.n22=k*E+h*p+n*C+c*B;this.n23=k*e+h*l+n*v+c*F;this.n24=k*m+h*j+n*t+c*U;this.n31=A*O+y*f+x*o+s*I;this.n32=A*E+y*p+x*C+s*B;this.n33=A*e+y*l+x*v+s*F;this.n34=A*m+y*j+x*t+s*U;this.n41=G*O+N*f+K*o+J*I;
|
|
|
|
+this.n42=G*E+N*p+K*C+J*B;this.n43=G*e+N*l+K*v+J*F;this.n44=G*m+N*j+K*t+J*U;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,i=this.n14,q=this.n21,k=this.n22,h=this.n23,n=this.n24,c=this.n31,A=this.n32,y=this.n33,x=this.n34,s=this.n41,G=this.n42,N=this.n43,K=this.n44,J=a.n11,O=a.n21,E=a.n31,e=a.n41,m=a.n12,f=a.n22,p=a.n32,l=a.n42,j=a.n13,o=a.n23,C=a.n33,v=a.n43,t=a.n14,I=a.n24,B=a.n34;a=a.n44;this.n11=b*J+g*O+d*E+i*e;this.n12=b*m+g*f+d*p+i*l;this.n13=b*j+g*o+d*C+i*v;this.n14=
|
|
|
|
+b*t+g*I+d*B+i*a;this.n21=q*J+k*O+h*E+n*e;this.n22=q*m+k*f+h*p+n*l;this.n23=q*j+k*o+h*C+n*v;this.n24=q*t+k*I+h*B+n*a;this.n31=c*J+A*O+y*E+x*e;this.n32=c*m+A*f+y*p+x*l;this.n33=c*j+A*o+y*C+x*v;this.n34=c*t+A*I+y*B+x*a;this.n41=s*J+G*O+N*E+K*e;this.n42=s*m+G*f+N*p+K*l;this.n43=s*j+G*o+N*C+K*v;this.n44=s*t+G*I+N*B+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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
|
|
a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
|
|
-this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var j=b[d];b[d]=b[e];
|
|
|
|
-b[e]=j}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
|
|
|
-this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},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,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};
|
|
|
|
-THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
|
|
|
|
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),j=Math.sin(b),n=1-e,o=a.x,k=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*k-j*m;d.n13=n*o*m+j*k;d.n21=n*o*k+j*m;d.n22=n*k*k+e;d.n23=n*k*m-j*o;d.n31=n*o*m-j*k;d.n32=n*k*m+j*o;d.n33=n*m*m+e;return d};
|
|
|
|
|
|
+this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var i=b[g];b[g]=b[d];
|
|
|
|
+b[d]=i}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
|
|
|
+this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},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,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d};
|
|
|
|
+THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
|
|
|
|
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),q=1-d,k=a.x,h=a.y,n=a.z;g.n11=q*k*k+d;g.n12=q*k*h-i*n;g.n13=q*k*n+i*h;g.n21=q*k*h+i*n;g.n22=q*h*h+d;g.n23=q*h*n-i*k;g.n31=q*k*n-i*h;g.n32=q*h*n+i*k;g.n33=q*n*n+d;return g};
|
|
THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
|
|
THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
|
|
a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
|
|
a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
|
|
a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
|
|
a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
|
|
a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
|
|
a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
|
|
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],A=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*j;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*k;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*A;return a};
|
|
|
|
-THREE.Matrix4.makeFrustum=function(a,b,d,e,j,n){var o,k,m;o=new THREE.Matrix4;k=2*j/(b-a);m=2*j/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+j)/(n-j);j=-2*n*j/(n-j);o.n11=k;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=j;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,e)};
|
|
|
|
-THREE.Matrix4.makeOrtho=function(a,b,d,e,j,n){var o,k,m,c;o=new THREE.Matrix4;k=b-a;m=d-e;c=n-j;a=(b+a)/k;d=(d+e)/m;j=(n+j)/c;o.n11=2/k;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-j;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
|
|
|
|
|
|
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],q=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],A=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*q+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*q;a.m[4]=b*k;a.m[5]=b*h;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*A;return a};
|
|
|
|
+THREE.Matrix4.makeFrustum=function(a,b,g,d,i,q){var k,h,n;k=new THREE.Matrix4;h=2*i/(b-a);n=2*i/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(q+i)/(q-i);i=-2*q*i/(q-i);k.n11=h;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=n;k.n23=g;k.n24=0;k.n31=0;k.n32=0;k.n33=d;k.n34=i;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,g,d){var i;a=g*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,g,d)};
|
|
|
|
+THREE.Matrix4.makeOrtho=function(a,b,g,d,i,q){var k,h,n,c;k=new THREE.Matrix4;h=b-a;n=g-d;c=q-i;a=(b+a)/h;g=(g+d)/n;i=(q+i)/c;k.n11=2/h;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/n;k.n23=0;k.n24=-g;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-i;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};
|
|
THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||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.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||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,b,d,e,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
|
-THREE.Face4=function(a,b,d,e,j,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
|
|
|
|
|
+THREE.Face3=function(a,b,g,d,i){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
|
+THREE.Face4=function(a,b,g,d,i,q){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=q instanceof Array?q:[q]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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.geometryChunks={};this.hasTangents=false};
|
|
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.geometryChunks={};this.hasTangents=false};
|
|
-THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;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 b,d,e,j,n,o,k=new THREE.Vector3,m=new THREE.Vector3;e=0;for(j=this.vertices.length;e<j;e++){n=this.vertices[e];n.normal.set(0,0,0)}e=0;for(j=this.faces.length;e<j;e++){n=this.faces[e];if(a&&n.vertexNormals.length){k.set(0,0,0);b=0;for(d=n.normal.length;b<d;b++)k.addSelf(n.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[n.a];d=this.vertices[n.b];o=this.vertices[n.c];k.sub(o.position,
|
|
|
|
-d.position);m.sub(b.position,d.position);k.crossSelf(m)}k.isZero()||k.normalize();n.normal.copy(k)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
|
|
|
|
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeTangents:function(){function a(z,H,Q,C){n=z.vertices[H].position;o=z.vertices[Q].position;
|
|
|
|
-k=z.vertices[C].position;m=j[0];c=j[1];A=j[2];y=o.x-n.x;s=k.x-n.x;r=o.y-n.y;E=k.y-n.y;M=o.z-n.z;P=k.z-n.z;J=c.u-m.u;K=A.u-m.u;w=c.v-m.v;g=A.v-m.v;l=1/(J*g-K*w);i.set((g*y-w*s)*l,(g*r-w*E)*l,(g*M-w*P)*l);u.set((J*s-K*y)*l,(J*E-K*r)*l,(J*P-K*M)*l);p[H].addSelf(i);p[Q].addSelf(i);p[C].addSelf(i);h[H].addSelf(u);h[Q].addSelf(u);h[C].addSelf(u)}var b,d,e,j,n,o,k,m,c,A,y,s,r,E,M,P,J,K,w,g,l,f,p=[],h=[],i=new THREE.Vector3,u=new THREE.Vector3,t=new THREE.Vector3,G=new THREE.Vector3;f=new THREE.Vector3;b=
|
|
|
|
-0;for(d=this.vertices.length;b<d;b++){p[b]=new THREE.Vector3;h[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];j=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
|
|
|
|
-this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){f.copy(this.vertices[b].normal);e=p[b];t.copy(e);t.subSelf(f.multiplyScalar(f.dot(e))).normalize();G.cross(this.vertices[b].normal,e);test=G.dot(h[b]);e=test<0?-1:1;this.vertices[b].tangent.set(t.x,t.y,t.z,e)}this.hasTangents=true},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
|
|
|
|
|
|
+THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a<b;a++){g=this.faces[a];g.centroid.set(0,0,0);if(g instanceof THREE.Face3){g.centroid.addSelf(this.vertices[g.a].position);g.centroid.addSelf(this.vertices[g.b].position);g.centroid.addSelf(this.vertices[g.c].position);g.centroid.divideScalar(3)}else if(g instanceof THREE.Face4){g.centroid.addSelf(this.vertices[g.a].position);g.centroid.addSelf(this.vertices[g.b].position);g.centroid.addSelf(this.vertices[g.c].position);
|
|
|
|
+g.centroid.addSelf(this.vertices[g.d].position);g.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,g,d,i,q,k,h=new THREE.Vector3,n=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){q=this.vertices[d];q.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;d++){q=this.faces[d];if(a&&q.vertexNormals.length){h.set(0,0,0);b=0;for(g=q.normal.length;b<g;b++)h.addSelf(q.vertexNormals[b]);h.divideScalar(3)}else{b=this.vertices[q.a];g=this.vertices[q.b];k=this.vertices[q.c];h.sub(k.position,
|
|
|
|
+g.position);n.sub(b.position,g.position);h.crossSelf(n)}h.isZero()||h.normalize();q.normal.copy(h)}},computeVertexNormals:function(){var a,b=[],g,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(g=this.faces.length;a<g;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
|
|
|
|
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(g=this.faces.length;a<g;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(t,I,B,F){q=t.vertices[I].position;k=t.vertices[B].position;
|
|
|
|
+h=t.vertices[F].position;n=i[0];c=i[1];A=i[2];y=k.x-q.x;x=h.x-q.x;s=k.y-q.y;G=h.y-q.y;N=k.z-q.z;K=h.z-q.z;J=c.u-n.u;O=A.u-n.u;E=c.v-n.v;e=A.v-n.v;m=1/(J*e-O*E);j.set((e*y-E*x)*m,(e*s-E*G)*m,(e*N-E*K)*m);o.set((J*x-O*y)*m,(J*G-O*s)*m,(J*K-O*N)*m);p[I].addSelf(j);p[B].addSelf(j);p[F].addSelf(j);l[I].addSelf(o);l[B].addSelf(o);l[F].addSelf(o)}var b,g,d,i,q,k,h,n,c,A,y,x,s,G,N,K,J,O,E,e,m,f,p=[],l=[],j=new THREE.Vector3,o=new THREE.Vector3,C=new THREE.Vector3,v=new THREE.Vector3;f=new THREE.Vector3;b=
|
|
|
|
+0;for(g=this.vertices.length;b<g;b++){p[b]=new THREE.Vector3;l[b]=new THREE.Vector3}b=0;for(g=this.faces.length;b<g;b++){d=this.faces[b];i=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
|
|
|
|
+this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(g=this.vertices.length;b<g;b++){f.copy(this.vertices[b].normal);d=p[b];C.copy(d);C.subSelf(f.multiplyScalar(f.dot(d))).normalize();v.cross(this.vertices[b].normal,d);test=v.dot(l[b]);d=test<0?-1:1;this.vertices[b].tangent.set(C.x,C.y,C.z,d)}this.hasTangents=true},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={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 a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=
|
|
y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=
|
|
-vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(A){var y=[];b=0;for(d=A.length;b<d;b++)A[b]==undefined?y.push("undefined"):y.push(A[b].toString());return y.join("_")}var b,d,e,j,n,o,k,m,c={};e=0;for(j=this.faces.length;e<j;e++){n=this.faces[e];o=n.material;k=a(o);if(c[k]==undefined)c[k]={hash:k,counter:0};m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,
|
|
|
|
-vertices:0};n=n instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+n>65535){c[k].counter+=1;m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
|
-THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.translateX=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);j.cross(j.clone(),this.up);this.position.addSelf(j);this.target.position.addSelf(j)};this.translateZ=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);
|
|
|
|
-this.position.subSelf(j);this.target.position.subSelf(j)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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;
|
|
|
|
|
|
+vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(A){var y=[];b=0;for(g=A.length;b<g;b++)A[b]==undefined?y.push("undefined"):y.push(A[b].toString());return y.join("_")}var b,g,d,i,q,k,h,n,c={};d=0;for(i=this.faces.length;d<i;d++){q=this.faces[d];k=q.material;h=a(k);if(c[h]==undefined)c[h]={hash:h,counter:0};n=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:k,
|
|
|
|
+vertices:0};q=q instanceof THREE.Face3?3:4;if(this.geometryChunks[n].vertices+q>65535){c[h].counter+=1;n=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:k,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=q}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
|
+THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);
|
|
|
|
+this.position.subSelf(i);this.target.position.subSelf(i)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
|
|
THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.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.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
|
|
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.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
|
|
this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
|
|
this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
|
|
@@ -85,94 +85,94 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi
|
|
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
|
|
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
|
|
this.blending+"<br/>)"}};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}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
this.blending+"<br/>)"}};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}this.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;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
|
|
THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
|
|
-THREE.Texture=function(a,b,d,e,j,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.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: "+
|
|
|
|
|
|
+THREE.Texture=function(a,b,g,d,i,q){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=q!==undefined?q:THREE.LinearMipMapLinearFilter;this.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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
|
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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
|
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];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.Scene=function(){this.objects=[];this.lights=[];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.Projector=function(){function a(K,w){var g=0,l=1,f=K.z+K.w,p=w.z+w.w,h=-K.z+K.w,i=-w.z+w.w;if(f>=0&&p>=0&&h>=0&&i>=0)return true;else if(f<0&&p<0||h<0&&i<0)return false;else{if(f<0)g=Math.max(g,f/(f-p));else if(p<0)l=Math.min(l,f/(f-p));if(h<0)g=Math.max(g,h/(h-i));else if(i<0)l=Math.min(l,h/(h-i));if(l<g)return false;else{K.lerpSelf(w,g);w.lerpSelf(K,1-l);return true}}}var b=null,d,e,j,n=[],o,k,m=[],c,A,y=[],s=new THREE.Vector4,r=new THREE.Matrix4,E=new THREE.Matrix4,M=new THREE.Vector4,P=
|
|
|
|
-new THREE.Vector4,J;this.projectScene=function(K,w){var g,l,f,p,h,i,u,t,G,z,H,Q,C,O,D,R,S;b=[];j=k=A=0;w.autoUpdateMatrix&&w.updateMatrix();r.multiply(w.projectionMatrix,w.matrix);u=K.objects;g=0;for(l=u.length;g<l;g++){t=u[g];t.autoUpdateMatrix&&t.updateMatrix();G=t.matrix;z=t.rotationMatrix;H=t.material;Q=t.overdraw;if(t instanceof THREE.Mesh){C=t.geometry;O=C.vertices;f=0;for(p=O.length;f<p;f++){D=O[f];D.positionWorld.copy(D.position);G.multiplyVector3(D.positionWorld);h=D.positionScreen;h.copy(D.positionWorld);
|
|
|
|
-r.multiplyVector4(h);h.multiplyScalar(1/h.w);D.__visible=h.z>0&&h.z<1}C=C.faces;f=0;for(p=C.length;f<p;f++){D=C[f];if(D instanceof THREE.Face3){h=O[D.a];i=O[D.b];R=O[D.c];if(h.__visible&&i.__visible&&R.__visible)if(t.doubleSided||t.flipSided!=(R.positionScreen.x-h.positionScreen.x)*(i.positionScreen.y-h.positionScreen.y)-(R.positionScreen.y-h.positionScreen.y)*(i.positionScreen.x-h.positionScreen.x)<0){d=n[j]=n[j]||new THREE.RenderableFace3;d.v1.positionWorld.copy(h.positionWorld);d.v2.positionWorld.copy(i.positionWorld);
|
|
|
|
-d.v3.positionWorld.copy(R.positionWorld);d.v1.positionScreen.copy(h.positionScreen);d.v2.positionScreen.copy(i.positionScreen);d.v3.positionScreen.copy(R.positionScreen);d.normalWorld.copy(D.normal);z.multiplyVector3(d.normalWorld);d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);r.multiplyVector3(d.centroidScreen);R=D.vertexNormals;J=d.vertexNormalsWorld;h=0;for(i=R.length;h<i;h++){S=J[h]=J[h]||new THREE.Vector3;S.copy(R[h]);z.multiplyVector3(S)}d.z=
|
|
|
|
-d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(t.geometry.uvs[f]){d.uvs[0]=t.geometry.uvs[f][0];d.uvs[1]=t.geometry.uvs[f][1];d.uvs[2]=t.geometry.uvs[f][2]}b.push(d);j++}}else if(D instanceof THREE.Face4){h=O[D.a];i=O[D.b];R=O[D.c];S=O[D.d];if(h.__visible&&i.__visible&&R.__visible&&S.__visible)if(t.doubleSided||t.flipSided!=((S.positionScreen.x-h.positionScreen.x)*(i.positionScreen.y-h.positionScreen.y)-(S.positionScreen.y-h.positionScreen.y)*(i.positionScreen.x-h.positionScreen.x)<
|
|
|
|
-0||(i.positionScreen.x-R.positionScreen.x)*(S.positionScreen.y-R.positionScreen.y)-(i.positionScreen.y-R.positionScreen.y)*(S.positionScreen.x-R.positionScreen.x)<0)){d=n[j]=n[j]||new THREE.RenderableFace3;d.v1.positionWorld.copy(h.positionWorld);d.v2.positionWorld.copy(i.positionWorld);d.v3.positionWorld.copy(S.positionWorld);d.v1.positionScreen.copy(h.positionScreen);d.v2.positionScreen.copy(i.positionScreen);d.v3.positionScreen.copy(S.positionScreen);d.normalWorld.copy(D.normal);z.multiplyVector3(d.normalWorld);
|
|
|
|
-d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);r.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(t.geometry.uvs[f]){d.uvs[0]=t.geometry.uvs[f][0];d.uvs[1]=t.geometry.uvs[f][1];d.uvs[2]=t.geometry.uvs[f][3]}b.push(d);j++;e=n[j]=n[j]||new THREE.RenderableFace3;e.v1.positionWorld.copy(i.positionWorld);e.v2.positionWorld.copy(R.positionWorld);e.v3.positionWorld.copy(S.positionWorld);
|
|
|
|
-e.v1.positionScreen.copy(i.positionScreen);e.v2.positionScreen.copy(R.positionScreen);e.v3.positionScreen.copy(S.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=H;e.faceMaterial=D.material;e.overdraw=Q;if(t.geometry.uvs[f]){e.uvs[0]=t.geometry.uvs[f][1];e.uvs[1]=t.geometry.uvs[f][2];e.uvs[2]=t.geometry.uvs[f][3]}b.push(e);j++}}}}else if(t instanceof THREE.Line){E.multiply(r,G);O=t.geometry.vertices;
|
|
|
|
-D=O[0];D.positionScreen.copy(D.position);E.multiplyVector4(D.positionScreen);f=1;for(p=O.length;f<p;f++){h=O[f];h.positionScreen.copy(h.position);E.multiplyVector4(h.positionScreen);i=O[f-1];M.copy(h.positionScreen);P.copy(i.positionScreen);if(a(M,P)){M.multiplyScalar(1/M.w);P.multiplyScalar(1/P.w);o=m[k]=m[k]||new THREE.RenderableLine;o.v1.positionScreen.copy(M);o.v2.positionScreen.copy(P);o.z=Math.max(M.z,P.z);o.material=t.material;b.push(o);k++}}}else if(t instanceof THREE.Particle){s.set(t.position.x,
|
|
|
|
-t.position.y,t.position.z,1);r.multiplyVector4(s);s.z/=s.w;if(s.z>0&&s.z<1){c=y[A]=y[A]||new THREE.RenderableParticle;c.x=s.x/s.w;c.y=s.y/s.w;c.z=s.z;c.rotation=t.rotation.z;c.scale.x=t.scale.x*Math.abs(c.x-(s.x+w.projectionMatrix.n11)/(s.w+w.projectionMatrix.n14));c.scale.y=t.scale.y*Math.abs(c.y-(s.y+w.projectionMatrix.n22)/(s.w+w.projectionMatrix.n24));c.material=t.material;b.push(c);A++}}}b.sort(function(I,v){return v.z-I.z});return b};this.unprojectVector=function(K,w){var g=new THREE.Matrix4;
|
|
|
|
-g.multiply(THREE.Matrix4.makeInvert(w.matrix),THREE.Matrix4.makeInvert(w.projectionMatrix));g.multiplyVector3(K);return K}};
|
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,j,n;this.domElement=document.createElement("div");this.setSize=function(o,k){d=o;e=k;j=d/2;n=e/2};this.render=function(o,k){var m,c,A,y,s,r,E,M;a=b.projectScene(o,k);m=0;for(c=a.length;m<c;m++){s=a[m];if(s instanceof THREE.RenderableParticle){E=s.x*j+j;M=s.y*n+n;A=0;for(y=s.material.length;A<y;A++){r=s.material[A];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=E+"px";r.style.top=M+"px"}}}}}};
|
|
|
|
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,j,n,o,k=d.getContext("2d"),m=1,c=0,A=null,y=null,s=1,r,E,M,P,J,K,w,g,l,f=new THREE.Color,p=new THREE.Color,h=new THREE.Color,i=new THREE.Color,u=new THREE.Color,t,G,z,H,Q,C,O,D,R,S,I=new THREE.Rectangle,v=new THREE.Rectangle,B=new THREE.Rectangle,W=false,Y=new THREE.Color,N=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,X=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
|
|
|
|
-na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=d;this.autoClear=true;this.setSize=function(ga,ua){e=ga;j=ua;n=e/2;o=j/2;d.width=e;d.height=j;I.set(-n,-o,n,o)};this.clear=function(){if(!v.isEmpty()){v.inflate(1);v.minSelf(I);k.clearRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());
|
|
|
|
-v.empty()}};this.render=function(ga,ua){function Ka(q){var T,L,x,F=q.lights;N.setRGB(0,0,0);U.setRGB(0,0,0);aa.setRGB(0,0,0);q=0;for(T=F.length;q<T;q++){L=F[q];x=L.color;if(L instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(L instanceof THREE.DirectionalLight){U.r+=x.r;U.g+=x.g;U.b+=x.b}else if(L instanceof THREE.PointLight){aa.r+=x.r;aa.g+=x.g;aa.b+=x.b}}}function va(q,T,L,x){var F,V,$,ba,ca=q.lights;q=0;for(F=ca.length;q<F;q++){V=ca[q];$=V.color;ba=V.intensity;if(V instanceof THREE.DirectionalLight){V=
|
|
|
|
-L.dot(V.position)*ba;if(V>0){x.r+=$.r*V;x.g+=$.g*V;x.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,T);X.normalize();V=L.dot(X)*ba;if(V>0){x.r+=$.r*V;x.g+=$.g*V;x.b+=$.b*V}}}}function La(q,T,L){if(L.opacity!=0){Ba(L.opacity);wa(L.blending);var x,F,V,$,ba,ca;if(L instanceof THREE.ParticleBasicMaterial){if(L.map){$=L.map;ba=$.width>>1;ca=$.height>>1;F=T.scale.x*n;V=T.scale.y*o;L=F*ba;x=V*ca;B.set(q.x-L,q.y-x,q.x+L,q.y+x);if(!I.instersects(B))return;k.save();k.translate(q.x,q.y);k.rotate(-T.rotation);
|
|
|
|
-k.scale(F,-V);k.translate(-ba,-ca);k.drawImage($,0,0);k.restore()}k.beginPath();k.moveTo(q.x-10,q.y);k.lineTo(q.x+10,q.y);k.moveTo(q.x,q.y-10);k.lineTo(q.x,q.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(L instanceof THREE.ParticleCircleMaterial){if(W){Y.r=N.r+U.r+aa.r;Y.g=N.g+U.g+aa.g;Y.b=N.b+U.b+aa.b;f.r=L.color.r*Y.r;f.g=L.color.g*Y.g;f.b=L.color.b*Y.b;f.updateStyleString()}else f.__styleString=L.color.__styleString;L=T.scale.x*n;x=T.scale.y*o;B.set(q.x-L,q.y-x,q.x+L,q.y+
|
|
|
|
-x);if(I.instersects(B)){F=f.__styleString;if(y!=F)k.fillStyle=y=F;k.save();k.translate(q.x,q.y);k.rotate(-T.rotation);k.scale(L,x);k.beginPath();k.arc(0,0,1,0,Ja,true);k.closePath();k.fill();k.restore()}}}}function Ma(q,T,L,x){if(x.opacity!=0){Ba(x.opacity);wa(x.blending);k.beginPath();k.moveTo(q.positionScreen.x,q.positionScreen.y);k.lineTo(T.positionScreen.x,T.positionScreen.y);k.closePath();if(x instanceof THREE.LineBasicMaterial){f.__styleString=x.color.__styleString;q=x.linewidth;if(s!=q)k.lineWidth=
|
|
|
|
-s=q;q=f.__styleString;if(A!=q)k.strokeStyle=A=q;k.stroke();B.inflate(x.linewidth*2)}}}function Fa(q,T,L,x,F,V){if(F.opacity!=0){Ba(F.opacity);wa(F.blending);P=q.positionScreen.x;J=q.positionScreen.y;K=T.positionScreen.x;w=T.positionScreen.y;g=L.positionScreen.x;l=L.positionScreen.y;k.beginPath();k.moveTo(P,J);k.lineTo(K,w);k.lineTo(g,l);k.lineTo(P,J);k.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(P,J,K,w,g,l,F.map.image,
|
|
|
|
-x.uvs[0].u,x.uvs[0].v,x.uvs[1].u,x.uvs[1].v,x.uvs[2].u,x.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){q=ua.matrix;X.copy(x.vertexNormalsWorld[0]);Q=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;C=-(X.x*q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;X.copy(x.vertexNormalsWorld[1]);O=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;D=-(X.x*q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;X.copy(x.vertexNormalsWorld[2]);R=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;S=-(X.x*
|
|
|
|
-q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;qa(P,J,K,w,g,l,F.env_map.image,Q,C,O,D,R,S)}}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString);else if(F instanceof THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(P,J,K,w,g,l,F.map.image,x.uvs[0].u,x.uvs[0].v,x.uvs[1].u,x.uvs[1].v,x.uvs[2].u,x.uvs[2].v);wa(THREE.SubtractiveBlending)}if(W)if(!F.wireframe&&F.shading==THREE.SmoothShading&&x.vertexNormalsWorld.length==3){p.r=h.r=
|
|
|
|
-i.r=N.r;p.g=h.g=i.g=N.g;p.b=h.b=i.b=N.b;va(V,x.v1.positionWorld,x.vertexNormalsWorld[0],p);va(V,x.v2.positionWorld,x.vertexNormalsWorld[1],h);va(V,x.v3.positionWorld,x.vertexNormalsWorld[2],i);u.r=(h.r+i.r)*0.5;u.g=(h.g+i.g)*0.5;u.b=(h.b+i.b)*0.5;H=Ga(p,h,i,u);qa(P,J,K,w,g,l,H,0,0,1,0,0,1)}else{Y.r=N.r;Y.g=N.g;Y.b=N.b;va(V,x.centroidWorld,x.normalWorld,Y);f.r=F.color.r*Y.r;f.g=F.color.g*Y.g;f.b=F.color.b*Y.b;f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}else F.wireframe?
|
|
|
|
-xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){t=F.__2near;G=F.__farPlusNear;z=F.__farMinusNear;p.r=p.g=p.b=1-t/(G-q.positionScreen.z*z);h.r=h.g=h.b=1-t/(G-T.positionScreen.z*z);i.r=i.g=i.b=1-t/(G-L.positionScreen.z*z);u.r=(h.r+i.r)*0.5;u.g=(h.g+i.g)*0.5;u.b=(h.b+i.b)*0.5;H=Ga(p,h,i,u);qa(P,J,K,w,g,l,H,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){f.r=Ca(x.normalWorld.x);f.g=Ca(x.normalWorld.y);f.b=Ca(x.normalWorld.z);
|
|
|
|
-f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}}}function xa(q,T){if(A!=q)k.strokeStyle=A=q;if(s!=T)k.lineWidth=s=T;k.stroke();B.inflate(T*2)}function ya(q){if(y!=q)k.fillStyle=y=q;k.fill()}function qa(q,T,L,x,F,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;L-=q;x-=T;F-=q;V-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*L-ea*F)*ja;ea=(ra*x-ea*V)*ja;L=(ha*F-ia*L)*ja;x=(ha*V-ia*x)*ja;q=
|
|
|
|
-q-ka*ba-L*ca;T=T-ea*ba-x*ca;k.save();k.transform(ka,ea,L,x,q,T);k.clip();k.drawImage($,0,0);k.restore()}function Ba(q){if(m!=q)k.globalAlpha=m=q}function wa(q){if(c!=q){switch(q){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=q}}function Ga(q,T,L,x){var F=~~(q.r*255),V=~~(q.g*255);q=~~(q.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*
|
|
|
|
-255);var ca=~~(L.r*255),ha=~~(L.g*255);L=~~(L.b*255);var ea=~~(x.r*255),ia=~~(x.g*255);x=~~(x.b*255);da[0]=F<0?0:F>255?255:F;da[1]=V<0?0:V>255?255:V;da[2]=q<0?0:q>255?255:q;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=L<0?0:L>255?255:L;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=x<0?0:x>255?255:x;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(q){q=(q+1)*0.5;return q<0?
|
|
|
|
-0:q>1?1:q}function Da(q,T){var L=T.x-q.x,x=T.y-q.y,F=1/Math.sqrt(L*L+x*x);L*=F;x*=F;T.x+=L;T.y+=x;q.x-=L;q.y-=x}var za,Ha,Z,fa,ma,Ea,Ia,sa;k.setTransform(1,0,0,-1,n,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());(W=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];B.empty();if(Z instanceof THREE.RenderableParticle){r=Z;r.x*=n;r.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(r,
|
|
|
|
-Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){r=Z.v1;E=Z.v2;r.positionScreen.x*=n;r.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;B.addPoint(r.positionScreen.x,r.positionScreen.y);B.addPoint(E.positionScreen.x,E.positionScreen.y);if(I.instersects(B)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(r,E,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){r=Z.v1;E=Z.v2;M=Z.v3;r.positionScreen.x*=n;r.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=
|
|
|
|
-o;M.positionScreen.x*=n;M.positionScreen.y*=o;if(Z.overdraw){Da(r.positionScreen,E.positionScreen);Da(E.positionScreen,M.positionScreen);Da(M.positionScreen,r.positionScreen)}B.add3Points(r.positionScreen.x,r.positionScreen.y,E.positionScreen.x,E.positionScreen.y,M.positionScreen.x,M.positionScreen.y);if(I.instersects(B)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(r,
|
|
|
|
-E,M,Z,sa,ga)}else Fa(r,E,M,Z,sa,ga)}}}v.addRectangle(B)}k.lineWidth=1;k.strokeStyle="rgba( 255, 0, 0, 0.5 )";k.strokeRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());k.setTransform(1,0,0,1,0,0)}};
|
|
|
|
-THREE.SVGRenderer=function(){function a(D,R,S){var I,v,B,W;I=0;for(v=D.lights.length;I<v;I++){B=D.lights[I];if(B instanceof THREE.DirectionalLight){W=R.normalWorld.dot(B.position)*B.intensity;if(W>0){S.r+=B.color.r*W;S.g+=B.color.g*W;S.b+=B.color.b*W}}else if(B instanceof THREE.PointLight){i.sub(B.position,R.centroidWorld);i.normalize();W=R.normalWorld.dot(i)*B.intensity;if(W>0){S.r+=B.color.r*W;S.g+=B.color.g*W;S.b+=B.color.b*W}}}}function b(D,R,S,I,v,B){z=e(H++);z.setAttribute("d","M "+D.positionScreen.x+
|
|
|
|
-" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(v instanceof THREE.MeshBasicMaterial)w.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshLambertMaterial)if(K){g.r=l.r;g.g=l.g;g.b=l.b;a(B,I,g);w.r=v.color.r*g.r;w.g=v.color.g*g.g;w.b=v.color.b*g.b;w.updateStyleString()}else w.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshDepthMaterial){h=1-v.__2near/(v.__farPlusNear-I.z*v.__farMinusNear);
|
|
|
|
-w.setRGB(h,h,h)}else v instanceof THREE.MeshNormalMaterial&&w.setRGB(j(I.normalWorld.x),j(I.normalWorld.y),j(I.normalWorld.z));v.wireframe?z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+v.wireframe_linewidth+"; stroke-opacity: "+v.opacity+"; stroke-linecap: "+v.wireframe_linecap+"; stroke-linejoin: "+v.wireframe_linejoin):z.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+v.opacity);k.appendChild(z)}function d(D,R,S,I,v,B,W){z=e(H++);z.setAttribute("d",
|
|
|
|
-"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)w.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(K){g.r=l.r;g.g=l.g;g.b=l.b;a(W,v,g);w.r=B.color.r*g.r;w.g=B.color.g*g.g;w.b=B.color.b*g.b;w.updateStyleString()}else w.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){h=
|
|
|
|
-1-B.__2near/(B.__farPlusNear-v.z*B.__farMinusNear);w.setRGB(h,h,h)}else B instanceof THREE.MeshNormalMaterial&&w.setRGB(j(v.normalWorld.x),j(v.normalWorld.y),j(v.normalWorld.z));B.wireframe?z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):z.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+B.opacity);k.appendChild(z)}
|
|
|
|
-function e(D){if(u[D]==null){u[D]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&u[D].setAttribute("shape-rendering","crispEdges");return u[D]}return u[D]}function j(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var n=null,o=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,A,y,s,r,E,M,P=new THREE.Rectangle,J=new THREE.Rectangle,K=false,w=new THREE.Color(16777215),g=new THREE.Color(16777215),l=new THREE.Color(0),f=new THREE.Color(0),
|
|
|
|
-p=new THREE.Color(0),h,i=new THREE.Vector3,u=[],t=[],G=[],z,H,Q,C,O=1;this.domElement=k;this.autoClear=true;this.setQuality=function(D){switch(D){case "high":O=1;break;case "low":O=0}};this.setSize=function(D,R){m=D;c=R;A=m/2;y=c/2;k.setAttribute("viewBox",-A+" "+-y+" "+m+" "+c);k.setAttribute("width",m);k.setAttribute("height",c);P.set(-A,-y,A,y)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(D,R){var S,I,v,B,W,Y,N,U;this.autoClear&&this.clear();
|
|
|
|
-n=o.projectScene(D,R);C=Q=H=0;if(K=D.lights.length>0){N=D.lights;l.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);S=0;for(I=N.length;S<I;S++){v=N[S];B=v.color;if(v instanceof THREE.AmbientLight){l.r+=B.r;l.g+=B.g;l.b+=B.b}else if(v instanceof THREE.DirectionalLight){f.r+=B.r;f.g+=B.g;f.b+=B.b}else if(v instanceof THREE.PointLight){p.r+=B.r;p.g+=B.g;p.b+=B.b}}}S=0;for(I=n.length;S<I;S++){N=n[S];J.empty();if(N instanceof THREE.RenderableParticle){s=N;s.x*=A;s.y*=-y;v=0;for(B=N.material.length;v<B;v++)if(U=
|
|
|
|
-N.material[v]){W=s;Y=N;U=U;var aa=Q++;if(t[aa]==null){t[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&t[aa].setAttribute("shape-rendering","crispEdges")}z=t[aa];z.setAttribute("cx",W.x);z.setAttribute("cy",W.y);z.setAttribute("r",Y.scale.x*A);if(U instanceof THREE.ParticleCircleMaterial){if(K){g.r=l.r+f.r+p.r;g.g=l.g+f.g+p.g;g.b=l.b+f.b+p.b;w.r=U.color.r*g.r;w.g=U.color.g*g.g;w.b=U.color.b*g.b;w.updateStyleString()}else w=U.color;z.setAttribute("style","fill: "+w.__styleString)}k.appendChild(z)}}else if(N instanceof
|
|
|
|
-THREE.RenderableLine){s=N.v1;r=N.v2;s.positionScreen.x*=A;s.positionScreen.y*=-y;r.positionScreen.x*=A;r.positionScreen.y*=-y;J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);if(P.instersects(J)){v=0;for(B=N.material.length;v<B;)if(U=N.material[v++]){W=s;Y=r;U=U;aa=C++;if(G[aa]==null){G[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");O==0&&G[aa].setAttribute("shape-rendering","crispEdges")}z=G[aa];z.setAttribute("x1",W.positionScreen.x);
|
|
|
|
-z.setAttribute("y1",W.positionScreen.y);z.setAttribute("x2",Y.positionScreen.x);z.setAttribute("y2",Y.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){w.__styleString=U.color.__styleString;z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);k.appendChild(z)}}}}else if(N instanceof THREE.RenderableFace3){s=N.v1;r=N.v2;E=N.v3;s.positionScreen.x*=A;s.positionScreen.y*=
|
|
|
|
--y;r.positionScreen.x*=A;r.positionScreen.y*=-y;E.positionScreen.x*=A;E.positionScreen.y*=-y;J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);if(P.instersects(J)){v=0;for(B=N.meshMaterial.length;v<B;){U=N.meshMaterial[v++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&b(s,r,E,N,U,D)}else U&&b(s,r,E,N,U,D)}}}else if(N instanceof THREE.RenderableFace4){s=
|
|
|
|
-N.v1;r=N.v2;E=N.v3;M=N.v4;s.positionScreen.x*=A;s.positionScreen.y*=-y;r.positionScreen.x*=A;r.positionScreen.y*=-y;E.positionScreen.x*=A;E.positionScreen.y*=-y;M.positionScreen.x*=A;M.positionScreen.y*=-y;J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);J.addPoint(M.positionScreen.x,M.positionScreen.y);if(P.instersects(J)){v=0;for(B=N.meshMaterial.length;v<B;){U=N.meshMaterial[v++];if(U instanceof
|
|
|
|
-THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&d(s,r,E,M,N,U,D)}else U&&d(s,r,E,M,N,U,D)}}}}}};
|
|
|
|
-THREE.WebGLRenderer=function(a){function b(g,l){var f=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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 vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
|
|
|
-g));c.attachShader(f,o("vertex",p+l));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function d(g,l){if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
|
|
|
|
-c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP,
|
|
|
|
-g.image.__webGLTextureCube)}}function e(g,l){if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,g.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(g.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(g.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(g.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,k(g.min_filter));c.generateMipmap(c.TEXTURE_2D);
|
|
|
|
-c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,g.__webGLTexture)}function j(g,l){var f,p,h;f=0;for(p=l.length;f<p;f++){h=l[f];g.uniforms[h]=c.getUniformLocation(g,h)}}function n(g,l){var f,p,h;f=0;for(p=l.length;f<p;f++){h=l[f];g.attributes[h]=c.getAttribLocation(g,h);g.attributes[h]>=0&&c.enableVertexAttribArray(g.attributes[h])}}function o(g,l){var f;if(g=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")f=c.createShader(c.VERTEX_SHADER);
|
|
|
|
-c.shaderSource(f,l);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function k(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
|
|
|
|
-case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var m=document.createElement("canvas"),c,A,y,s=new THREE.Matrix4,r,E=new Float32Array(16),M=new Float32Array(16),P=new Float32Array(16),J=new Float32Array(9),K=new Float32Array(16);a=function(g,l){if(g){var f,p,h,i=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=g.lights.length;f<p;f++){h=g.lights[f];h instanceof THREE.DirectionalLight&&i++;h instanceof
|
|
|
|
-THREE.PointLight&&pointLights++}if(pointLights+i<=l){maxDirLights=i;maxPointLights=pointLights}else{maxDirLights=Math.ceil(l*i/(pointLights+i));maxPointLights=l-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:l-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(w){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
|
|
|
|
-c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);A=y=function(g,l){var f=[g?"#define MAX_DIR_LIGHTS "+g:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",g?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
|
|
|
|
-"",l?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",l?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
|
|
-g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",g?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",g?"}":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",l?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
|
-"",l?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",l?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",l?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
|
|
|
|
-p=[g?"#define MAX_DIR_LIGHTS "+g:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
|
-g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
|
-l?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",l?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",l?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",l?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",l?"float pointSpecularWeight = 0.0;":"",l?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
|
-"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",g?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"vec3 dirVector = normalize( lDirection.xyz );":"",g?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
|
-"",g?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",g?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",g?"float dirSpecularWeight = 0.0;":"",g?"if ( dirDotNormalHalf >= 0.0 )":"",g?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",g?"dirDiffuse += mColor * dirDiffuseWeight;":"",g?"dirSpecular += mSpecular * dirSpecularWeight;":"",g?"}":"","vec4 totalLight = mAmbient;",g?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;":
|
|
|
|
|
|
+THREE.Projector=function(){function a(f,p){var l=0,j=1,o=f.z+f.w,C=p.z+p.w,v=-f.z+f.w,t=-p.z+p.w;if(o>=0&&C>=0&&v>=0&&t>=0)return true;else if(o<0&&C<0||v<0&&t<0)return false;else{if(o<0)l=Math.max(l,o/(o-C));else if(C<0)j=Math.min(j,o/(o-C));if(v<0)l=Math.max(l,v/(v-t));else if(t<0)j=Math.min(j,v/(v-t));if(j<l)return false;else{f.lerpSelf(p,l);p.lerpSelf(f,1-j);return true}}}function b(f,p){return p.z-f.z}var g=null,d,i,q=[],k,h,n,c=[],A,y,x=[],s,G,N=[],K=new THREE.Vector4,J=new THREE.Matrix4,O=
|
|
|
|
+new THREE.Matrix4,E=new THREE.Vector4,e=new THREE.Vector4,m;this.projectObjects=function(f,p){var l,j,o,C;g=[];i=0;J.multiply(p.projectionMatrix,p.matrix);o=f.objects;l=0;for(j=o.length;l<j;l++){C=o[l];if(C.visible!==false){d=q[i]=q[i]||new THREE.RenderableObject;K.copy(C.position);J.multiplyVector4(K);d.object=C;d.z=K.z;g.push(d);i++}}g.sort(b);return g};this.projectScene=function(f,p){var l,j,o,C,v,t,I,B,F,U,P,W,T,D,r,w,Q;g=[];n=y=G=0;p.autoUpdateMatrix&&p.updateMatrix();J.multiply(p.projectionMatrix,
|
|
|
|
+p.matrix);I=f.objects;l=0;for(j=I.length;l<j;l++){B=I[l];if(B.visible!==false){B.autoUpdateMatrix&&B.updateMatrix();F=B.matrix;U=B.rotationMatrix;P=B.material;W=B.overdraw;if(B instanceof THREE.Mesh){T=B.geometry;D=T.vertices;o=0;for(C=D.length;o<C;o++){r=D[o];r.positionWorld.copy(r.position);F.multiplyVector3(r.positionWorld);v=r.positionScreen;v.copy(r.positionWorld);J.multiplyVector4(v);v.multiplyScalar(1/v.w);r.__visible=v.z>0&&v.z<1}T=T.faces;o=0;for(C=T.length;o<C;o++){r=T[o];if(r instanceof
|
|
|
|
+THREE.Face3){v=D[r.a];t=D[r.b];w=D[r.c];if(v.__visible&&t.__visible&&w.__visible)if(B.doubleSided||B.flipSided!=(w.positionScreen.x-v.positionScreen.x)*(t.positionScreen.y-v.positionScreen.y)-(w.positionScreen.y-v.positionScreen.y)*(t.positionScreen.x-v.positionScreen.x)<0){k=c[n]=c[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(v.positionWorld);k.v2.positionWorld.copy(t.positionWorld);k.v3.positionWorld.copy(w.positionWorld);k.v1.positionScreen.copy(v.positionScreen);k.v2.positionScreen.copy(t.positionScreen);
|
|
|
|
+k.v3.positionScreen.copy(w.positionScreen);k.normalWorld.copy(r.normal);U.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);F.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);J.multiplyVector3(k.centroidScreen);w=r.vertexNormals;m=k.vertexNormalsWorld;v=0;for(t=w.length;v<t;v++){Q=m[v]=m[v]||new THREE.Vector3;Q.copy(w[v]);U.multiplyVector3(Q)}k.z=k.centroidScreen.z;k.meshMaterial=P;k.faceMaterial=r.material;k.overdraw=W;if(B.geometry.uvs[o]){k.uvs[0]=B.geometry.uvs[o][0];
|
|
|
|
+k.uvs[1]=B.geometry.uvs[o][1];k.uvs[2]=B.geometry.uvs[o][2]}g.push(k);n++}}else if(r instanceof THREE.Face4){v=D[r.a];t=D[r.b];w=D[r.c];Q=D[r.d];if(v.__visible&&t.__visible&&w.__visible&&Q.__visible)if(B.doubleSided||B.flipSided!=((Q.positionScreen.x-v.positionScreen.x)*(t.positionScreen.y-v.positionScreen.y)-(Q.positionScreen.y-v.positionScreen.y)*(t.positionScreen.x-v.positionScreen.x)<0||(t.positionScreen.x-w.positionScreen.x)*(Q.positionScreen.y-w.positionScreen.y)-(t.positionScreen.y-w.positionScreen.y)*
|
|
|
|
+(Q.positionScreen.x-w.positionScreen.x)<0)){k=c[n]=c[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(v.positionWorld);k.v2.positionWorld.copy(t.positionWorld);k.v3.positionWorld.copy(Q.positionWorld);k.v1.positionScreen.copy(v.positionScreen);k.v2.positionScreen.copy(t.positionScreen);k.v3.positionScreen.copy(Q.positionScreen);k.normalWorld.copy(r.normal);U.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);F.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);
|
|
|
|
+J.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterial=P;k.faceMaterial=r.material;k.overdraw=W;if(B.geometry.uvs[o]){k.uvs[0]=B.geometry.uvs[o][0];k.uvs[1]=B.geometry.uvs[o][1];k.uvs[2]=B.geometry.uvs[o][3]}g.push(k);n++;h=c[n]=c[n]||new THREE.RenderableFace3;h.v1.positionWorld.copy(t.positionWorld);h.v2.positionWorld.copy(w.positionWorld);h.v3.positionWorld.copy(Q.positionWorld);h.v1.positionScreen.copy(t.positionScreen);h.v2.positionScreen.copy(w.positionScreen);h.v3.positionScreen.copy(Q.positionScreen);
|
|
|
|
+h.normalWorld.copy(k.normalWorld);h.centroidWorld.copy(k.centroidWorld);h.centroidScreen.copy(k.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterial=P;h.faceMaterial=r.material;h.overdraw=W;if(B.geometry.uvs[o]){h.uvs[0]=B.geometry.uvs[o][1];h.uvs[1]=B.geometry.uvs[o][2];h.uvs[2]=B.geometry.uvs[o][3]}g.push(h);n++}}}}else if(B instanceof THREE.Line){O.multiply(J,F);D=B.geometry.vertices;r=D[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);o=1;for(C=D.length;o<C;o++){v=D[o];
|
|
|
|
+v.positionScreen.copy(v.position);O.multiplyVector4(v.positionScreen);t=D[o-1];E.copy(v.positionScreen);e.copy(t.positionScreen);if(a(E,e)){E.multiplyScalar(1/E.w);e.multiplyScalar(1/e.w);A=x[y]=x[y]||new THREE.RenderableLine;A.v1.positionScreen.copy(E);A.v2.positionScreen.copy(e);A.z=Math.max(E.z,e.z);A.material=B.material;g.push(A);y++}}}else if(B instanceof THREE.Particle){K.set(B.position.x,B.position.y,B.position.z,1);J.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){s=N[G]=N[G]||new THREE.RenderableParticle;
|
|
|
|
+s.x=K.x/K.w;s.y=K.y/K.w;s.z=K.z;s.rotation=B.rotation.z;s.scale.x=B.scale.x*Math.abs(s.x-(K.x+p.projectionMatrix.n11)/(K.w+p.projectionMatrix.n14));s.scale.y=B.scale.y*Math.abs(s.y-(K.y+p.projectionMatrix.n22)/(K.w+p.projectionMatrix.n24));s.material=B.material;g.push(s);G++}}}}g.sort(b);return g};this.unprojectVector=function(f,p){var l=new THREE.Matrix4;l.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));l.multiplyVector3(f);return f}};
|
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,q;this.domElement=document.createElement("div");this.setSize=function(k,h){g=k;d=h;i=g/2;q=d/2};this.render=function(k,h){var n,c,A,y,x,s,G,N;a=b.projectScene(k,h);n=0;for(c=a.length;n<c;n++){x=a[n];if(x instanceof THREE.RenderableParticle){G=x.x*i+i;N=x.y*q+q;A=0;for(y=x.material.length;A<y;A++){s=x.material[A];if(s instanceof THREE.ParticleDOMMaterial){s=s.domElement;s.style.left=G+"px";s.style.top=N+"px"}}}}}};
|
|
|
|
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,g=document.createElement("canvas"),d,i,q,k,h=g.getContext("2d"),n=1,c=0,A=null,y=null,x=1,s,G,N,K,J,O,E,e,m,f=new THREE.Color,p=new THREE.Color,l=new THREE.Color,j=new THREE.Color,o=new THREE.Color,C,v,t,I,B,F,U,P,W,T,D=new THREE.Rectangle,r=new THREE.Rectangle,w=new THREE.Rectangle,Q=false,Y=new THREE.Color,M=new THREE.Color,S=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,X=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
|
|
|
|
+na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=g;this.autoClear=true;this.setSize=function(ga,ua){d=ga;i=ua;q=d/2;k=i/2;g.width=d;g.height=i;D.set(-q,-k,q,k)};this.clear=function(){if(!r.isEmpty()){r.inflate(1);r.minSelf(D);h.clearRect(r.getX(),r.getY(),r.getWidth(),r.getHeight());
|
|
|
|
+r.empty()}};this.render=function(ga,ua){function Ka(u){var R,L,z,H=u.lights;M.setRGB(0,0,0);S.setRGB(0,0,0);aa.setRGB(0,0,0);u=0;for(R=H.length;u<R;u++){L=H[u];z=L.color;if(L instanceof THREE.AmbientLight){M.r+=z.r;M.g+=z.g;M.b+=z.b}else if(L instanceof THREE.DirectionalLight){S.r+=z.r;S.g+=z.g;S.b+=z.b}else if(L instanceof THREE.PointLight){aa.r+=z.r;aa.g+=z.g;aa.b+=z.b}}}function va(u,R,L,z){var H,V,$,ba,ca=u.lights;u=0;for(H=ca.length;u<H;u++){V=ca[u];$=V.color;ba=V.intensity;if(V instanceof THREE.DirectionalLight){V=
|
|
|
|
+L.dot(V.position)*ba;if(V>0){z.r+=$.r*V;z.g+=$.g*V;z.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,R);X.normalize();V=L.dot(X)*ba;if(V>0){z.r+=$.r*V;z.g+=$.g*V;z.b+=$.b*V}}}}function La(u,R,L){if(L.opacity!=0){Ba(L.opacity);wa(L.blending);var z,H,V,$,ba,ca;if(L instanceof THREE.ParticleBasicMaterial){if(L.map){$=L.map;ba=$.width>>1;ca=$.height>>1;H=R.scale.x*q;V=R.scale.y*k;L=H*ba;z=V*ca;w.set(u.x-L,u.y-z,u.x+L,u.y+z);if(!D.instersects(w))return;h.save();h.translate(u.x,u.y);h.rotate(-R.rotation);
|
|
|
|
+h.scale(H,-V);h.translate(-ba,-ca);h.drawImage($,0,0);h.restore()}h.beginPath();h.moveTo(u.x-10,u.y);h.lineTo(u.x+10,u.y);h.moveTo(u.x,u.y-10);h.lineTo(u.x,u.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}else if(L instanceof THREE.ParticleCircleMaterial){if(Q){Y.r=M.r+S.r+aa.r;Y.g=M.g+S.g+aa.g;Y.b=M.b+S.b+aa.b;f.r=L.color.r*Y.r;f.g=L.color.g*Y.g;f.b=L.color.b*Y.b;f.updateStyleString()}else f.__styleString=L.color.__styleString;L=R.scale.x*q;z=R.scale.y*k;w.set(u.x-L,u.y-z,u.x+L,u.y+
|
|
|
|
+z);if(D.instersects(w)){H=f.__styleString;if(y!=H)h.fillStyle=y=H;h.save();h.translate(u.x,u.y);h.rotate(-R.rotation);h.scale(L,z);h.beginPath();h.arc(0,0,1,0,Ja,true);h.closePath();h.fill();h.restore()}}}}function Ma(u,R,L,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);h.beginPath();h.moveTo(u.positionScreen.x,u.positionScreen.y);h.lineTo(R.positionScreen.x,R.positionScreen.y);h.closePath();if(z instanceof THREE.LineBasicMaterial){f.__styleString=z.color.__styleString;u=z.linewidth;if(x!=u)h.lineWidth=
|
|
|
|
+x=u;u=f.__styleString;if(A!=u)h.strokeStyle=A=u;h.stroke();w.inflate(z.linewidth*2)}}}function Fa(u,R,L,z,H,V){if(H.opacity!=0){Ba(H.opacity);wa(H.blending);K=u.positionScreen.x;J=u.positionScreen.y;O=R.positionScreen.x;E=R.positionScreen.y;e=L.positionScreen.x;m=L.positionScreen.y;h.beginPath();h.moveTo(K,J);h.lineTo(O,E);h.lineTo(e,m);h.lineTo(K,J);h.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,E,e,m,H.map.image,
|
|
|
|
+z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){u=ua.matrix;X.copy(z.vertexNormalsWorld[0]);B=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;F=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[1]);U=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;P=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[2]);W=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;T=-(X.x*
|
|
|
|
+u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;qa(K,J,O,E,e,m,H.env_map.image,B,F,U,P,W,T)}}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,E,e,m,H.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(Q)if(!H.wireframe&&H.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){p.r=l.r=
|
|
|
|
+j.r=M.r;p.g=l.g=j.g=M.g;p.b=l.b=j.b=M.b;va(V,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(V,z.v2.positionWorld,z.vertexNormalsWorld[1],l);va(V,z.v3.positionWorld,z.vertexNormalsWorld[2],j);o.r=(l.r+j.r)*0.5;o.g=(l.g+j.g)*0.5;o.b=(l.b+j.b)*0.5;I=Ga(p,l,j,o);qa(K,J,O,E,e,m,I,0,0,1,0,0,1)}else{Y.r=M.r;Y.g=M.g;Y.b=M.b;va(V,z.centroidWorld,z.normalWorld,Y);f.r=H.color.r*Y.r;f.g=H.color.g*Y.g;f.b=H.color.b*Y.b;f.updateStyleString();H.wireframe?xa(f.__styleString,H.wireframe_linewidth):ya(f.__styleString)}else H.wireframe?
|
|
|
|
+xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){C=H.__2near;v=H.__farPlusNear;t=H.__farMinusNear;p.r=p.g=p.b=1-C/(v-u.positionScreen.z*t);l.r=l.g=l.b=1-C/(v-R.positionScreen.z*t);j.r=j.g=j.b=1-C/(v-L.positionScreen.z*t);o.r=(l.r+j.r)*0.5;o.g=(l.g+j.g)*0.5;o.b=(l.b+j.b)*0.5;I=Ga(p,l,j,o);qa(K,J,O,E,e,m,I,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){f.r=Ca(z.normalWorld.x);f.g=Ca(z.normalWorld.y);f.b=Ca(z.normalWorld.z);
|
|
|
|
+f.updateStyleString();H.wireframe?xa(f.__styleString,H.wireframe_linewidth):ya(f.__styleString)}}}function xa(u,R){if(A!=u)h.strokeStyle=A=u;if(x!=R)h.lineWidth=x=R;h.stroke();w.inflate(R*2)}function ya(u){if(y!=u)h.fillStyle=y=u;h.fill()}function qa(u,R,L,z,H,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;L-=u;z-=R;H-=u;V-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*L-ea*H)*ja;ea=(ra*z-ea*V)*ja;L=(ha*H-ia*L)*ja;z=(ha*V-ia*z)*ja;u=
|
|
|
|
+u-ka*ba-L*ca;R=R-ea*ba-z*ca;h.save();h.transform(ka,ea,L,z,u,R);h.clip();h.drawImage($,0,0);h.restore()}function Ba(u){if(n!=u)h.globalAlpha=n=u}function wa(u){if(c!=u){switch(u){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=u}}function Ga(u,R,L,z){var H=~~(u.r*255),V=~~(u.g*255);u=~~(u.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b*
|
|
|
|
+255);var ca=~~(L.r*255),ha=~~(L.g*255);L=~~(L.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=H<0?0:H>255?255:H;da[1]=V<0?0:V>255?255:V;da[2]=u<0?0:u>255?255:u;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=L<0?0:L>255?255:L;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(u){u=(u+1)*0.5;return u<0?
|
|
|
|
+0:u>1?1:u}function Da(u,R){var L=R.x-u.x,z=R.y-u.y,H=1/Math.sqrt(L*L+z*z);L*=H;z*=H;R.x+=L;R.y+=z;u.x-=L;u.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;h.setTransform(1,0,0,-1,q,k);this.autoClear&&this.clear();a=b.projectScene(ga,ua);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(D.getX(),D.getY(),D.getWidth(),D.getHeight());(Q=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];w.empty();if(Z instanceof THREE.RenderableParticle){s=Z;s.x*=q;s.y*=k;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(s,
|
|
|
|
+Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){s=Z.v1;G=Z.v2;s.positionScreen.x*=q;s.positionScreen.y*=k;G.positionScreen.x*=q;G.positionScreen.y*=k;w.addPoint(s.positionScreen.x,s.positionScreen.y);w.addPoint(G.positionScreen.x,G.positionScreen.y);if(D.instersects(w)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(s,G,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){s=Z.v1;G=Z.v2;N=Z.v3;s.positionScreen.x*=q;s.positionScreen.y*=k;G.positionScreen.x*=q;G.positionScreen.y*=
|
|
|
|
+k;N.positionScreen.x*=q;N.positionScreen.y*=k;if(Z.overdraw){Da(s.positionScreen,G.positionScreen);Da(G.positionScreen,N.positionScreen);Da(N.positionScreen,s.positionScreen)}w.add3Points(s.positionScreen.x,s.positionScreen.y,G.positionScreen.x,G.positionScreen.y,N.positionScreen.x,N.positionScreen.y);if(D.instersects(w)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(s,
|
|
|
|
+G,N,Z,sa,ga)}else Fa(s,G,N,Z,sa,ga)}}}r.addRectangle(w)}h.lineWidth=1;h.strokeStyle="rgba( 255, 0, 0, 0.5 )";h.strokeRect(r.getX(),r.getY(),r.getWidth(),r.getHeight());h.setTransform(1,0,0,1,0,0)}};
|
|
|
|
+THREE.SVGRenderer=function(){function a(P,W,T){var D,r,w,Q;D=0;for(r=P.lights.length;D<r;D++){w=P.lights[D];if(w instanceof THREE.DirectionalLight){Q=W.normalWorld.dot(w.position)*w.intensity;if(Q>0){T.r+=w.color.r*Q;T.g+=w.color.g*Q;T.b+=w.color.b*Q}}else if(w instanceof THREE.PointLight){j.sub(w.position,W.centroidWorld);j.normalize();Q=W.normalWorld.dot(j)*w.intensity;if(Q>0){T.r+=w.color.r*Q;T.g+=w.color.g*Q;T.b+=w.color.b*Q}}}}function b(P,W,T,D,r,w){t=d(I++);t.setAttribute("d","M "+P.positionScreen.x+
|
|
|
|
+" "+P.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(r instanceof THREE.MeshBasicMaterial)E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshLambertMaterial)if(O){e.r=m.r;e.g=m.g;e.b=m.b;a(w,D,e);E.r=r.color.r*e.r;E.g=r.color.g*e.g;E.b=r.color.b*e.b;E.updateStyleString()}else E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){l=1-r.__2near/(r.__farPlusNear-D.z*r.__farMinusNear);
|
|
|
|
+E.setRGB(l,l,l)}else r instanceof THREE.MeshNormalMaterial&&E.setRGB(i(D.normalWorld.x),i(D.normalWorld.y),i(D.normalWorld.z));r.wireframe?t.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):t.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+r.opacity);h.appendChild(t)}function g(P,W,T,D,r,w,Q){t=d(I++);t.setAttribute("d",
|
|
|
|
+"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(O){e.r=m.r;e.g=m.g;e.b=m.b;a(Q,r,e);E.r=w.color.r*e.r;E.g=w.color.g*e.g;E.b=w.color.b*e.b;E.updateStyleString()}else E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){l=
|
|
|
|
+1-w.__2near/(w.__farPlusNear-r.z*w.__farMinusNear);E.setRGB(l,l,l)}else w instanceof THREE.MeshNormalMaterial&&E.setRGB(i(r.normalWorld.x),i(r.normalWorld.y),i(r.normalWorld.z));w.wireframe?t.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):t.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+w.opacity);h.appendChild(t)}
|
|
|
|
+function d(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function i(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var q=null,k=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,A,y,x,s,G,N,K=new THREE.Rectangle,J=new THREE.Rectangle,O=false,E=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),f=new THREE.Color(0),
|
|
|
|
+p=new THREE.Color(0),l,j=new THREE.Vector3,o=[],C=[],v=[],t,I,B,F,U=1;this.domElement=h;this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,W){n=P;c=W;A=n/2;y=c/2;h.setAttribute("viewBox",-A+" "+-y+" "+n+" "+c);h.setAttribute("width",n);h.setAttribute("height",c);K.set(-A,-y,A,y)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(P,W){var T,D,r,w,Q,Y,M,S;this.autoClear&&this.clear();
|
|
|
|
+q=k.projectScene(P,W);F=B=I=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);T=0;for(D=M.length;T<D;T++){r=M[T];w=r.color;if(r instanceof THREE.AmbientLight){m.r+=w.r;m.g+=w.g;m.b+=w.b}else if(r instanceof THREE.DirectionalLight){f.r+=w.r;f.g+=w.g;f.b+=w.b}else if(r instanceof THREE.PointLight){p.r+=w.r;p.g+=w.g;p.b+=w.b}}}T=0;for(D=q.length;T<D;T++){M=q[T];J.empty();if(M instanceof THREE.RenderableParticle){x=M;x.x*=A;x.y*=-y;r=0;for(w=M.material.length;r<w;r++)if(S=
|
|
|
|
+M.material[r]){Q=x;Y=M;S=S;var aa=B++;if(C[aa]==null){C[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&C[aa].setAttribute("shape-rendering","crispEdges")}t=C[aa];t.setAttribute("cx",Q.x);t.setAttribute("cy",Q.y);t.setAttribute("r",Y.scale.x*A);if(S instanceof THREE.ParticleCircleMaterial){if(O){e.r=m.r+f.r+p.r;e.g=m.g+f.g+p.g;e.b=m.b+f.b+p.b;E.r=S.color.r*e.r;E.g=S.color.g*e.g;E.b=S.color.b*e.b;E.updateStyleString()}else E=S.color;t.setAttribute("style","fill: "+E.__styleString)}h.appendChild(t)}}else if(M instanceof
|
|
|
|
+THREE.RenderableLine){x=M.v1;s=M.v2;x.positionScreen.x*=A;x.positionScreen.y*=-y;s.positionScreen.x*=A;s.positionScreen.y*=-y;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(s.positionScreen.x,s.positionScreen.y);if(K.instersects(J)){r=0;for(w=M.material.length;r<w;)if(S=M.material[r++]){Q=x;Y=s;S=S;aa=F++;if(v[aa]==null){v[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");U==0&&v[aa].setAttribute("shape-rendering","crispEdges")}t=v[aa];t.setAttribute("x1",Q.positionScreen.x);
|
|
|
|
+t.setAttribute("y1",Q.positionScreen.y);t.setAttribute("x2",Y.positionScreen.x);t.setAttribute("y2",Y.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){E.__styleString=S.color.__styleString;t.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);h.appendChild(t)}}}}else if(M instanceof THREE.RenderableFace3){x=M.v1;s=M.v2;G=M.v3;x.positionScreen.x*=A;x.positionScreen.y*=
|
|
|
|
+-y;s.positionScreen.x*=A;s.positionScreen.y*=-y;G.positionScreen.x*=A;G.positionScreen.y*=-y;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(G.positionScreen.x,G.positionScreen.y);if(K.instersects(J)){r=0;for(w=M.meshMaterial.length;r<w;){S=M.meshMaterial[r++];if(S instanceof THREE.MeshFaceMaterial){Q=0;for(Y=M.faceMaterial.length;Q<Y;)(S=M.faceMaterial[Q++])&&b(x,s,G,M,S,P)}else S&&b(x,s,G,M,S,P)}}}else if(M instanceof THREE.RenderableFace4){x=
|
|
|
|
+M.v1;s=M.v2;G=M.v3;N=M.v4;x.positionScreen.x*=A;x.positionScreen.y*=-y;s.positionScreen.x*=A;s.positionScreen.y*=-y;G.positionScreen.x*=A;G.positionScreen.y*=-y;N.positionScreen.x*=A;N.positionScreen.y*=-y;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(G.positionScreen.x,G.positionScreen.y);J.addPoint(N.positionScreen.x,N.positionScreen.y);if(K.instersects(J)){r=0;for(w=M.meshMaterial.length;r<w;){S=M.meshMaterial[r++];if(S instanceof
|
|
|
|
+THREE.MeshFaceMaterial){Q=0;for(Y=M.faceMaterial.length;Q<Y;)(S=M.faceMaterial[Q++])&&g(x,s,G,N,M,S,P)}else S&&g(x,s,G,N,M,S,P)}}}}}};
|
|
|
|
+THREE.WebGLRenderer=function(a){function b(e,m){var f=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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 vec2 uv;\n"].join("\n");c.attachShader(f,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
|
|
|
+e));c.attachShader(f,k("vertex",p+m));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
|
|
|
|
+c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP,
|
|
|
|
+e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(e.min_filter));c.generateMipmap(c.TEXTURE_2D);
|
|
|
|
+c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function i(e,m){var f,p,l;f=0;for(p=m.length;f<p;f++){l=m[f];e.uniforms[l]=c.getUniformLocation(e,l)}}function q(e,m){var f,p,l;f=0;for(p=m.length;f<p;f++){l=m[f];e.attributes[l]=c.getAttribLocation(e,l);e.attributes[l]>=0&&c.enableVertexAttribArray(e.attributes[l])}}function k(e,m){var f;if(e=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")f=c.createShader(c.VERTEX_SHADER);
|
|
|
|
+c.shaderSource(f,m);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function h(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
|
|
|
|
+case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,A,y,x=new THREE.Matrix4,s,G=new Float32Array(16),N=new Float32Array(16),K=new Float32Array(16),J=new Float32Array(9),O=new Float32Array(16);a=function(e,m){if(e){var f,p,l,j=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=e.lights.length;f<p;f++){l=e.lights[f];l instanceof THREE.DirectionalLight&&j++;l instanceof
|
|
|
|
+THREE.PointLight&&pointLights++}if(pointLights+j<=m){maxDirLights=j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*j/(pointLights+j));maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a,4);this.domElement=n;this.autoClear=true;try{c=n.getContext("experimental-webgl",{antialias:true})}catch(E){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
|
|
|
|
+c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);A=y=function(e,m){var f=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
|
|
|
|
+"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
|
|
+e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",m?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
|
+"",m?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",m?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",m?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
|
|
|
|
+p=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
|
+e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
|
+m?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",m?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",m?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",m?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",m?"float pointSpecularWeight = 0.0;":"",m?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
|
+"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
|
+"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;":
|
|
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
|
|
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
|
|
-f=b(p,f);c.useProgram(f);j(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);g&&j(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&j(f,["pointLightNumber","pointLightColor",
|
|
|
|
-"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);n(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(g,l){m.width=g;m.height=l;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(g,l){var f,p,h,i,u,t=[],
|
|
|
|
-G=[],z=[];i=[];u=[];c.uniform1i(g.uniforms.enableLighting,l.length);f=0;for(p=l.length;f<p;f++){h=l[f];if(h instanceof THREE.AmbientLight)t.push(h);else if(h instanceof THREE.DirectionalLight)z.push(h);else h instanceof THREE.PointLight&&G.push(h)}f=h=i=u=0;for(p=t.length;f<p;f++){h+=t[f].color.r;i+=t[f].color.g;u+=t[f].color.b}c.uniform3f(g.uniforms.ambientLightColor,h,i,u);i=[];u=[];f=0;for(p=z.length;f<p;f++){h=z[f];i.push(h.color.r*h.intensity);i.push(h.color.g*h.intensity);i.push(h.color.b*h.intensity);
|
|
|
|
-u.push(h.position.x);u.push(h.position.y);u.push(h.position.z)}if(z.length){c.uniform1i(g.uniforms.directionalLightNumber,z.length);c.uniform3fv(g.uniforms.directionalLightDirection,u);c.uniform3fv(g.uniforms.directionalLightColor,i)}i=[];u=[];f=0;for(p=G.length;f<p;f++){h=G[f];i.push(h.color.r*h.intensity);i.push(h.color.g*h.intensity);i.push(h.color.b*h.intensity);u.push(h.position.x);u.push(h.position.y);u.push(h.position.z)}if(G.length){c.uniform1i(g.uniforms.pointLightNumber,G.length);c.uniform3fv(g.uniforms.pointLightPosition,
|
|
|
|
-u);c.uniform3fv(g.uniforms.pointLightColor,i)}};this.createBuffers=function(g,l){var f,p,h,i,u,t,G,z,H,Q=[],C=[],O=[],D=[],R=[],S=[],I=0,v=g.geometry.geometryChunks[l],B;h=false;f=0;for(p=g.material.length;f<p;f++){meshMaterial=g.material[f];if(meshMaterial instanceof THREE.MeshFaceMaterial){u=0;for(B=v.material.length;u<B;u++)if(v.material[u]&&v.material[u].shading!=undefined&&v.material[u].shading==THREE.SmoothShading){h=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
|
|
|
-THREE.SmoothShading){h=true;break}if(h)break}B=h;f=0;for(p=v.faces.length;f<p;f++){h=v.faces[f];i=g.geometry.faces[h];u=i.vertexNormals;faceNormal=i.normal;h=g.geometry.uvs[h];if(i instanceof THREE.Face3){t=g.geometry.vertices[i.a].position;G=g.geometry.vertices[i.b].position;z=g.geometry.vertices[i.c].position;O.push(t.x,t.y,t.z);O.push(G.x,G.y,G.z);O.push(z.x,z.y,z.z);if(g.geometry.hasTangents){t=g.geometry.vertices[i.a].tangent;G=g.geometry.vertices[i.b].tangent;z=g.geometry.vertices[i.c].tangent;
|
|
|
|
-R.push(t.x,t.y,t.z,t.w);R.push(G.x,G.y,G.z,G.w);R.push(z.x,z.y,z.z,z.w)}if(u.length==3&&B)for(i=0;i<3;i++)D.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<3;i++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(h)for(i=0;i<3;i++)S.push(h[i].u,h[i].v);Q.push(I,I+1,I+2);C.push(I,I+1);C.push(I,I+2);C.push(I+1,I+2);I+=3}else if(i instanceof THREE.Face4){t=g.geometry.vertices[i.a].position;G=g.geometry.vertices[i.b].position;z=g.geometry.vertices[i.c].position;H=g.geometry.vertices[i.d].position;O.push(t.x,
|
|
|
|
-t.y,t.z);O.push(G.x,G.y,G.z);O.push(z.x,z.y,z.z);O.push(H.x,H.y,H.z);if(g.geometry.hasTangents){t=g.geometry.vertices[i.a].tangent;G=g.geometry.vertices[i.b].tangent;z=g.geometry.vertices[i.c].tangent;i=g.geometry.vertices[i.d].tangent;R.push(t.x,t.y,t.z,t.w);R.push(G.x,G.y,G.z,G.w);R.push(z.x,z.y,z.z,z.w);R.push(i.x,i.y,i.z,i.w)}if(u.length==4&&B)for(i=0;i<4;i++)D.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<4;i++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(h)for(i=0;i<4;i++)S.push(h[i].u,h[i].v);
|
|
|
|
-Q.push(I,I+1,I+2);Q.push(I,I+2,I+3);C.push(I,I+1);C.push(I,I+2);C.push(I,I+3);C.push(I+1,I+2);C.push(I+2,I+3);I+=4}}if(O.length){v.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(O),c.STATIC_DRAW);v.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);if(g.geometry.hasTangents){v.__webGLTangentBuffer=c.createBuffer();
|
|
|
|
-c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}if(S.length>0){v.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW)}v.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);v.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
|
|
|
-v.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),c.STATIC_DRAW);v.__webGLFaceCount=Q.length;v.__webGLLineCount=C.length}};this.renderBuffer=function(g,l,f,p){var h,i,u,t,G,z,H,Q,C;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(C in f.uniforms)H.push(C);j(f.program,H);n(f.program,["position","normal","uv","tangent"])}C=
|
|
|
|
-f.program}else C=y;if(C!=A){c.useProgram(C);A=C}C==y&&this.setupLights(C,l);this.loadCamera(C,g);this.loadMatrices(C);if(f instanceof THREE.MeshShaderMaterial){u=f.wireframe;t=f.wireframe_linewidth;g=C;l=f.uniforms;var O;for(h in l){Q=l[h].type;H=l[h].value;O=g.uniforms[h];if(Q=="i")c.uniform1i(O,H);else if(Q=="f")c.uniform1f(O,H);else if(Q=="v3")c.uniform3f(O,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(O,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(O,H);if(Q=l[h].texture)Q.image instanceof Array&&Q.image.length==
|
|
|
|
-6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){h=f.color;i=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;G=f.map;z=f.env_map;l=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(C.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(C.uniforms.mixEnvMap,l);c.uniform1f(C.uniforms.mReflectivity,g);c.uniform1i(C.uniforms.useRefract,
|
|
|
|
-Q);c.uniform1f(C.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(C.uniforms.mOpacity,i);c.uniform1i(C.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;c.uniform1f(C.uniforms.mOpacity,i);c.uniform1f(C.uniforms.m2Near,f.__2near);c.uniform1f(C.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(C.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(C.uniforms.material,3)}else if(f instanceof
|
|
|
|
-THREE.MeshPhongMaterial){h=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(C.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(C.uniforms.mSpecular,g.r,g.g,g.b,i);c.uniform1f(C.uniforms.mShininess,f);c.uniform1i(C.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(C.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(C.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(C.uniforms.material,5);z=f.env_map}if(G){e(G,0);c.uniform1i(C.uniforms.tMap,
|
|
|
|
-0);c.uniform1i(C.uniforms.enableMap,1)}else c.uniform1i(C.uniforms.enableMap,0);if(z){d(z,1);c.uniform1i(C.uniforms.tCube,1);c.uniform1i(C.uniforms.enableCubeMap,1)}else c.uniform1i(C.uniforms.enableCubeMap,0);i=C.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
|
|
|
|
-c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(u){c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
|
|
|
|
-0)}};this.renderPass=function(g,l,f,p,h,i){var u,t,G,z,H;G=0;for(z=f.material.length;G<z;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(t=p.material.length;u<t;u++)if((H=p.material[u])&&H.blending==h&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}else if((H=u)&&H.blending==h&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}};this.render=function(g,l){var f,p,h,i,u=g.lights;this.initWebGLObjects(g);this.autoClear&&this.clear();
|
|
|
|
-l.autoUpdateMatrix&&l.updateMatrix();E.set(l.matrix.flatten());P.set(l.projectionMatrix.flatten());f=0;for(p=g.__webGLObjects.length;f<p;f++){h=g.__webGLObjects[f];i=h.object;h=h.buffer;if(i.visible){this.setupMatrices(i,l);this.renderPass(l,u,i,h,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){h=g.__webGLObjects[f];i=h.object;h=h.buffer;if(i.visible){this.setupMatrices(i,l);this.renderPass(l,u,i,h,THREE.AdditiveBlending,false);this.renderPass(l,u,i,h,THREE.SubtractiveBlending,
|
|
|
|
-false);this.renderPass(l,u,i,h,THREE.AdditiveBlending,true);this.renderPass(l,u,i,h,THREE.SubtractiveBlending,true);this.renderPass(l,u,i,h,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(g){var l,f,p,h,i,u;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}l=0;for(f=g.objects.length;l<f;l++){p=g.objects[l];if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};u=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(i in p.geometry.geometryChunks){h=p.geometry.geometryChunks[i];
|
|
|
|
-h.__webGLVertexBuffer||this.createBuffers(p,i);if(u[i]==undefined){h={buffer:h,object:p};g.__webGLObjects.push(h);u[i]=1}}}};this.removeObject=function(g,l){var f,p;for(f=g.__webGLObjects.length-1;f>=0;f--){p=g.__webGLObjects[f].object;l==p&&g.__webGLObjects.splice(f,1)}};this.setupMatrices=function(g,l){g.autoUpdateMatrix&&g.updateMatrix();s.multiply(l.matrix,g.matrix);M.set(s.flatten());r=THREE.Matrix4.makeInvert3x3(s).transpose();J.set(r.m);K.set(g.matrix.flatten())};this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,
|
|
|
|
-false,E);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,P);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,l){c.uniform3f(g.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
|
|
|
|
-c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,l){if(g){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
|
|
|
|
|
+f=b(p,f);c.useProgram(f);i(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&i(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(f,["pointLightNumber","pointLightColor",
|
|
|
|
+"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);q(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(e,m){n.width=e;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var f,p,l,j,o,C=[],
|
|
|
|
+v=[],t=[];j=[];o=[];c.uniform1i(e.uniforms.enableLighting,m.length);f=0;for(p=m.length;f<p;f++){l=m[f];if(l instanceof THREE.AmbientLight)C.push(l);else if(l instanceof THREE.DirectionalLight)t.push(l);else l instanceof THREE.PointLight&&v.push(l)}f=l=j=o=0;for(p=C.length;f<p;f++){l+=C[f].color.r;j+=C[f].color.g;o+=C[f].color.b}c.uniform3f(e.uniforms.ambientLightColor,l,j,o);j=[];o=[];f=0;for(p=t.length;f<p;f++){l=t[f];j.push(l.color.r*l.intensity);j.push(l.color.g*l.intensity);j.push(l.color.b*l.intensity);
|
|
|
|
+o.push(l.position.x);o.push(l.position.y);o.push(l.position.z)}if(t.length){c.uniform1i(e.uniforms.directionalLightNumber,t.length);c.uniform3fv(e.uniforms.directionalLightDirection,o);c.uniform3fv(e.uniforms.directionalLightColor,j)}j=[];o=[];f=0;for(p=v.length;f<p;f++){l=v[f];j.push(l.color.r*l.intensity);j.push(l.color.g*l.intensity);j.push(l.color.b*l.intensity);o.push(l.position.x);o.push(l.position.y);o.push(l.position.z)}if(v.length){c.uniform1i(e.uniforms.pointLightNumber,v.length);c.uniform3fv(e.uniforms.pointLightPosition,
|
|
|
|
+o);c.uniform3fv(e.uniforms.pointLightColor,j)}};this.createBuffers=function(e,m){var f,p,l,j,o,C,v,t,I,B=[],F=[],U=[],P=[],W=[],T=[],D=0,r=e.geometry.geometryChunks[m],w;l=false;f=0;for(p=e.material.length;f<p;f++){meshMaterial=e.material[f];if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(w=r.material.length;o<w;o++)if(r.material[o]&&r.material[o].shading!=undefined&&r.material[o].shading==THREE.SmoothShading){l=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
|
|
|
+THREE.SmoothShading){l=true;break}if(l)break}w=l;f=0;for(p=r.faces.length;f<p;f++){l=r.faces[f];j=e.geometry.faces[l];o=j.vertexNormals;faceNormal=j.normal;l=e.geometry.uvs[l];if(j instanceof THREE.Face3){C=e.geometry.vertices[j.a].position;v=e.geometry.vertices[j.b].position;t=e.geometry.vertices[j.c].position;U.push(C.x,C.y,C.z);U.push(v.x,v.y,v.z);U.push(t.x,t.y,t.z);if(e.geometry.hasTangents){C=e.geometry.vertices[j.a].tangent;v=e.geometry.vertices[j.b].tangent;t=e.geometry.vertices[j.c].tangent;
|
|
|
|
+W.push(C.x,C.y,C.z,C.w);W.push(v.x,v.y,v.z,v.w);W.push(t.x,t.y,t.z,t.w)}if(o.length==3&&w)for(j=0;j<3;j++)P.push(o[j].x,o[j].y,o[j].z);else for(j=0;j<3;j++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(l)for(j=0;j<3;j++)T.push(l[j].u,l[j].v);B.push(D,D+1,D+2);F.push(D,D+1);F.push(D,D+2);F.push(D+1,D+2);D+=3}else if(j instanceof THREE.Face4){C=e.geometry.vertices[j.a].position;v=e.geometry.vertices[j.b].position;t=e.geometry.vertices[j.c].position;I=e.geometry.vertices[j.d].position;U.push(C.x,
|
|
|
|
+C.y,C.z);U.push(v.x,v.y,v.z);U.push(t.x,t.y,t.z);U.push(I.x,I.y,I.z);if(e.geometry.hasTangents){C=e.geometry.vertices[j.a].tangent;v=e.geometry.vertices[j.b].tangent;t=e.geometry.vertices[j.c].tangent;j=e.geometry.vertices[j.d].tangent;W.push(C.x,C.y,C.z,C.w);W.push(v.x,v.y,v.z,v.w);W.push(t.x,t.y,t.z,t.w);W.push(j.x,j.y,j.z,j.w)}if(o.length==4&&w)for(j=0;j<4;j++)P.push(o[j].x,o[j].y,o[j].z);else for(j=0;j<4;j++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(l)for(j=0;j<4;j++)T.push(l[j].u,l[j].v);
|
|
|
|
+B.push(D,D+1,D+2);B.push(D,D+2,D+3);F.push(D,D+1);F.push(D,D+2);F.push(D,D+3);F.push(D+1,D+2);F.push(D+2,D+3);D+=4}}if(U.length){r.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW);r.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,r.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);if(e.geometry.hasTangents){r.__webGLTangentBuffer=c.createBuffer();
|
|
|
|
+c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}if(T.length>0){r.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}r.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(B),c.STATIC_DRAW);r.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
|
|
|
+r.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);r.__webGLFaceCount=B.length;r.__webGLLineCount=F.length}};this.renderBuffer=function(e,m,f,p){var l,j,o,C,v,t,I,B,F;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in f.uniforms)I.push(F);i(f.program,I);q(f.program,["position","normal","uv","tangent"])}F=
|
|
|
|
+f.program}else F=y;if(F!=A){c.useProgram(F);A=F}F==y&&this.setupLights(F,m);this.loadCamera(F,e);this.loadMatrices(F);if(f instanceof THREE.MeshShaderMaterial){o=f.wireframe;C=f.wireframe_linewidth;e=F;m=f.uniforms;var U;for(l in m){B=m[l].type;I=m[l].value;U=e.uniforms[l];if(B=="i")c.uniform1i(U,I);else if(B=="f")c.uniform1f(U,I);else if(B=="v3")c.uniform3f(U,I.x,I.y,I.z);else if(B=="c")c.uniform3f(U,I.r,I.g,I.b);else if(B=="t"){c.uniform1i(U,I);if(B=m[l].texture)B.image instanceof Array&&B.image.length==
|
|
|
|
+6?g(B,I):d(B,I)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){l=f.color;j=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;v=f.map;t=f.env_map;m=f.combine==THREE.MixOperation;e=f.reflectivity;B=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;I=f.refraction_ratio;c.uniform4f(F.uniforms.mColor,l.r*j,l.g*j,l.b*j,j);c.uniform1i(F.uniforms.mixEnvMap,m);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract,
|
|
|
|
+B);c.uniform1f(F.uniforms.mRefractionRatio,I)}if(f instanceof THREE.MeshNormalMaterial){j=f.opacity;c.uniform1f(F.uniforms.mOpacity,j);c.uniform1i(F.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){j=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;c.uniform1f(F.uniforms.mOpacity,j);c.uniform1f(F.uniforms.m2Near,f.__2near);c.uniform1f(F.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(F.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(F.uniforms.material,3)}else if(f instanceof
|
|
|
|
+THREE.MeshPhongMaterial){l=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(F.uniforms.mAmbient,l.r,l.g,l.b,j);c.uniform4f(F.uniforms.mSpecular,e.r,e.g,e.b,j);c.uniform1f(F.uniforms.mShininess,f);c.uniform1i(F.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(F.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(F.uniforms.material,5);t=f.env_map}if(v){d(v,0);c.uniform1i(F.uniforms.tMap,
|
|
|
|
+0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(t){g(t,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);j=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);if(j.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0)}if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
|
|
|
|
+c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(o){c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
|
|
|
|
+0)}};this.renderPass=function(e,m,f,p,l,j){var o,C,v,t,I;v=0;for(t=f.material.length;v<t;v++){o=f.material[v];if(o instanceof THREE.MeshFaceMaterial){o=0;for(C=p.material.length;o<C;o++)if((I=p.material[o])&&I.blending==l&&I.opacity<1==j){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}else if((I=o)&&I.blending==l&&I.opacity<1==j){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}};this.render=function(e,m){var f,p,l,j,o=e.lights;this.initWebGLObjects(e);this.autoClear&&this.clear();
|
|
|
|
+m.autoUpdateMatrix&&m.updateMatrix();G.set(m.matrix.flatten());K.set(m.projectionMatrix.flatten());f=0;for(p=e.__webGLObjects.length;f<p;f++){l=e.__webGLObjects[f];j=l.object;l=l.buffer;if(j.visible){this.setupMatrices(j,m);this.renderPass(m,o,j,l,THREE.NormalBlending,false)}}f=0;for(p=e.__webGLObjects.length;f<p;f++){l=e.__webGLObjects[f];j=l.object;l=l.buffer;if(j.visible){this.setupMatrices(j,m);this.renderPass(m,o,j,l,THREE.AdditiveBlending,false);this.renderPass(m,o,j,l,THREE.SubtractiveBlending,
|
|
|
|
+false);this.renderPass(m,o,j,l,THREE.AdditiveBlending,true);this.renderPass(m,o,j,l,THREE.SubtractiveBlending,true);this.renderPass(m,o,j,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,f,p,l,j,o;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}m=0;for(f=e.objects.length;m<f;m++){p=e.objects[m];if(e.__webGLObjectsMap[p.id]==undefined)e.__webGLObjectsMap[p.id]={};o=e.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(j in p.geometry.geometryChunks){l=p.geometry.geometryChunks[j];
|
|
|
|
+l.__webGLVertexBuffer||this.createBuffers(p,j);if(o[j]==undefined){l={buffer:l,object:p};e.__webGLObjects.push(l);o[j]=1}}}};this.removeObject=function(e,m){var f,p;for(f=e.__webGLObjects.length-1;f>=0;f--){p=e.__webGLObjects[f].object;m==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(m.matrix,e.matrix);N.set(x.flatten());s=THREE.Matrix4.makeInvert3x3(x).transpose();J.set(s.m);O.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,
|
|
|
|
+false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,O)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
|
|
|
|
+c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
|
THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
|
|
THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
|
|
THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
|
|
THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
|