mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-26 05:15:58 +10:00
Fixed Projector::projectObjects.
This commit is contained in:
+118
-118
@@ -1,61 +1,61 @@
|
||||
// Three.js r31 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
||||
THREE.Color.prototype={setRGB:function(a,b,f){this.r=a;this.g=b;this.b=f;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};
|
||||
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,f){this.x=a||0;this.y=b||0;this.z=f||0};
|
||||
THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;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,f=this.y,d=this.z;this.x=f*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-f*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,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+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+" )"}};
|
||||
THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1};
|
||||
THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;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;
|
||||
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+")"}};
|
||||
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,f,d=a.objects,i=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)i=i.concat(this.intersectObject(f))}i.sort(function(p,k){return p.distance-k.distance});return i},intersectObject:function(a){function b(R,D,K,F){F=F.clone().subSelf(D);K=K.clone().subSelf(D);var e=R.clone().subSelf(D);R=F.dot(F);D=F.dot(K);F=F.dot(e);var m=K.dot(K);K=K.dot(e);e=1/(R*m-D*D);m=(m*F-D*K)*e;R=(R*K-D*F)*e;return m>0&&R>0&&m+R<1}var f,d,i,p,k,l,n,c,C,A,
|
||||
y,r=a.geometry,G=r.vertices,M=[];f=0;for(d=r.faces.length;f<d;f++){i=r.faces[f];A=this.origin.clone();y=this.direction.clone();p=a.matrix.multiplyVector3(G[i.a].position.clone());k=a.matrix.multiplyVector3(G[i.b].position.clone());l=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());C=y.dot(c);if(C<0){c=c.dot((new THREE.Vector3).sub(p,A))/C;A=A.addSelf(y.multiplyScalar(c));
|
||||
if(i instanceof THREE.Face3){if(b(A,p,k,l)){i={distance:this.origin.distanceTo(A),point:A,face:i,object:a};M.push(i)}}else if(i instanceof THREE.Face4)if(b(A,p,k,n)||b(A,k,l,n)){i={distance:this.origin.distanceTo(A),point:A,face:i,object:a};M.push(i)}}}return M}};
|
||||
THREE.Rectangle=function(){function a(){p=d-b;k=i-f}var b,f,d,i,p,k,l=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return p};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return i};this.set=function(n,c,C,A){l=false;b=n;f=c;d=C;i=A;a()};this.addPoint=function(n,c){if(l){l=false;b=n;f=c;d=n;i=c}else{b=b<n?b:n;f=f<c?f:c;d=d>n?d:n;i=i>c?
|
||||
i:c}a()};this.add3Points=function(n,c,C,A,y,r){if(l){l=false;b=n<C?n<y?n:y:C<y?C:y;f=c<A?c<r?c:r:A<r?A:r;d=n>C?n>y?n:y:C>y?C:y;i=c>A?c>r?c:r:A>r?A:r}else{b=n<C?n<y?n<b?n:b:y<b?y:b:C<y?C<b?C:b:y<b?y:b;f=c<A?c<r?c<f?c:f:r<f?r:f:A<r?A<f?A:f:r<f?r:f;d=n>C?n>y?n>d?n:d:y>d?y:d:C>y?C>d?C:d:y>d?y:d;i=c>A?c>r?c>i?c:i:r>i?r:i:A>r?A>i?A:i:r>i?r:i}a()};this.addRectangle=function(n){if(l){l=false;b=n.getLeft();f=n.getTop();d=n.getRight();i=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();f=f<n.getTop()?f:n.getTop();
|
||||
d=d>n.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;f-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();f=f>n.getTop()?f: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(f,n.getTop())>=0};this.empty=function(){l=true;i=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+p+", 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,f,d,i,p,k,l,n,c,C,A,y,r,G,M){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=p||1;this.n23=k||0;this.n24=l||0;this.n31=n||0;this.n32=c||0;this.n33=C||1;this.n34=A||0;this.n41=y||0;this.n42=r||0;this.n43=G||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,f,d,i,p,k,l,n,c,C,A,y,r,G,M){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=p;this.n23=k;this.n24=l;this.n31=n;this.n32=c;this.n33=C;this.n34=A;this.n41=y;this.n42=r;this.n43=G;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,f){var d=new THREE.Vector3,i=new THREE.Vector3,p=new THREE.Vector3;p.sub(a,b).normalize();d.cross(f,p).normalize();i.cross(p,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=p.x;
|
||||
this.n32=p.y;this.n33=p.z;this.n34=-p.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
|
||||
i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+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 f=a.n11,d=a.n12,i=a.n13,p=a.n14,k=a.n21,l=a.n22,n=a.n23,c=a.n24,C=a.n31,A=a.n32,
|
||||
y=a.n33,r=a.n34,G=a.n41,M=a.n42,R=a.n43,D=a.n44,K=b.n11,F=b.n12,e=b.n13,m=b.n14,g=b.n21,q=b.n22,j=b.n23,h=b.n24,u=b.n31,x=b.n32,E=b.n33,o=b.n34,z=b.n41,P=b.n42,t=b.n43,U=b.n44;this.n11=f*K+d*g+i*u+p*z;this.n12=f*F+d*q+i*x+p*P;this.n13=f*e+d*j+i*E+p*t;this.n14=f*m+d*h+i*o+p*U;this.n21=k*K+l*g+n*u+c*z;this.n22=k*F+l*q+n*x+c*P;this.n23=k*e+l*j+n*E+c*t;this.n24=k*m+l*h+n*o+c*U;this.n31=C*K+A*g+y*u+r*z;this.n32=C*F+A*q+y*x+r*P;this.n33=C*e+A*j+y*E+r*t;this.n34=C*m+A*h+y*o+r*U;this.n41=G*K+M*g+R*u+D*z;
|
||||
this.n42=G*F+M*q+R*x+D*P;this.n43=G*e+M*j+R*E+D*t;this.n44=G*m+M*h+R*o+D*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,p=this.n21,k=this.n22,l=this.n23,n=this.n24,c=this.n31,C=this.n32,A=this.n33,y=this.n34,r=this.n41,G=this.n42,M=this.n43,R=this.n44,D=a.n11,K=a.n21,F=a.n31,e=a.n41,m=a.n12,g=a.n22,q=a.n32,j=a.n42,h=a.n13,u=a.n23,x=a.n33,E=a.n43,o=a.n14,z=a.n24,P=a.n34;a=a.n44;this.n11=b*D+f*K+d*F+i*e;this.n12=b*m+f*g+d*q+i*j;this.n13=b*h+f*u+d*x+i*E;this.n14=
|
||||
b*o+f*z+d*P+i*a;this.n21=p*D+k*K+l*F+n*e;this.n22=p*m+k*g+l*q+n*j;this.n23=p*h+k*u+l*x+n*E;this.n24=p*o+k*z+l*P+n*a;this.n31=c*D+C*K+A*F+y*e;this.n32=c*m+C*g+A*q+y*j;this.n33=c*h+C*u+A*x+y*E;this.n34=c*o+C*z+A*P+y*a;this.n41=r*D+G*K+M*F+R*e;this.n42=r*m+G*g+M*q+R*j;this.n43=r*h+G*u+M*x+R*E;this.n44=r*o+G*z+M*P+R*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,h=[];a=0;for(b=d.length;a<b;a++){g=d[a];if(g instanceof THREE.Mesh)h=h.concat(this.intersectObject(g))}h.sort(function(q,j){return q.distance-j.distance});return h},intersectObject:function(a){function b(K,J,O,D){D=D.clone().subSelf(J);O=O.clone().subSelf(J);var e=K.clone().subSelf(J);K=D.dot(D);J=D.dot(O);D=D.dot(e);var m=O.dot(O);O=O.dot(e);e=1/(K*m-J*J);m=(m*D-J*O)*e;K=(K*O-J*D)*e;return m>0&&K>0&&m+K<1}var g,d,h,q,j,l,n,c,A,y,
|
||||
x,s=a.geometry,G=s.vertices,N=[];g=0;for(d=s.faces.length;g<d;g++){h=s.faces[g];y=this.origin.clone();x=this.direction.clone();q=a.matrix.multiplyVector3(G[h.a].position.clone());j=a.matrix.multiplyVector3(G[h.b].position.clone());l=a.matrix.multiplyVector3(G[h.c].position.clone());n=h instanceof THREE.Face4?a.matrix.multiplyVector3(G[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.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(h instanceof THREE.Face3){if(b(y,q,j,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};N.push(h)}}else if(h instanceof THREE.Face4)if(b(y,q,j,n)||b(y,j,l,n)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};N.push(h)}}}return N}};
|
||||
THREE.Rectangle=function(){function a(){q=d-b;j=h-g}var b,g,d,h,q,j,l=true;this.getX=function(){return b};this.getY=function(){return g};this.getWidth=function(){return q};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return g};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(n,c,A,y){l=false;b=n;g=c;d=A;h=y;a()};this.addPoint=function(n,c){if(l){l=false;b=n;g=c;d=n;h=c}else{b=b<n?b:n;g=g<c?g:c;d=d>n?d:n;h=h>c?
|
||||
h:c}a()};this.add3Points=function(n,c,A,y,x,s){if(l){l=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;h=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;h=c>y?c>s?c>h?c:h:s>h?s:h:y>s?y>h?y:h:s>h?s:h}a()};this.addRectangle=function(n){if(l){l=false;b=n.getLeft();g=n.getTop();d=n.getRight();h=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();g=g<n.getTop()?g:n.getTop();
|
||||
d=d>n.getRight()?d:n.getRight();h=h>n.getBottom()?h:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;h+=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();h=h<n.getBottom()?h:n.getBottom();a()};this.instersects=function(n){return Math.min(d,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(h,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){l=true;h=d=g=b=0;a()};this.isEmpty=function(){return l};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+h+", width: "+q+", height: "+j+" )"}};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,h,q,j,l,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=h||0;this.n22=q||1;this.n23=j||0;this.n24=l||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,h,q,j,l,n,c,A,y,x,s,G,N){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=h;this.n22=q;this.n23=j;this.n24=l;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,h=new THREE.Vector3,q=new THREE.Vector3;q.sub(a,b).normalize();d.cross(g,q).normalize();h.cross(q,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.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,h=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)*h;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24*
|
||||
h;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*h;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,h=a.n13,q=a.n14,j=a.n21,l=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,D=b.n12,e=b.n13,m=b.n14,f=b.n21,p=b.n22,k=b.n23,i=b.n24,o=b.n31,C=b.n32,u=b.n33,t=b.n34,I=b.n41,B=b.n42,E=b.n43,U=b.n44;this.n11=g*O+d*f+h*o+q*I;this.n12=g*D+d*p+h*C+q*B;this.n13=g*e+d*k+h*u+q*E;this.n14=g*m+d*i+h*t+q*U;this.n21=j*O+l*f+n*o+c*I;this.n22=j*D+l*p+n*C+c*B;this.n23=j*e+l*k+n*u+c*E;this.n24=j*m+l*i+n*t+c*U;this.n31=A*O+y*f+x*o+s*I;this.n32=A*D+y*p+x*C+s*B;this.n33=A*e+y*k+x*u+s*E;this.n34=A*m+y*i+x*t+s*U;this.n41=G*O+N*f+K*o+J*I;
|
||||
this.n42=G*D+N*p+K*C+J*B;this.n43=G*e+N*k+K*u+J*E;this.n44=G*m+N*i+K*t+J*U;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,h=this.n14,q=this.n21,j=this.n22,l=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,D=a.n31,e=a.n41,m=a.n12,f=a.n22,p=a.n32,k=a.n42,i=a.n13,o=a.n23,C=a.n33,u=a.n43,t=a.n14,I=a.n24,B=a.n34;a=a.n44;this.n11=b*J+g*O+d*D+h*e;this.n12=b*m+g*f+d*p+h*k;this.n13=b*i+g*o+d*C+h*u;this.n14=
|
||||
b*t+g*I+d*B+h*a;this.n21=q*J+j*O+l*D+n*e;this.n22=q*m+j*f+l*p+n*k;this.n23=q*i+j*o+l*C+n*u;this.n24=q*t+j*I+l*B+n*a;this.n31=c*J+A*O+y*D+x*e;this.n32=c*m+A*f+y*p+x*k;this.n33=c*i+A*o+y*C+x*u;this.n34=c*t+A*I+y*B+x*a;this.n41=s*J+G*O+N*D+K*e;this.n42=s*m+G*f+N*p+K*k;this.n43=s*i+G*o+N*C+K*u;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*
|
||||
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,f,d){var i=b[f];b[f]=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,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
|
||||
THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;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 f=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),p=1-d,k=a.x,l=a.y,n=a.z;f.n11=p*k*k+d;f.n12=p*k*l-i*n;f.n13=p*k*n+i*l;f.n21=p*k*l+i*n;f.n22=p*l*l+d;f.n23=p*l*n-i*k;f.n31=p*k*n-i*l;f.n32=p*l*n+i*k;f.n33=p*n*n+d;return f};
|
||||
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 h=b[g];b[g]=b[d];
|
||||
b[d]=h}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),h=Math.sin(b),q=1-d,j=a.x,l=a.y,n=a.z;g.n11=q*j*j+d;g.n12=q*j*l-h*n;g.n13=q*j*n+h*l;g.n21=q*j*l+h*n;g.n22=q*l*l+d;g.n23=q*l*n-h*j;g.n31=q*j*n-h*l;g.n32=q*l*n+h*j;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*
|
||||
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.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 f=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],p=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],l=-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],C=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*p+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*p;a.m[4]=b*k;a.m[5]=b*l;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*C;return a};
|
||||
THREE.Matrix4.makeFrustum=function(a,b,f,d,i,p){var k,l,n;k=new THREE.Matrix4;l=2*i/(b-a);n=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(p+i)/(p-i);i=-2*p*i/(p-i);k.n11=l;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=n;k.n23=f;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,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)};
|
||||
THREE.Matrix4.makeOrtho=function(a,b,f,d,i,p){var k,l,n,c;k=new THREE.Matrix4;l=b-a;n=f-d;c=p-i;a=(b+a)/l;f=(f+d)/n;i=(p+i)/c;k.n11=2/l;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/n;k.n23=0;k.n24=-f;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.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],h=b[6]*b[1]-b[2]*b[5],q=-b[10]*b[4]+b[6]*b[8],j=b[10]*b[0]-b[2]*b[8],l=-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*h;a.m[3]=b*q;a.m[4]=b*j;a.m[5]=b*l;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,h,q){var j,l,n;j=new THREE.Matrix4;l=2*h/(b-a);n=2*h/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(q+h)/(q-h);h=-2*q*h/(q-h);j.n11=l;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=n;j.n23=g;j.n24=0;j.n31=0;j.n32=0;j.n33=d;j.n34=h;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,g,d){var h;a=g*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,g,d)};
|
||||
THREE.Matrix4.makeOrtho=function(a,b,g,d,h,q){var j,l,n,c;j=new THREE.Matrix4;l=b-a;n=g-d;c=q-h;a=(b+a)/l;g=(g+d)/n;h=(q+h)/c;j.n11=2/l;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/n;j.n23=0;j.n24=-g;j.n31=0;j.n32=0;j.n33=-2/c;j.n34=-h;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};
|
||||
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,f,d,i){this.a=a;this.b=b;this.c=f;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,f,d,i,p){this.a=a;this.b=b;this.c=f;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=p instanceof Array?p:[p]};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,h){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=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
||||
THREE.Face4=function(a,b,g,d,h,q){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];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.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
|
||||
f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,i,p,k,l=new THREE.Vector3,n=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){p=this.vertices[d];p.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;d++){p=this.faces[d];if(a&&p.vertexNormals.length){l.set(0,0,0);b=0;for(f=p.normal.length;b<f;b++)l.addSelf(p.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[p.a];f=this.vertices[p.b];k=this.vertices[p.c];l.sub(k.position,
|
||||
f.position);n.sub(b.position,f.position);l.crossSelf(n)}l.isZero()||l.normalize();p.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;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(f=this.faces.length;a<f;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(o,z,P,t){p=o.vertices[z].position;k=o.vertices[P].position;
|
||||
l=o.vertices[t].position;n=i[0];c=i[1];C=i[2];A=k.x-p.x;y=l.x-p.x;r=k.y-p.y;G=l.y-p.y;M=k.z-p.z;R=l.z-p.z;D=c.u-n.u;K=C.u-n.u;F=c.v-n.v;e=C.v-n.v;m=1/(D*e-K*F);h.set((e*A-F*y)*m,(e*r-F*G)*m,(e*M-F*R)*m);u.set((D*y-K*A)*m,(D*G-K*r)*m,(D*R-K*M)*m);q[z].addSelf(h);q[P].addSelf(h);q[t].addSelf(h);j[z].addSelf(u);j[P].addSelf(u);j[t].addSelf(u)}var b,f,d,i,p,k,l,n,c,C,A,y,r,G,M,R,D,K,F,e,m,g,q=[],j=[],h=new THREE.Vector3,u=new THREE.Vector3,x=new THREE.Vector3,E=new THREE.Vector3;g=new THREE.Vector3;b=
|
||||
0;for(f=this.vertices.length;b<f;b++){q[b]=new THREE.Vector3;j[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;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(f=this.vertices.length;b<f;b++){g.copy(this.vertices[b].normal);d=q[b];x.copy(d);x.subSelf(g.multiplyScalar(g.dot(d))).normalize();E.cross(this.vertices[b].normal,d);test=E.dot(j[b]);d=test<0?-1:1;this.vertices[b].tangent.set(x.x,x.y,x.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],
|
||||
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,h,q,j,l=new THREE.Vector3,n=new THREE.Vector3;d=0;for(h=this.vertices.length;d<h;d++){q=this.vertices[d];q.normal.set(0,0,0)}d=0;for(h=this.faces.length;d<h;d++){q=this.faces[d];if(a&&q.vertexNormals.length){l.set(0,0,0);b=0;for(g=q.normal.length;b<g;b++)l.addSelf(q.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[q.a];g=this.vertices[q.b];j=this.vertices[q.c];l.sub(j.position,
|
||||
g.position);n.sub(b.position,g.position);l.crossSelf(n)}l.isZero()||l.normalize();q.normal.copy(l)}},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,E){q=t.vertices[I].position;j=t.vertices[B].position;
|
||||
l=t.vertices[E].position;n=h[0];c=h[1];A=h[2];y=j.x-q.x;x=l.x-q.x;s=j.y-q.y;G=l.y-q.y;N=j.z-q.z;K=l.z-q.z;J=c.u-n.u;O=A.u-n.u;D=c.v-n.v;e=A.v-n.v;m=1/(J*e-O*D);i.set((e*y-D*x)*m,(e*s-D*G)*m,(e*N-D*K)*m);o.set((J*x-O*y)*m,(J*G-O*s)*m,(J*K-O*N)*m);p[I].addSelf(i);p[B].addSelf(i);p[E].addSelf(i);k[I].addSelf(o);k[B].addSelf(o);k[E].addSelf(o)}var b,g,d,h,q,j,l,n,c,A,y,x,s,G,N,K,J,O,D,e,m,f,p=[],k=[],i=new THREE.Vector3,o=new THREE.Vector3,C=new THREE.Vector3,u=new THREE.Vector3;f=new THREE.Vector3;b=
|
||||
0;for(g=this.vertices.length;b<g;b++){p[b]=new THREE.Vector3;k[b]=new THREE.Vector3}b=0;for(g=this.faces.length;b<g;b++){d=this.faces[b];h=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();u.cross(this.vertices[b].normal,d);test=u.dot(k[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]=
|
||||
vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(C){var A=[];b=0;for(f=C.length;b<f;b++)C[b]==undefined?A.push("undefined"):A.push(C[b].toString());return A.join("_")}var b,f,d,i,p,k,l,n,c={};d=0;for(i=this.faces.length;d<i;d++){p=this.faces[d];k=p.material;l=a(k);if(c[l]==undefined)c[l]={hash:l,counter:0};n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:k,
|
||||
vertices:0};p=p instanceof THREE.Face3?3:4;if(this.geometryChunks[n].vertices+p>65535){c[l].counter+=1;n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:k,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=p}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
||||
THREE.Camera=function(a,b,f,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,f,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;
|
||||
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,h,q,j,l,n,c={};d=0;for(h=this.faces.length;d<h;d++){q=this.faces[d];j=q.material;l=a(j);if(c[l]==undefined)c[l]={hash:l,counter:0};n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:j,
|
||||
vertices:0};q=q instanceof THREE.Face3?3:4;if(this.geometryChunks[n].vertices+q>65535){c[l].counter+=1;n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:j,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(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
|
||||
this.position.subSelf(h);this.target.position.subSelf(h)};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.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};
|
||||
@@ -85,93 +85,93 @@ 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: "+
|
||||
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.Texture=function(a,b,f,d,i,p){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=p!==undefined?p: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,h,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=h!==undefined?h: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(){};
|
||||
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.Projector=function(){function a(q,j){var h=0,u=1,x=q.z+q.w,E=j.z+j.w,o=-q.z+q.w,z=-j.z+j.w;if(x>=0&&E>=0&&o>=0&&z>=0)return true;else if(x<0&&E<0||o<0&&z<0)return false;else{if(x<0)h=Math.max(h,x/(x-E));else if(E<0)u=Math.min(u,x/(x-E));if(o<0)h=Math.max(h,o/(o-z));else if(z<0)u=Math.min(u,o/(o-z));if(u<h)return false;else{q.lerpSelf(j,h);j.lerpSelf(q,1-u);return true}}}function b(q,j){return j.z-q.z}var f=null,d,i,p=[],k,l,n,c=[],C,A,y=[],r,G,M=[],R=new THREE.Vector3,D=new THREE.Vector4,K=
|
||||
new THREE.Matrix4,F=new THREE.Matrix4,e=new THREE.Vector4,m=new THREE.Vector4,g;this.projectObjects=function(q){var j,h,u;f=[];i=0;h=q.objects;q=0;for(j=h.length;q<j;q++){u=h[q];if(u.visible!==false){d=p[i]=p[i]||new THREE.RenderableObject;D.copy(u.position);K.multiplyVector4(D);D.multiplyScalar(1/D.w);d.object=u;d.z=R.z;f.push(d);i++}}f.sort(b);return f};this.projectScene=function(q,j){var h,u,x,E,o,z,P,t,U,O,X,V,I,w,s,N,S;f=[];n=A=G=0;j.autoUpdateMatrix&&j.updateMatrix();K.multiply(j.projectionMatrix,
|
||||
j.matrix);P=q.objects;h=0;for(u=P.length;h<u;h++){t=P[h];if(t.visible!==false){t.autoUpdateMatrix&&t.updateMatrix();U=t.matrix;O=t.rotationMatrix;X=t.material;V=t.overdraw;if(t instanceof THREE.Mesh){I=t.geometry;w=I.vertices;x=0;for(E=w.length;x<E;x++){s=w[x];s.positionWorld.copy(s.position);U.multiplyVector3(s.positionWorld);o=s.positionScreen;o.copy(s.positionWorld);K.multiplyVector4(o);o.multiplyScalar(1/o.w);s.__visible=o.z>0&&o.z<1}I=I.faces;x=0;for(E=I.length;x<E;x++){s=I[x];if(s instanceof
|
||||
THREE.Face3){o=w[s.a];z=w[s.b];N=w[s.c];if(o.__visible&&z.__visible&&N.__visible)if(t.doubleSided||t.flipSided!=(N.positionScreen.x-o.positionScreen.x)*(z.positionScreen.y-o.positionScreen.y)-(N.positionScreen.y-o.positionScreen.y)*(z.positionScreen.x-o.positionScreen.x)<0){k=c[n]=c[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(o.positionWorld);k.v2.positionWorld.copy(z.positionWorld);k.v3.positionWorld.copy(N.positionWorld);k.v1.positionScreen.copy(o.positionScreen);k.v2.positionScreen.copy(z.positionScreen);
|
||||
k.v3.positionScreen.copy(N.positionScreen);k.normalWorld.copy(s.normal);O.multiplyVector3(k.normalWorld);k.centroidWorld.copy(s.centroid);U.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);K.multiplyVector3(k.centroidScreen);N=s.vertexNormals;g=k.vertexNormalsWorld;o=0;for(z=N.length;o<z;o++){S=g[o]=g[o]||new THREE.Vector3;S.copy(N[o]);O.multiplyVector3(S)}k.z=k.centroidScreen.z;k.meshMaterial=X;k.faceMaterial=s.material;k.overdraw=V;if(t.geometry.uvs[x]){k.uvs[0]=t.geometry.uvs[x][0];
|
||||
k.uvs[1]=t.geometry.uvs[x][1];k.uvs[2]=t.geometry.uvs[x][2]}f.push(k);n++}}else if(s instanceof THREE.Face4){o=w[s.a];z=w[s.b];N=w[s.c];S=w[s.d];if(o.__visible&&z.__visible&&N.__visible&&S.__visible)if(t.doubleSided||t.flipSided!=((S.positionScreen.x-o.positionScreen.x)*(z.positionScreen.y-o.positionScreen.y)-(S.positionScreen.y-o.positionScreen.y)*(z.positionScreen.x-o.positionScreen.x)<0||(z.positionScreen.x-N.positionScreen.x)*(S.positionScreen.y-N.positionScreen.y)-(z.positionScreen.y-N.positionScreen.y)*
|
||||
(S.positionScreen.x-N.positionScreen.x)<0)){k=c[n]=c[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(o.positionWorld);k.v2.positionWorld.copy(z.positionWorld);k.v3.positionWorld.copy(S.positionWorld);k.v1.positionScreen.copy(o.positionScreen);k.v2.positionScreen.copy(z.positionScreen);k.v3.positionScreen.copy(S.positionScreen);k.normalWorld.copy(s.normal);O.multiplyVector3(k.normalWorld);k.centroidWorld.copy(s.centroid);U.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);
|
||||
K.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterial=X;k.faceMaterial=s.material;k.overdraw=V;if(t.geometry.uvs[x]){k.uvs[0]=t.geometry.uvs[x][0];k.uvs[1]=t.geometry.uvs[x][1];k.uvs[2]=t.geometry.uvs[x][3]}f.push(k);n++;l=c[n]=c[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(z.positionWorld);l.v2.positionWorld.copy(N.positionWorld);l.v3.positionWorld.copy(S.positionWorld);l.v1.positionScreen.copy(z.positionScreen);l.v2.positionScreen.copy(N.positionScreen);l.v3.positionScreen.copy(S.positionScreen);
|
||||
l.normalWorld.copy(k.normalWorld);l.centroidWorld.copy(k.centroidWorld);l.centroidScreen.copy(k.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterial=X;l.faceMaterial=s.material;l.overdraw=V;if(t.geometry.uvs[x]){l.uvs[0]=t.geometry.uvs[x][1];l.uvs[1]=t.geometry.uvs[x][2];l.uvs[2]=t.geometry.uvs[x][3]}f.push(l);n++}}}}else if(t instanceof THREE.Line){F.multiply(K,U);w=t.geometry.vertices;s=w[0];s.positionScreen.copy(s.position);F.multiplyVector4(s.positionScreen);x=1;for(E=w.length;x<E;x++){o=w[x];
|
||||
o.positionScreen.copy(o.position);F.multiplyVector4(o.positionScreen);z=w[x-1];e.copy(o.positionScreen);m.copy(z.positionScreen);if(a(e,m)){e.multiplyScalar(1/e.w);m.multiplyScalar(1/m.w);C=y[A]=y[A]||new THREE.RenderableLine;C.v1.positionScreen.copy(e);C.v2.positionScreen.copy(m);C.z=Math.max(e.z,m.z);C.material=t.material;f.push(C);A++}}}else if(t instanceof THREE.Particle){D.set(t.position.x,t.position.y,t.position.z,1);K.multiplyVector4(D);D.z/=D.w;if(D.z>0&&D.z<1){r=M[G]=M[G]||new THREE.RenderableParticle;
|
||||
r.x=D.x/D.w;r.y=D.y/D.w;r.z=D.z;r.rotation=t.rotation.z;r.scale.x=t.scale.x*Math.abs(r.x-(D.x+j.projectionMatrix.n11)/(D.w+j.projectionMatrix.n14));r.scale.y=t.scale.y*Math.abs(r.y-(D.y+j.projectionMatrix.n22)/(D.w+j.projectionMatrix.n24));r.material=t.material;f.push(r);G++}}}}f.sort(b);return f};this.unprojectVector=function(q,j){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(j.matrix),THREE.Matrix4.makeInvert(j.projectionMatrix));h.multiplyVector3(q);return q}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,p;this.domElement=document.createElement("div");this.setSize=function(k,l){f=k;d=l;i=f/2;p=d/2};this.render=function(k,l){var n,c,C,A,y,r,G,M;a=b.projectScene(k,l);n=0;for(c=a.length;n<c;n++){y=a[n];if(y instanceof THREE.RenderableParticle){G=y.x*i+i;M=y.y*p+p;C=0;for(A=y.material.length;C<A;C++){r=y.material[C];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=G+"px";r.style.top=M+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,p,k,l=f.getContext("2d"),n=1,c=0,C=null,A=null,y=1,r,G,M,R,D,K,F,e,m,g=new THREE.Color,q=new THREE.Color,j=new THREE.Color,h=new THREE.Color,u=new THREE.Color,x,E,o,z,P,t,U,O,X,V,I=new THREE.Rectangle,w=new THREE.Rectangle,s=new THREE.Rectangle,N=false,S=new THREE.Color,L=new THREE.Color,T=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,Y=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=f;this.autoClear=true;this.setSize=function(ga,ua){d=ga;i=ua;p=d/2;k=i/2;f.width=d;f.height=i;I.set(-p,-k,p,k)};this.clear=function(){if(!w.isEmpty()){w.inflate(1);w.minSelf(I);l.clearRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());
|
||||
w.empty()}};this.render=function(ga,ua){function Ka(v){var Q,J,B,H=v.lights;L.setRGB(0,0,0);T.setRGB(0,0,0);aa.setRGB(0,0,0);v=0;for(Q=H.length;v<Q;v++){J=H[v];B=J.color;if(J instanceof THREE.AmbientLight){L.r+=B.r;L.g+=B.g;L.b+=B.b}else if(J instanceof THREE.DirectionalLight){T.r+=B.r;T.g+=B.g;T.b+=B.b}else if(J instanceof THREE.PointLight){aa.r+=B.r;aa.g+=B.g;aa.b+=B.b}}}function va(v,Q,J,B){var H,W,$,ba,ca=v.lights;v=0;for(H=ca.length;v<H;v++){W=ca[v];$=W.color;ba=W.intensity;if(W instanceof THREE.DirectionalLight){W=
|
||||
J.dot(W.position)*ba;if(W>0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,Q);Y.normalize();W=J.dot(Y)*ba;if(W>0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}}}function La(v,Q,J){if(J.opacity!=0){Ba(J.opacity);wa(J.blending);var B,H,W,$,ba,ca;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){$=J.map;ba=$.width>>1;ca=$.height>>1;H=Q.scale.x*p;W=Q.scale.y*k;J=H*ba;B=W*ca;s.set(v.x-J,v.y-B,v.x+J,v.y+B);if(I.instersects(s)){l.save();l.translate(v.x,v.y);l.rotate(-Q.rotation);
|
||||
l.scale(H,-W);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}else if(J instanceof THREE.ParticleCircleMaterial){if(N){S.r=L.r+T.r+aa.r;S.g=L.g+T.g+aa.g;S.b=L.b+T.b+aa.b;g.r=J.color.r*S.r;g.g=J.color.g*S.g;g.b=J.color.b*S.b;g.updateStyleString()}else g.__styleString=J.color.__styleString;J=Q.scale.x*p;B=Q.scale.y*k;s.set(v.x-J,v.y-B,v.x+J,v.y+B);if(I.instersects(s)){H=g.__styleString;if(A!=H)l.fillStyle=A=H;l.save();l.translate(v.x,v.y);l.rotate(-Q.rotation);l.scale(J,B);l.beginPath();l.arc(0,
|
||||
0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(v,Q,J,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(Q.positionScreen.x,Q.positionScreen.y);l.closePath();if(B instanceof THREE.LineBasicMaterial){g.__styleString=B.color.__styleString;v=B.linewidth;if(y!=v)l.lineWidth=y=v;v=g.__styleString;if(C!=v)l.strokeStyle=C=v;l.stroke();s.inflate(B.linewidth*2)}}}function Fa(v,Q,J,B,H,W){if(H.opacity!=0){Ba(H.opacity);wa(H.blending);
|
||||
R=v.positionScreen.x;D=v.positionScreen.y;K=Q.positionScreen.x;F=Q.positionScreen.y;e=J.positionScreen.x;m=J.positionScreen.y;l.beginPath();l.moveTo(R,D);l.lineTo(K,F);l.lineTo(e,m);l.lineTo(R,D);l.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,H.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=
|
||||
ua.matrix;Y.copy(B.vertexNormalsWorld[0]);P=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;t=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);U=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;O=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);X=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;V=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;qa(R,D,K,F,e,m,H.env_map.image,P,t,U,O,X,V)}}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(R,D,K,F,e,m,H.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!H.wireframe&&H.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){q.r=j.r=h.r=L.r;q.g=j.g=h.g=L.g;q.b=j.b=h.b=L.b;va(W,B.v1.positionWorld,B.vertexNormalsWorld[0],q);va(W,B.v2.positionWorld,B.vertexNormalsWorld[1],j);va(W,B.v3.positionWorld,B.vertexNormalsWorld[2],
|
||||
h);u.r=(j.r+h.r)*0.5;u.g=(j.g+h.g)*0.5;u.b=(j.b+h.b)*0.5;z=Ga(q,j,h,u);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else{S.r=L.r;S.g=L.g;S.b=L.b;va(W,B.centroidWorld,B.normalWorld,S);g.r=H.color.r*S.r;g.g=H.color.g*S.g;g.b=H.color.b*S.b;g.updateStyleString();H.wireframe?xa(g.__styleString,H.wireframe_linewidth):ya(g.__styleString)}else H.wireframe?xa(H.color.__styleString,H.wireframe_linewidth):ya(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){x=H.__2near;E=H.__farPlusNear;o=H.__farMinusNear;
|
||||
q.r=q.g=q.b=1-x/(E-v.positionScreen.z*o);j.r=j.g=j.b=1-x/(E-Q.positionScreen.z*o);h.r=h.g=h.b=1-x/(E-J.positionScreen.z*o);u.r=(j.r+h.r)*0.5;u.g=(j.g+h.g)*0.5;u.b=(j.b+h.b)*0.5;z=Ga(q,j,h,u);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){g.r=Ca(B.normalWorld.x);g.g=Ca(B.normalWorld.y);g.b=Ca(B.normalWorld.z);g.updateStyleString();H.wireframe?xa(g.__styleString,H.wireframe_linewidth):ya(g.__styleString)}}}function xa(v,Q){if(C!=v)l.strokeStyle=C=v;if(y!=Q)l.lineWidth=
|
||||
y=Q;l.stroke();s.inflate(Q*2)}function ya(v){if(A!=v)l.fillStyle=A=v;l.fill()}function qa(v,Q,J,B,H,W,$,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;J-=v;B-=Q;H-=v;W-=Q;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*J-ea*H)*ja;ea=(ra*B-ea*W)*ja;J=(ha*H-ia*J)*ja;B=(ha*W-ia*B)*ja;v=v-ka*ba-J*ca;Q=Q-ea*ba-B*ca;l.save();l.transform(ka,ea,J,B,v,Q);l.clip();l.drawImage($,0,0);l.restore()}function Ba(v){if(n!=v)l.globalAlpha=n=v}function wa(v){if(c!=
|
||||
v){switch(v){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=v}}function Ga(v,Q,J,B){var H=~~(v.r*255),W=~~(v.g*255);v=~~(v.b*255);var $=~~(Q.r*255),ba=~~(Q.g*255);Q=~~(Q.b*255);var ca=~~(J.r*255),ha=~~(J.g*255);J=~~(J.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=H<0?0:H>255?255:H;da[1]=W<0?0:W>255?255:W;da[2]=v<0?0:v>
|
||||
255?255:v;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=Q<0?0:Q>255?255:Q;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=J<0?0:J>255?255:J;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Da(v,Q){var J=Q.x-v.x,B=Q.y-v.y,H=1/Math.sqrt(J*J+B*B);J*=H;B*=H;Q.x+=J;Q.y+=B;v.x-=J;v.y-=B}var za,Ha,Z,fa,ma,Ea,Ia,sa;l.setTransform(1,0,0,-1,
|
||||
p,k);this.autoClear&&this.clear();a=b.projectScene(ga,ua);(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];s.empty();if(Z instanceof THREE.RenderableParticle){r=Z;r.x*=p;r.y*=k;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;G=Z.v2;r.positionScreen.x*=p;r.positionScreen.y*=k;G.positionScreen.x*=p;G.positionScreen.y*=k;s.addPoint(r.positionScreen.x,r.positionScreen.y);s.addPoint(G.positionScreen.x,G.positionScreen.y);
|
||||
if(I.instersects(s)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(r,G,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){r=Z.v1;G=Z.v2;M=Z.v3;r.positionScreen.x*=p;r.positionScreen.y*=k;G.positionScreen.x*=p;G.positionScreen.y*=k;M.positionScreen.x*=p;M.positionScreen.y*=k;if(Z.overdraw){Da(r.positionScreen,G.positionScreen);Da(G.positionScreen,M.positionScreen);Da(M.positionScreen,r.positionScreen)}s.add3Points(r.positionScreen.x,r.positionScreen.y,G.positionScreen.x,G.positionScreen.y,
|
||||
M.positionScreen.x,M.positionScreen.y);if(I.instersects(s)){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,G,M,Z,sa,ga)}else Fa(r,G,M,Z,sa,ga)}}}w.addRectangle(s)}l.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(O,X,V){var I,w,s,N;I=0;for(w=O.lights.length;I<w;I++){s=O.lights[I];if(s instanceof THREE.DirectionalLight){N=X.normalWorld.dot(s.position)*s.intensity;if(N>0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}else if(s instanceof THREE.PointLight){h.sub(s.position,X.centroidWorld);h.normalize();N=X.normalWorld.dot(h)*s.intensity;if(N>0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}}}function b(O,X,V,I,w,s){o=d(z++);o.setAttribute("d","M "+O.positionScreen.x+
|
||||
" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(s,I,e);F.r=w.color.r*e.r;F.g=w.color.g*e.g;F.b=w.color.b*e.b;F.updateStyleString()}else F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){j=1-w.__2near/(w.__farPlusNear-I.z*w.__farMinusNear);
|
||||
F.setRGB(j,j,j)}else w instanceof THREE.MeshNormalMaterial&&F.setRGB(i(I.normalWorld.x),i(I.normalWorld.y),i(I.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(o)}function f(O,X,V,I,w,s,N){o=d(z++);o.setAttribute("d",
|
||||
"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(N,w,e);F.r=s.color.r*e.r;F.g=s.color.g*e.g;F.b=s.color.b*e.b;F.updateStyleString()}else F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){j=
|
||||
1-s.__2near/(s.__farPlusNear-w.z*s.__farMinusNear);F.setRGB(j,j,j)}else s instanceof THREE.MeshNormalMaterial&&F.setRGB(i(w.normalWorld.x),i(w.normalWorld.y),i(w.normalWorld.z));s.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+s.opacity);l.appendChild(o)}
|
||||
function d(O){if(u[O]==null){u[O]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&u[O].setAttribute("shape-rendering","crispEdges");return u[O]}return u[O]}function i(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var p=null,k=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,C,A,y,r,G,M,R=new THREE.Rectangle,D=new THREE.Rectangle,K=false,F=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),g=new THREE.Color(0),
|
||||
q=new THREE.Color(0),j,h=new THREE.Vector3,u=[],x=[],E=[],o,z,P,t,U=1;this.domElement=l;this.autoClear=true;this.setQuality=function(O){switch(O){case "high":U=1;break;case "low":U=0}};this.setSize=function(O,X){n=O;c=X;C=n/2;A=c/2;l.setAttribute("viewBox",-C+" "+-A+" "+n+" "+c);l.setAttribute("width",n);l.setAttribute("height",c);R.set(-C,-A,C,A)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(O,X){var V,I,w,s,N,S,L,T;this.autoClear&&this.clear();
|
||||
p=k.projectScene(O,X);t=P=z=0;if(K=O.lights.length>0){L=O.lights;m.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);V=0;for(I=L.length;V<I;V++){w=L[V];s=w.color;if(w instanceof THREE.AmbientLight){m.r+=s.r;m.g+=s.g;m.b+=s.b}else if(w instanceof THREE.DirectionalLight){g.r+=s.r;g.g+=s.g;g.b+=s.b}else if(w instanceof THREE.PointLight){q.r+=s.r;q.g+=s.g;q.b+=s.b}}}V=0;for(I=p.length;V<I;V++){L=p[V];D.empty();if(L instanceof THREE.RenderableParticle){y=L;y.x*=C;y.y*=-A;w=0;for(s=L.material.length;w<s;w++)if(T=
|
||||
L.material[w]){N=y;S=L;T=T;var aa=P++;if(x[aa]==null){x[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&x[aa].setAttribute("shape-rendering","crispEdges")}o=x[aa];o.setAttribute("cx",N.x);o.setAttribute("cy",N.y);o.setAttribute("r",S.scale.x*C);if(T instanceof THREE.ParticleCircleMaterial){if(K){e.r=m.r+g.r+q.r;e.g=m.g+g.g+q.g;e.b=m.b+g.b+q.b;F.r=T.color.r*e.r;F.g=T.color.g*e.g;F.b=T.color.b*e.b;F.updateStyleString()}else F=T.color;o.setAttribute("style","fill: "+F.__styleString)}l.appendChild(o)}}else if(L instanceof
|
||||
THREE.RenderableLine){y=L.v1;r=L.v2;y.positionScreen.x*=C;y.positionScreen.y*=-A;r.positionScreen.x*=C;r.positionScreen.y*=-A;D.addPoint(y.positionScreen.x,y.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);if(R.instersects(D)){w=0;for(s=L.material.length;w<s;)if(T=L.material[w++]){N=y;S=r;T=T;aa=t++;if(E[aa]==null){E[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");U==0&&E[aa].setAttribute("shape-rendering","crispEdges")}o=E[aa];o.setAttribute("x1",N.positionScreen.x);
|
||||
o.setAttribute("y1",N.positionScreen.y);o.setAttribute("x2",S.positionScreen.x);o.setAttribute("y2",S.positionScreen.y);if(T instanceof THREE.LineBasicMaterial){F.__styleString=T.color.__styleString;o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin);l.appendChild(o)}}}}else if(L instanceof THREE.RenderableFace3){y=L.v1;r=L.v2;G=L.v3;y.positionScreen.x*=C;y.positionScreen.y*=
|
||||
-A;r.positionScreen.x*=C;r.positionScreen.y*=-A;G.positionScreen.x*=C;G.positionScreen.y*=-A;D.addPoint(y.positionScreen.x,y.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);D.addPoint(G.positionScreen.x,G.positionScreen.y);if(R.instersects(D)){w=0;for(s=L.meshMaterial.length;w<s;){T=L.meshMaterial[w++];if(T instanceof THREE.MeshFaceMaterial){N=0;for(S=L.faceMaterial.length;N<S;)(T=L.faceMaterial[N++])&&b(y,r,G,L,T,O)}else T&&b(y,r,G,L,T,O)}}}else if(L instanceof THREE.RenderableFace4){y=
|
||||
L.v1;r=L.v2;G=L.v3;M=L.v4;y.positionScreen.x*=C;y.positionScreen.y*=-A;r.positionScreen.x*=C;r.positionScreen.y*=-A;G.positionScreen.x*=C;G.positionScreen.y*=-A;M.positionScreen.x*=C;M.positionScreen.y*=-A;D.addPoint(y.positionScreen.x,y.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);D.addPoint(G.positionScreen.x,G.positionScreen.y);D.addPoint(M.positionScreen.x,M.positionScreen.y);if(R.instersects(D)){w=0;for(s=L.meshMaterial.length;w<s;){T=L.meshMaterial[w++];if(T instanceof
|
||||
THREE.MeshFaceMaterial){N=0;for(S=L.faceMaterial.length;N<S;)(T=L.faceMaterial[N++])&&f(y,r,G,M,L,T,O)}else T&&f(y,r,G,M,L,T,O)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(e,m){var g=c.createProgram(),q=[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(g,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
||||
e));c.attachShader(g,k("vertex",q+m));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function f(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 g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);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,
|
||||
THREE.Projector=function(){function a(f,p){var k=0,i=1,o=f.z+f.w,C=p.z+p.w,u=-f.z+f.w,t=-p.z+p.w;if(o>=0&&C>=0&&u>=0&&t>=0)return true;else if(o<0&&C<0||u<0&&t<0)return false;else{if(o<0)k=Math.max(k,o/(o-C));else if(C<0)i=Math.min(i,o/(o-C));if(u<0)k=Math.max(k,u/(u-t));else if(t<0)i=Math.min(i,u/(u-t));if(i<k)return false;else{f.lerpSelf(p,k);p.lerpSelf(f,1-i);return true}}}function b(f,p){return p.z-f.z}var g=null,d,h,q=[],j,l,n,c=[],A,y,x=[],s,G,N=[],K=new THREE.Vector4,J=new THREE.Matrix4,O=
|
||||
new THREE.Matrix4,D=new THREE.Vector4,e=new THREE.Vector4,m;this.projectObjects=function(f,p){var k,i,o,C;g=[];h=0;J.multiply(p.projectionMatrix,p.matrix);o=f.objects;k=0;for(i=o.length;k<i;k++){C=o[k];if(C.visible!==false){d=q[h]=q[h]||new THREE.RenderableObject;K.copy(C.position);J.multiplyVector4(K);d.object=C;d.z=K.z;g.push(d);h++}}g.sort(b);return g};this.projectScene=function(f,p){var k,i,o,C,u,t,I,B,E,U,P,W,T,F,r,w,Q;g=[];n=y=G=0;p.autoUpdateMatrix&&p.updateMatrix();J.multiply(p.projectionMatrix,
|
||||
p.matrix);I=f.objects;k=0;for(i=I.length;k<i;k++){B=I[k];if(B.visible!==false){B.autoUpdateMatrix&&B.updateMatrix();E=B.matrix;U=B.rotationMatrix;P=B.material;W=B.overdraw;if(B instanceof THREE.Mesh){T=B.geometry;F=T.vertices;o=0;for(C=F.length;o<C;o++){r=F[o];r.positionWorld.copy(r.position);E.multiplyVector3(r.positionWorld);u=r.positionScreen;u.copy(r.positionWorld);J.multiplyVector4(u);u.multiplyScalar(1/u.w);r.__visible=u.z>0&&u.z<1}T=T.faces;o=0;for(C=T.length;o<C;o++){r=T[o];if(r instanceof
|
||||
THREE.Face3){u=F[r.a];t=F[r.b];w=F[r.c];if(u.__visible&&t.__visible&&w.__visible)if(B.doubleSided||B.flipSided!=(w.positionScreen.x-u.positionScreen.x)*(t.positionScreen.y-u.positionScreen.y)-(w.positionScreen.y-u.positionScreen.y)*(t.positionScreen.x-u.positionScreen.x)<0){j=c[n]=c[n]||new THREE.RenderableFace3;j.v1.positionWorld.copy(u.positionWorld);j.v2.positionWorld.copy(t.positionWorld);j.v3.positionWorld.copy(w.positionWorld);j.v1.positionScreen.copy(u.positionScreen);j.v2.positionScreen.copy(t.positionScreen);
|
||||
j.v3.positionScreen.copy(w.positionScreen);j.normalWorld.copy(r.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(r.centroid);E.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);J.multiplyVector3(j.centroidScreen);w=r.vertexNormals;m=j.vertexNormalsWorld;u=0;for(t=w.length;u<t;u++){Q=m[u]=m[u]||new THREE.Vector3;Q.copy(w[u]);U.multiplyVector3(Q)}j.z=j.centroidScreen.z;j.meshMaterial=P;j.faceMaterial=r.material;j.overdraw=W;if(B.geometry.uvs[o]){j.uvs[0]=B.geometry.uvs[o][0];
|
||||
j.uvs[1]=B.geometry.uvs[o][1];j.uvs[2]=B.geometry.uvs[o][2]}g.push(j);n++}}else if(r instanceof THREE.Face4){u=F[r.a];t=F[r.b];w=F[r.c];Q=F[r.d];if(u.__visible&&t.__visible&&w.__visible&&Q.__visible)if(B.doubleSided||B.flipSided!=((Q.positionScreen.x-u.positionScreen.x)*(t.positionScreen.y-u.positionScreen.y)-(Q.positionScreen.y-u.positionScreen.y)*(t.positionScreen.x-u.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)){j=c[n]=c[n]||new THREE.RenderableFace3;j.v1.positionWorld.copy(u.positionWorld);j.v2.positionWorld.copy(t.positionWorld);j.v3.positionWorld.copy(Q.positionWorld);j.v1.positionScreen.copy(u.positionScreen);j.v2.positionScreen.copy(t.positionScreen);j.v3.positionScreen.copy(Q.positionScreen);j.normalWorld.copy(r.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(r.centroid);E.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);
|
||||
J.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=P;j.faceMaterial=r.material;j.overdraw=W;if(B.geometry.uvs[o]){j.uvs[0]=B.geometry.uvs[o][0];j.uvs[1]=B.geometry.uvs[o][1];j.uvs[2]=B.geometry.uvs[o][3]}g.push(j);n++;l=c[n]=c[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(t.positionWorld);l.v2.positionWorld.copy(w.positionWorld);l.v3.positionWorld.copy(Q.positionWorld);l.v1.positionScreen.copy(t.positionScreen);l.v2.positionScreen.copy(w.positionScreen);l.v3.positionScreen.copy(Q.positionScreen);
|
||||
l.normalWorld.copy(j.normalWorld);l.centroidWorld.copy(j.centroidWorld);l.centroidScreen.copy(j.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterial=P;l.faceMaterial=r.material;l.overdraw=W;if(B.geometry.uvs[o]){l.uvs[0]=B.geometry.uvs[o][1];l.uvs[1]=B.geometry.uvs[o][2];l.uvs[2]=B.geometry.uvs[o][3]}g.push(l);n++}}}}else if(B instanceof THREE.Line){O.multiply(J,E);F=B.geometry.vertices;r=F[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);o=1;for(C=F.length;o<C;o++){u=F[o];
|
||||
u.positionScreen.copy(u.position);O.multiplyVector4(u.positionScreen);t=F[o-1];D.copy(u.positionScreen);e.copy(t.positionScreen);if(a(D,e)){D.multiplyScalar(1/D.w);e.multiplyScalar(1/e.w);A=x[y]=x[y]||new THREE.RenderableLine;A.v1.positionScreen.copy(D);A.v2.positionScreen.copy(e);A.z=Math.max(D.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 k=new THREE.Matrix4;k.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));k.multiplyVector3(f);return f}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,h,q;this.domElement=document.createElement("div");this.setSize=function(j,l){g=j;d=l;h=g/2;q=d/2};this.render=function(j,l){var n,c,A,y,x,s,G,N;a=b.projectScene(j,l);n=0;for(c=a.length;n<c;n++){x=a[n];if(x instanceof THREE.RenderableParticle){G=x.x*h+h;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,h,q,j,l=g.getContext("2d"),n=1,c=0,A=null,y=null,x=1,s,G,N,K,J,O,D,e,m,f=new THREE.Color,p=new THREE.Color,k=new THREE.Color,i=new THREE.Color,o=new THREE.Color,C,u,t,I,B,E,U,P,W,T,F=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;h=ua;q=d/2;j=h/2;g.width=d;g.height=h;F.set(-q,-j,q,j)};this.clear=function(){if(!r.isEmpty()){r.inflate(1);r.minSelf(F);l.clearRect(r.getX(),r.getY(),r.getWidth(),r.getHeight());
|
||||
r.empty()}};this.render=function(ga,ua){function Ka(v){var R,L,z,H=v.lights;M.setRGB(0,0,0);S.setRGB(0,0,0);aa.setRGB(0,0,0);v=0;for(R=H.length;v<R;v++){L=H[v];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(v,R,L,z){var H,V,$,ba,ca=v.lights;v=0;for(H=ca.length;v<H;v++){V=ca[v];$=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(v,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*j;L=H*ba;z=V*ca;w.set(v.x-L,v.y-z,v.x+L,v.y+z);if(F.instersects(w)){l.save();l.translate(v.x,v.y);l.rotate(-R.rotation);
|
||||
l.scale(H,-V);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}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*j;w.set(v.x-L,v.y-z,v.x+L,v.y+z);if(F.instersects(w)){H=f.__styleString;if(y!=H)l.fillStyle=y=H;l.save();l.translate(v.x,v.y);l.rotate(-R.rotation);l.scale(L,z);l.beginPath();l.arc(0,
|
||||
0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(v,R,L,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(R.positionScreen.x,R.positionScreen.y);l.closePath();if(z instanceof THREE.LineBasicMaterial){f.__styleString=z.color.__styleString;v=z.linewidth;if(x!=v)l.lineWidth=x=v;v=f.__styleString;if(A!=v)l.strokeStyle=A=v;l.stroke();w.inflate(z.linewidth*2)}}}function Fa(v,R,L,z,H,V){if(H.opacity!=0){Ba(H.opacity);wa(H.blending);
|
||||
K=v.positionScreen.x;J=v.positionScreen.y;O=R.positionScreen.x;D=R.positionScreen.y;e=L.positionScreen.x;m=L.positionScreen.y;l.beginPath();l.moveTo(K,J);l.lineTo(O,D);l.lineTo(e,m);l.lineTo(K,J);l.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(K,J,O,D,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){v=
|
||||
ua.matrix;X.copy(z.vertexNormalsWorld[0]);B=(X.x*v.n11+X.y*v.n12+X.z*v.n13)*0.5+0.5;E=-(X.x*v.n21+X.y*v.n22+X.z*v.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[1]);U=(X.x*v.n11+X.y*v.n12+X.z*v.n13)*0.5+0.5;P=-(X.x*v.n21+X.y*v.n22+X.z*v.n23)*0.5+0.5;X.copy(z.vertexNormalsWorld[2]);W=(X.x*v.n11+X.y*v.n12+X.z*v.n13)*0.5+0.5;T=-(X.x*v.n21+X.y*v.n22+X.z*v.n23)*0.5+0.5;qa(K,J,O,D,e,m,H.env_map.image,B,E,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,D,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=k.r=i.r=M.r;p.g=k.g=i.g=M.g;p.b=k.b=i.b=M.b;va(V,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(V,z.v2.positionWorld,z.vertexNormalsWorld[1],k);va(V,z.v3.positionWorld,z.vertexNormalsWorld[2],
|
||||
i);o.r=(k.r+i.r)*0.5;o.g=(k.g+i.g)*0.5;o.b=(k.b+i.b)*0.5;I=Ga(p,k,i,o);qa(K,J,O,D,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;u=H.__farPlusNear;t=H.__farMinusNear;
|
||||
p.r=p.g=p.b=1-C/(u-v.positionScreen.z*t);k.r=k.g=k.b=1-C/(u-R.positionScreen.z*t);i.r=i.g=i.b=1-C/(u-L.positionScreen.z*t);o.r=(k.r+i.r)*0.5;o.g=(k.g+i.g)*0.5;o.b=(k.b+i.b)*0.5;I=Ga(p,k,i,o);qa(K,J,O,D,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(v,R){if(A!=v)l.strokeStyle=A=v;if(x!=R)l.lineWidth=
|
||||
x=R;l.stroke();w.inflate(R*2)}function ya(v){if(y!=v)l.fillStyle=y=v;l.fill()}function qa(v,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-=v;z-=R;H-=v;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;v=v-ka*ba-L*ca;R=R-ea*ba-z*ca;l.save();l.transform(ka,ea,L,z,v,R);l.clip();l.drawImage($,0,0);l.restore()}function Ba(v){if(n!=v)l.globalAlpha=n=v}function wa(v){if(c!=
|
||||
v){switch(v){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=v}}function Ga(v,R,L,z){var H=~~(v.r*255),V=~~(v.g*255);v=~~(v.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]=v<0?0:v>
|
||||
255?255:v;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(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Da(v,R){var L=R.x-v.x,z=R.y-v.y,H=1/Math.sqrt(L*L+z*z);L*=H;z*=H;R.x+=L;R.y+=z;v.x-=L;v.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;l.setTransform(1,0,0,-1,
|
||||
q,j);this.autoClear&&this.clear();a=b.projectScene(ga,ua);(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*=j;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*=j;G.positionScreen.x*=q;G.positionScreen.y*=j;w.addPoint(s.positionScreen.x,s.positionScreen.y);w.addPoint(G.positionScreen.x,G.positionScreen.y);
|
||||
if(F.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*=j;G.positionScreen.x*=q;G.positionScreen.y*=j;N.positionScreen.x*=q;N.positionScreen.y*=j;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(F.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)}l.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(P,W,T){var F,r,w,Q;F=0;for(r=P.lights.length;F<r;F++){w=P.lights[F];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){i.sub(w.position,W.centroidWorld);i.normalize();Q=W.normalWorld.dot(i)*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,F,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)D.__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,F,e);D.r=r.color.r*e.r;D.g=r.color.g*e.g;D.b=r.color.b*e.b;D.updateStyleString()}else D.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){k=1-r.__2near/(r.__farPlusNear-F.z*r.__farMinusNear);
|
||||
D.setRGB(k,k,k)}else r instanceof THREE.MeshNormalMaterial&&D.setRGB(h(F.normalWorld.x),h(F.normalWorld.y),h(F.normalWorld.z));r.wireframe?t.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):t.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+r.opacity);l.appendChild(t)}function g(P,W,T,F,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 "+F.positionScreen.x+","+F.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)D.__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);D.r=w.color.r*e.r;D.g=w.color.g*e.g;D.b=w.color.b*e.b;D.updateStyleString()}else D.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){k=
|
||||
1-w.__2near/(w.__farPlusNear-r.z*w.__farMinusNear);D.setRGB(k,k,k)}else w instanceof THREE.MeshNormalMaterial&&D.setRGB(h(r.normalWorld.x),h(r.normalWorld.y),h(r.normalWorld.z));w.wireframe?t.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):t.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+w.opacity);l.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 h(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var q=null,j=new THREE.Projector,l=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,D=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),f=new THREE.Color(0),
|
||||
p=new THREE.Color(0),k,i=new THREE.Vector3,o=[],C=[],u=[],t,I,B,E,U=1;this.domElement=l;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;l.setAttribute("viewBox",-A+" "+-y+" "+n+" "+c);l.setAttribute("width",n);l.setAttribute("height",c);K.set(-A,-y,A,y)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(P,W){var T,F,r,w,Q,Y,M,S;this.autoClear&&this.clear();
|
||||
q=j.projectScene(P,W);E=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(F=M.length;T<F;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(F=q.length;T<F;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;D.r=S.color.r*e.r;D.g=S.color.g*e.g;D.b=S.color.b*e.b;D.updateStyleString()}else D=S.color;t.setAttribute("style","fill: "+D.__styleString)}l.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=E++;if(u[aa]==null){u[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");U==0&&u[aa].setAttribute("shape-rendering","crispEdges")}t=u[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){D.__styleString=S.color.__styleString;t.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);l.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,j("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
||||
e));c.attachShader(f,j("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,l(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,l(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,l(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,l(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 g,q,j;g=0;for(q=m.length;g<q;g++){j=m[g];e.uniforms[j]=c.getUniformLocation(e,j)}}function p(e,m){var g,q,j;g=0;for(q=m.length;g<q;g++){j=m[g];e.attributes[j]=c.getAttribLocation(e,j);e.attributes[j]>=0&&c.enableVertexAttribArray(e.attributes[j])}}function k(e,m){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER);
|
||||
c.shaderSource(g,m);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function l(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,C,A,y=new THREE.Matrix4,r,G=new Float32Array(16),M=new Float32Array(16),R=new Float32Array(16),D=new Float32Array(9),K=new Float32Array(16);a=function(e,m){if(e){var g,q,j,h=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=e.lights.length;g<q;g++){j=e.lights[g];j instanceof THREE.DirectionalLight&&h++;j instanceof
|
||||
THREE.PointLight&&pointLights++}if(pointLights+h<=m){maxDirLights=h;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*h/(pointLights+h));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(F){}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);C=A=function(e,m){var g=[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 ];":
|
||||
c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function h(e,m){var f,p,k;f=0;for(p=m.length;f<p;f++){k=m[f];e.uniforms[k]=c.getUniformLocation(e,k)}}function q(e,m){var f,p,k;f=0;for(p=m.length;f<p;f++){k=m[f];e.attributes[k]=c.getAttribLocation(e,k);e.attributes[k]>=0&&c.enableVertexAttribArray(e.attributes[k])}}function j(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 l(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,k,i=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=e.lights.length;f<p;f++){k=e.lights[f];k instanceof THREE.DirectionalLight&&i++;k instanceof
|
||||
THREE.PointLight&&pointLights++}if(pointLights+i<=m){maxDirLights=i;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*i/(pointLights+i));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(D){}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"),
|
||||
q=[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;",
|
||||
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");
|
||||
g=b(q,g);c.useProgram(g);i(g,["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(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(g,["pointLightNumber","pointLightColor",
|
||||
"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);p(g,["position","normal","uv"]);return g}(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 g,q,j,h,u,x=[],
|
||||
E=[],o=[];h=[];u=[];c.uniform1i(e.uniforms.enableLighting,m.length);g=0;for(q=m.length;g<q;g++){j=m[g];if(j instanceof THREE.AmbientLight)x.push(j);else if(j instanceof THREE.DirectionalLight)o.push(j);else j instanceof THREE.PointLight&&E.push(j)}g=j=h=u=0;for(q=x.length;g<q;g++){j+=x[g].color.r;h+=x[g].color.g;u+=x[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,j,h,u);h=[];u=[];g=0;for(q=o.length;g<q;g++){j=o[g];h.push(j.color.r*j.intensity);h.push(j.color.g*j.intensity);h.push(j.color.b*j.intensity);
|
||||
u.push(j.position.x);u.push(j.position.y);u.push(j.position.z)}if(o.length){c.uniform1i(e.uniforms.directionalLightNumber,o.length);c.uniform3fv(e.uniforms.directionalLightDirection,u);c.uniform3fv(e.uniforms.directionalLightColor,h)}h=[];u=[];g=0;for(q=E.length;g<q;g++){j=E[g];h.push(j.color.r*j.intensity);h.push(j.color.g*j.intensity);h.push(j.color.b*j.intensity);u.push(j.position.x);u.push(j.position.y);u.push(j.position.z)}if(E.length){c.uniform1i(e.uniforms.pointLightNumber,E.length);c.uniform3fv(e.uniforms.pointLightPosition,
|
||||
u);c.uniform3fv(e.uniforms.pointLightColor,h)}};this.createBuffers=function(e,m){var g,q,j,h,u,x,E,o,z,P=[],t=[],U=[],O=[],X=[],V=[],I=0,w=e.geometry.geometryChunks[m],s;j=false;g=0;for(q=e.material.length;g<q;g++){meshMaterial=e.material[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){u=0;for(s=w.material.length;u<s;u++)if(w.material[u]&&w.material[u].shading!=undefined&&w.material[u].shading==THREE.SmoothShading){j=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
||||
THREE.SmoothShading){j=true;break}if(j)break}s=j;g=0;for(q=w.faces.length;g<q;g++){j=w.faces[g];h=e.geometry.faces[j];u=h.vertexNormals;faceNormal=h.normal;j=e.geometry.uvs[j];if(h instanceof THREE.Face3){x=e.geometry.vertices[h.a].position;E=e.geometry.vertices[h.b].position;o=e.geometry.vertices[h.c].position;U.push(x.x,x.y,x.z);U.push(E.x,E.y,E.z);U.push(o.x,o.y,o.z);if(e.geometry.hasTangents){x=e.geometry.vertices[h.a].tangent;E=e.geometry.vertices[h.b].tangent;o=e.geometry.vertices[h.c].tangent;
|
||||
X.push(x.x,x.y,x.z,x.w);X.push(E.x,E.y,E.z,E.w);X.push(o.x,o.y,o.z,o.w)}if(u.length==3&&s)for(h=0;h<3;h++)O.push(u[h].x,u[h].y,u[h].z);else for(h=0;h<3;h++)O.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(h=0;h<3;h++)V.push(j[h].u,j[h].v);P.push(I,I+1,I+2);t.push(I,I+1);t.push(I,I+2);t.push(I+1,I+2);I+=3}else if(h instanceof THREE.Face4){x=e.geometry.vertices[h.a].position;E=e.geometry.vertices[h.b].position;o=e.geometry.vertices[h.c].position;z=e.geometry.vertices[h.d].position;U.push(x.x,
|
||||
x.y,x.z);U.push(E.x,E.y,E.z);U.push(o.x,o.y,o.z);U.push(z.x,z.y,z.z);if(e.geometry.hasTangents){x=e.geometry.vertices[h.a].tangent;E=e.geometry.vertices[h.b].tangent;o=e.geometry.vertices[h.c].tangent;h=e.geometry.vertices[h.d].tangent;X.push(x.x,x.y,x.z,x.w);X.push(E.x,E.y,E.z,E.w);X.push(o.x,o.y,o.z,o.w);X.push(h.x,h.y,h.z,h.w)}if(u.length==4&&s)for(h=0;h<4;h++)O.push(u[h].x,u[h].y,u[h].z);else for(h=0;h<4;h++)O.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(h=0;h<4;h++)V.push(j[h].u,j[h].v);
|
||||
P.push(I,I+1,I+2);P.push(I,I+2,I+3);t.push(I,I+1);t.push(I,I+2);t.push(I,I+3);t.push(I+1,I+2);t.push(I+2,I+3);I+=4}}if(U.length){w.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW);w.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(O),c.STATIC_DRAW);if(e.geometry.hasTangents){w.__webGLTangentBuffer=c.createBuffer();
|
||||
c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}if(V.length>0){w.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}w.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);w.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
w.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);w.__webGLFaceCount=P.length;w.__webGLLineCount=t.length}};this.renderBuffer=function(e,m,g,q){var j,h,u,x,E,o,z,P,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)z.push(t);i(g.program,z);p(g.program,["position","normal","uv","tangent"])}t=
|
||||
g.program}else t=A;if(t!=C){c.useProgram(t);C=t}t==A&&this.setupLights(t,m);this.loadCamera(t,e);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){u=g.wireframe;x=g.wireframe_linewidth;e=t;m=g.uniforms;var U;for(j in m){P=m[j].type;z=m[j].value;U=e.uniforms[j];if(P=="i")c.uniform1i(U,z);else if(P=="f")c.uniform1f(U,z);else if(P=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(P=="c")c.uniform3f(U,z.r,z.g,z.b);else if(P=="t"){c.uniform1i(U,z);if(P=m[j].texture)P.image instanceof Array&&P.image.length==
|
||||
6?f(P,z):d(P,z)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){j=g.color;h=g.opacity;u=g.wireframe;x=g.wireframe_linewidth;E=g.map;o=g.env_map;m=g.combine==THREE.MixOperation;e=g.reflectivity;P=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;z=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,j.r*h,j.g*h,j.b*h,h);c.uniform1i(t.uniforms.mixEnvMap,m);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract,
|
||||
P);c.uniform1f(t.uniforms.mRefractionRatio,z)}if(g instanceof THREE.MeshNormalMaterial){h=g.opacity;c.uniform1f(t.uniforms.mOpacity,h);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){h=g.opacity;u=g.wireframe;x=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,h);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof
|
||||
THREE.MeshPhongMaterial){j=g.ambient;e=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,j.r,j.g,j.b,h);c.uniform4f(t.uniforms.mSpecular,e.r,e.g,e.b,h);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);o=g.env_map}if(E){d(E,0);c.uniform1i(t.uniforms.tMap,
|
||||
0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(o){f(o,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);h=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);if(h.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0)}if(h.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer);
|
||||
c.vertexAttribPointer(h.tangent,4,c.FLOAT,false,0,0)}if(h.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(h.uv);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(h.uv);if(u){c.lineWidth(x);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT,
|
||||
0)}};this.renderPass=function(e,m,g,q,j,h){var u,x,E,o,z;E=0;for(o=g.material.length;E<o;E++){u=g.material[E];if(u instanceof THREE.MeshFaceMaterial){u=0;for(x=q.material.length;u<x;u++)if((z=q.material[u])&&z.blending==j&&z.opacity<1==h){this.setBlending(z.blending);this.renderBuffer(e,m,z,q)}}else if((z=u)&&z.blending==j&&z.opacity<1==h){this.setBlending(z.blending);this.renderBuffer(e,m,z,q)}}};this.render=function(e,m){var g,q,j,h,u=e.lights;this.initWebGLObjects(e);this.autoClear&&this.clear();
|
||||
m.autoUpdateMatrix&&m.updateMatrix();G.set(m.matrix.flatten());R.set(m.projectionMatrix.flatten());g=0;for(q=e.__webGLObjects.length;g<q;g++){j=e.__webGLObjects[g];h=j.object;j=j.buffer;if(h.visible){this.setupMatrices(h,m);this.renderPass(m,u,h,j,THREE.NormalBlending,false)}}g=0;for(q=e.__webGLObjects.length;g<q;g++){j=e.__webGLObjects[g];h=j.object;j=j.buffer;if(h.visible){this.setupMatrices(h,m);this.renderPass(m,u,h,j,THREE.AdditiveBlending,false);this.renderPass(m,u,h,j,THREE.SubtractiveBlending,
|
||||
false);this.renderPass(m,u,h,j,THREE.AdditiveBlending,true);this.renderPass(m,u,h,j,THREE.SubtractiveBlending,true);this.renderPass(m,u,h,j,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,g,q,j,h,u;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}m=0;for(g=e.objects.length;m<g;m++){q=e.objects[m];if(e.__webGLObjectsMap[q.id]==undefined)e.__webGLObjectsMap[q.id]={};u=e.__webGLObjectsMap[q.id];if(q instanceof THREE.Mesh)for(h in q.geometry.geometryChunks){j=q.geometry.geometryChunks[h];
|
||||
j.__webGLVertexBuffer||this.createBuffers(q,h);if(u[h]==undefined){j={buffer:j,object:q};e.__webGLObjects.push(j);u[h]=1}}}};this.removeObject=function(e,m){var g,q;for(g=e.__webGLObjects.length-1;g>=0;g--){q=e.__webGLObjects[g].object;m==q&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();y.multiply(m.matrix,e.matrix);M.set(y.flatten());r=THREE.Matrix4.makeInvert3x3(y).transpose();D.set(r.m);K.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,
|
||||
false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,R);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,D);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,K)};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,
|
||||
f=b(p,f);c.useProgram(f);h(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&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&h(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,k,i,o,C=[],
|
||||
u=[],t=[];i=[];o=[];c.uniform1i(e.uniforms.enableLighting,m.length);f=0;for(p=m.length;f<p;f++){k=m[f];if(k instanceof THREE.AmbientLight)C.push(k);else if(k instanceof THREE.DirectionalLight)t.push(k);else k instanceof THREE.PointLight&&u.push(k)}f=k=i=o=0;for(p=C.length;f<p;f++){k+=C[f].color.r;i+=C[f].color.g;o+=C[f].color.b}c.uniform3f(e.uniforms.ambientLightColor,k,i,o);i=[];o=[];f=0;for(p=t.length;f<p;f++){k=t[f];i.push(k.color.r*k.intensity);i.push(k.color.g*k.intensity);i.push(k.color.b*k.intensity);
|
||||
o.push(k.position.x);o.push(k.position.y);o.push(k.position.z)}if(t.length){c.uniform1i(e.uniforms.directionalLightNumber,t.length);c.uniform3fv(e.uniforms.directionalLightDirection,o);c.uniform3fv(e.uniforms.directionalLightColor,i)}i=[];o=[];f=0;for(p=u.length;f<p;f++){k=u[f];i.push(k.color.r*k.intensity);i.push(k.color.g*k.intensity);i.push(k.color.b*k.intensity);o.push(k.position.x);o.push(k.position.y);o.push(k.position.z)}if(u.length){c.uniform1i(e.uniforms.pointLightNumber,u.length);c.uniform3fv(e.uniforms.pointLightPosition,
|
||||
o);c.uniform3fv(e.uniforms.pointLightColor,i)}};this.createBuffers=function(e,m){var f,p,k,i,o,C,u,t,I,B=[],E=[],U=[],P=[],W=[],T=[],F=0,r=e.geometry.geometryChunks[m],w;k=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){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
||||
THREE.SmoothShading){k=true;break}if(k)break}w=k;f=0;for(p=r.faces.length;f<p;f++){k=r.faces[f];i=e.geometry.faces[k];o=i.vertexNormals;faceNormal=i.normal;k=e.geometry.uvs[k];if(i instanceof THREE.Face3){C=e.geometry.vertices[i.a].position;u=e.geometry.vertices[i.b].position;t=e.geometry.vertices[i.c].position;U.push(C.x,C.y,C.z);U.push(u.x,u.y,u.z);U.push(t.x,t.y,t.z);if(e.geometry.hasTangents){C=e.geometry.vertices[i.a].tangent;u=e.geometry.vertices[i.b].tangent;t=e.geometry.vertices[i.c].tangent;
|
||||
W.push(C.x,C.y,C.z,C.w);W.push(u.x,u.y,u.z,u.w);W.push(t.x,t.y,t.z,t.w)}if(o.length==3&&w)for(i=0;i<3;i++)P.push(o[i].x,o[i].y,o[i].z);else for(i=0;i<3;i++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(i=0;i<3;i++)T.push(k[i].u,k[i].v);B.push(F,F+1,F+2);E.push(F,F+1);E.push(F,F+2);E.push(F+1,F+2);F+=3}else if(i instanceof THREE.Face4){C=e.geometry.vertices[i.a].position;u=e.geometry.vertices[i.b].position;t=e.geometry.vertices[i.c].position;I=e.geometry.vertices[i.d].position;U.push(C.x,
|
||||
C.y,C.z);U.push(u.x,u.y,u.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[i.a].tangent;u=e.geometry.vertices[i.b].tangent;t=e.geometry.vertices[i.c].tangent;i=e.geometry.vertices[i.d].tangent;W.push(C.x,C.y,C.z,C.w);W.push(u.x,u.y,u.z,u.w);W.push(t.x,t.y,t.z,t.w);W.push(i.x,i.y,i.z,i.w)}if(o.length==4&&w)for(i=0;i<4;i++)P.push(o[i].x,o[i].y,o[i].z);else for(i=0;i<4;i++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(i=0;i<4;i++)T.push(k[i].u,k[i].v);
|
||||
B.push(F,F+1,F+2);B.push(F,F+2,F+3);E.push(F,F+1);E.push(F,F+2);E.push(F,F+3);E.push(F+1,F+2);E.push(F+2,F+3);F+=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(E),c.STATIC_DRAW);r.__webGLFaceCount=B.length;r.__webGLLineCount=E.length}};this.renderBuffer=function(e,m,f,p){var k,i,o,C,u,t,I,B,E;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(E in f.uniforms)I.push(E);h(f.program,I);q(f.program,["position","normal","uv","tangent"])}E=
|
||||
f.program}else E=y;if(E!=A){c.useProgram(E);A=E}E==y&&this.setupLights(E,m);this.loadCamera(E,e);this.loadMatrices(E);if(f instanceof THREE.MeshShaderMaterial){o=f.wireframe;C=f.wireframe_linewidth;e=E;m=f.uniforms;var U;for(k in m){B=m[k].type;I=m[k].value;U=e.uniforms[k];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[k].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){k=f.color;i=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;u=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(E.uniforms.mColor,k.r*i,k.g*i,k.b*i,i);c.uniform1i(E.uniforms.mixEnvMap,m);c.uniform1f(E.uniforms.mReflectivity,e);c.uniform1i(E.uniforms.useRefract,
|
||||
B);c.uniform1f(E.uniforms.mRefractionRatio,I)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(E.uniforms.mOpacity,i);c.uniform1i(E.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,i);c.uniform1f(E.uniforms.m2Near,f.__2near);c.uniform1f(E.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(f instanceof
|
||||
THREE.MeshPhongMaterial){k=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(E.uniforms.mAmbient,k.r,k.g,k.b,i);c.uniform4f(E.uniforms.mSpecular,e.r,e.g,e.b,i);c.uniform1f(E.uniforms.mShininess,f);c.uniform1i(E.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);t=f.env_map}if(u){d(u,0);c.uniform1i(E.uniforms.tMap,
|
||||
0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(t){g(t,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);i=E.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(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,k,i){var o,C,u,t,I;u=0;for(t=f.material.length;u<t;u++){o=f.material[u];if(o instanceof THREE.MeshFaceMaterial){o=0;for(C=p.material.length;o<C;o++)if((I=p.material[o])&&I.blending==k&&I.opacity<1==i){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}else if((I=o)&&I.blending==k&&I.opacity<1==i){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}};this.render=function(e,m){var f,p,k,i,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++){k=e.__webGLObjects[f];i=k.object;k=k.buffer;if(i.visible){this.setupMatrices(i,m);this.renderPass(m,o,i,k,THREE.NormalBlending,false)}}f=0;for(p=e.__webGLObjects.length;f<p;f++){k=e.__webGLObjects[f];i=k.object;k=k.buffer;if(i.visible){this.setupMatrices(i,m);this.renderPass(m,o,i,k,THREE.AdditiveBlending,false);this.renderPass(m,o,i,k,THREE.SubtractiveBlending,
|
||||
false);this.renderPass(m,o,i,k,THREE.AdditiveBlending,true);this.renderPass(m,o,i,k,THREE.SubtractiveBlending,true);this.renderPass(m,o,i,k,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,f,p,k,i,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(i in p.geometry.geometryChunks){k=p.geometry.geometryChunks[i];
|
||||
k.__webGLVertexBuffer||this.createBuffers(p,i);if(o[i]==undefined){k={buffer:k,object:p};e.__webGLObjects.push(k);o[i]=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.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
|
||||
|
||||
+119
-119
@@ -1,61 +1,61 @@
|
||||
// ThreeDebug.js r31 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
||||
THREE.Color.prototype={setRGB:function(a,b,f){this.r=a;this.g=b;this.b=f;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};
|
||||
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,f){this.x=a||0;this.y=b||0;this.z=f||0};
|
||||
THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;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,f=this.y,d=this.z;this.x=f*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-f*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,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+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+" )"}};
|
||||
THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1};
|
||||
THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;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;
|
||||
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+")"}};
|
||||
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,f,d=a.objects,j=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)j=j.concat(this.intersectObject(f))}j.sort(function(p,l){return p.distance-l.distance});return j},intersectObject:function(a){function b(R,D,K,F){F=F.clone().subSelf(D);K=K.clone().subSelf(D);var e=R.clone().subSelf(D);R=F.dot(F);D=F.dot(K);F=F.dot(e);var m=K.dot(K);K=K.dot(e);e=1/(R*m-D*D);m=(m*F-D*K)*e;R=(R*K-D*F)*e;return m>0&&R>0&&m+R<1}var f,d,j,p,l,h,n,c,C,A,
|
||||
y,r=a.geometry,G=r.vertices,M=[];f=0;for(d=r.faces.length;f<d;f++){j=r.faces[f];A=this.origin.clone();y=this.direction.clone();p=a.matrix.multiplyVector3(G[j.a].position.clone());l=a.matrix.multiplyVector3(G[j.b].position.clone());h=a.matrix.multiplyVector3(G[j.c].position.clone());n=j instanceof THREE.Face4?a.matrix.multiplyVector3(G[j.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(j.normal.clone());C=y.dot(c);if(C<0){c=c.dot((new THREE.Vector3).sub(p,A))/C;A=A.addSelf(y.multiplyScalar(c));
|
||||
if(j instanceof THREE.Face3){if(b(A,p,l,h)){j={distance:this.origin.distanceTo(A),point:A,face:j,object:a};M.push(j)}}else if(j instanceof THREE.Face4)if(b(A,p,l,n)||b(A,l,h,n)){j={distance:this.origin.distanceTo(A),point:A,face:j,object:a};M.push(j)}}}return M}};
|
||||
THREE.Rectangle=function(){function a(){p=d-b;l=j-f}var b,f,d,j,p,l,h=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return p};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return j};this.set=function(n,c,C,A){h=false;b=n;f=c;d=C;j=A;a()};this.addPoint=function(n,c){if(h){h=false;b=n;f=c;d=n;j=c}else{b=b<n?b:n;f=f<c?f:c;d=d>n?d:n;j=j>c?
|
||||
j:c}a()};this.add3Points=function(n,c,C,A,y,r){if(h){h=false;b=n<C?n<y?n:y:C<y?C:y;f=c<A?c<r?c:r:A<r?A:r;d=n>C?n>y?n:y:C>y?C:y;j=c>A?c>r?c:r:A>r?A:r}else{b=n<C?n<y?n<b?n:b:y<b?y:b:C<y?C<b?C:b:y<b?y:b;f=c<A?c<r?c<f?c:f:r<f?r:f:A<r?A<f?A:f:r<f?r:f;d=n>C?n>y?n>d?n:d:y>d?y:d:C>y?C>d?C:d:y>d?y:d;j=c>A?c>r?c>j?c:j:r>j?r:j:A>r?A>j?A:j:r>j?r:j}a()};this.addRectangle=function(n){if(h){h=false;b=n.getLeft();f=n.getTop();d=n.getRight();j=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();f=f<n.getTop()?f:n.getTop();
|
||||
d=d>n.getRight()?d:n.getRight();j=j>n.getBottom()?j:n.getBottom()}a()};this.inflate=function(n){b-=n;f-=n;d+=n;j+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();f=f>n.getTop()?f:n.getTop();d=d<n.getRight()?d:n.getRight();j=j<n.getBottom()?j:n.getBottom();a()};this.instersects=function(n){return Math.min(d,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(j,n.getBottom())-Math.max(f,n.getTop())>=0};this.empty=function(){h=true;j=d=f=b=0;a()};this.isEmpty=function(){return h};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+j+", width: "+p+", height: "+l+" )"}};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,f,d,j,p,l,h,n,c,C,A,y,r,G,M){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=j||0;this.n22=p||1;this.n23=l||0;this.n24=h||0;this.n31=n||0;this.n32=c||0;this.n33=C||1;this.n34=A||0;this.n41=y||0;this.n42=r||0;this.n43=G||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,f,d,j,p,l,h,n,c,C,A,y,r,G,M){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=j;this.n22=p;this.n23=l;this.n24=h;this.n31=n;this.n32=c;this.n33=C;this.n34=A;this.n41=y;this.n42=r;this.n43=G;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,f){var d=new THREE.Vector3,j=new THREE.Vector3,p=new THREE.Vector3;p.sub(a,b).normalize();d.cross(f,p).normalize();j.cross(p,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=p.x;
|
||||
this.n32=p.y;this.n33=p.z;this.n34=-p.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,j=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*j;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*j;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,j=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*j;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
|
||||
j;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*j;a.w=this.n41*b+this.n42*f+this.n43*d+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 f=a.n11,d=a.n12,j=a.n13,p=a.n14,l=a.n21,h=a.n22,n=a.n23,c=a.n24,C=a.n31,A=a.n32,
|
||||
y=a.n33,r=a.n34,G=a.n41,M=a.n42,R=a.n43,D=a.n44,K=b.n11,F=b.n12,e=b.n13,m=b.n14,g=b.n21,q=b.n22,k=b.n23,i=b.n24,v=b.n31,x=b.n32,E=b.n33,o=b.n34,z=b.n41,P=b.n42,t=b.n43,U=b.n44;this.n11=f*K+d*g+j*v+p*z;this.n12=f*F+d*q+j*x+p*P;this.n13=f*e+d*k+j*E+p*t;this.n14=f*m+d*i+j*o+p*U;this.n21=l*K+h*g+n*v+c*z;this.n22=l*F+h*q+n*x+c*P;this.n23=l*e+h*k+n*E+c*t;this.n24=l*m+h*i+n*o+c*U;this.n31=C*K+A*g+y*v+r*z;this.n32=C*F+A*q+y*x+r*P;this.n33=C*e+A*k+y*E+r*t;this.n34=C*m+A*i+y*o+r*U;this.n41=G*K+M*g+R*v+D*z;
|
||||
this.n42=G*F+M*q+R*x+D*P;this.n43=G*e+M*k+R*E+D*t;this.n44=G*m+M*i+R*o+D*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,j=this.n14,p=this.n21,l=this.n22,h=this.n23,n=this.n24,c=this.n31,C=this.n32,A=this.n33,y=this.n34,r=this.n41,G=this.n42,M=this.n43,R=this.n44,D=a.n11,K=a.n21,F=a.n31,e=a.n41,m=a.n12,g=a.n22,q=a.n32,k=a.n42,i=a.n13,v=a.n23,x=a.n33,E=a.n43,o=a.n14,z=a.n24,P=a.n34;a=a.n44;this.n11=b*D+f*K+d*F+j*e;this.n12=b*m+f*g+d*q+j*k;this.n13=b*i+f*v+d*x+j*E;this.n14=
|
||||
b*o+f*z+d*P+j*a;this.n21=p*D+l*K+h*F+n*e;this.n22=p*m+l*g+h*q+n*k;this.n23=p*i+l*v+h*x+n*E;this.n24=p*o+l*z+h*P+n*a;this.n31=c*D+C*K+A*F+y*e;this.n32=c*m+C*g+A*q+y*k;this.n33=c*i+C*v+A*x+y*E;this.n34=c*o+C*z+A*P+y*a;this.n41=r*D+G*K+M*F+R*e;this.n42=r*m+G*g+M*q+R*k;this.n43=r*i+G*v+M*x+R*E;this.n44=r*o+G*z+M*P+R*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*
|
||||
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,f,d){var j=b[f];b[f]=b[d];
|
||||
b[d]=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,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
|
||||
THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;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 f=new THREE.Matrix4,d=Math.cos(b),j=Math.sin(b),p=1-d,l=a.x,h=a.y,n=a.z;f.n11=p*l*l+d;f.n12=p*l*h-j*n;f.n13=p*l*n+j*h;f.n21=p*l*h+j*n;f.n22=p*h*h+d;f.n23=p*h*n-j*l;f.n31=p*l*n-j*h;f.n32=p*h*n+j*l;f.n33=p*n*n+d;return f};
|
||||
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*
|
||||
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.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 f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],p=-b[10]*b[4]+b[6]*b[8],l=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],C=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*p+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*j;a.m[3]=b*p;a.m[4]=b*l;a.m[5]=b*h;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*C;return a};
|
||||
THREE.Matrix4.makeFrustum=function(a,b,f,d,j,p){var l,h,n;l=new THREE.Matrix4;h=2*j/(b-a);n=2*j/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(p+j)/(p-j);j=-2*p*j/(p-j);l.n11=h;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=n;l.n23=f;l.n24=0;l.n31=0;l.n32=0;l.n33=d;l.n34=j;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,f,d){var j;a=f*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,f,d)};
|
||||
THREE.Matrix4.makeOrtho=function(a,b,f,d,j,p){var l,h,n,c;l=new THREE.Matrix4;h=b-a;n=f-d;c=p-j;a=(b+a)/h;f=(f+d)/n;j=(p+j)/c;l.n11=2/h;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/n;l.n23=0;l.n24=-f;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-j;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};
|
||||
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.Face3=function(a,b,f,d,j){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];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,f,d,j,p){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=p instanceof Array?p:[p]};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.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
|
||||
f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,j,p,l,h=new THREE.Vector3,n=new THREE.Vector3;d=0;for(j=this.vertices.length;d<j;d++){p=this.vertices[d];p.normal.set(0,0,0)}d=0;for(j=this.faces.length;d<j;d++){p=this.faces[d];if(a&&p.vertexNormals.length){h.set(0,0,0);b=0;for(f=p.normal.length;b<f;b++)h.addSelf(p.vertexNormals[b]);h.divideScalar(3)}else{b=this.vertices[p.a];f=this.vertices[p.b];l=this.vertices[p.c];h.sub(l.position,
|
||||
f.position);n.sub(b.position,f.position);h.crossSelf(n)}h.isZero()||h.normalize();p.normal.copy(h)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;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(f=this.faces.length;a<f;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(o,z,P,t){p=o.vertices[z].position;l=o.vertices[P].position;
|
||||
h=o.vertices[t].position;n=j[0];c=j[1];C=j[2];A=l.x-p.x;y=h.x-p.x;r=l.y-p.y;G=h.y-p.y;M=l.z-p.z;R=h.z-p.z;D=c.u-n.u;K=C.u-n.u;F=c.v-n.v;e=C.v-n.v;m=1/(D*e-K*F);i.set((e*A-F*y)*m,(e*r-F*G)*m,(e*M-F*R)*m);v.set((D*y-K*A)*m,(D*G-K*r)*m,(D*R-K*M)*m);q[z].addSelf(i);q[P].addSelf(i);q[t].addSelf(i);k[z].addSelf(v);k[P].addSelf(v);k[t].addSelf(v)}var b,f,d,j,p,l,h,n,c,C,A,y,r,G,M,R,D,K,F,e,m,g,q=[],k=[],i=new THREE.Vector3,v=new THREE.Vector3,x=new THREE.Vector3,E=new THREE.Vector3;g=new THREE.Vector3;b=
|
||||
0;for(f=this.vertices.length;b<f;b++){q[b]=new THREE.Vector3;k[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];j=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(f=this.vertices.length;b<f;b++){g.copy(this.vertices[b].normal);d=q[b];x.copy(d);x.subSelf(g.multiplyScalar(g.dot(d))).normalize();E.cross(this.vertices[b].normal,d);test=E.dot(k[b]);d=test<0?-1:1;this.vertices[b].tangent.set(x.x,x.y,x.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],
|
||||
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]=
|
||||
vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(C){var A=[];b=0;for(f=C.length;b<f;b++)C[b]==undefined?A.push("undefined"):A.push(C[b].toString());return A.join("_")}var b,f,d,j,p,l,h,n,c={};d=0;for(j=this.faces.length;d<j;d++){p=this.faces[d];l=p.material;h=a(l);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:l,
|
||||
vertices:0};p=p instanceof THREE.Face3?3:4;if(this.geometryChunks[n].vertices+p>65535){c[h].counter+=1;n=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:l,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=p}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
||||
THREE.Camera=function(a,b,f,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,f,d);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.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};
|
||||
@@ -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: "+
|
||||
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.Texture=function(a,b,f,d,j,p){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=p!==undefined?p: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(){};
|
||||
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.Projector=function(){function a(q,k){var i=0,v=1,x=q.z+q.w,E=k.z+k.w,o=-q.z+q.w,z=-k.z+k.w;if(x>=0&&E>=0&&o>=0&&z>=0)return true;else if(x<0&&E<0||o<0&&z<0)return false;else{if(x<0)i=Math.max(i,x/(x-E));else if(E<0)v=Math.min(v,x/(x-E));if(o<0)i=Math.max(i,o/(o-z));else if(z<0)v=Math.min(v,o/(o-z));if(v<i)return false;else{q.lerpSelf(k,i);k.lerpSelf(q,1-v);return true}}}function b(q,k){return k.z-q.z}var f=null,d,j,p=[],l,h,n,c=[],C,A,y=[],r,G,M=[],R=new THREE.Vector3,D=new THREE.Vector4,K=
|
||||
new THREE.Matrix4,F=new THREE.Matrix4,e=new THREE.Vector4,m=new THREE.Vector4,g;this.projectObjects=function(q){var k,i,v;f=[];j=0;i=q.objects;q=0;for(k=i.length;q<k;q++){v=i[q];if(v.visible!==false){d=p[j]=p[j]||new THREE.RenderableObject;D.copy(v.position);K.multiplyVector4(D);D.multiplyScalar(1/D.w);d.object=v;d.z=R.z;f.push(d);j++}}f.sort(b);return f};this.projectScene=function(q,k){var i,v,x,E,o,z,P,t,U,O,X,V,H,w,s,N,S;f=[];n=A=G=0;k.autoUpdateMatrix&&k.updateMatrix();K.multiply(k.projectionMatrix,
|
||||
k.matrix);P=q.objects;i=0;for(v=P.length;i<v;i++){t=P[i];if(t.visible!==false){t.autoUpdateMatrix&&t.updateMatrix();U=t.matrix;O=t.rotationMatrix;X=t.material;V=t.overdraw;if(t instanceof THREE.Mesh){H=t.geometry;w=H.vertices;x=0;for(E=w.length;x<E;x++){s=w[x];s.positionWorld.copy(s.position);U.multiplyVector3(s.positionWorld);o=s.positionScreen;o.copy(s.positionWorld);K.multiplyVector4(o);o.multiplyScalar(1/o.w);s.__visible=o.z>0&&o.z<1}H=H.faces;x=0;for(E=H.length;x<E;x++){s=H[x];if(s instanceof
|
||||
THREE.Face3){o=w[s.a];z=w[s.b];N=w[s.c];if(o.__visible&&z.__visible&&N.__visible)if(t.doubleSided||t.flipSided!=(N.positionScreen.x-o.positionScreen.x)*(z.positionScreen.y-o.positionScreen.y)-(N.positionScreen.y-o.positionScreen.y)*(z.positionScreen.x-o.positionScreen.x)<0){l=c[n]=c[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(o.positionWorld);l.v2.positionWorld.copy(z.positionWorld);l.v3.positionWorld.copy(N.positionWorld);l.v1.positionScreen.copy(o.positionScreen);l.v2.positionScreen.copy(z.positionScreen);
|
||||
l.v3.positionScreen.copy(N.positionScreen);l.normalWorld.copy(s.normal);O.multiplyVector3(l.normalWorld);l.centroidWorld.copy(s.centroid);U.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);K.multiplyVector3(l.centroidScreen);N=s.vertexNormals;g=l.vertexNormalsWorld;o=0;for(z=N.length;o<z;o++){S=g[o]=g[o]||new THREE.Vector3;S.copy(N[o]);O.multiplyVector3(S)}l.z=l.centroidScreen.z;l.meshMaterial=X;l.faceMaterial=s.material;l.overdraw=V;if(t.geometry.uvs[x]){l.uvs[0]=t.geometry.uvs[x][0];
|
||||
l.uvs[1]=t.geometry.uvs[x][1];l.uvs[2]=t.geometry.uvs[x][2]}f.push(l);n++}}else if(s instanceof THREE.Face4){o=w[s.a];z=w[s.b];N=w[s.c];S=w[s.d];if(o.__visible&&z.__visible&&N.__visible&&S.__visible)if(t.doubleSided||t.flipSided!=((S.positionScreen.x-o.positionScreen.x)*(z.positionScreen.y-o.positionScreen.y)-(S.positionScreen.y-o.positionScreen.y)*(z.positionScreen.x-o.positionScreen.x)<0||(z.positionScreen.x-N.positionScreen.x)*(S.positionScreen.y-N.positionScreen.y)-(z.positionScreen.y-N.positionScreen.y)*
|
||||
(S.positionScreen.x-N.positionScreen.x)<0)){l=c[n]=c[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(o.positionWorld);l.v2.positionWorld.copy(z.positionWorld);l.v3.positionWorld.copy(S.positionWorld);l.v1.positionScreen.copy(o.positionScreen);l.v2.positionScreen.copy(z.positionScreen);l.v3.positionScreen.copy(S.positionScreen);l.normalWorld.copy(s.normal);O.multiplyVector3(l.normalWorld);l.centroidWorld.copy(s.centroid);U.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);
|
||||
K.multiplyVector3(l.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterial=X;l.faceMaterial=s.material;l.overdraw=V;if(t.geometry.uvs[x]){l.uvs[0]=t.geometry.uvs[x][0];l.uvs[1]=t.geometry.uvs[x][1];l.uvs[2]=t.geometry.uvs[x][3]}f.push(l);n++;h=c[n]=c[n]||new THREE.RenderableFace3;h.v1.positionWorld.copy(z.positionWorld);h.v2.positionWorld.copy(N.positionWorld);h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(z.positionScreen);h.v2.positionScreen.copy(N.positionScreen);h.v3.positionScreen.copy(S.positionScreen);
|
||||
h.normalWorld.copy(l.normalWorld);h.centroidWorld.copy(l.centroidWorld);h.centroidScreen.copy(l.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterial=X;h.faceMaterial=s.material;h.overdraw=V;if(t.geometry.uvs[x]){h.uvs[0]=t.geometry.uvs[x][1];h.uvs[1]=t.geometry.uvs[x][2];h.uvs[2]=t.geometry.uvs[x][3]}f.push(h);n++}}}}else if(t instanceof THREE.Line){F.multiply(K,U);w=t.geometry.vertices;s=w[0];s.positionScreen.copy(s.position);F.multiplyVector4(s.positionScreen);x=1;for(E=w.length;x<E;x++){o=w[x];
|
||||
o.positionScreen.copy(o.position);F.multiplyVector4(o.positionScreen);z=w[x-1];e.copy(o.positionScreen);m.copy(z.positionScreen);if(a(e,m)){e.multiplyScalar(1/e.w);m.multiplyScalar(1/m.w);C=y[A]=y[A]||new THREE.RenderableLine;C.v1.positionScreen.copy(e);C.v2.positionScreen.copy(m);C.z=Math.max(e.z,m.z);C.material=t.material;f.push(C);A++}}}else if(t instanceof THREE.Particle){D.set(t.position.x,t.position.y,t.position.z,1);K.multiplyVector4(D);D.z/=D.w;if(D.z>0&&D.z<1){r=M[G]=M[G]||new THREE.RenderableParticle;
|
||||
r.x=D.x/D.w;r.y=D.y/D.w;r.z=D.z;r.rotation=t.rotation.z;r.scale.x=t.scale.x*Math.abs(r.x-(D.x+k.projectionMatrix.n11)/(D.w+k.projectionMatrix.n14));r.scale.y=t.scale.y*Math.abs(r.y-(D.y+k.projectionMatrix.n22)/(D.w+k.projectionMatrix.n24));r.material=t.material;f.push(r);G++}}}}f.sort(b);return f};this.unprojectVector=function(q,k){var i=new THREE.Matrix4;i.multiply(THREE.Matrix4.makeInvert(k.matrix),THREE.Matrix4.makeInvert(k.projectionMatrix));i.multiplyVector3(q);return q}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,j,p;this.domElement=document.createElement("div");this.setSize=function(l,h){f=l;d=h;j=f/2;p=d/2};this.render=function(l,h){var n,c,C,A,y,r,G,M;a=b.projectScene(l,h);n=0;for(c=a.length;n<c;n++){y=a[n];if(y instanceof THREE.RenderableParticle){G=y.x*j+j;M=y.y*p+p;C=0;for(A=y.material.length;C<A;C++){r=y.material[C];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=G+"px";r.style.top=M+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,j,p,l,h=f.getContext("2d"),n=1,c=0,C=null,A=null,y=1,r,G,M,R,D,K,F,e,m,g=new THREE.Color,q=new THREE.Color,k=new THREE.Color,i=new THREE.Color,v=new THREE.Color,x,E,o,z,P,t,U,O,X,V,H=new THREE.Rectangle,w=new THREE.Rectangle,s=new THREE.Rectangle,N=false,S=new THREE.Color,L=new THREE.Color,T=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,Y=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=f;this.autoClear=true;this.setSize=function(ga,ua){d=ga;j=ua;p=d/2;l=j/2;f.width=d;f.height=j;H.set(-p,-l,p,l)};this.clear=function(){if(!w.isEmpty()){w.inflate(1);w.minSelf(H);h.clearRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());
|
||||
w.empty()}};this.render=function(ga,ua){function Ka(u){var Q,J,B,I=u.lights;L.setRGB(0,0,0);T.setRGB(0,0,0);aa.setRGB(0,0,0);u=0;for(Q=I.length;u<Q;u++){J=I[u];B=J.color;if(J instanceof THREE.AmbientLight){L.r+=B.r;L.g+=B.g;L.b+=B.b}else if(J instanceof THREE.DirectionalLight){T.r+=B.r;T.g+=B.g;T.b+=B.b}else if(J instanceof THREE.PointLight){aa.r+=B.r;aa.g+=B.g;aa.b+=B.b}}}function va(u,Q,J,B){var I,W,$,ba,ca=u.lights;u=0;for(I=ca.length;u<I;u++){W=ca[u];$=W.color;ba=W.intensity;if(W instanceof THREE.DirectionalLight){W=
|
||||
J.dot(W.position)*ba;if(W>0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,Q);Y.normalize();W=J.dot(Y)*ba;if(W>0){B.r+=$.r*W;B.g+=$.g*W;B.b+=$.b*W}}}}function La(u,Q,J){if(J.opacity!=0){Ba(J.opacity);wa(J.blending);var B,I,W,$,ba,ca;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){$=J.map;ba=$.width>>1;ca=$.height>>1;I=Q.scale.x*p;W=Q.scale.y*l;J=I*ba;B=W*ca;s.set(u.x-J,u.y-B,u.x+J,u.y+B);if(!H.instersects(s))return;h.save();h.translate(u.x,u.y);h.rotate(-Q.rotation);
|
||||
h.scale(I,-W);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(J instanceof THREE.ParticleCircleMaterial){if(N){S.r=L.r+T.r+aa.r;S.g=L.g+T.g+aa.g;S.b=L.b+T.b+aa.b;g.r=J.color.r*S.r;g.g=J.color.g*S.g;g.b=J.color.b*S.b;g.updateStyleString()}else g.__styleString=J.color.__styleString;J=Q.scale.x*p;B=Q.scale.y*l;s.set(u.x-J,u.y-B,u.x+J,u.y+
|
||||
B);if(H.instersects(s)){I=g.__styleString;if(A!=I)h.fillStyle=A=I;h.save();h.translate(u.x,u.y);h.rotate(-Q.rotation);h.scale(J,B);h.beginPath();h.arc(0,0,1,0,Ja,true);h.closePath();h.fill();h.restore()}}}}function Ma(u,Q,J,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);h.beginPath();h.moveTo(u.positionScreen.x,u.positionScreen.y);h.lineTo(Q.positionScreen.x,Q.positionScreen.y);h.closePath();if(B instanceof THREE.LineBasicMaterial){g.__styleString=B.color.__styleString;u=B.linewidth;if(y!=u)h.lineWidth=
|
||||
y=u;u=g.__styleString;if(C!=u)h.strokeStyle=C=u;h.stroke();s.inflate(B.linewidth*2)}}}function Fa(u,Q,J,B,I,W){if(I.opacity!=0){Ba(I.opacity);wa(I.blending);R=u.positionScreen.x;D=u.positionScreen.y;K=Q.positionScreen.x;F=Q.positionScreen.y;e=J.positionScreen.x;m=J.positionScreen.y;h.beginPath();h.moveTo(R,D);h.lineTo(K,F);h.lineTo(e,m);h.lineTo(R,D);h.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,I.map.image,
|
||||
B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){u=ua.matrix;Y.copy(B.vertexNormalsWorld[0]);P=(Y.x*u.n11+Y.y*u.n12+Y.z*u.n13)*0.5+0.5;t=-(Y.x*u.n21+Y.y*u.n22+Y.z*u.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);U=(Y.x*u.n11+Y.y*u.n12+Y.z*u.n13)*0.5+0.5;O=-(Y.x*u.n21+Y.y*u.n22+Y.z*u.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);X=(Y.x*u.n11+Y.y*u.n12+Y.z*u.n13)*0.5+0.5;V=-(Y.x*
|
||||
u.n21+Y.y*u.n22+Y.z*u.n23)*0.5+0.5;qa(R,D,K,F,e,m,I.env_map.image,P,t,U,O,X,V)}}else I.wireframe?xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&qa(R,D,K,F,e,m,I.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){q.r=k.r=
|
||||
i.r=L.r;q.g=k.g=i.g=L.g;q.b=k.b=i.b=L.b;va(W,B.v1.positionWorld,B.vertexNormalsWorld[0],q);va(W,B.v2.positionWorld,B.vertexNormalsWorld[1],k);va(W,B.v3.positionWorld,B.vertexNormalsWorld[2],i);v.r=(k.r+i.r)*0.5;v.g=(k.g+i.g)*0.5;v.b=(k.b+i.b)*0.5;z=Ga(q,k,i,v);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else{S.r=L.r;S.g=L.g;S.b=L.b;va(W,B.centroidWorld,B.normalWorld,S);g.r=I.color.r*S.r;g.g=I.color.g*S.g;g.b=I.color.b*S.b;g.updateStyleString();I.wireframe?xa(g.__styleString,I.wireframe_linewidth):ya(g.__styleString)}else I.wireframe?
|
||||
xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){x=I.__2near;E=I.__farPlusNear;o=I.__farMinusNear;q.r=q.g=q.b=1-x/(E-u.positionScreen.z*o);k.r=k.g=k.b=1-x/(E-Q.positionScreen.z*o);i.r=i.g=i.b=1-x/(E-J.positionScreen.z*o);v.r=(k.r+i.r)*0.5;v.g=(k.g+i.g)*0.5;v.b=(k.b+i.b)*0.5;z=Ga(q,k,i,v);qa(R,D,K,F,e,m,z,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){g.r=Ca(B.normalWorld.x);g.g=Ca(B.normalWorld.y);g.b=Ca(B.normalWorld.z);
|
||||
g.updateStyleString();I.wireframe?xa(g.__styleString,I.wireframe_linewidth):ya(g.__styleString)}}}function xa(u,Q){if(C!=u)h.strokeStyle=C=u;if(y!=Q)h.lineWidth=y=Q;h.stroke();s.inflate(Q*2)}function ya(u){if(A!=u)h.fillStyle=A=u;h.fill()}function qa(u,Q,J,B,I,W,$,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;J-=u;B-=Q;I-=u;W-=Q;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*J-ea*I)*ja;ea=(ra*B-ea*W)*ja;J=(ha*I-ia*J)*ja;B=(ha*W-ia*B)*ja;u=
|
||||
u-ka*ba-J*ca;Q=Q-ea*ba-B*ca;h.save();h.transform(ka,ea,J,B,u,Q);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,Q,J,B){var I=~~(u.r*255),W=~~(u.g*255);u=~~(u.b*255);var $=~~(Q.r*255),ba=~~(Q.g*255);Q=~~(Q.b*
|
||||
255);var ca=~~(J.r*255),ha=~~(J.g*255);J=~~(J.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=I<0?0:I>255?255:I;da[1]=W<0?0:W>255?255:W;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]=Q<0?0:Q>255?255:Q;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=J<0?0:J>255?255:J;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;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,Q){var J=Q.x-u.x,B=Q.y-u.y,I=1/Math.sqrt(J*J+B*B);J*=I;B*=I;Q.x+=J;Q.y+=B;u.x-=J;u.y-=B}var za,Ha,Z,fa,ma,Ea,Ia,sa;h.setTransform(1,0,0,-1,p,l);this.autoClear&&this.clear();a=b.projectScene(ga,ua);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(H.getX(),H.getY(),H.getWidth(),H.getHeight());(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];s.empty();if(Z instanceof THREE.RenderableParticle){r=Z;r.x*=p;r.y*=l;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;G=Z.v2;r.positionScreen.x*=p;r.positionScreen.y*=l;G.positionScreen.x*=p;G.positionScreen.y*=l;s.addPoint(r.positionScreen.x,r.positionScreen.y);s.addPoint(G.positionScreen.x,G.positionScreen.y);if(H.instersects(s)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(r,G,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){r=Z.v1;G=Z.v2;M=Z.v3;r.positionScreen.x*=p;r.positionScreen.y*=l;G.positionScreen.x*=p;G.positionScreen.y*=
|
||||
l;M.positionScreen.x*=p;M.positionScreen.y*=l;if(Z.overdraw){Da(r.positionScreen,G.positionScreen);Da(G.positionScreen,M.positionScreen);Da(M.positionScreen,r.positionScreen)}s.add3Points(r.positionScreen.x,r.positionScreen.y,G.positionScreen.x,G.positionScreen.y,M.positionScreen.x,M.positionScreen.y);if(H.instersects(s)){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,
|
||||
G,M,Z,sa,ga)}else Fa(r,G,M,Z,sa,ga)}}}w.addRectangle(s)}h.lineWidth=1;h.strokeStyle="rgba( 255, 0, 0, 0.5 )";h.strokeRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());h.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(O,X,V){var H,w,s,N;H=0;for(w=O.lights.length;H<w;H++){s=O.lights[H];if(s instanceof THREE.DirectionalLight){N=X.normalWorld.dot(s.position)*s.intensity;if(N>0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}else if(s instanceof THREE.PointLight){i.sub(s.position,X.centroidWorld);i.normalize();N=X.normalWorld.dot(i)*s.intensity;if(N>0){V.r+=s.color.r*N;V.g+=s.color.g*N;V.b+=s.color.b*N}}}}function b(O,X,V,H,w,s){o=d(z++);o.setAttribute("d","M "+O.positionScreen.x+
|
||||
" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(s,H,e);F.r=w.color.r*e.r;F.g=w.color.g*e.g;F.b=w.color.b*e.b;F.updateStyleString()}else F.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){k=1-w.__2near/(w.__farPlusNear-H.z*w.__farMinusNear);
|
||||
F.setRGB(k,k,k)}else w instanceof THREE.MeshNormalMaterial&&F.setRGB(j(H.normalWorld.x),j(H.normalWorld.y),j(H.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+w.opacity);h.appendChild(o)}function f(O,X,V,H,w,s,N){o=d(z++);o.setAttribute("d",
|
||||
"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(K){e.r=m.r;e.g=m.g;e.b=m.b;a(N,w,e);F.r=s.color.r*e.r;F.g=s.color.g*e.g;F.b=s.color.b*e.b;F.updateStyleString()}else F.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){k=
|
||||
1-s.__2near/(s.__farPlusNear-w.z*s.__farMinusNear);F.setRGB(k,k,k)}else s instanceof THREE.MeshNormalMaterial&&F.setRGB(j(w.normalWorld.x),j(w.normalWorld.y),j(w.normalWorld.z));s.wireframe?o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):o.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+s.opacity);h.appendChild(o)}
|
||||
function d(O){if(v[O]==null){v[O]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&v[O].setAttribute("shape-rendering","crispEdges");return v[O]}return v[O]}function j(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var p=null,l=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,C,A,y,r,G,M,R=new THREE.Rectangle,D=new THREE.Rectangle,K=false,F=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),g=new THREE.Color(0),
|
||||
q=new THREE.Color(0),k,i=new THREE.Vector3,v=[],x=[],E=[],o,z,P,t,U=1;this.domElement=h;this.autoClear=true;this.setQuality=function(O){switch(O){case "high":U=1;break;case "low":U=0}};this.setSize=function(O,X){n=O;c=X;C=n/2;A=c/2;h.setAttribute("viewBox",-C+" "+-A+" "+n+" "+c);h.setAttribute("width",n);h.setAttribute("height",c);R.set(-C,-A,C,A)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(O,X){var V,H,w,s,N,S,L,T;this.autoClear&&this.clear();
|
||||
p=l.projectScene(O,X);t=P=z=0;if(K=O.lights.length>0){L=O.lights;m.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);V=0;for(H=L.length;V<H;V++){w=L[V];s=w.color;if(w instanceof THREE.AmbientLight){m.r+=s.r;m.g+=s.g;m.b+=s.b}else if(w instanceof THREE.DirectionalLight){g.r+=s.r;g.g+=s.g;g.b+=s.b}else if(w instanceof THREE.PointLight){q.r+=s.r;q.g+=s.g;q.b+=s.b}}}V=0;for(H=p.length;V<H;V++){L=p[V];D.empty();if(L instanceof THREE.RenderableParticle){y=L;y.x*=C;y.y*=-A;w=0;for(s=L.material.length;w<s;w++)if(T=
|
||||
L.material[w]){N=y;S=L;T=T;var aa=P++;if(x[aa]==null){x[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&x[aa].setAttribute("shape-rendering","crispEdges")}o=x[aa];o.setAttribute("cx",N.x);o.setAttribute("cy",N.y);o.setAttribute("r",S.scale.x*C);if(T instanceof THREE.ParticleCircleMaterial){if(K){e.r=m.r+g.r+q.r;e.g=m.g+g.g+q.g;e.b=m.b+g.b+q.b;F.r=T.color.r*e.r;F.g=T.color.g*e.g;F.b=T.color.b*e.b;F.updateStyleString()}else F=T.color;o.setAttribute("style","fill: "+F.__styleString)}h.appendChild(o)}}else if(L instanceof
|
||||
THREE.RenderableLine){y=L.v1;r=L.v2;y.positionScreen.x*=C;y.positionScreen.y*=-A;r.positionScreen.x*=C;r.positionScreen.y*=-A;D.addPoint(y.positionScreen.x,y.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);if(R.instersects(D)){w=0;for(s=L.material.length;w<s;)if(T=L.material[w++]){N=y;S=r;T=T;aa=t++;if(E[aa]==null){E[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");U==0&&E[aa].setAttribute("shape-rendering","crispEdges")}o=E[aa];o.setAttribute("x1",N.positionScreen.x);
|
||||
o.setAttribute("y1",N.positionScreen.y);o.setAttribute("x2",S.positionScreen.x);o.setAttribute("y2",S.positionScreen.y);if(T instanceof THREE.LineBasicMaterial){F.__styleString=T.color.__styleString;o.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin);h.appendChild(o)}}}}else if(L instanceof THREE.RenderableFace3){y=L.v1;r=L.v2;G=L.v3;y.positionScreen.x*=C;y.positionScreen.y*=
|
||||
-A;r.positionScreen.x*=C;r.positionScreen.y*=-A;G.positionScreen.x*=C;G.positionScreen.y*=-A;D.addPoint(y.positionScreen.x,y.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);D.addPoint(G.positionScreen.x,G.positionScreen.y);if(R.instersects(D)){w=0;for(s=L.meshMaterial.length;w<s;){T=L.meshMaterial[w++];if(T instanceof THREE.MeshFaceMaterial){N=0;for(S=L.faceMaterial.length;N<S;)(T=L.faceMaterial[N++])&&b(y,r,G,L,T,O)}else T&&b(y,r,G,L,T,O)}}}else if(L instanceof THREE.RenderableFace4){y=
|
||||
L.v1;r=L.v2;G=L.v3;M=L.v4;y.positionScreen.x*=C;y.positionScreen.y*=-A;r.positionScreen.x*=C;r.positionScreen.y*=-A;G.positionScreen.x*=C;G.positionScreen.y*=-A;M.positionScreen.x*=C;M.positionScreen.y*=-A;D.addPoint(y.positionScreen.x,y.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);D.addPoint(G.positionScreen.x,G.positionScreen.y);D.addPoint(M.positionScreen.x,M.positionScreen.y);if(R.instersects(D)){w=0;for(s=L.meshMaterial.length;w<s;){T=L.meshMaterial[w++];if(T instanceof
|
||||
THREE.MeshFaceMaterial){N=0;for(S=L.faceMaterial.length;N<S;)(T=L.faceMaterial[N++])&&f(y,r,G,M,L,T,O)}else T&&f(y,r,G,M,L,T,O)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(e,m){var g=c.createProgram(),q=[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(g,l("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
||||
e));c.attachShader(g,l("vertex",q+m));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function f(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 g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);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,
|
||||
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 j(e,m){var g,q,k;g=0;for(q=m.length;g<q;g++){k=m[g];e.uniforms[k]=c.getUniformLocation(e,k)}}function p(e,m){var g,q,k;g=0;for(q=m.length;g<q;g++){k=m[g];e.attributes[k]=c.getAttribLocation(e,k);e.attributes[k]>=0&&c.enableVertexAttribArray(e.attributes[k])}}function l(e,m){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER);
|
||||
c.shaderSource(g,m);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}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,C,A,y=new THREE.Matrix4,r,G=new Float32Array(16),M=new Float32Array(16),R=new Float32Array(16),D=new Float32Array(9),K=new Float32Array(16);a=function(e,m){if(e){var g,q,k,i=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=e.lights.length;g<q;g++){k=e.lights[g];k instanceof THREE.DirectionalLight&&i++;k instanceof
|
||||
THREE.PointLight&&pointLights++}if(pointLights+i<=m){maxDirLights=i;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*i/(pointLights+i));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(F){}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);C=A=function(e,m){var g=[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 ];":
|
||||
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"),
|
||||
q=[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;",
|
||||
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");
|
||||
g=b(q,g);c.useProgram(g);j(g,["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&&j(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&j(g,["pointLightNumber","pointLightColor",
|
||||
"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);p(g,["position","normal","uv"]);return g}(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 g,q,k,i,v,x=[],
|
||||
E=[],o=[];i=[];v=[];c.uniform1i(e.uniforms.enableLighting,m.length);g=0;for(q=m.length;g<q;g++){k=m[g];if(k instanceof THREE.AmbientLight)x.push(k);else if(k instanceof THREE.DirectionalLight)o.push(k);else k instanceof THREE.PointLight&&E.push(k)}g=k=i=v=0;for(q=x.length;g<q;g++){k+=x[g].color.r;i+=x[g].color.g;v+=x[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,k,i,v);i=[];v=[];g=0;for(q=o.length;g<q;g++){k=o[g];i.push(k.color.r*k.intensity);i.push(k.color.g*k.intensity);i.push(k.color.b*k.intensity);
|
||||
v.push(k.position.x);v.push(k.position.y);v.push(k.position.z)}if(o.length){c.uniform1i(e.uniforms.directionalLightNumber,o.length);c.uniform3fv(e.uniforms.directionalLightDirection,v);c.uniform3fv(e.uniforms.directionalLightColor,i)}i=[];v=[];g=0;for(q=E.length;g<q;g++){k=E[g];i.push(k.color.r*k.intensity);i.push(k.color.g*k.intensity);i.push(k.color.b*k.intensity);v.push(k.position.x);v.push(k.position.y);v.push(k.position.z)}if(E.length){c.uniform1i(e.uniforms.pointLightNumber,E.length);c.uniform3fv(e.uniforms.pointLightPosition,
|
||||
v);c.uniform3fv(e.uniforms.pointLightColor,i)}};this.createBuffers=function(e,m){var g,q,k,i,v,x,E,o,z,P=[],t=[],U=[],O=[],X=[],V=[],H=0,w=e.geometry.geometryChunks[m],s;k=false;g=0;for(q=e.material.length;g<q;g++){meshMaterial=e.material[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){v=0;for(s=w.material.length;v<s;v++)if(w.material[v]&&w.material[v].shading!=undefined&&w.material[v].shading==THREE.SmoothShading){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
||||
THREE.SmoothShading){k=true;break}if(k)break}s=k;g=0;for(q=w.faces.length;g<q;g++){k=w.faces[g];i=e.geometry.faces[k];v=i.vertexNormals;faceNormal=i.normal;k=e.geometry.uvs[k];if(i instanceof THREE.Face3){x=e.geometry.vertices[i.a].position;E=e.geometry.vertices[i.b].position;o=e.geometry.vertices[i.c].position;U.push(x.x,x.y,x.z);U.push(E.x,E.y,E.z);U.push(o.x,o.y,o.z);if(e.geometry.hasTangents){x=e.geometry.vertices[i.a].tangent;E=e.geometry.vertices[i.b].tangent;o=e.geometry.vertices[i.c].tangent;
|
||||
X.push(x.x,x.y,x.z,x.w);X.push(E.x,E.y,E.z,E.w);X.push(o.x,o.y,o.z,o.w)}if(v.length==3&&s)for(i=0;i<3;i++)O.push(v[i].x,v[i].y,v[i].z);else for(i=0;i<3;i++)O.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(i=0;i<3;i++)V.push(k[i].u,k[i].v);P.push(H,H+1,H+2);t.push(H,H+1);t.push(H,H+2);t.push(H+1,H+2);H+=3}else if(i instanceof THREE.Face4){x=e.geometry.vertices[i.a].position;E=e.geometry.vertices[i.b].position;o=e.geometry.vertices[i.c].position;z=e.geometry.vertices[i.d].position;U.push(x.x,
|
||||
x.y,x.z);U.push(E.x,E.y,E.z);U.push(o.x,o.y,o.z);U.push(z.x,z.y,z.z);if(e.geometry.hasTangents){x=e.geometry.vertices[i.a].tangent;E=e.geometry.vertices[i.b].tangent;o=e.geometry.vertices[i.c].tangent;i=e.geometry.vertices[i.d].tangent;X.push(x.x,x.y,x.z,x.w);X.push(E.x,E.y,E.z,E.w);X.push(o.x,o.y,o.z,o.w);X.push(i.x,i.y,i.z,i.w)}if(v.length==4&&s)for(i=0;i<4;i++)O.push(v[i].x,v[i].y,v[i].z);else for(i=0;i<4;i++)O.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(i=0;i<4;i++)V.push(k[i].u,k[i].v);
|
||||
P.push(H,H+1,H+2);P.push(H,H+2,H+3);t.push(H,H+1);t.push(H,H+2);t.push(H,H+3);t.push(H+1,H+2);t.push(H+2,H+3);H+=4}}if(U.length){w.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW);w.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(O),c.STATIC_DRAW);if(e.geometry.hasTangents){w.__webGLTangentBuffer=c.createBuffer();
|
||||
c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}if(V.length>0){w.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}w.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);w.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
w.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);w.__webGLFaceCount=P.length;w.__webGLLineCount=t.length}};this.renderBuffer=function(e,m,g,q){var k,i,v,x,E,o,z,P,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)z.push(t);j(g.program,z);p(g.program,["position","normal","uv","tangent"])}t=
|
||||
g.program}else t=A;if(t!=C){c.useProgram(t);C=t}t==A&&this.setupLights(t,m);this.loadCamera(t,e);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){v=g.wireframe;x=g.wireframe_linewidth;e=t;m=g.uniforms;var U;for(k in m){P=m[k].type;z=m[k].value;U=e.uniforms[k];if(P=="i")c.uniform1i(U,z);else if(P=="f")c.uniform1f(U,z);else if(P=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(P=="c")c.uniform3f(U,z.r,z.g,z.b);else if(P=="t"){c.uniform1i(U,z);if(P=m[k].texture)P.image instanceof Array&&P.image.length==
|
||||
6?f(P,z):d(P,z)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){k=g.color;i=g.opacity;v=g.wireframe;x=g.wireframe_linewidth;E=g.map;o=g.env_map;m=g.combine==THREE.MixOperation;e=g.reflectivity;P=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;z=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,k.r*i,k.g*i,k.b*i,i);c.uniform1i(t.uniforms.mixEnvMap,m);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract,
|
||||
P);c.uniform1f(t.uniforms.mRefractionRatio,z)}if(g instanceof THREE.MeshNormalMaterial){i=g.opacity;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){i=g.opacity;v=g.wireframe;x=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof
|
||||
THREE.MeshPhongMaterial){k=g.ambient;e=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,k.r,k.g,k.b,i);c.uniform4f(t.uniforms.mSpecular,e.r,e.g,e.b,i);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);o=g.env_map}if(E){d(E,0);c.uniform1i(t.uniforms.tMap,
|
||||
0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(o){f(o,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);i=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer);
|
||||
c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(v){c.lineWidth(x);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT,
|
||||
0)}};this.renderPass=function(e,m,g,q,k,i){var v,x,E,o,z;E=0;for(o=g.material.length;E<o;E++){v=g.material[E];if(v instanceof THREE.MeshFaceMaterial){v=0;for(x=q.material.length;v<x;v++)if((z=q.material[v])&&z.blending==k&&z.opacity<1==i){this.setBlending(z.blending);this.renderBuffer(e,m,z,q)}}else if((z=v)&&z.blending==k&&z.opacity<1==i){this.setBlending(z.blending);this.renderBuffer(e,m,z,q)}}};this.render=function(e,m){var g,q,k,i,v=e.lights;this.initWebGLObjects(e);this.autoClear&&this.clear();
|
||||
m.autoUpdateMatrix&&m.updateMatrix();G.set(m.matrix.flatten());R.set(m.projectionMatrix.flatten());g=0;for(q=e.__webGLObjects.length;g<q;g++){k=e.__webGLObjects[g];i=k.object;k=k.buffer;if(i.visible){this.setupMatrices(i,m);this.renderPass(m,v,i,k,THREE.NormalBlending,false)}}g=0;for(q=e.__webGLObjects.length;g<q;g++){k=e.__webGLObjects[g];i=k.object;k=k.buffer;if(i.visible){this.setupMatrices(i,m);this.renderPass(m,v,i,k,THREE.AdditiveBlending,false);this.renderPass(m,v,i,k,THREE.SubtractiveBlending,
|
||||
false);this.renderPass(m,v,i,k,THREE.AdditiveBlending,true);this.renderPass(m,v,i,k,THREE.SubtractiveBlending,true);this.renderPass(m,v,i,k,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,g,q,k,i,v;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}m=0;for(g=e.objects.length;m<g;m++){q=e.objects[m];if(e.__webGLObjectsMap[q.id]==undefined)e.__webGLObjectsMap[q.id]={};v=e.__webGLObjectsMap[q.id];if(q instanceof THREE.Mesh)for(i in q.geometry.geometryChunks){k=q.geometry.geometryChunks[i];
|
||||
k.__webGLVertexBuffer||this.createBuffers(q,i);if(v[i]==undefined){k={buffer:k,object:q};e.__webGLObjects.push(k);v[i]=1}}}};this.removeObject=function(e,m){var g,q;for(g=e.__webGLObjects.length-1;g>=0;g--){q=e.__webGLObjects[g].object;m==q&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();y.multiply(m.matrix,e.matrix);M.set(y.flatten());r=THREE.Matrix4.makeInvert3x3(y).transpose();D.set(r.m);K.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,
|
||||
false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,R);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,D);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,K)};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,
|
||||
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.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
|
||||
|
||||
+118
-118
@@ -12,21 +12,21 @@ THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1}
|
||||
THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;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+")"}};
|
||||
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,e,d=a.objects,g=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(l,h){return l.distance-h.distance});return g},intersectObject:function(a){function b(N,F,A,p){p=p.clone().subSelf(F);A=A.clone().subSelf(F);var i=N.clone().subSelf(F);N=p.dot(p);F=p.dot(A);p=p.dot(i);var o=A.dot(A);A=A.dot(i);i=1/(N*o-F*F);o=(o*p-F*A)*i;N=(N*A-F*p)*i;return o>0&&N>0&&o+N<1}var e,d,g,l,h,f,j,c,t,y,
|
||||
s,r=a.geometry,w=r.vertices,B=[];e=0;for(d=r.faces.length;e<d;e++){g=r.faces[e];y=this.origin.clone();s=this.direction.clone();l=a.matrix.multiplyVector3(w[g.a].position.clone());h=a.matrix.multiplyVector3(w[g.b].position.clone());f=a.matrix.multiplyVector3(w[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(w[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());t=s.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(l,y))/t;y=y.addSelf(s.multiplyScalar(c));
|
||||
THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,g=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(l,h){return l.distance-h.distance});return g},intersectObject:function(a){function b(J,H,D,n){n=n.clone().subSelf(H);D=D.clone().subSelf(H);var i=J.clone().subSelf(H);J=n.dot(n);H=n.dot(D);n=n.dot(i);var p=D.dot(D);D=D.dot(i);i=1/(J*p-H*H);p=(p*n-H*D)*i;J=(J*D-H*n)*i;return p>0&&J>0&&p+J<1}var e,d,g,l,h,f,j,c,t,y,
|
||||
s,q=a.geometry,x=q.vertices,B=[];e=0;for(d=q.faces.length;e<d;e++){g=q.faces[e];y=this.origin.clone();s=this.direction.clone();l=a.matrix.multiplyVector3(x[g.a].position.clone());h=a.matrix.multiplyVector3(x[g.b].position.clone());f=a.matrix.multiplyVector3(x[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(x[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());t=s.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(l,y))/t;y=y.addSelf(s.multiplyScalar(c));
|
||||
if(g instanceof THREE.Face3){if(b(y,l,h,f)){g={distance:this.origin.distanceTo(y),point:y,face:g,object:a};B.push(g)}}else if(g instanceof THREE.Face4)if(b(y,l,h,j)||b(y,h,f,j)){g={distance:this.origin.distanceTo(y),point:y,face:g,object:a};B.push(g)}}}return B}};
|
||||
THREE.Rectangle=function(){function a(){l=d-b;h=g-e}var b,e,d,g,l,h,f=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return l};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(j,c,t,y){f=false;b=j;e=c;d=t;g=y;a()};this.addPoint=function(j,c){if(f){f=false;b=j;e=c;d=j;g=c}else{b=b<j?b:j;e=e<c?e:c;d=d>j?d:j;g=g>c?
|
||||
g:c}a()};this.add3Points=function(j,c,t,y,s,r){if(f){f=false;b=j<t?j<s?j:s:t<s?t:s;e=c<y?c<r?c:r:y<r?y:r;d=j>t?j>s?j:s:t>s?t:s;g=c>y?c>r?c:r:y>r?y:r}else{b=j<t?j<s?j<b?j:b:s<b?s:b:t<s?t<b?t:b:s<b?s:b;e=c<y?c<r?c<e?c:e:r<e?r:e:y<r?y<e?y:e:r<e?r:e;d=j>t?j>s?j>d?j:d:s>d?s:d:t>s?t>d?t:d:s>d?s:d;g=c>y?c>r?c>g?c:g:r>g?r:g:y>r?y>g?y:g:r>g?r:g}a()};this.addRectangle=function(j){if(f){f=false;b=j.getLeft();e=j.getTop();d=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();e=e<j.getTop()?e:j.getTop();
|
||||
g:c}a()};this.add3Points=function(j,c,t,y,s,q){if(f){f=false;b=j<t?j<s?j:s:t<s?t:s;e=c<y?c<q?c:q:y<q?y:q;d=j>t?j>s?j:s:t>s?t:s;g=c>y?c>q?c:q:y>q?y:q}else{b=j<t?j<s?j<b?j:b:s<b?s:b:t<s?t<b?t:b:s<b?s:b;e=c<y?c<q?c<e?c:e:q<e?q:e:y<q?y<e?y:e:q<e?q:e;d=j>t?j>s?j>d?j:d:s>d?s:d:t>s?t>d?t:d:s>d?s:d;g=c>y?c>q?c>g?c:g:q>g?q:g:y>q?y>g?y:g:q>g?q:g}a()};this.addRectangle=function(j){if(f){f=false;b=j.getLeft();e=j.getTop();d=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();e=e<j.getTop()?e:j.getTop();
|
||||
d=d>j.getRight()?d:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;d+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e:j.getTop();d=d<j.getRight()?d:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){f=true;g=d=e=b=0;a()};this.isEmpty=function(){return f};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+g+", width: "+l+", height: "+h+" )"}};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,e,d,g,l,h,f,j,c,t,y,s,r,w,B){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=l||1;this.n23=h||0;this.n24=f||0;this.n31=j||0;this.n32=c||0;this.n33=t||1;this.n34=y||0;this.n41=s||0;this.n42=r||0;this.n43=w||0;this.n44=B||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,e,d,g,l,h,f,j,c,t,y,s,r,w,B){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=l;this.n23=h;this.n24=f;this.n31=j;this.n32=c;this.n33=t;this.n34=y;this.n41=s;this.n42=r;this.n43=w;this.n44=B;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
THREE.Matrix4=function(a,b,e,d,g,l,h,f,j,c,t,y,s,q,x,B){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=l||1;this.n23=h||0;this.n24=f||0;this.n31=j||0;this.n32=c||0;this.n33=t||1;this.n34=y||0;this.n41=s||0;this.n42=q||0;this.n43=x||0;this.n44=B||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,e,d,g,l,h,f,j,c,t,y,s,q,x,B){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=l;this.n23=h;this.n24=f;this.n31=j;this.n32=c;this.n33=t;this.n34=y;this.n41=s;this.n42=q;this.n43=x;this.n44=B;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,e){var d=new THREE.Vector3,g=new THREE.Vector3,l=new THREE.Vector3;l.sub(a,b).normalize();d.cross(e,l).normalize();g.cross(l,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=l.x;
|
||||
this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,g=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24*
|
||||
g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*g;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 e=a.n11,d=a.n12,g=a.n13,l=a.n14,h=a.n21,f=a.n22,j=a.n23,c=a.n24,t=a.n31,y=a.n32,
|
||||
s=a.n33,r=a.n34,w=a.n41,B=a.n42,N=a.n43,F=a.n44,A=b.n11,p=b.n12,i=b.n13,o=b.n14,k=b.n21,v=b.n22,n=b.n23,m=b.n24,z=b.n31,G=b.n32,L=b.n33,x=b.n34,J=b.n41,R=b.n42,D=b.n43,V=b.n44;this.n11=e*A+d*k+g*z+l*J;this.n12=e*p+d*v+g*G+l*R;this.n13=e*i+d*n+g*L+l*D;this.n14=e*o+d*m+g*x+l*V;this.n21=h*A+f*k+j*z+c*J;this.n22=h*p+f*v+j*G+c*R;this.n23=h*i+f*n+j*L+c*D;this.n24=h*o+f*m+j*x+c*V;this.n31=t*A+y*k+s*z+r*J;this.n32=t*p+y*v+s*G+r*R;this.n33=t*i+y*n+s*L+r*D;this.n34=t*o+y*m+s*x+r*V;this.n41=w*A+B*k+N*z+F*J;
|
||||
this.n42=w*p+B*v+N*G+F*R;this.n43=w*i+B*n+N*L+F*D;this.n44=w*o+B*m+N*x+F*V;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,l=this.n21,h=this.n22,f=this.n23,j=this.n24,c=this.n31,t=this.n32,y=this.n33,s=this.n34,r=this.n41,w=this.n42,B=this.n43,N=this.n44,F=a.n11,A=a.n21,p=a.n31,i=a.n41,o=a.n12,k=a.n22,v=a.n32,n=a.n42,m=a.n13,z=a.n23,G=a.n33,L=a.n43,x=a.n14,J=a.n24,R=a.n34;a=a.n44;this.n11=b*F+e*A+d*p+g*i;this.n12=b*o+e*k+d*v+g*n;this.n13=b*m+e*z+d*G+g*L;this.n14=
|
||||
b*x+e*J+d*R+g*a;this.n21=l*F+h*A+f*p+j*i;this.n22=l*o+h*k+f*v+j*n;this.n23=l*m+h*z+f*G+j*L;this.n24=l*x+h*J+f*R+j*a;this.n31=c*F+t*A+y*p+s*i;this.n32=c*o+t*k+y*v+s*n;this.n33=c*m+t*z+y*G+s*L;this.n34=c*x+t*J+y*R+s*a;this.n41=r*F+w*A+B*p+N*i;this.n42=r*o+w*k+B*v+N*n;this.n43=r*m+w*z+B*G+N*L;this.n44=r*x+w*J+B*R+N*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*=
|
||||
s=a.n33,q=a.n34,x=a.n41,B=a.n42,J=a.n43,H=a.n44,D=b.n11,n=b.n12,i=b.n13,p=b.n14,k=b.n21,w=b.n22,o=b.n23,m=b.n24,v=b.n31,L=b.n32,C=b.n33,A=b.n34,P=b.n41,I=b.n42,M=b.n43,W=b.n44;this.n11=e*D+d*k+g*v+l*P;this.n12=e*n+d*w+g*L+l*I;this.n13=e*i+d*o+g*C+l*M;this.n14=e*p+d*m+g*A+l*W;this.n21=h*D+f*k+j*v+c*P;this.n22=h*n+f*w+j*L+c*I;this.n23=h*i+f*o+j*C+c*M;this.n24=h*p+f*m+j*A+c*W;this.n31=t*D+y*k+s*v+q*P;this.n32=t*n+y*w+s*L+q*I;this.n33=t*i+y*o+s*C+q*M;this.n34=t*p+y*m+s*A+q*W;this.n41=x*D+B*k+J*v+H*P;
|
||||
this.n42=x*n+B*w+J*L+H*I;this.n43=x*i+B*o+J*C+H*M;this.n44=x*p+B*m+J*A+H*W;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,l=this.n21,h=this.n22,f=this.n23,j=this.n24,c=this.n31,t=this.n32,y=this.n33,s=this.n34,q=this.n41,x=this.n42,B=this.n43,J=this.n44,H=a.n11,D=a.n21,n=a.n31,i=a.n41,p=a.n12,k=a.n22,w=a.n32,o=a.n42,m=a.n13,v=a.n23,L=a.n33,C=a.n43,A=a.n14,P=a.n24,I=a.n34;a=a.n44;this.n11=b*H+e*D+d*n+g*i;this.n12=b*p+e*k+d*w+g*o;this.n13=b*m+e*v+d*L+g*C;this.n14=
|
||||
b*A+e*P+d*I+g*a;this.n21=l*H+h*D+f*n+j*i;this.n22=l*p+h*k+f*w+j*o;this.n23=l*m+h*v+f*L+j*C;this.n24=l*A+h*P+f*I+j*a;this.n31=c*H+t*D+y*n+s*i;this.n32=c*p+t*k+y*w+s*o;this.n33=c*m+t*v+y*L+s*C;this.n34=c*A+t*P+y*I+s*a;this.n41=q*H+x*D+B*n+J*i;this.n42=q*p+x*k+B*w+J*o;this.n43=q*m+x*v+B*L+J*C;this.n44=q*A+x*P+B*I+J*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*
|
||||
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,e,d){var g=b[e];b[e]=b[d];
|
||||
b[d]=g}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,
|
||||
@@ -47,10 +47,10 @@ THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){
|
||||
THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
|
||||
e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,e,d,g,l,h,f=new THREE.Vector3,j=new THREE.Vector3;d=0;for(g=this.vertices.length;d<g;d++){l=this.vertices[d];l.normal.set(0,0,0)}d=0;for(g=this.faces.length;d<g;d++){l=this.faces[d];if(a&&l.vertexNormals.length){f.set(0,0,0);b=0;for(e=l.normal.length;b<e;b++)f.addSelf(l.vertexNormals[b]);f.divideScalar(3)}else{b=this.vertices[l.a];e=this.vertices[l.b];h=this.vertices[l.c];f.sub(h.position,
|
||||
e.position);j.sub(b.position,e.position);f.crossSelf(j)}f.isZero()||f.normalize();l.normal.copy(f)}},computeVertexNormals:function(){var a,b=[],e,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(e=this.faces.length;a<e;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(e=this.faces.length;a<e;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(x,J,R,D){l=x.vertices[J].position;h=x.vertices[R].position;
|
||||
f=x.vertices[D].position;j=g[0];c=g[1];t=g[2];y=h.x-l.x;s=f.x-l.x;r=h.y-l.y;w=f.y-l.y;B=h.z-l.z;N=f.z-l.z;F=c.u-j.u;A=t.u-j.u;p=c.v-j.v;i=t.v-j.v;o=1/(F*i-A*p);m.set((i*y-p*s)*o,(i*r-p*w)*o,(i*B-p*N)*o);z.set((F*s-A*y)*o,(F*w-A*r)*o,(F*N-A*B)*o);v[J].addSelf(m);v[R].addSelf(m);v[D].addSelf(m);n[J].addSelf(z);n[R].addSelf(z);n[D].addSelf(z)}var b,e,d,g,l,h,f,j,c,t,y,s,r,w,B,N,F,A,p,i,o,k,v=[],n=[],m=new THREE.Vector3,z=new THREE.Vector3,G=new THREE.Vector3,L=new THREE.Vector3;k=new THREE.Vector3;b=
|
||||
0;for(e=this.vertices.length;b<e;b++){v[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];g=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(e=this.vertices.length;b<e;b++){k.copy(this.vertices[b].normal);d=v[b];G.copy(d);G.subSelf(k.multiplyScalar(k.dot(d))).normalize();L.cross(this.vertices[b].normal,d);test=L.dot(n[b]);d=test<0?-1:1;this.vertices[b].tangent.set(G.x,G.y,G.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],
|
||||
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(e=this.faces.length;a<e;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(A,P,I,M){l=A.vertices[P].position;h=A.vertices[I].position;
|
||||
f=A.vertices[M].position;j=g[0];c=g[1];t=g[2];y=h.x-l.x;s=f.x-l.x;q=h.y-l.y;x=f.y-l.y;B=h.z-l.z;J=f.z-l.z;H=c.u-j.u;D=t.u-j.u;n=c.v-j.v;i=t.v-j.v;p=1/(H*i-D*n);m.set((i*y-n*s)*p,(i*q-n*x)*p,(i*B-n*J)*p);v.set((H*s-D*y)*p,(H*x-D*q)*p,(H*J-D*B)*p);w[P].addSelf(m);w[I].addSelf(m);w[M].addSelf(m);o[P].addSelf(v);o[I].addSelf(v);o[M].addSelf(v)}var b,e,d,g,l,h,f,j,c,t,y,s,q,x,B,J,H,D,n,i,p,k,w=[],o=[],m=new THREE.Vector3,v=new THREE.Vector3,L=new THREE.Vector3,C=new THREE.Vector3;k=new THREE.Vector3;b=
|
||||
0;for(e=this.vertices.length;b<e;b++){w[b]=new THREE.Vector3;o[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];g=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(e=this.vertices.length;b<e;b++){k.copy(this.vertices[b].normal);d=w[b];L.copy(d);L.subSelf(k.multiplyScalar(k.dot(d))).normalize();C.cross(this.vertices[b].normal,d);test=C.dot(o[b]);d=test<0?-1:1;this.vertices[b].tangent.set(L.x,L.y,L.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]=
|
||||
vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var y=[];b=0;for(e=t.length;b<e;b++)t[b]==undefined?y.push("undefined"):y.push(t[b].toString());return y.join("_")}var b,e,d,g,l,h,f,j,c={};d=0;for(g=this.faces.length;d<g;d++){l=this.faces[d];h=l.material;f=a(h);if(c[f]==undefined)c[f]={hash:f,counter:0};j=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:h,
|
||||
vertices:0};l=l instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+l>65535){c[f].counter+=1;j=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:h,vertices:0}}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
||||
@@ -89,94 +89,94 @@ THREE.Texture=function(a,b,e,d,g,l){this.image=a;this.mapping=b!==undefined?b:ne
|
||||
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.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(v,n){var m=0,z=1,G=v.z+v.w,L=n.z+n.w,x=-v.z+v.w,J=-n.z+n.w;if(G>=0&&L>=0&&x>=0&&J>=0)return true;else if(G<0&&L<0||x<0&&J<0)return false;else{if(G<0)m=Math.max(m,G/(G-L));else if(L<0)z=Math.min(z,G/(G-L));if(x<0)m=Math.max(m,x/(x-J));else if(J<0)z=Math.min(z,x/(x-J));if(z<m)return false;else{v.lerpSelf(n,m);n.lerpSelf(v,1-z);return true}}}function b(v,n){return n.z-v.z}var e=null,d,g,l=[],h,f,j,c=[],t,y,s=[],r,w,B=[],N=new THREE.Vector3,F=new THREE.Vector4,A=
|
||||
new THREE.Matrix4,p=new THREE.Matrix4,i=new THREE.Vector4,o=new THREE.Vector4,k;this.projectObjects=function(v){var n,m,z;e=[];g=0;m=v.objects;v=0;for(n=m.length;v<n;v++){z=m[v];if(z.visible!==false){d=l[g]=l[g]||new THREE.RenderableObject;F.copy(z.position);A.multiplyVector4(F);F.multiplyScalar(1/F.w);d.object=z;d.z=N.z;e.push(d);g++}}e.sort(b);return e};this.projectScene=function(v,n){var m,z,G,L,x,J,R,D,V,T,$,W,O,H,C,S,q;e=[];j=y=w=0;n.autoUpdateMatrix&&n.updateMatrix();A.multiply(n.projectionMatrix,
|
||||
n.matrix);R=v.objects;m=0;for(z=R.length;m<z;m++){D=R[m];if(D.visible!==false){D.autoUpdateMatrix&&D.updateMatrix();V=D.matrix;T=D.rotationMatrix;$=D.material;W=D.overdraw;if(D instanceof THREE.Mesh){O=D.geometry;H=O.vertices;G=0;for(L=H.length;G<L;G++){C=H[G];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);x=C.positionScreen;x.copy(C.positionWorld);A.multiplyVector4(x);x.multiplyScalar(1/x.w);C.__visible=x.z>0&&x.z<1}O=O.faces;G=0;for(L=O.length;G<L;G++){C=O[G];if(C instanceof
|
||||
THREE.Face3){x=H[C.a];J=H[C.b];S=H[C.c];if(x.__visible&&J.__visible&&S.__visible)if(D.doubleSided||D.flipSided!=(S.positionScreen.x-x.positionScreen.x)*(J.positionScreen.y-x.positionScreen.y)-(S.positionScreen.y-x.positionScreen.y)*(J.positionScreen.x-x.positionScreen.x)<0){h=c[j]=c[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(x.positionWorld);h.v2.positionWorld.copy(J.positionWorld);h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(x.positionScreen);h.v2.positionScreen.copy(J.positionScreen);
|
||||
h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(C.normal);T.multiplyVector3(h.normalWorld);h.centroidWorld.copy(C.centroid);V.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);A.multiplyVector3(h.centroidScreen);S=C.vertexNormals;k=h.vertexNormalsWorld;x=0;for(J=S.length;x<J;x++){q=k[x]=k[x]||new THREE.Vector3;q.copy(S[x]);T.multiplyVector3(q)}h.z=h.centroidScreen.z;h.meshMaterial=$;h.faceMaterial=C.material;h.overdraw=W;if(D.geometry.uvs[G]){h.uvs[0]=D.geometry.uvs[G][0];
|
||||
h.uvs[1]=D.geometry.uvs[G][1];h.uvs[2]=D.geometry.uvs[G][2]}e.push(h);j++}}else if(C instanceof THREE.Face4){x=H[C.a];J=H[C.b];S=H[C.c];q=H[C.d];if(x.__visible&&J.__visible&&S.__visible&&q.__visible)if(D.doubleSided||D.flipSided!=((q.positionScreen.x-x.positionScreen.x)*(J.positionScreen.y-x.positionScreen.y)-(q.positionScreen.y-x.positionScreen.y)*(J.positionScreen.x-x.positionScreen.x)<0||(J.positionScreen.x-S.positionScreen.x)*(q.positionScreen.y-S.positionScreen.y)-(J.positionScreen.y-S.positionScreen.y)*
|
||||
(q.positionScreen.x-S.positionScreen.x)<0)){h=c[j]=c[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(x.positionWorld);h.v2.positionWorld.copy(J.positionWorld);h.v3.positionWorld.copy(q.positionWorld);h.v1.positionScreen.copy(x.positionScreen);h.v2.positionScreen.copy(J.positionScreen);h.v3.positionScreen.copy(q.positionScreen);h.normalWorld.copy(C.normal);T.multiplyVector3(h.normalWorld);h.centroidWorld.copy(C.centroid);V.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);
|
||||
A.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterial=$;h.faceMaterial=C.material;h.overdraw=W;if(D.geometry.uvs[G]){h.uvs[0]=D.geometry.uvs[G][0];h.uvs[1]=D.geometry.uvs[G][1];h.uvs[2]=D.geometry.uvs[G][3]}e.push(h);j++;f=c[j]=c[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(J.positionWorld);f.v2.positionWorld.copy(S.positionWorld);f.v3.positionWorld.copy(q.positionWorld);f.v1.positionScreen.copy(J.positionScreen);f.v2.positionScreen.copy(S.positionScreen);f.v3.positionScreen.copy(q.positionScreen);
|
||||
f.normalWorld.copy(h.normalWorld);f.centroidWorld.copy(h.centroidWorld);f.centroidScreen.copy(h.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=$;f.faceMaterial=C.material;f.overdraw=W;if(D.geometry.uvs[G]){f.uvs[0]=D.geometry.uvs[G][1];f.uvs[1]=D.geometry.uvs[G][2];f.uvs[2]=D.geometry.uvs[G][3]}e.push(f);j++}}}}else if(D instanceof THREE.Line){p.multiply(A,V);H=D.geometry.vertices;C=H[0];C.positionScreen.copy(C.position);p.multiplyVector4(C.positionScreen);G=1;for(L=H.length;G<L;G++){x=H[G];
|
||||
x.positionScreen.copy(x.position);p.multiplyVector4(x.positionScreen);J=H[G-1];i.copy(x.positionScreen);o.copy(J.positionScreen);if(a(i,o)){i.multiplyScalar(1/i.w);o.multiplyScalar(1/o.w);t=s[y]=s[y]||new THREE.RenderableLine;t.v1.positionScreen.copy(i);t.v2.positionScreen.copy(o);t.z=Math.max(i.z,o.z);t.material=D.material;e.push(t);y++}}}else if(D instanceof THREE.Particle){F.set(D.position.x,D.position.y,D.position.z,1);A.multiplyVector4(F);F.z/=F.w;if(F.z>0&&F.z<1){r=B[w]=B[w]||new THREE.RenderableParticle;
|
||||
r.x=F.x/F.w;r.y=F.y/F.w;r.z=F.z;r.rotation=D.rotation.z;r.scale.x=D.scale.x*Math.abs(r.x-(F.x+n.projectionMatrix.n11)/(F.w+n.projectionMatrix.n14));r.scale.y=D.scale.y*Math.abs(r.y-(F.y+n.projectionMatrix.n22)/(F.w+n.projectionMatrix.n24));r.material=D.material;e.push(r);w++}}}}e.sort(b);return e};this.unprojectVector=function(v,n){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));m.multiplyVector3(v);return v}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,l;this.domElement=document.createElement("div");this.setSize=function(h,f){e=h;d=f;g=e/2;l=d/2};this.render=function(h,f){var j,c,t,y,s,r,w,B;a=b.projectScene(h,f);j=0;for(c=a.length;j<c;j++){s=a[j];if(s instanceof THREE.RenderableParticle){w=s.x*g+g;B=s.y*l+l;t=0;for(y=s.material.length;t<y;t++){r=s.material[t];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=w+"px";r.style.top=B+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,g,l,h,f=e.getContext("2d"),j=1,c=0,t=null,y=null,s=1,r,w,B,N,F,A,p,i,o,k=new THREE.Color,v=new THREE.Color,n=new THREE.Color,m=new THREE.Color,z=new THREE.Color,G,L,x,J,R,D,V,T,$,W,O=new THREE.Rectangle,H=new THREE.Rectangle,C=new THREE.Rectangle,S=false,q=new THREE.Color,u=new THREE.Color,E=new THREE.Color,M=new THREE.Color,X=Math.PI*2,Y=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
|
||||
ea.width=ea.height=2;ma=ea.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);oa=ma.getImageData(0,0,2,2);fa=oa.data;ra=document.createElement("canvas");ra.width=ra.height=pa;va=ra.getContext("2d");va.translate(-pa/2,-pa/2);va.scale(pa,pa);pa--;this.domElement=e;this.autoClear=true;this.setSize=function(ia,wa){d=ia;g=wa;l=d/2;h=g/2;e.width=d;e.height=g;O.set(-l,-h,l,h)};this.clear=function(){if(!H.isEmpty()){H.inflate(1);H.minSelf(O);f.clearRect(H.getX(),H.getY(),H.getWidth(),H.getHeight());
|
||||
H.empty()}};this.render=function(ia,wa){function Ka(I){var U,Q,K,P=I.lights;u.setRGB(0,0,0);E.setRGB(0,0,0);M.setRGB(0,0,0);I=0;for(U=P.length;I<U;I++){Q=P[I];K=Q.color;if(Q instanceof THREE.AmbientLight){u.r+=K.r;u.g+=K.g;u.b+=K.b}else if(Q instanceof THREE.DirectionalLight){E.r+=K.r;E.g+=K.g;E.b+=K.b}else if(Q instanceof THREE.PointLight){M.r+=K.r;M.g+=K.g;M.b+=K.b}}}function xa(I,U,Q,K){var P,Z,ba,ca,da=I.lights;I=0;for(P=da.length;I<P;I++){Z=da[I];ba=Z.color;ca=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=
|
||||
Q.dot(Z.position)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,U);Y.normalize();Z=Q.dot(Y)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}}}function La(I,U,Q){if(Q.opacity!=0){Ca(Q.opacity);ya(Q.blending);var K,P,Z,ba,ca,da;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){ba=Q.map;ca=ba.width>>1;da=ba.height>>1;P=U.scale.x*l;Z=U.scale.y*h;Q=P*ca;K=Z*da;C.set(I.x-Q,I.y-K,I.x+Q,I.y+K);if(O.instersects(C)){f.save();f.translate(I.x,I.y);
|
||||
f.rotate(-U.rotation);f.scale(P,-Z);f.translate(-ca,-da);f.drawImage(ba,0,0);f.restore()}}}else if(Q instanceof THREE.ParticleCircleMaterial){if(S){q.r=u.r+E.r+M.r;q.g=u.g+E.g+M.g;q.b=u.b+E.b+M.b;k.r=Q.color.r*q.r;k.g=Q.color.g*q.g;k.b=Q.color.b*q.b;k.updateStyleString()}else k.__styleString=Q.color.__styleString;Q=U.scale.x*l;K=U.scale.y*h;C.set(I.x-Q,I.y-K,I.x+Q,I.y+K);if(O.instersects(C)){P=k.__styleString;if(y!=P)f.fillStyle=y=P;f.save();f.translate(I.x,I.y);f.rotate(-U.rotation);f.scale(Q,K);
|
||||
f.beginPath();f.arc(0,0,1,0,X,true);f.closePath();f.fill();f.restore()}}}}function Ma(I,U,Q,K){if(K.opacity!=0){Ca(K.opacity);ya(K.blending);f.beginPath();f.moveTo(I.positionScreen.x,I.positionScreen.y);f.lineTo(U.positionScreen.x,U.positionScreen.y);f.closePath();if(K instanceof THREE.LineBasicMaterial){k.__styleString=K.color.__styleString;I=K.linewidth;if(s!=I)f.lineWidth=s=I;I=k.__styleString;if(t!=I)f.strokeStyle=t=I;f.stroke();C.inflate(K.linewidth*2)}}}function Ga(I,U,Q,K,P,Z){if(P.opacity!=
|
||||
0){Ca(P.opacity);ya(P.blending);N=I.positionScreen.x;F=I.positionScreen.y;A=U.positionScreen.x;p=U.positionScreen.y;i=Q.positionScreen.x;o=Q.positionScreen.y;f.beginPath();f.moveTo(N,F);f.lineTo(A,p);f.lineTo(i,o);f.lineTo(N,F);f.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&sa(N,F,A,p,i,o,P.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof
|
||||
THREE.SphericalReflectionMapping){I=wa.matrix;Y.copy(K.vertexNormalsWorld[0]);R=(Y.x*I.n11+Y.y*I.n12+Y.z*I.n13)*0.5+0.5;D=-(Y.x*I.n21+Y.y*I.n22+Y.z*I.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[1]);V=(Y.x*I.n11+Y.y*I.n12+Y.z*I.n13)*0.5+0.5;T=-(Y.x*I.n21+Y.y*I.n22+Y.z*I.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[2]);$=(Y.x*I.n11+Y.y*I.n12+Y.z*I.n13)*0.5+0.5;W=-(Y.x*I.n21+Y.y*I.n22+Y.z*I.n23)*0.5+0.5;sa(N,F,A,p,i,o,P.env_map.image,R,D,V,T,$,W)}}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):
|
||||
Aa(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&sa(N,F,A,p,i,o,P.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);ya(THREE.SubtractiveBlending)}if(S)if(!P.wireframe&&P.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){v.r=n.r=m.r=u.r;v.g=n.g=m.g=u.g;v.b=n.b=m.b=u.b;xa(Z,K.v1.positionWorld,K.vertexNormalsWorld[0],v);xa(Z,K.v2.positionWorld,K.vertexNormalsWorld[1],n);xa(Z,
|
||||
K.v3.positionWorld,K.vertexNormalsWorld[2],m);z.r=(n.r+m.r)*0.5;z.g=(n.g+m.g)*0.5;z.b=(n.b+m.b)*0.5;J=Ha(v,n,m,z);sa(N,F,A,p,i,o,J,0,0,1,0,0,1)}else{q.r=u.r;q.g=u.g;q.b=u.b;xa(Z,K.centroidWorld,K.normalWorld,q);k.r=P.color.r*q.r;k.g=P.color.g*q.g;k.b=P.color.b*q.b;k.updateStyleString();P.wireframe?za(k.__styleString,P.wireframe_linewidth):Aa(k.__styleString)}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):Aa(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){G=P.__2near;
|
||||
L=P.__farPlusNear;x=P.__farMinusNear;v.r=v.g=v.b=1-G/(L-I.positionScreen.z*x);n.r=n.g=n.b=1-G/(L-U.positionScreen.z*x);m.r=m.g=m.b=1-G/(L-Q.positionScreen.z*x);z.r=(n.r+m.r)*0.5;z.g=(n.g+m.g)*0.5;z.b=(n.b+m.b)*0.5;J=Ha(v,n,m,z);sa(N,F,A,p,i,o,J,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){k.r=Da(K.normalWorld.x);k.g=Da(K.normalWorld.y);k.b=Da(K.normalWorld.z);k.updateStyleString();P.wireframe?za(k.__styleString,P.wireframe_linewidth):Aa(k.__styleString)}}}function za(I,U){if(t!=I)f.strokeStyle=
|
||||
t=I;if(s!=U)f.lineWidth=s=U;f.stroke();C.inflate(U*2)}function Aa(I){if(y!=I)f.fillStyle=y=I;f.fill()}function sa(I,U,Q,K,P,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;Q-=I;K-=U;P-=I;Z-=U;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*Q-ga*P)*la;ga=(ta*K-ga*Z)*la;Q=(ja*P-ka*Q)*la;K=(ja*Z-ka*K)*la;I=I-na*ca-Q*da;U=U-ga*ca-K*da;f.save();f.transform(na,ga,Q,K,I,U);f.clip();f.drawImage(ba,0,0);f.restore()}function Ca(I){if(j!=I)f.globalAlpha=
|
||||
j=I}function ya(I){if(c!=I){switch(I){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=I}}function Ha(I,U,Q,K){var P=~~(I.r*255),Z=~~(I.g*255);I=~~(I.b*255);var ba=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(Q.r*255),ja=~~(Q.g*255);Q=~~(Q.b*255);var ga=~~(K.r*255),ka=~~(K.g*255);K=~~(K.b*255);fa[0]=P<0?0:P>255?255:P;fa[1]=Z<0?0:
|
||||
Z>255?255:Z;fa[2]=I<0?0:I>255?255:I;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=Q<0?0:Q>255?255:Q;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=K<0?0:K>255?255:K;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function Ea(I,U){var Q=U.x-I.x,K=U.y-I.y,P=1/Math.sqrt(Q*Q+K*K);Q*=P;K*=P;U.x+=Q;U.y+=K;I.x-=Q;I.y-=K}var Ba,Ia,aa,ha,qa,Fa,
|
||||
Ja,ua;f.setTransform(1,0,0,-1,l,h);this.autoClear&&this.clear();a=b.projectScene(ia,wa);(S=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba<Ia;Ba++){aa=a[Ba];C.empty();if(aa instanceof THREE.RenderableParticle){r=aa;r.x*=l;r.y*=h;ha=0;for(qa=aa.material.length;ha<qa;ha++)La(r,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){r=aa.v1;w=aa.v2;r.positionScreen.x*=l;r.positionScreen.y*=h;w.positionScreen.x*=l;w.positionScreen.y*=h;C.addPoint(r.positionScreen.x,r.positionScreen.y);
|
||||
C.addPoint(w.positionScreen.x,w.positionScreen.y);if(O.instersects(C)){ha=0;for(qa=aa.material.length;ha<qa;)Ma(r,w,aa,aa.material[ha++],ia)}}else if(aa instanceof THREE.RenderableFace3){r=aa.v1;w=aa.v2;B=aa.v3;r.positionScreen.x*=l;r.positionScreen.y*=h;w.positionScreen.x*=l;w.positionScreen.y*=h;B.positionScreen.x*=l;B.positionScreen.y*=h;if(aa.overdraw){Ea(r.positionScreen,w.positionScreen);Ea(w.positionScreen,B.positionScreen);Ea(B.positionScreen,r.positionScreen)}C.add3Points(r.positionScreen.x,
|
||||
r.positionScreen.y,w.positionScreen.x,w.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(O.instersects(C)){ha=0;for(qa=aa.meshMaterial.length;ha<qa;){ua=aa.meshMaterial[ha++];if(ua instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=aa.faceMaterial.length;Fa<Ja;)(ua=aa.faceMaterial[Fa++])&&Ga(r,w,B,aa,ua,ia)}else Ga(r,w,B,aa,ua,ia)}}}H.addRectangle(C)}f.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(T,$,W){var O,H,C,S;O=0;for(H=T.lights.length;O<H;O++){C=T.lights[O];if(C instanceof THREE.DirectionalLight){S=$.normalWorld.dot(C.position)*C.intensity;if(S>0){W.r+=C.color.r*S;W.g+=C.color.g*S;W.b+=C.color.b*S}}else if(C instanceof THREE.PointLight){m.sub(C.position,$.centroidWorld);m.normalize();S=$.normalWorld.dot(m)*C.intensity;if(S>0){W.r+=C.color.r*S;W.g+=C.color.g*S;W.b+=C.color.b*S}}}}function b(T,$,W,O,H,C){x=d(J++);x.setAttribute("d","M "+T.positionScreen.x+
|
||||
" "+T.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)p.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(A){i.r=o.r;i.g=o.g;i.b=o.b;a(C,O,i);p.r=H.color.r*i.r;p.g=H.color.g*i.g;p.b=H.color.b*i.b;p.updateStyleString()}else p.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){n=1-H.__2near/(H.__farPlusNear-O.z*H.__farMinusNear);
|
||||
p.setRGB(n,n,n)}else H instanceof THREE.MeshNormalMaterial&&p.setRGB(g(O.normalWorld.x),g(O.normalWorld.y),g(O.normalWorld.z));H.wireframe?x.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):x.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+H.opacity);f.appendChild(x)}function e(T,$,W,O,H,C,S){x=d(J++);x.setAttribute("d",
|
||||
"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)p.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(A){i.r=o.r;i.g=o.g;i.b=o.b;a(S,H,i);p.r=C.color.r*i.r;p.g=C.color.g*i.g;p.b=C.color.b*i.b;p.updateStyleString()}else p.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){n=
|
||||
1-C.__2near/(C.__farPlusNear-H.z*C.__farMinusNear);p.setRGB(n,n,n)}else C instanceof THREE.MeshNormalMaterial&&p.setRGB(g(H.normalWorld.x),g(H.normalWorld.y),g(H.normalWorld.z));C.wireframe?x.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):x.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+C.opacity);f.appendChild(x)}
|
||||
function d(T){if(z[T]==null){z[T]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&z[T].setAttribute("shape-rendering","crispEdges");return z[T]}return z[T]}function g(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var l=null,h=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,y,s,r,w,B,N=new THREE.Rectangle,F=new THREE.Rectangle,A=false,p=new THREE.Color(16777215),i=new THREE.Color(16777215),o=new THREE.Color(0),k=new THREE.Color(0),
|
||||
v=new THREE.Color(0),n,m=new THREE.Vector3,z=[],G=[],L=[],x,J,R,D,V=1;this.domElement=f;this.autoClear=true;this.setQuality=function(T){switch(T){case "high":V=1;break;case "low":V=0}};this.setSize=function(T,$){j=T;c=$;t=j/2;y=c/2;f.setAttribute("viewBox",-t+" "+-y+" "+j+" "+c);f.setAttribute("width",j);f.setAttribute("height",c);N.set(-t,-y,t,y)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(T,$){var W,O,H,C,S,q,u,E;this.autoClear&&this.clear();
|
||||
l=h.projectScene(T,$);D=R=J=0;if(A=T.lights.length>0){u=T.lights;o.setRGB(0,0,0);k.setRGB(0,0,0);v.setRGB(0,0,0);W=0;for(O=u.length;W<O;W++){H=u[W];C=H.color;if(H instanceof THREE.AmbientLight){o.r+=C.r;o.g+=C.g;o.b+=C.b}else if(H instanceof THREE.DirectionalLight){k.r+=C.r;k.g+=C.g;k.b+=C.b}else if(H instanceof THREE.PointLight){v.r+=C.r;v.g+=C.g;v.b+=C.b}}}W=0;for(O=l.length;W<O;W++){u=l[W];F.empty();if(u instanceof THREE.RenderableParticle){s=u;s.x*=t;s.y*=-y;H=0;for(C=u.material.length;H<C;H++)if(E=
|
||||
u.material[H]){S=s;q=u;E=E;var M=R++;if(G[M]==null){G[M]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&G[M].setAttribute("shape-rendering","crispEdges")}x=G[M];x.setAttribute("cx",S.x);x.setAttribute("cy",S.y);x.setAttribute("r",q.scale.x*t);if(E instanceof THREE.ParticleCircleMaterial){if(A){i.r=o.r+k.r+v.r;i.g=o.g+k.g+v.g;i.b=o.b+k.b+v.b;p.r=E.color.r*i.r;p.g=E.color.g*i.g;p.b=E.color.b*i.b;p.updateStyleString()}else p=E.color;x.setAttribute("style","fill: "+p.__styleString)}f.appendChild(x)}}else if(u instanceof
|
||||
THREE.RenderableLine){s=u.v1;r=u.v2;s.positionScreen.x*=t;s.positionScreen.y*=-y;r.positionScreen.x*=t;r.positionScreen.y*=-y;F.addPoint(s.positionScreen.x,s.positionScreen.y);F.addPoint(r.positionScreen.x,r.positionScreen.y);if(N.instersects(F)){H=0;for(C=u.material.length;H<C;)if(E=u.material[H++]){S=s;q=r;E=E;M=D++;if(L[M]==null){L[M]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&L[M].setAttribute("shape-rendering","crispEdges")}x=L[M];x.setAttribute("x1",S.positionScreen.x);
|
||||
x.setAttribute("y1",S.positionScreen.y);x.setAttribute("x2",q.positionScreen.x);x.setAttribute("y2",q.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){p.__styleString=E.color.__styleString;x.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.linecap+"; stroke-linejoin: "+E.linejoin);f.appendChild(x)}}}}else if(u instanceof THREE.RenderableFace3){s=u.v1;r=u.v2;w=u.v3;s.positionScreen.x*=t;s.positionScreen.y*=
|
||||
-y;r.positionScreen.x*=t;r.positionScreen.y*=-y;w.positionScreen.x*=t;w.positionScreen.y*=-y;F.addPoint(s.positionScreen.x,s.positionScreen.y);F.addPoint(r.positionScreen.x,r.positionScreen.y);F.addPoint(w.positionScreen.x,w.positionScreen.y);if(N.instersects(F)){H=0;for(C=u.meshMaterial.length;H<C;){E=u.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){S=0;for(q=u.faceMaterial.length;S<q;)(E=u.faceMaterial[S++])&&b(s,r,w,u,E,T)}else E&&b(s,r,w,u,E,T)}}}else if(u instanceof THREE.RenderableFace4){s=
|
||||
u.v1;r=u.v2;w=u.v3;B=u.v4;s.positionScreen.x*=t;s.positionScreen.y*=-y;r.positionScreen.x*=t;r.positionScreen.y*=-y;w.positionScreen.x*=t;w.positionScreen.y*=-y;B.positionScreen.x*=t;B.positionScreen.y*=-y;F.addPoint(s.positionScreen.x,s.positionScreen.y);F.addPoint(r.positionScreen.x,r.positionScreen.y);F.addPoint(w.positionScreen.x,w.positionScreen.y);F.addPoint(B.positionScreen.x,B.positionScreen.y);if(N.instersects(F)){H=0;for(C=u.meshMaterial.length;H<C;){E=u.meshMaterial[H++];if(E instanceof
|
||||
THREE.MeshFaceMaterial){S=0;for(q=u.faceMaterial.length;S<q;)(E=u.faceMaterial[S++])&&e(s,r,w,B,u,E,T)}else E&&e(s,r,w,B,u,E,T)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(i,o){var k=c.createProgram(),v=[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(k,h("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
||||
i));c.attachShader(k,h("vertex",v+o));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};return k}function e(i,o){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.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 k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP,
|
||||
i.image.__webGLTextureCube)}}function d(i,o){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(i.min_filter));c.generateMipmap(c.TEXTURE_2D);
|
||||
c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,o){var k,v,n;k=0;for(v=o.length;k<v;k++){n=o[k];i.uniforms[n]=c.getUniformLocation(i,n)}}function l(i,o){var k,v,n;k=0;for(v=o.length;k<v;k++){n=o[k];i.attributes[n]=c.getAttribLocation(i,n);i.attributes[n]>=0&&c.enableVertexAttribArray(i.attributes[n])}}function h(i,o){var k;if(i=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")k=c.createShader(c.VERTEX_SHADER);
|
||||
c.shaderSource(k,o);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function f(i){switch(i){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 j=document.createElement("canvas"),c,t,y,s=new THREE.Matrix4,r,w=new Float32Array(16),B=new Float32Array(16),N=new Float32Array(16),F=new Float32Array(9),A=new Float32Array(16);a=function(i,o){if(i){var k,v,n,m=pointLights=maxDirLights=maxPointLights=0;k=0;for(v=i.lights.length;k<v;k++){n=i.lights[k];n instanceof THREE.DirectionalLight&&m++;n instanceof
|
||||
THREE.PointLight&&pointLights++}if(pointLights+m<=o){maxDirLights=m;maxPointLights=pointLights}else{maxDirLights=Math.ceil(o*m/(pointLights+m));maxPointLights=o-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:o-1}}(a,4);this.domElement=j;this.autoClear=true;try{c=j.getContext("experimental-webgl",{antialias:true})}catch(p){}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);t=y=function(i,o){var k=[i?"#define MAX_DIR_LIGHTS "+i:"",o?"#define MAX_POINT_LIGHTS "+o:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
|
||||
"",o?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",o?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"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;",
|
||||
i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",o?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
||||
"",o?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",o?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",o?"}":"","}\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"),
|
||||
v=[i?"#define MAX_DIR_LIGHTS "+i:"",o?"#define MAX_POINT_LIGHTS "+o:"","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;",
|
||||
i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"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 );",
|
||||
o?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",o?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",o?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",o?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",o?"float pointSpecularWeight = 0.0;":"",o?"if ( pointDotNormalHalf >= 0.0 )":
|
||||
"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
||||
"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;":
|
||||
THREE.Projector=function(){function a(k,w){var o=0,m=1,v=k.z+k.w,L=w.z+w.w,C=-k.z+k.w,A=-w.z+w.w;if(v>=0&&L>=0&&C>=0&&A>=0)return true;else if(v<0&&L<0||C<0&&A<0)return false;else{if(v<0)o=Math.max(o,v/(v-L));else if(L<0)m=Math.min(m,v/(v-L));if(C<0)o=Math.max(o,C/(C-A));else if(A<0)m=Math.min(m,C/(C-A));if(m<o)return false;else{k.lerpSelf(w,o);w.lerpSelf(k,1-m);return true}}}function b(k,w){return w.z-k.z}var e=null,d,g,l=[],h,f,j,c=[],t,y,s=[],q,x,B=[],J=new THREE.Vector4,H=new THREE.Matrix4,D=
|
||||
new THREE.Matrix4,n=new THREE.Vector4,i=new THREE.Vector4,p;this.projectObjects=function(k,w){var o,m,v,L;e=[];g=0;H.multiply(w.projectionMatrix,w.matrix);v=k.objects;o=0;for(m=v.length;o<m;o++){L=v[o];if(L.visible!==false){d=l[g]=l[g]||new THREE.RenderableObject;J.copy(L.position);H.multiplyVector4(J);d.object=L;d.z=J.z;e.push(d);g++}}e.sort(b);return e};this.projectScene=function(k,w){var o,m,v,L,C,A,P,I,M,W,S,$,V,N,z,F,T;e=[];j=y=x=0;w.autoUpdateMatrix&&w.updateMatrix();H.multiply(w.projectionMatrix,
|
||||
w.matrix);P=k.objects;o=0;for(m=P.length;o<m;o++){I=P[o];if(I.visible!==false){I.autoUpdateMatrix&&I.updateMatrix();M=I.matrix;W=I.rotationMatrix;S=I.material;$=I.overdraw;if(I instanceof THREE.Mesh){V=I.geometry;N=V.vertices;v=0;for(L=N.length;v<L;v++){z=N[v];z.positionWorld.copy(z.position);M.multiplyVector3(z.positionWorld);C=z.positionScreen;C.copy(z.positionWorld);H.multiplyVector4(C);C.multiplyScalar(1/C.w);z.__visible=C.z>0&&C.z<1}V=V.faces;v=0;for(L=V.length;v<L;v++){z=V[v];if(z instanceof
|
||||
THREE.Face3){C=N[z.a];A=N[z.b];F=N[z.c];if(C.__visible&&A.__visible&&F.__visible)if(I.doubleSided||I.flipSided!=(F.positionScreen.x-C.positionScreen.x)*(A.positionScreen.y-C.positionScreen.y)-(F.positionScreen.y-C.positionScreen.y)*(A.positionScreen.x-C.positionScreen.x)<0){h=c[j]=c[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(C.positionWorld);h.v2.positionWorld.copy(A.positionWorld);h.v3.positionWorld.copy(F.positionWorld);h.v1.positionScreen.copy(C.positionScreen);h.v2.positionScreen.copy(A.positionScreen);
|
||||
h.v3.positionScreen.copy(F.positionScreen);h.normalWorld.copy(z.normal);W.multiplyVector3(h.normalWorld);h.centroidWorld.copy(z.centroid);M.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);H.multiplyVector3(h.centroidScreen);F=z.vertexNormals;p=h.vertexNormalsWorld;C=0;for(A=F.length;C<A;C++){T=p[C]=p[C]||new THREE.Vector3;T.copy(F[C]);W.multiplyVector3(T)}h.z=h.centroidScreen.z;h.meshMaterial=S;h.faceMaterial=z.material;h.overdraw=$;if(I.geometry.uvs[v]){h.uvs[0]=I.geometry.uvs[v][0];
|
||||
h.uvs[1]=I.geometry.uvs[v][1];h.uvs[2]=I.geometry.uvs[v][2]}e.push(h);j++}}else if(z instanceof THREE.Face4){C=N[z.a];A=N[z.b];F=N[z.c];T=N[z.d];if(C.__visible&&A.__visible&&F.__visible&&T.__visible)if(I.doubleSided||I.flipSided!=((T.positionScreen.x-C.positionScreen.x)*(A.positionScreen.y-C.positionScreen.y)-(T.positionScreen.y-C.positionScreen.y)*(A.positionScreen.x-C.positionScreen.x)<0||(A.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-(A.positionScreen.y-F.positionScreen.y)*
|
||||
(T.positionScreen.x-F.positionScreen.x)<0)){h=c[j]=c[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(C.positionWorld);h.v2.positionWorld.copy(A.positionWorld);h.v3.positionWorld.copy(T.positionWorld);h.v1.positionScreen.copy(C.positionScreen);h.v2.positionScreen.copy(A.positionScreen);h.v3.positionScreen.copy(T.positionScreen);h.normalWorld.copy(z.normal);W.multiplyVector3(h.normalWorld);h.centroidWorld.copy(z.centroid);M.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);
|
||||
H.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterial=S;h.faceMaterial=z.material;h.overdraw=$;if(I.geometry.uvs[v]){h.uvs[0]=I.geometry.uvs[v][0];h.uvs[1]=I.geometry.uvs[v][1];h.uvs[2]=I.geometry.uvs[v][3]}e.push(h);j++;f=c[j]=c[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(A.positionWorld);f.v2.positionWorld.copy(F.positionWorld);f.v3.positionWorld.copy(T.positionWorld);f.v1.positionScreen.copy(A.positionScreen);f.v2.positionScreen.copy(F.positionScreen);f.v3.positionScreen.copy(T.positionScreen);
|
||||
f.normalWorld.copy(h.normalWorld);f.centroidWorld.copy(h.centroidWorld);f.centroidScreen.copy(h.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=S;f.faceMaterial=z.material;f.overdraw=$;if(I.geometry.uvs[v]){f.uvs[0]=I.geometry.uvs[v][1];f.uvs[1]=I.geometry.uvs[v][2];f.uvs[2]=I.geometry.uvs[v][3]}e.push(f);j++}}}}else if(I instanceof THREE.Line){D.multiply(H,M);N=I.geometry.vertices;z=N[0];z.positionScreen.copy(z.position);D.multiplyVector4(z.positionScreen);v=1;for(L=N.length;v<L;v++){C=N[v];
|
||||
C.positionScreen.copy(C.position);D.multiplyVector4(C.positionScreen);A=N[v-1];n.copy(C.positionScreen);i.copy(A.positionScreen);if(a(n,i)){n.multiplyScalar(1/n.w);i.multiplyScalar(1/i.w);t=s[y]=s[y]||new THREE.RenderableLine;t.v1.positionScreen.copy(n);t.v2.positionScreen.copy(i);t.z=Math.max(n.z,i.z);t.material=I.material;e.push(t);y++}}}else if(I instanceof THREE.Particle){J.set(I.position.x,I.position.y,I.position.z,1);H.multiplyVector4(J);J.z/=J.w;if(J.z>0&&J.z<1){q=B[x]=B[x]||new THREE.RenderableParticle;
|
||||
q.x=J.x/J.w;q.y=J.y/J.w;q.z=J.z;q.rotation=I.rotation.z;q.scale.x=I.scale.x*Math.abs(q.x-(J.x+w.projectionMatrix.n11)/(J.w+w.projectionMatrix.n14));q.scale.y=I.scale.y*Math.abs(q.y-(J.y+w.projectionMatrix.n22)/(J.w+w.projectionMatrix.n24));q.material=I.material;e.push(q);x++}}}}e.sort(b);return e};this.unprojectVector=function(k,w){var o=new THREE.Matrix4;o.multiply(THREE.Matrix4.makeInvert(w.matrix),THREE.Matrix4.makeInvert(w.projectionMatrix));o.multiplyVector3(k);return k}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,l;this.domElement=document.createElement("div");this.setSize=function(h,f){e=h;d=f;g=e/2;l=d/2};this.render=function(h,f){var j,c,t,y,s,q,x,B;a=b.projectScene(h,f);j=0;for(c=a.length;j<c;j++){s=a[j];if(s instanceof THREE.RenderableParticle){x=s.x*g+g;B=s.y*l+l;t=0;for(y=s.material.length;t<y;t++){q=s.material[t];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=x+"px";q.style.top=B+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,g,l,h,f=e.getContext("2d"),j=1,c=0,t=null,y=null,s=1,q,x,B,J,H,D,n,i,p,k=new THREE.Color,w=new THREE.Color,o=new THREE.Color,m=new THREE.Color,v=new THREE.Color,L,C,A,P,I,M,W,S,$,V,N=new THREE.Rectangle,z=new THREE.Rectangle,F=new THREE.Rectangle,T=false,r=new THREE.Color,u=new THREE.Color,E=new THREE.Color,O=new THREE.Color,X=Math.PI*2,Y=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
|
||||
ea.width=ea.height=2;ma=ea.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);oa=ma.getImageData(0,0,2,2);fa=oa.data;ra=document.createElement("canvas");ra.width=ra.height=pa;va=ra.getContext("2d");va.translate(-pa/2,-pa/2);va.scale(pa,pa);pa--;this.domElement=e;this.autoClear=true;this.setSize=function(ia,wa){d=ia;g=wa;l=d/2;h=g/2;e.width=d;e.height=g;N.set(-l,-h,l,h)};this.clear=function(){if(!z.isEmpty()){z.inflate(1);z.minSelf(N);f.clearRect(z.getX(),z.getY(),z.getWidth(),z.getHeight());
|
||||
z.empty()}};this.render=function(ia,wa){function Ka(G){var U,R,K,Q=G.lights;u.setRGB(0,0,0);E.setRGB(0,0,0);O.setRGB(0,0,0);G=0;for(U=Q.length;G<U;G++){R=Q[G];K=R.color;if(R instanceof THREE.AmbientLight){u.r+=K.r;u.g+=K.g;u.b+=K.b}else if(R instanceof THREE.DirectionalLight){E.r+=K.r;E.g+=K.g;E.b+=K.b}else if(R instanceof THREE.PointLight){O.r+=K.r;O.g+=K.g;O.b+=K.b}}}function xa(G,U,R,K){var Q,Z,ba,ca,da=G.lights;G=0;for(Q=da.length;G<Q;G++){Z=da[G];ba=Z.color;ca=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=
|
||||
R.dot(Z.position)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,U);Y.normalize();Z=R.dot(Y)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}}}function La(G,U,R){if(R.opacity!=0){Ca(R.opacity);ya(R.blending);var K,Q,Z,ba,ca,da;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ba=R.map;ca=ba.width>>1;da=ba.height>>1;Q=U.scale.x*l;Z=U.scale.y*h;R=Q*ca;K=Z*da;F.set(G.x-R,G.y-K,G.x+R,G.y+K);if(N.instersects(F)){f.save();f.translate(G.x,G.y);
|
||||
f.rotate(-U.rotation);f.scale(Q,-Z);f.translate(-ca,-da);f.drawImage(ba,0,0);f.restore()}}}else if(R instanceof THREE.ParticleCircleMaterial){if(T){r.r=u.r+E.r+O.r;r.g=u.g+E.g+O.g;r.b=u.b+E.b+O.b;k.r=R.color.r*r.r;k.g=R.color.g*r.g;k.b=R.color.b*r.b;k.updateStyleString()}else k.__styleString=R.color.__styleString;R=U.scale.x*l;K=U.scale.y*h;F.set(G.x-R,G.y-K,G.x+R,G.y+K);if(N.instersects(F)){Q=k.__styleString;if(y!=Q)f.fillStyle=y=Q;f.save();f.translate(G.x,G.y);f.rotate(-U.rotation);f.scale(R,K);
|
||||
f.beginPath();f.arc(0,0,1,0,X,true);f.closePath();f.fill();f.restore()}}}}function Ma(G,U,R,K){if(K.opacity!=0){Ca(K.opacity);ya(K.blending);f.beginPath();f.moveTo(G.positionScreen.x,G.positionScreen.y);f.lineTo(U.positionScreen.x,U.positionScreen.y);f.closePath();if(K instanceof THREE.LineBasicMaterial){k.__styleString=K.color.__styleString;G=K.linewidth;if(s!=G)f.lineWidth=s=G;G=k.__styleString;if(t!=G)f.strokeStyle=t=G;f.stroke();F.inflate(K.linewidth*2)}}}function Ga(G,U,R,K,Q,Z){if(Q.opacity!=
|
||||
0){Ca(Q.opacity);ya(Q.blending);J=G.positionScreen.x;H=G.positionScreen.y;D=U.positionScreen.x;n=U.positionScreen.y;i=R.positionScreen.x;p=R.positionScreen.y;f.beginPath();f.moveTo(J,H);f.lineTo(D,n);f.lineTo(i,p);f.lineTo(J,H);f.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(J,H,D,n,i,p,Q.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
|
||||
THREE.SphericalReflectionMapping){G=wa.matrix;Y.copy(K.vertexNormalsWorld[0]);I=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;M=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[1]);W=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;S=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[2]);$=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;V=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;sa(J,H,D,n,i,p,Q.env_map.image,I,M,W,S,$,V)}}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):
|
||||
Aa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(J,H,D,n,i,p,Q.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);ya(THREE.SubtractiveBlending)}if(T)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){w.r=o.r=m.r=u.r;w.g=o.g=m.g=u.g;w.b=o.b=m.b=u.b;xa(Z,K.v1.positionWorld,K.vertexNormalsWorld[0],w);xa(Z,K.v2.positionWorld,K.vertexNormalsWorld[1],o);xa(Z,
|
||||
K.v3.positionWorld,K.vertexNormalsWorld[2],m);v.r=(o.r+m.r)*0.5;v.g=(o.g+m.g)*0.5;v.b=(o.b+m.b)*0.5;P=Ha(w,o,m,v);sa(J,H,D,n,i,p,P,0,0,1,0,0,1)}else{r.r=u.r;r.g=u.g;r.b=u.b;xa(Z,K.centroidWorld,K.normalWorld,r);k.r=Q.color.r*r.r;k.g=Q.color.g*r.g;k.b=Q.color.b*r.b;k.updateStyleString();Q.wireframe?za(k.__styleString,Q.wireframe_linewidth):Aa(k.__styleString)}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):Aa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){L=Q.__2near;
|
||||
C=Q.__farPlusNear;A=Q.__farMinusNear;w.r=w.g=w.b=1-L/(C-G.positionScreen.z*A);o.r=o.g=o.b=1-L/(C-U.positionScreen.z*A);m.r=m.g=m.b=1-L/(C-R.positionScreen.z*A);v.r=(o.r+m.r)*0.5;v.g=(o.g+m.g)*0.5;v.b=(o.b+m.b)*0.5;P=Ha(w,o,m,v);sa(J,H,D,n,i,p,P,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){k.r=Da(K.normalWorld.x);k.g=Da(K.normalWorld.y);k.b=Da(K.normalWorld.z);k.updateStyleString();Q.wireframe?za(k.__styleString,Q.wireframe_linewidth):Aa(k.__styleString)}}}function za(G,U){if(t!=G)f.strokeStyle=
|
||||
t=G;if(s!=U)f.lineWidth=s=U;f.stroke();F.inflate(U*2)}function Aa(G){if(y!=G)f.fillStyle=y=G;f.fill()}function sa(G,U,R,K,Q,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;R-=G;K-=U;Q-=G;Z-=U;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*R-ga*Q)*la;ga=(ta*K-ga*Z)*la;R=(ja*Q-ka*R)*la;K=(ja*Z-ka*K)*la;G=G-na*ca-R*da;U=U-ga*ca-K*da;f.save();f.transform(na,ga,R,K,G,U);f.clip();f.drawImage(ba,0,0);f.restore()}function Ca(G){if(j!=G)f.globalAlpha=
|
||||
j=G}function ya(G){if(c!=G){switch(G){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=G}}function Ha(G,U,R,K){var Q=~~(G.r*255),Z=~~(G.g*255);G=~~(G.b*255);var ba=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(R.r*255),ja=~~(R.g*255);R=~~(R.b*255);var ga=~~(K.r*255),ka=~~(K.g*255);K=~~(K.b*255);fa[0]=Q<0?0:Q>255?255:Q;fa[1]=Z<0?0:
|
||||
Z>255?255:Z;fa[2]=G<0?0:G>255?255:G;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=R<0?0:R>255?255:R;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=K<0?0:K>255?255:K;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ea(G,U){var R=U.x-G.x,K=U.y-G.y,Q=1/Math.sqrt(R*R+K*K);R*=Q;K*=Q;U.x+=R;U.y+=K;G.x-=R;G.y-=K}var Ba,Ia,aa,ha,qa,Fa,
|
||||
Ja,ua;f.setTransform(1,0,0,-1,l,h);this.autoClear&&this.clear();a=b.projectScene(ia,wa);(T=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba<Ia;Ba++){aa=a[Ba];F.empty();if(aa instanceof THREE.RenderableParticle){q=aa;q.x*=l;q.y*=h;ha=0;for(qa=aa.material.length;ha<qa;ha++)La(q,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){q=aa.v1;x=aa.v2;q.positionScreen.x*=l;q.positionScreen.y*=h;x.positionScreen.x*=l;x.positionScreen.y*=h;F.addPoint(q.positionScreen.x,q.positionScreen.y);
|
||||
F.addPoint(x.positionScreen.x,x.positionScreen.y);if(N.instersects(F)){ha=0;for(qa=aa.material.length;ha<qa;)Ma(q,x,aa,aa.material[ha++],ia)}}else if(aa instanceof THREE.RenderableFace3){q=aa.v1;x=aa.v2;B=aa.v3;q.positionScreen.x*=l;q.positionScreen.y*=h;x.positionScreen.x*=l;x.positionScreen.y*=h;B.positionScreen.x*=l;B.positionScreen.y*=h;if(aa.overdraw){Ea(q.positionScreen,x.positionScreen);Ea(x.positionScreen,B.positionScreen);Ea(B.positionScreen,q.positionScreen)}F.add3Points(q.positionScreen.x,
|
||||
q.positionScreen.y,x.positionScreen.x,x.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(N.instersects(F)){ha=0;for(qa=aa.meshMaterial.length;ha<qa;){ua=aa.meshMaterial[ha++];if(ua instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=aa.faceMaterial.length;Fa<Ja;)(ua=aa.faceMaterial[Fa++])&&Ga(q,x,B,aa,ua,ia)}else Ga(q,x,B,aa,ua,ia)}}}z.addRectangle(F)}f.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(S,$,V){var N,z,F,T;N=0;for(z=S.lights.length;N<z;N++){F=S.lights[N];if(F instanceof THREE.DirectionalLight){T=$.normalWorld.dot(F.position)*F.intensity;if(T>0){V.r+=F.color.r*T;V.g+=F.color.g*T;V.b+=F.color.b*T}}else if(F instanceof THREE.PointLight){m.sub(F.position,$.centroidWorld);m.normalize();T=$.normalWorld.dot(m)*F.intensity;if(T>0){V.r+=F.color.r*T;V.g+=F.color.g*T;V.b+=F.color.b*T}}}}function b(S,$,V,N,z,F){A=d(P++);A.setAttribute("d","M "+S.positionScreen.x+
|
||||
" "+S.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(D){i.r=p.r;i.g=p.g;i.b=p.b;a(F,N,i);n.r=z.color.r*i.r;n.g=z.color.g*i.g;n.b=z.color.b*i.b;n.updateStyleString()}else n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){o=1-z.__2near/(z.__farPlusNear-N.z*z.__farMinusNear);
|
||||
n.setRGB(o,o,o)}else z instanceof THREE.MeshNormalMaterial&&n.setRGB(g(N.normalWorld.x),g(N.normalWorld.y),g(N.normalWorld.z));z.wireframe?A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):A.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+z.opacity);f.appendChild(A)}function e(S,$,V,N,z,F,T){A=d(P++);A.setAttribute("d",
|
||||
"M "+S.positionScreen.x+" "+S.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(D){i.r=p.r;i.g=p.g;i.b=p.b;a(T,z,i);n.r=F.color.r*i.r;n.g=F.color.g*i.g;n.b=F.color.b*i.b;n.updateStyleString()}else n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){o=
|
||||
1-F.__2near/(F.__farPlusNear-z.z*F.__farMinusNear);n.setRGB(o,o,o)}else F instanceof THREE.MeshNormalMaterial&&n.setRGB(g(z.normalWorld.x),g(z.normalWorld.y),g(z.normalWorld.z));F.wireframe?A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):A.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+F.opacity);f.appendChild(A)}
|
||||
function d(S){if(v[S]==null){v[S]=document.createElementNS("http://www.w3.org/2000/svg","path");W==0&&v[S].setAttribute("shape-rendering","crispEdges");return v[S]}return v[S]}function g(S){return S<0?Math.min((1+S)*0.5,0.5):0.5+Math.min(S*0.5,0.5)}var l=null,h=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,y,s,q,x,B,J=new THREE.Rectangle,H=new THREE.Rectangle,D=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),p=new THREE.Color(0),k=new THREE.Color(0),
|
||||
w=new THREE.Color(0),o,m=new THREE.Vector3,v=[],L=[],C=[],A,P,I,M,W=1;this.domElement=f;this.autoClear=true;this.setQuality=function(S){switch(S){case "high":W=1;break;case "low":W=0}};this.setSize=function(S,$){j=S;c=$;t=j/2;y=c/2;f.setAttribute("viewBox",-t+" "+-y+" "+j+" "+c);f.setAttribute("width",j);f.setAttribute("height",c);J.set(-t,-y,t,y)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(S,$){var V,N,z,F,T,r,u,E;this.autoClear&&this.clear();
|
||||
l=h.projectScene(S,$);M=I=P=0;if(D=S.lights.length>0){u=S.lights;p.setRGB(0,0,0);k.setRGB(0,0,0);w.setRGB(0,0,0);V=0;for(N=u.length;V<N;V++){z=u[V];F=z.color;if(z instanceof THREE.AmbientLight){p.r+=F.r;p.g+=F.g;p.b+=F.b}else if(z instanceof THREE.DirectionalLight){k.r+=F.r;k.g+=F.g;k.b+=F.b}else if(z instanceof THREE.PointLight){w.r+=F.r;w.g+=F.g;w.b+=F.b}}}V=0;for(N=l.length;V<N;V++){u=l[V];H.empty();if(u instanceof THREE.RenderableParticle){s=u;s.x*=t;s.y*=-y;z=0;for(F=u.material.length;z<F;z++)if(E=
|
||||
u.material[z]){T=s;r=u;E=E;var O=I++;if(L[O]==null){L[O]=document.createElementNS("http://www.w3.org/2000/svg","circle");W==0&&L[O].setAttribute("shape-rendering","crispEdges")}A=L[O];A.setAttribute("cx",T.x);A.setAttribute("cy",T.y);A.setAttribute("r",r.scale.x*t);if(E instanceof THREE.ParticleCircleMaterial){if(D){i.r=p.r+k.r+w.r;i.g=p.g+k.g+w.g;i.b=p.b+k.b+w.b;n.r=E.color.r*i.r;n.g=E.color.g*i.g;n.b=E.color.b*i.b;n.updateStyleString()}else n=E.color;A.setAttribute("style","fill: "+n.__styleString)}f.appendChild(A)}}else if(u instanceof
|
||||
THREE.RenderableLine){s=u.v1;q=u.v2;s.positionScreen.x*=t;s.positionScreen.y*=-y;q.positionScreen.x*=t;q.positionScreen.y*=-y;H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(q.positionScreen.x,q.positionScreen.y);if(J.instersects(H)){z=0;for(F=u.material.length;z<F;)if(E=u.material[z++]){T=s;r=q;E=E;O=M++;if(C[O]==null){C[O]=document.createElementNS("http://www.w3.org/2000/svg","line");W==0&&C[O].setAttribute("shape-rendering","crispEdges")}A=C[O];A.setAttribute("x1",T.positionScreen.x);
|
||||
A.setAttribute("y1",T.positionScreen.y);A.setAttribute("x2",r.positionScreen.x);A.setAttribute("y2",r.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){n.__styleString=E.color.__styleString;A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.linecap+"; stroke-linejoin: "+E.linejoin);f.appendChild(A)}}}}else if(u instanceof THREE.RenderableFace3){s=u.v1;q=u.v2;x=u.v3;s.positionScreen.x*=t;s.positionScreen.y*=
|
||||
-y;q.positionScreen.x*=t;q.positionScreen.y*=-y;x.positionScreen.x*=t;x.positionScreen.y*=-y;H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(q.positionScreen.x,q.positionScreen.y);H.addPoint(x.positionScreen.x,x.positionScreen.y);if(J.instersects(H)){z=0;for(F=u.meshMaterial.length;z<F;){E=u.meshMaterial[z++];if(E instanceof THREE.MeshFaceMaterial){T=0;for(r=u.faceMaterial.length;T<r;)(E=u.faceMaterial[T++])&&b(s,q,x,u,E,S)}else E&&b(s,q,x,u,E,S)}}}else if(u instanceof THREE.RenderableFace4){s=
|
||||
u.v1;q=u.v2;x=u.v3;B=u.v4;s.positionScreen.x*=t;s.positionScreen.y*=-y;q.positionScreen.x*=t;q.positionScreen.y*=-y;x.positionScreen.x*=t;x.positionScreen.y*=-y;B.positionScreen.x*=t;B.positionScreen.y*=-y;H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(q.positionScreen.x,q.positionScreen.y);H.addPoint(x.positionScreen.x,x.positionScreen.y);H.addPoint(B.positionScreen.x,B.positionScreen.y);if(J.instersects(H)){z=0;for(F=u.meshMaterial.length;z<F;){E=u.meshMaterial[z++];if(E instanceof
|
||||
THREE.MeshFaceMaterial){T=0;for(r=u.faceMaterial.length;T<r;)(E=u.faceMaterial[T++])&&e(s,q,x,B,u,E,S)}else E&&e(s,q,x,B,u,E,S)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(i,p){var k=c.createProgram(),w=[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(k,h("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
|
||||
i));c.attachShader(k,h("vertex",w+p));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};return k}function e(i,p){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.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 k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_CUBE_MAP,
|
||||
i.image.__webGLTextureCube)}}function d(i,p){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(i.min_filter));c.generateMipmap(c.TEXTURE_2D);
|
||||
c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,p){var k,w,o;k=0;for(w=p.length;k<w;k++){o=p[k];i.uniforms[o]=c.getUniformLocation(i,o)}}function l(i,p){var k,w,o;k=0;for(w=p.length;k<w;k++){o=p[k];i.attributes[o]=c.getAttribLocation(i,o);i.attributes[o]>=0&&c.enableVertexAttribArray(i.attributes[o])}}function h(i,p){var k;if(i=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")k=c.createShader(c.VERTEX_SHADER);
|
||||
c.shaderSource(k,p);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function f(i){switch(i){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 j=document.createElement("canvas"),c,t,y,s=new THREE.Matrix4,q,x=new Float32Array(16),B=new Float32Array(16),J=new Float32Array(16),H=new Float32Array(9),D=new Float32Array(16);a=function(i,p){if(i){var k,w,o,m=pointLights=maxDirLights=maxPointLights=0;k=0;for(w=i.lights.length;k<w;k++){o=i.lights[k];o instanceof THREE.DirectionalLight&&m++;o instanceof
|
||||
THREE.PointLight&&pointLights++}if(pointLights+m<=p){maxDirLights=m;maxPointLights=pointLights}else{maxDirLights=Math.ceil(p*m/(pointLights+m));maxPointLights=p-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:p-1}}(a,4);this.domElement=j;this.autoClear=true;try{c=j.getContext("experimental-webgl",{antialias:true})}catch(n){}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);t=y=function(i,p){var k=[i?"#define MAX_DIR_LIGHTS "+i:"",p?"#define MAX_POINT_LIGHTS "+p:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
|
||||
"",p?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",p?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",p?"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;",
|
||||
i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",p?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",p?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",p?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
||||
"",p?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",p?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",p?"}":"","}\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"),
|
||||
w=[i?"#define MAX_DIR_LIGHTS "+i:"",p?"#define MAX_POINT_LIGHTS "+p:"","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;",
|
||||
i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",p?"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 );",
|
||||
p?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",p?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",p?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",p?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",p?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",p?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",p?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",p?"float pointSpecularWeight = 0.0;":"",p?"if ( pointDotNormalHalf >= 0.0 )":
|
||||
"",p?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",p?"pointDiffuse += mColor * pointDiffuseWeight;":"",p?"pointSpecular += mSpecular * pointSpecularWeight;":"",p?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
||||
"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",p?"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");
|
||||
k=b(v,k);c.useProgram(k);g(k,["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"]);i&&g(k,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&g(k,["pointLightNumber","pointLightColor",
|
||||
"pointLightPosition"]);c.uniform1i(k.uniforms.enableMap,0);c.uniform1i(k.uniforms.tMap,0);c.uniform1i(k.uniforms.enableCubeMap,0);c.uniform1i(k.uniforms.tCube,1);c.uniform1i(k.uniforms.mixEnvMap,0);c.uniform1i(k.uniforms.useRefract,0);l(k,["position","normal","uv"]);return k}(a.directional,a.point);this.setSize=function(i,o){j.width=i;j.height=o;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,o){var k,v,n,m,z,G=[],
|
||||
L=[],x=[];m=[];z=[];c.uniform1i(i.uniforms.enableLighting,o.length);k=0;for(v=o.length;k<v;k++){n=o[k];if(n instanceof THREE.AmbientLight)G.push(n);else if(n instanceof THREE.DirectionalLight)x.push(n);else n instanceof THREE.PointLight&&L.push(n)}k=n=m=z=0;for(v=G.length;k<v;k++){n+=G[k].color.r;m+=G[k].color.g;z+=G[k].color.b}c.uniform3f(i.uniforms.ambientLightColor,n,m,z);m=[];z=[];k=0;for(v=x.length;k<v;k++){n=x[k];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);
|
||||
z.push(n.position.x);z.push(n.position.y);z.push(n.position.z)}if(x.length){c.uniform1i(i.uniforms.directionalLightNumber,x.length);c.uniform3fv(i.uniforms.directionalLightDirection,z);c.uniform3fv(i.uniforms.directionalLightColor,m)}m=[];z=[];k=0;for(v=L.length;k<v;k++){n=L[k];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);z.push(n.position.x);z.push(n.position.y);z.push(n.position.z)}if(L.length){c.uniform1i(i.uniforms.pointLightNumber,L.length);c.uniform3fv(i.uniforms.pointLightPosition,
|
||||
z);c.uniform3fv(i.uniforms.pointLightColor,m)}};this.createBuffers=function(i,o){var k,v,n,m,z,G,L,x,J,R=[],D=[],V=[],T=[],$=[],W=[],O=0,H=i.geometry.geometryChunks[o],C;n=false;k=0;for(v=i.material.length;k<v;k++){meshMaterial=i.material[k];if(meshMaterial instanceof THREE.MeshFaceMaterial){z=0;for(C=H.material.length;z<C;z++)if(H.material[z]&&H.material[z].shading!=undefined&&H.material[z].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
||||
THREE.SmoothShading){n=true;break}if(n)break}C=n;k=0;for(v=H.faces.length;k<v;k++){n=H.faces[k];m=i.geometry.faces[n];z=m.vertexNormals;faceNormal=m.normal;n=i.geometry.uvs[n];if(m instanceof THREE.Face3){G=i.geometry.vertices[m.a].position;L=i.geometry.vertices[m.b].position;x=i.geometry.vertices[m.c].position;V.push(G.x,G.y,G.z);V.push(L.x,L.y,L.z);V.push(x.x,x.y,x.z);if(i.geometry.hasTangents){G=i.geometry.vertices[m.a].tangent;L=i.geometry.vertices[m.b].tangent;x=i.geometry.vertices[m.c].tangent;
|
||||
$.push(G.x,G.y,G.z,G.w);$.push(L.x,L.y,L.z,L.w);$.push(x.x,x.y,x.z,x.w)}if(z.length==3&&C)for(m=0;m<3;m++)T.push(z[m].x,z[m].y,z[m].z);else for(m=0;m<3;m++)T.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<3;m++)W.push(n[m].u,n[m].v);R.push(O,O+1,O+2);D.push(O,O+1);D.push(O,O+2);D.push(O+1,O+2);O+=3}else if(m instanceof THREE.Face4){G=i.geometry.vertices[m.a].position;L=i.geometry.vertices[m.b].position;x=i.geometry.vertices[m.c].position;J=i.geometry.vertices[m.d].position;V.push(G.x,
|
||||
G.y,G.z);V.push(L.x,L.y,L.z);V.push(x.x,x.y,x.z);V.push(J.x,J.y,J.z);if(i.geometry.hasTangents){G=i.geometry.vertices[m.a].tangent;L=i.geometry.vertices[m.b].tangent;x=i.geometry.vertices[m.c].tangent;m=i.geometry.vertices[m.d].tangent;$.push(G.x,G.y,G.z,G.w);$.push(L.x,L.y,L.z,L.w);$.push(x.x,x.y,x.z,x.w);$.push(m.x,m.y,m.z,m.w)}if(z.length==4&&C)for(m=0;m<4;m++)T.push(z[m].x,z[m].y,z[m].z);else for(m=0;m<4;m++)T.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<4;m++)W.push(n[m].u,n[m].v);
|
||||
R.push(O,O+1,O+2);R.push(O,O+2,O+3);D.push(O,O+1);D.push(O,O+2);D.push(O,O+3);D.push(O+1,O+2);D.push(O+2,O+3);O+=4}}if(V.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW);if(i.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();
|
||||
c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array($),c.STATIC_DRAW)}if(W.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),c.STATIC_DRAW);H.__webGLFaceCount=R.length;H.__webGLLineCount=D.length}};this.renderBuffer=function(i,o,k,v){var n,m,z,G,L,x,J,R,D;if(k instanceof THREE.MeshShaderMaterial){if(!k.program){k.program=b(k.fragment_shader,k.vertex_shader);J=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in k.uniforms)J.push(D);g(k.program,J);l(k.program,["position","normal","uv","tangent"])}D=
|
||||
k.program}else D=y;if(D!=t){c.useProgram(D);t=D}D==y&&this.setupLights(D,o);this.loadCamera(D,i);this.loadMatrices(D);if(k instanceof THREE.MeshShaderMaterial){z=k.wireframe;G=k.wireframe_linewidth;i=D;o=k.uniforms;var V;for(n in o){R=o[n].type;J=o[n].value;V=i.uniforms[n];if(R=="i")c.uniform1i(V,J);else if(R=="f")c.uniform1f(V,J);else if(R=="v3")c.uniform3f(V,J.x,J.y,J.z);else if(R=="c")c.uniform3f(V,J.r,J.g,J.b);else if(R=="t"){c.uniform1i(V,J);if(R=o[n].texture)R.image instanceof Array&&R.image.length==
|
||||
6?e(R,J):d(R,J)}}}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshBasicMaterial){n=k.color;m=k.opacity;z=k.wireframe;G=k.wireframe_linewidth;L=k.map;x=k.env_map;o=k.combine==THREE.MixOperation;i=k.reflectivity;R=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;J=k.refraction_ratio;c.uniform4f(D.uniforms.mColor,n.r*m,n.g*m,n.b*m,m);c.uniform1i(D.uniforms.mixEnvMap,o);c.uniform1f(D.uniforms.mReflectivity,i);c.uniform1i(D.uniforms.useRefract,
|
||||
R);c.uniform1f(D.uniforms.mRefractionRatio,J)}if(k instanceof THREE.MeshNormalMaterial){m=k.opacity;c.uniform1f(D.uniforms.mOpacity,m);c.uniform1i(D.uniforms.material,4)}else if(k instanceof THREE.MeshDepthMaterial){m=k.opacity;z=k.wireframe;G=k.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,m);c.uniform1f(D.uniforms.m2Near,k.__2near);c.uniform1f(D.uniforms.mFarPlusNear,k.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,k.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(k instanceof
|
||||
THREE.MeshPhongMaterial){n=k.ambient;i=k.specular;k=k.shininess;c.uniform4f(D.uniforms.mAmbient,n.r,n.g,n.b,m);c.uniform4f(D.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(D.uniforms.mShininess,k);c.uniform1i(D.uniforms.material,2)}else if(k instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(k instanceof THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,0);else if(k instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);x=k.env_map}if(L){d(L,0);c.uniform1i(D.uniforms.tMap,
|
||||
0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(x){e(x,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);m=D.attributes;c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);
|
||||
c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0)}if(m.uv>=0)if(v.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.enableVertexAttribArray(m.uv);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(m.uv);if(z){c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);c.drawElements(c.LINES,v.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,v.__webGLFaceCount,c.UNSIGNED_SHORT,
|
||||
0)}};this.renderPass=function(i,o,k,v,n,m){var z,G,L,x,J;L=0;for(x=k.material.length;L<x;L++){z=k.material[L];if(z instanceof THREE.MeshFaceMaterial){z=0;for(G=v.material.length;z<G;z++)if((J=v.material[z])&&J.blending==n&&J.opacity<1==m){this.setBlending(J.blending);this.renderBuffer(i,o,J,v)}}else if((J=z)&&J.blending==n&&J.opacity<1==m){this.setBlending(J.blending);this.renderBuffer(i,o,J,v)}}};this.render=function(i,o){var k,v,n,m,z=i.lights;this.initWebGLObjects(i);this.autoClear&&this.clear();
|
||||
o.autoUpdateMatrix&&o.updateMatrix();w.set(o.matrix.flatten());N.set(o.projectionMatrix.flatten());k=0;for(v=i.__webGLObjects.length;k<v;k++){n=i.__webGLObjects[k];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,o);this.renderPass(o,z,m,n,THREE.NormalBlending,false)}}k=0;for(v=i.__webGLObjects.length;k<v;k++){n=i.__webGLObjects[k];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,o);this.renderPass(o,z,m,n,THREE.AdditiveBlending,false);this.renderPass(o,z,m,n,THREE.SubtractiveBlending,
|
||||
false);this.renderPass(o,z,m,n,THREE.AdditiveBlending,true);this.renderPass(o,z,m,n,THREE.SubtractiveBlending,true);this.renderPass(o,z,m,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var o,k,v,n,m,z;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}o=0;for(k=i.objects.length;o<k;o++){v=i.objects[o];if(i.__webGLObjectsMap[v.id]==undefined)i.__webGLObjectsMap[v.id]={};z=i.__webGLObjectsMap[v.id];if(v instanceof THREE.Mesh)for(m in v.geometry.geometryChunks){n=v.geometry.geometryChunks[m];
|
||||
n.__webGLVertexBuffer||this.createBuffers(v,m);if(z[m]==undefined){n={buffer:n,object:v};i.__webGLObjects.push(n);z[m]=1}}}};this.removeObject=function(i,o){var k,v;for(k=i.__webGLObjects.length-1;k>=0;k--){v=i.__webGLObjects[k].object;o==v&&i.__webGLObjects.splice(k,1)}};this.setupMatrices=function(i,o){i.autoUpdateMatrix&&i.updateMatrix();s.multiply(o.matrix,i.matrix);B.set(s.flatten());r=THREE.Matrix4.makeInvert3x3(s).transpose();F.set(r.m);A.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,
|
||||
false,w);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,B);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,N);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,F);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,A)};this.loadCamera=function(i,o){c.uniform3f(i.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(i){switch(i){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(i,o){if(i){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="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}};
|
||||
k=b(w,k);c.useProgram(k);g(k,["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"]);i&&g(k,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&g(k,["pointLightNumber","pointLightColor",
|
||||
"pointLightPosition"]);c.uniform1i(k.uniforms.enableMap,0);c.uniform1i(k.uniforms.tMap,0);c.uniform1i(k.uniforms.enableCubeMap,0);c.uniform1i(k.uniforms.tCube,1);c.uniform1i(k.uniforms.mixEnvMap,0);c.uniform1i(k.uniforms.useRefract,0);l(k,["position","normal","uv"]);return k}(a.directional,a.point);this.setSize=function(i,p){j.width=i;j.height=p;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,p){var k,w,o,m,v,L=[],
|
||||
C=[],A=[];m=[];v=[];c.uniform1i(i.uniforms.enableLighting,p.length);k=0;for(w=p.length;k<w;k++){o=p[k];if(o instanceof THREE.AmbientLight)L.push(o);else if(o instanceof THREE.DirectionalLight)A.push(o);else o instanceof THREE.PointLight&&C.push(o)}k=o=m=v=0;for(w=L.length;k<w;k++){o+=L[k].color.r;m+=L[k].color.g;v+=L[k].color.b}c.uniform3f(i.uniforms.ambientLightColor,o,m,v);m=[];v=[];k=0;for(w=A.length;k<w;k++){o=A[k];m.push(o.color.r*o.intensity);m.push(o.color.g*o.intensity);m.push(o.color.b*o.intensity);
|
||||
v.push(o.position.x);v.push(o.position.y);v.push(o.position.z)}if(A.length){c.uniform1i(i.uniforms.directionalLightNumber,A.length);c.uniform3fv(i.uniforms.directionalLightDirection,v);c.uniform3fv(i.uniforms.directionalLightColor,m)}m=[];v=[];k=0;for(w=C.length;k<w;k++){o=C[k];m.push(o.color.r*o.intensity);m.push(o.color.g*o.intensity);m.push(o.color.b*o.intensity);v.push(o.position.x);v.push(o.position.y);v.push(o.position.z)}if(C.length){c.uniform1i(i.uniforms.pointLightNumber,C.length);c.uniform3fv(i.uniforms.pointLightPosition,
|
||||
v);c.uniform3fv(i.uniforms.pointLightColor,m)}};this.createBuffers=function(i,p){var k,w,o,m,v,L,C,A,P,I=[],M=[],W=[],S=[],$=[],V=[],N=0,z=i.geometry.geometryChunks[p],F;o=false;k=0;for(w=i.material.length;k<w;k++){meshMaterial=i.material[k];if(meshMaterial instanceof THREE.MeshFaceMaterial){v=0;for(F=z.material.length;v<F;v++)if(z.material[v]&&z.material[v].shading!=undefined&&z.material[v].shading==THREE.SmoothShading){o=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
||||
THREE.SmoothShading){o=true;break}if(o)break}F=o;k=0;for(w=z.faces.length;k<w;k++){o=z.faces[k];m=i.geometry.faces[o];v=m.vertexNormals;faceNormal=m.normal;o=i.geometry.uvs[o];if(m instanceof THREE.Face3){L=i.geometry.vertices[m.a].position;C=i.geometry.vertices[m.b].position;A=i.geometry.vertices[m.c].position;W.push(L.x,L.y,L.z);W.push(C.x,C.y,C.z);W.push(A.x,A.y,A.z);if(i.geometry.hasTangents){L=i.geometry.vertices[m.a].tangent;C=i.geometry.vertices[m.b].tangent;A=i.geometry.vertices[m.c].tangent;
|
||||
$.push(L.x,L.y,L.z,L.w);$.push(C.x,C.y,C.z,C.w);$.push(A.x,A.y,A.z,A.w)}if(v.length==3&&F)for(m=0;m<3;m++)S.push(v[m].x,v[m].y,v[m].z);else for(m=0;m<3;m++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(o)for(m=0;m<3;m++)V.push(o[m].u,o[m].v);I.push(N,N+1,N+2);M.push(N,N+1);M.push(N,N+2);M.push(N+1,N+2);N+=3}else if(m instanceof THREE.Face4){L=i.geometry.vertices[m.a].position;C=i.geometry.vertices[m.b].position;A=i.geometry.vertices[m.c].position;P=i.geometry.vertices[m.d].position;W.push(L.x,
|
||||
L.y,L.z);W.push(C.x,C.y,C.z);W.push(A.x,A.y,A.z);W.push(P.x,P.y,P.z);if(i.geometry.hasTangents){L=i.geometry.vertices[m.a].tangent;C=i.geometry.vertices[m.b].tangent;A=i.geometry.vertices[m.c].tangent;m=i.geometry.vertices[m.d].tangent;$.push(L.x,L.y,L.z,L.w);$.push(C.x,C.y,C.z,C.w);$.push(A.x,A.y,A.z,A.w);$.push(m.x,m.y,m.z,m.w)}if(v.length==4&&F)for(m=0;m<4;m++)S.push(v[m].x,v[m].y,v[m].z);else for(m=0;m<4;m++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(o)for(m=0;m<4;m++)V.push(o[m].u,o[m].v);
|
||||
I.push(N,N+1,N+2);I.push(N,N+2,N+3);M.push(N,N+1);M.push(N,N+2);M.push(N,N+3);M.push(N+1,N+2);M.push(N+2,N+3);N+=4}}if(W.length){z.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW);z.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW);if(i.geometry.hasTangents){z.__webGLTangentBuffer=c.createBuffer();
|
||||
c.bindBuffer(c.ARRAY_BUFFER,z.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array($),c.STATIC_DRAW)}if(V.length>0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);z.__webGLFaceCount=I.length;z.__webGLLineCount=M.length}};this.renderBuffer=function(i,p,k,w){var o,m,v,L,C,A,P,I,M;if(k instanceof THREE.MeshShaderMaterial){if(!k.program){k.program=b(k.fragment_shader,k.vertex_shader);P=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(M in k.uniforms)P.push(M);g(k.program,P);l(k.program,["position","normal","uv","tangent"])}M=
|
||||
k.program}else M=y;if(M!=t){c.useProgram(M);t=M}M==y&&this.setupLights(M,p);this.loadCamera(M,i);this.loadMatrices(M);if(k instanceof THREE.MeshShaderMaterial){v=k.wireframe;L=k.wireframe_linewidth;i=M;p=k.uniforms;var W;for(o in p){I=p[o].type;P=p[o].value;W=i.uniforms[o];if(I=="i")c.uniform1i(W,P);else if(I=="f")c.uniform1f(W,P);else if(I=="v3")c.uniform3f(W,P.x,P.y,P.z);else if(I=="c")c.uniform3f(W,P.r,P.g,P.b);else if(I=="t"){c.uniform1i(W,P);if(I=p[o].texture)I.image instanceof Array&&I.image.length==
|
||||
6?e(I,P):d(I,P)}}}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshBasicMaterial){o=k.color;m=k.opacity;v=k.wireframe;L=k.wireframe_linewidth;C=k.map;A=k.env_map;p=k.combine==THREE.MixOperation;i=k.reflectivity;I=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;P=k.refraction_ratio;c.uniform4f(M.uniforms.mColor,o.r*m,o.g*m,o.b*m,m);c.uniform1i(M.uniforms.mixEnvMap,p);c.uniform1f(M.uniforms.mReflectivity,i);c.uniform1i(M.uniforms.useRefract,
|
||||
I);c.uniform1f(M.uniforms.mRefractionRatio,P)}if(k instanceof THREE.MeshNormalMaterial){m=k.opacity;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1i(M.uniforms.material,4)}else if(k instanceof THREE.MeshDepthMaterial){m=k.opacity;v=k.wireframe;L=k.wireframe_linewidth;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1f(M.uniforms.m2Near,k.__2near);c.uniform1f(M.uniforms.mFarPlusNear,k.__farPlusNear);c.uniform1f(M.uniforms.mFarMinusNear,k.__farMinusNear);c.uniform1i(M.uniforms.material,3)}else if(k instanceof
|
||||
THREE.MeshPhongMaterial){o=k.ambient;i=k.specular;k=k.shininess;c.uniform4f(M.uniforms.mAmbient,o.r,o.g,o.b,m);c.uniform4f(M.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(M.uniforms.mShininess,k);c.uniform1i(M.uniforms.material,2)}else if(k instanceof THREE.MeshLambertMaterial)c.uniform1i(M.uniforms.material,1);else if(k instanceof THREE.MeshBasicMaterial)c.uniform1i(M.uniforms.material,0);else if(k instanceof THREE.MeshCubeMaterial){c.uniform1i(M.uniforms.material,5);A=k.env_map}if(C){d(C,0);c.uniform1i(M.uniforms.tMap,
|
||||
0);c.uniform1i(M.uniforms.enableMap,1)}else c.uniform1i(M.uniforms.enableMap,0);if(A){e(A,1);c.uniform1i(M.uniforms.tCube,1);c.uniform1i(M.uniforms.enableCubeMap,1)}else c.uniform1i(M.uniforms.enableCubeMap,0);m=M.attributes;c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer);
|
||||
c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0)}if(m.uv>=0)if(w.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.enableVertexAttribArray(m.uv);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(m.uv);if(v){c.lineWidth(L);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);c.drawElements(c.LINES,w.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,w.__webGLFaceCount,c.UNSIGNED_SHORT,
|
||||
0)}};this.renderPass=function(i,p,k,w,o,m){var v,L,C,A,P;C=0;for(A=k.material.length;C<A;C++){v=k.material[C];if(v instanceof THREE.MeshFaceMaterial){v=0;for(L=w.material.length;v<L;v++)if((P=w.material[v])&&P.blending==o&&P.opacity<1==m){this.setBlending(P.blending);this.renderBuffer(i,p,P,w)}}else if((P=v)&&P.blending==o&&P.opacity<1==m){this.setBlending(P.blending);this.renderBuffer(i,p,P,w)}}};this.render=function(i,p){var k,w,o,m,v=i.lights;this.initWebGLObjects(i);this.autoClear&&this.clear();
|
||||
p.autoUpdateMatrix&&p.updateMatrix();x.set(p.matrix.flatten());J.set(p.projectionMatrix.flatten());k=0;for(w=i.__webGLObjects.length;k<w;k++){o=i.__webGLObjects[k];m=o.object;o=o.buffer;if(m.visible){this.setupMatrices(m,p);this.renderPass(p,v,m,o,THREE.NormalBlending,false)}}k=0;for(w=i.__webGLObjects.length;k<w;k++){o=i.__webGLObjects[k];m=o.object;o=o.buffer;if(m.visible){this.setupMatrices(m,p);this.renderPass(p,v,m,o,THREE.AdditiveBlending,false);this.renderPass(p,v,m,o,THREE.SubtractiveBlending,
|
||||
false);this.renderPass(p,v,m,o,THREE.AdditiveBlending,true);this.renderPass(p,v,m,o,THREE.SubtractiveBlending,true);this.renderPass(p,v,m,o,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var p,k,w,o,m,v;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}p=0;for(k=i.objects.length;p<k;p++){w=i.objects[p];if(i.__webGLObjectsMap[w.id]==undefined)i.__webGLObjectsMap[w.id]={};v=i.__webGLObjectsMap[w.id];if(w instanceof THREE.Mesh)for(m in w.geometry.geometryChunks){o=w.geometry.geometryChunks[m];
|
||||
o.__webGLVertexBuffer||this.createBuffers(w,m);if(v[m]==undefined){o={buffer:o,object:w};i.__webGLObjects.push(o);v[m]=1}}}};this.removeObject=function(i,p){var k,w;for(k=i.__webGLObjects.length-1;k>=0;k--){w=i.__webGLObjects[k].object;p==w&&i.__webGLObjects.splice(k,1)}};this.setupMatrices=function(i,p){i.autoUpdateMatrix&&i.updateMatrix();s.multiply(p.matrix,i.matrix);B.set(s.flatten());q=THREE.Matrix4.makeInvert3x3(s).transpose();H.set(q.m);D.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,
|
||||
false,x);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,B);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,H);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,D)};this.loadCamera=function(i,p){c.uniform3f(i.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(i){switch(i){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(i,p){if(i){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="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.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
|
||||
var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,l=a.vertices,h=g.vertices,f=a.faces,j=g.faces,c=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var t=0,y=h.length;t<y;t++){var s=new THREE.Vertex(h[t].position.clone());e&&b.matrix.multiplyVector3(s.position);l.push(s)}t=0;for(y=j.length;t<y;t++){h=j[t];var r,w=h.vertexNormals;if(h instanceof THREE.Face3)r=new THREE.Face3(h.a+d,h.b+d,h.c+d);else if(h instanceof THREE.Face4)r=new THREE.Face4(h.a+d,h.b+
|
||||
d,h.c+d,h.d+d);r.centroid.copy(h.centroid);r.normal.copy(h.normal);e=0;for(l=w.length;e<l;e++){s=w[e];r.vertexNormals.push(s.clone())}r.material=h.material.slice();f.push(r)}t=0;for(y=g.length;t<y;t++){d=g[t];f=[];e=0;for(l=d.length;e<l;e++)f.push(new THREE.UV(d[e].u,d[e].v));c.push(f)}}},ImageUtils={loadTexture:function(a,b){var e=new Image;e.onload=function(){this.loaded=true};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a){var b,e,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
|
||||
var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,l=a.vertices,h=g.vertices,f=a.faces,j=g.faces,c=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var t=0,y=h.length;t<y;t++){var s=new THREE.Vertex(h[t].position.clone());e&&b.matrix.multiplyVector3(s.position);l.push(s)}t=0;for(y=j.length;t<y;t++){h=j[t];var q,x=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else if(h instanceof THREE.Face4)q=new THREE.Face4(h.a+d,h.b+
|
||||
d,h.c+d,h.d+d);q.centroid.copy(h.centroid);q.normal.copy(h.normal);e=0;for(l=x.length;e<l;e++){s=x[e];q.vertexNormals.push(s.clone())}q.material=h.material.slice();f.push(q)}t=0;for(y=g.length;t<y;t++){d=g[t];f=[];e=0;for(l=d.length;e<l;e++)f.push(new THREE.UV(d[e].u,d[e].v));c.push(f)}}},ImageUtils={loadTexture:function(a,b){var e=new Image;e.onload=function(){this.loaded=true};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a){var b,e,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
|
||||
new Image;d[b].loaded=0;d[b].onload=function(){d.loadCount+=1;this.loaded=true};d[b].src=a[b]}return d}},SceneUtils={addMesh:function(a,b,e,d,g,l,h,f,j,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=e;b.position.x=d;b.position.y=g;b.position.z=l;b.rotation.x=h;b.rotation.y=f;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,e){e=new THREE.MeshCubeMaterial({env_map:e});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),e);a.addObject(b);return b},addPanoramaCube:function(a,
|
||||
b,e){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,d,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
|
||||
return mesh},addPanoramaCubePlanes:function(a,b,e){var d=b/2;b=new Plane(b,b);var g=Math.PI/2,l=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));SceneUtils.addMesh(a,b,1,0,d,0,g,0,l,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));SceneUtils.addMesh(a,
|
||||
@@ -185,37 +185,37 @@ vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuni
|
||||
normal:{uniforms:{tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",
|
||||
value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );\nvec3 aoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}",
|
||||
vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
|
||||
basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"}}},Cube=function(a,b,e,d,g,l,h,f){function j(B,N,F,A,p,i,o,k){var v,n=d||1,m=g||1,z=n+1,G=m+1,L=p/2,x=i/2;p=p/n;i=i/m;var J=c.vertices.length;if(B=="x"&&N=="y"||B=="y"&&N=="x")v="z";else if(B=="x"&&N=="z"||B=="z"&&N=="x")v="y";else if(B=="z"&&N=="y"||B=="y"&&N=="z")v="x";for(iy=0;iy<G;iy++)for(ix=
|
||||
0;ix<z;ix++){var R=new THREE.Vector3;R[B]=(ix*p-L)*F;R[N]=(iy*i-x)*A;R[v]=o;c.vertices.push(new THREE.Vertex(R))}for(iy=0;iy<m;iy++)for(ix=0;ix<n;ix++){c.faces.push(new THREE.Face4(ix+z*iy+J,ix+z*(iy+1)+J,ix+1+z*(iy+1)+J,ix+1+z*iy+J,null,k));c.uvs.push([new THREE.UV(ix/n,iy/m),new THREE.UV(ix/n,(iy+1)/m),new THREE.UV((ix+1)/n,(iy+1)/m),new THREE.UV((ix+1)/n,iy/m)])}}THREE.Geometry.call(this);var c=this,t=a/2,y=b/2,s=e/2;h=h?-1:1;if(l!==undefined)if(l instanceof Array)this.materials=l;else{this.materials=
|
||||
[];for(var r=0;r<6;r++)this.materials.push([l])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(f!=undefined)for(var w in f)if(this.sides[w]!=undefined)this.sides[w]=f[w];this.sides.px&&j("z","y",1*h,-1,e,b,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,e,b,t,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,e,y,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,e,-y,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,a,b,s,this.materials[4]);this.sides.nz&&
|
||||
j("x","y",-1*h,-1,a,b,-s,this.materials[5]);(function(){for(var B=[],N=[],F=0,A=c.vertices.length;F<A;F++){for(var p=c.vertices[F],i=false,o=0,k=B.length;o<k;o++){var v=B[o];if(p.position.x==v.position.x&&p.position.y==v.position.y&&p.position.z==v.position.z){N[F]=o;i=true;break}}if(!i){N[F]=B.length;B.push(new THREE.Vertex(p.position.clone()))}}F=0;for(A=c.faces.length;F<A;F++){p=c.faces[F];p.a=N[p.a];p.b=N[p.b];p.c=N[p.c];p.d=N[p.d]}c.vertices=B})();this.computeCentroids();this.computeFaceNormals();
|
||||
basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"}}},Cube=function(a,b,e,d,g,l,h,f){function j(B,J,H,D,n,i,p,k){var w,o=d||1,m=g||1,v=o+1,L=m+1,C=n/2,A=i/2;n=n/o;i=i/m;var P=c.vertices.length;if(B=="x"&&J=="y"||B=="y"&&J=="x")w="z";else if(B=="x"&&J=="z"||B=="z"&&J=="x")w="y";else if(B=="z"&&J=="y"||B=="y"&&J=="z")w="x";for(iy=0;iy<L;iy++)for(ix=
|
||||
0;ix<v;ix++){var I=new THREE.Vector3;I[B]=(ix*n-C)*H;I[J]=(iy*i-A)*D;I[w]=p;c.vertices.push(new THREE.Vertex(I))}for(iy=0;iy<m;iy++)for(ix=0;ix<o;ix++){c.faces.push(new THREE.Face4(ix+v*iy+P,ix+v*(iy+1)+P,ix+1+v*(iy+1)+P,ix+1+v*iy+P,null,k));c.uvs.push([new THREE.UV(ix/o,iy/m),new THREE.UV(ix/o,(iy+1)/m),new THREE.UV((ix+1)/o,(iy+1)/m),new THREE.UV((ix+1)/o,iy/m)])}}THREE.Geometry.call(this);var c=this,t=a/2,y=b/2,s=e/2;h=h?-1:1;if(l!==undefined)if(l instanceof Array)this.materials=l;else{this.materials=
|
||||
[];for(var q=0;q<6;q++)this.materials.push([l])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(f!=undefined)for(var x in f)if(this.sides[x]!=undefined)this.sides[x]=f[x];this.sides.px&&j("z","y",1*h,-1,e,b,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,e,b,t,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,e,y,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,e,-y,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,a,b,s,this.materials[4]);this.sides.nz&&
|
||||
j("x","y",-1*h,-1,a,b,-s,this.materials[5]);(function(){for(var B=[],J=[],H=0,D=c.vertices.length;H<D;H++){for(var n=c.vertices[H],i=false,p=0,k=B.length;p<k;p++){var w=B[p];if(n.position.x==w.position.x&&n.position.y==w.position.y&&n.position.z==w.position.z){J[H]=p;i=true;break}}if(!i){J[H]=B.length;B.push(new THREE.Vertex(n.position.clone()))}}H=0;for(D=c.faces.length;H<D;H++){n=c.faces[H];n.a=J[n.a];n.b=J[n.b];n.c=J[n.c];n.d=J[n.d]}c.vertices=B})();this.computeCentroids();this.computeFaceNormals();
|
||||
this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
||||
var Cylinder=function(a,b,e,d,g){function l(c,t,y){h.vertices.push(new THREE.Vertex(new THREE.Vector3(c,t,y)))}THREE.Geometry.call(this);var h=this,f=Math.PI,j;for(j=0;j<a;j++)l(Math.sin(2*f*j/a)*b,Math.cos(2*f*j/a)*b,0);for(j=0;j<a;j++)l(Math.sin(2*f*j/a)*e,Math.cos(2*f*j/a)*e,d);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(e!=0){l(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){l(0,0,d+g);for(j=a+a/2;j<
|
||||
2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
||||
var Plane=function(a,b,e,d){THREE.Geometry.call(this);var g,l=a/2,h=b/2;e=e||1;d=d||1;var f=e+1,j=d+1;a=a/e;var c=b/d;for(g=0;g<j;g++)for(b=0;b<f;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-l,-(g*c-h),0)));for(g=0;g<d;g++)for(b=0;b<e;b++){this.faces.push(new THREE.Face4(b+f*g,b+f*(g+1),b+1+f*(g+1),b+1+f*g));this.uvs.push([new THREE.UV(b/e,g/d),new THREE.UV(b/e,(g+1)/d),new THREE.UV((b+1)/e,(g+1)/d),new THREE.UV((b+1)/e,g/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
||||
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
||||
var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,l=Math.max(3,b||8),h=Math.max(2,e||6);b=[];for(e=0;e<h+1;e++){d=e/h;var f=a*Math.cos(d*g),j=a*Math.sin(d*g),c=[],t=0;for(d=0;d<l;d++){var y=2*d/l,s=j*Math.sin(y*g);y=j*Math.cos(y*g);(e==0||e==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,f,s)))-1);c.push(t)}b.push(c)}var r,w;a=b.length;for(e=0;e<a;e++){g=b[e].length;if(e>0)for(d=0;d<g;d++){j=d==g-1;l=b[e][j?0:d+1];h=b[e][j?g-1:d];f=b[e-1][j?g-1:d];j=b[e-1][j?
|
||||
0:d+1];t=e/(a-1);y=(e-1)/(a-1);r=(d+1)/g;s=d/g;c=new THREE.UV(1-r,t);t=new THREE.UV(1-s,t);s=new THREE.UV(1-s,y);var B=new THREE.UV(1-r,y);if(e<b.length-1){y=this.vertices[l].position.clone();r=this.vertices[h].position.clone();w=this.vertices[f].position.clone();y.normalize();r.normalize();w.normalize();this.faces.push(new THREE.Face3(l,h,f,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([c,t,s])}if(e>1){y=this.vertices[l].position.clone();
|
||||
r=this.vertices[f].position.clone();w=this.vertices[j].position.clone();y.normalize();r.normalize();w.normalize();this.faces.push(new THREE.Face3(l,f,j,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([c,s,B])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,l=Math.max(3,b||8),h=Math.max(2,e||6);b=[];for(e=0;e<h+1;e++){d=e/h;var f=a*Math.cos(d*g),j=a*Math.sin(d*g),c=[],t=0;for(d=0;d<l;d++){var y=2*d/l,s=j*Math.sin(y*g);y=j*Math.cos(y*g);(e==0||e==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,f,s)))-1);c.push(t)}b.push(c)}var q,x;a=b.length;for(e=0;e<a;e++){g=b[e].length;if(e>0)for(d=0;d<g;d++){j=d==g-1;l=b[e][j?0:d+1];h=b[e][j?g-1:d];f=b[e-1][j?g-1:d];j=b[e-1][j?
|
||||
0:d+1];t=e/(a-1);y=(e-1)/(a-1);q=(d+1)/g;s=d/g;c=new THREE.UV(1-q,t);t=new THREE.UV(1-s,t);s=new THREE.UV(1-s,y);var B=new THREE.UV(1-q,y);if(e<b.length-1){y=this.vertices[l].position.clone();q=this.vertices[h].position.clone();x=this.vertices[f].position.clone();y.normalize();q.normalize();x.normalize();this.faces.push(new THREE.Face3(l,h,f,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,t,s])}if(e>1){y=this.vertices[l].position.clone();
|
||||
q=this.vertices[f].position.clone();x=this.vertices[j].position.clone();y.normalize();q.normalize();x.normalize();this.faces.push(new THREE.Face3(l,f,j,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,s,B])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
||||
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
||||
b},loadAsciiOld:function(a,b){var e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(l){THREE.Loader.prototype.loadAjaxBuffers(l.data.buffers,
|
||||
l.data.materials,b,e,g)};a.onerror=function(l){alert("worker.onerror: "+l.message+"\n"+l.data);l.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,g){var l=new XMLHttpRequest,h=d+"/"+a,f=0;l.onreadystatechange=function(){if(l.readyState==4)l.status==200||l.status==0?THREE.Loader.prototype.createBinModel(l.responseText,e,d,b):alert("Couldn't load ["+h+"] ["+l.status+"]");else if(l.readyState==3){if(g){if(f==0)f=l.getResponseHeader("Content-Length");g({total:f,loaded:l.responseText.length})}}else if(l.readyState==
|
||||
2)f=l.getResponseHeader("Content-Length")};l.open("GET",h,true);l.overrideMimeType("text/plain; charset=x-user-defined");l.setRequestHeader("Content-Type","text/plain");l.send(null)},createBinModel:function(a,b,e,d){var g=function(l){function h(q,u){var E=t(q,u),M=t(q,u+1),X=t(q,u+2),Y=t(q,u+3),ea=(Y<<1&255|X>>7)-127;E=(X&127)<<16|M<<8|E;if(E==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ea)}function f(q,u){var E=t(q,u),M=t(q,u+1),X=t(q,u+2);return(t(q,u+3)<<24)+(X<<16)+
|
||||
(M<<8)+E}function j(q,u){var E=t(q,u);return(t(q,u+1)<<8)+E}function c(q,u){var E=t(q,u);return E>127?E-256:E}function t(q,u){return q.charCodeAt(u)&255}function y(q){var u,E,M;u=f(a,q);E=f(a,q+k);M=f(a,q+v);q=j(a,q+n);THREE.Loader.prototype.f3(F,u,E,M,q)}function s(q){var u,E,M,X,Y,ea;u=f(a,q);E=f(a,q+k);M=f(a,q+v);X=j(a,q+n);Y=f(a,q+m);ea=f(a,q+z);q=f(a,q+G);THREE.Loader.prototype.f3n(F,i,u,E,M,X,Y,ea,q)}function r(q){var u,E,M,X;u=f(a,q);E=f(a,q+L);M=f(a,q+x);X=f(a,q+J);q=j(a,q+R);THREE.Loader.prototype.f4(F,
|
||||
u,E,M,X,q)}function w(q){var u,E,M,X,Y,ea,ma,oa;u=f(a,q);E=f(a,q+L);M=f(a,q+x);X=f(a,q+J);Y=j(a,q+R);ea=f(a,q+D);ma=f(a,q+V);oa=f(a,q+T);q=f(a,q+$);THREE.Loader.prototype.f4n(F,i,u,E,M,X,Y,ea,ma,oa,q)}function B(q){var u,E;u=f(a,q);E=f(a,q+W);q=f(a,q+O);THREE.Loader.prototype.uv3(F,o[u*2],o[u*2+1],o[E*2],o[E*2+1],o[q*2],o[q*2+1])}function N(q){var u,E,M;u=f(a,q);E=f(a,q+H);M=f(a,q+C);q=f(a,q+S);THREE.Loader.prototype.uv4(F,o[u*2],o[u*2+1],o[E*2],o[E*2+1],o[M*2],o[M*2+1],o[q*2],o[q*2+1])}var F=this,
|
||||
A=0,p,i=[],o=[],k,v,n,m,z,G,L,x,J,R,D,V,T,$,W,O,H,C,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,d,l);p={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:f(a,A+16),nnormals:f(a,A+16+4),nuvs:f(a,A+16+8),ntri_flat:f(a,A+16+12),ntri_smooth:f(a,A+16+16),ntri_flat_uv:f(a,
|
||||
A+16+20),ntri_smooth_uv:f(a,A+16+24),nquad_flat:f(a,A+16+28),nquad_smooth:f(a,A+16+32),nquad_flat_uv:f(a,A+16+36),nquad_smooth_uv:f(a,A+16+40)};A+=p.header_bytes;k=p.vertex_index_bytes;v=p.vertex_index_bytes*2;n=p.vertex_index_bytes*3;m=p.vertex_index_bytes*3+p.material_index_bytes;z=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;G=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;L=p.vertex_index_bytes;x=p.vertex_index_bytes*2;J=p.vertex_index_bytes*3;R=p.vertex_index_bytes*
|
||||
4;D=p.vertex_index_bytes*4+p.material_index_bytes;V=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;T=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*2;$=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;W=p.uv_index_bytes;O=p.uv_index_bytes*2;H=p.uv_index_bytes;C=p.uv_index_bytes*2;S=p.uv_index_bytes*3;A+=function(q){var u,E,M,X=p.vertex_coordinate_bytes*3,Y=q+p.nvertices*X;for(q=q;q<Y;q+=X){u=h(a,q);E=h(a,q+p.vertex_coordinate_bytes);M=h(a,
|
||||
q+p.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(F,u,E,M)}return p.nvertices*X}(A);A+=function(q){var u,E,M,X=p.normal_coordinate_bytes*3,Y=q+p.nnormals*X;for(q=q;q<Y;q+=X){u=c(a,q);E=c(a,q+p.normal_coordinate_bytes);M=c(a,q+p.normal_coordinate_bytes*2);i.push(u/127,E/127,M/127)}return p.nnormals*X}(A);A+=function(q){var u,E,M=p.uv_coordinate_bytes*2,X=q+p.nuvs*M;for(q=q;q<X;q+=M){u=h(a,q);E=h(a,q+p.uv_coordinate_bytes);o.push(u,E)}return p.nuvs*M}(A);A+=function(q){var u,E=p.vertex_index_bytes*
|
||||
3+p.material_index_bytes,M=q+p.ntri_flat*E;for(u=q;u<M;u+=E)y(u);return M-q}(A);A+=function(q){var u,E=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,M=q+p.ntri_smooth*E;for(u=q;u<M;u+=E)s(u);return M-q}(A);A+=function(q){var u,E=p.vertex_index_bytes*3+p.material_index_bytes,M=E+p.uv_index_bytes*3,X=q+p.ntri_flat_uv*M;for(u=q;u<X;u+=M){y(u);B(u+E)}return X-q}(A);A+=function(q){var u,E=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,M=E+p.uv_index_bytes*3,
|
||||
X=q+p.ntri_smooth_uv*M;for(u=q;u<X;u+=M){s(u);B(u+E)}return X-q}(A);A+=function(q){var u,E=p.vertex_index_bytes*4+p.material_index_bytes,M=q+p.nquad_flat*E;for(u=q;u<M;u+=E)r(u);return M-q}(A);A+=function(q){var u,E=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,M=q+p.nquad_smooth*E;for(u=q;u<M;u+=E)w(u);return M-q}(A);A+=function(q){var u,E=p.vertex_index_bytes*4+p.material_index_bytes,M=E+p.uv_index_bytes*4,X=q+p.nquad_flat_uv*M;for(u=q;u<X;u+=M){r(u);N(u+E)}return X-q}(A);
|
||||
A+=function(q){var u,E=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,M=E+p.uv_index_bytes*4,X=q+p.nquad_smooth_uv*M;for(u=q;u<X;u+=M){w(u);N(u+E)}return X-q}(A);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(e))},createModel:function(a,b,e){var d=function(g){var l=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(l,a.materials,g);(function(){var h,f,j,c,t;h=0;for(f=
|
||||
a.vertices.length;h<f;h+=3){j=a.vertices[h];c=a.vertices[h+1];t=a.vertices[h+2];THREE.Loader.prototype.v(l,j,c,t)}})();(function(){function h(w,B){THREE.Loader.prototype.f3(l,w[B],w[B+1],w[B+2],w[B+3])}function f(w,B){THREE.Loader.prototype.f3n(l,a.normals,w[B],w[B+1],w[B+2],w[B+3],w[B+4],w[B+5],w[B+6])}function j(w,B){THREE.Loader.prototype.f4(l,w[B],w[B+1],w[B+2],w[B+3],w[B+4])}function c(w,B){THREE.Loader.prototype.f4n(l,a.normals,w[B],w[B+1],w[B+2],w[B+3],w[B+4],w[B+5],w[B+6],w[B+7],w[B+8])}function t(w,
|
||||
B){var N,F,A;N=w[B];F=w[B+1];A=w[B+2];THREE.Loader.prototype.uv3(l,a.uvs[N*2],a.uvs[N*2+1],a.uvs[F*2],a.uvs[F*2+1],a.uvs[A*2],a.uvs[A*2+1])}function y(w,B){var N,F,A,p;N=w[B];F=w[B+1];A=w[B+2];p=w[B+3];THREE.Loader.prototype.uv4(l,a.uvs[N*2],a.uvs[N*2+1],a.uvs[F*2],a.uvs[F*2+1],a.uvs[A*2],a.uvs[A*2+1],a.uvs[p*2],a.uvs[p*2+1])}var s,r;s=0;for(r=a.triangles.length;s<r;s+=4)h(a.triangles,s);s=0;for(r=a.triangles_uv.length;s<r;s+=7){h(a.triangles_uv,s);t(a.triangles_uv,s+4)}s=0;for(r=a.triangles_n.length;s<
|
||||
r;s+=7)f(a.triangles_n,s);s=0;for(r=a.triangles_n_uv.length;s<r;s+=10){f(a.triangles_n_uv,s);t(a.triangles_n_uv,s+7)}s=0;for(r=a.quads.length;s<r;s+=5)j(a.quads,s);s=0;for(r=a.quads_uv.length;s<r;s+=9){j(a.quads_uv,s);y(a.quads_uv,s+5)}s=0;for(r=a.quads_n.length;s<r;s+=9)c(a.quads_n,s);s=0;for(r=a.quads_n_uv.length;s<r;s+=13){c(a.quads_n_uv,s);y(a.quads_n_uv,s+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
|
||||
2)f=l.getResponseHeader("Content-Length")};l.open("GET",h,true);l.overrideMimeType("text/plain; charset=x-user-defined");l.setRequestHeader("Content-Type","text/plain");l.send(null)},createBinModel:function(a,b,e,d){var g=function(l){function h(r,u){var E=t(r,u),O=t(r,u+1),X=t(r,u+2),Y=t(r,u+3),ea=(Y<<1&255|X>>7)-127;E=(X&127)<<16|O<<8|E;if(E==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ea)}function f(r,u){var E=t(r,u),O=t(r,u+1),X=t(r,u+2);return(t(r,u+3)<<24)+(X<<16)+
|
||||
(O<<8)+E}function j(r,u){var E=t(r,u);return(t(r,u+1)<<8)+E}function c(r,u){var E=t(r,u);return E>127?E-256:E}function t(r,u){return r.charCodeAt(u)&255}function y(r){var u,E,O;u=f(a,r);E=f(a,r+k);O=f(a,r+w);r=j(a,r+o);THREE.Loader.prototype.f3(H,u,E,O,r)}function s(r){var u,E,O,X,Y,ea;u=f(a,r);E=f(a,r+k);O=f(a,r+w);X=j(a,r+o);Y=f(a,r+m);ea=f(a,r+v);r=f(a,r+L);THREE.Loader.prototype.f3n(H,i,u,E,O,X,Y,ea,r)}function q(r){var u,E,O,X;u=f(a,r);E=f(a,r+C);O=f(a,r+A);X=f(a,r+P);r=j(a,r+I);THREE.Loader.prototype.f4(H,
|
||||
u,E,O,X,r)}function x(r){var u,E,O,X,Y,ea,ma,oa;u=f(a,r);E=f(a,r+C);O=f(a,r+A);X=f(a,r+P);Y=j(a,r+I);ea=f(a,r+M);ma=f(a,r+W);oa=f(a,r+S);r=f(a,r+$);THREE.Loader.prototype.f4n(H,i,u,E,O,X,Y,ea,ma,oa,r)}function B(r){var u,E;u=f(a,r);E=f(a,r+V);r=f(a,r+N);THREE.Loader.prototype.uv3(H,p[u*2],p[u*2+1],p[E*2],p[E*2+1],p[r*2],p[r*2+1])}function J(r){var u,E,O;u=f(a,r);E=f(a,r+z);O=f(a,r+F);r=f(a,r+T);THREE.Loader.prototype.uv4(H,p[u*2],p[u*2+1],p[E*2],p[E*2+1],p[O*2],p[O*2+1],p[r*2],p[r*2+1])}var H=this,
|
||||
D=0,n,i=[],p=[],k,w,o,m,v,L,C,A,P,I,M,W,S,$,V,N,z,F,T;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,d,l);n={signature:a.substr(D,8),header_bytes:t(a,D+8),vertex_coordinate_bytes:t(a,D+9),normal_coordinate_bytes:t(a,D+10),uv_coordinate_bytes:t(a,D+11),vertex_index_bytes:t(a,D+12),normal_index_bytes:t(a,D+13),uv_index_bytes:t(a,D+14),material_index_bytes:t(a,D+15),nvertices:f(a,D+16),nnormals:f(a,D+16+4),nuvs:f(a,D+16+8),ntri_flat:f(a,D+16+12),ntri_smooth:f(a,D+16+16),ntri_flat_uv:f(a,
|
||||
D+16+20),ntri_smooth_uv:f(a,D+16+24),nquad_flat:f(a,D+16+28),nquad_smooth:f(a,D+16+32),nquad_flat_uv:f(a,D+16+36),nquad_smooth_uv:f(a,D+16+40)};D+=n.header_bytes;k=n.vertex_index_bytes;w=n.vertex_index_bytes*2;o=n.vertex_index_bytes*3;m=n.vertex_index_bytes*3+n.material_index_bytes;v=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;C=n.vertex_index_bytes;A=n.vertex_index_bytes*2;P=n.vertex_index_bytes*3;I=n.vertex_index_bytes*
|
||||
4;M=n.vertex_index_bytes*4+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;V=n.uv_index_bytes;N=n.uv_index_bytes*2;z=n.uv_index_bytes;F=n.uv_index_bytes*2;T=n.uv_index_bytes*3;D+=function(r){var u,E,O,X=n.vertex_coordinate_bytes*3,Y=r+n.nvertices*X;for(r=r;r<Y;r+=X){u=h(a,r);E=h(a,r+n.vertex_coordinate_bytes);O=h(a,
|
||||
r+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(H,u,E,O)}return n.nvertices*X}(D);D+=function(r){var u,E,O,X=n.normal_coordinate_bytes*3,Y=r+n.nnormals*X;for(r=r;r<Y;r+=X){u=c(a,r);E=c(a,r+n.normal_coordinate_bytes);O=c(a,r+n.normal_coordinate_bytes*2);i.push(u/127,E/127,O/127)}return n.nnormals*X}(D);D+=function(r){var u,E,O=n.uv_coordinate_bytes*2,X=r+n.nuvs*O;for(r=r;r<X;r+=O){u=h(a,r);E=h(a,r+n.uv_coordinate_bytes);p.push(u,E)}return n.nuvs*O}(D);D+=function(r){var u,E=n.vertex_index_bytes*
|
||||
3+n.material_index_bytes,O=r+n.ntri_flat*E;for(u=r;u<O;u+=E)y(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,O=r+n.ntri_smooth*E;for(u=r;u<O;u+=E)s(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*3+n.material_index_bytes,O=E+n.uv_index_bytes*3,X=r+n.ntri_flat_uv*O;for(u=r;u<X;u+=O){y(u);B(u+E)}return X-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,O=E+n.uv_index_bytes*3,
|
||||
X=r+n.ntri_smooth_uv*O;for(u=r;u<X;u+=O){s(u);B(u+E)}return X-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes,O=r+n.nquad_flat*E;for(u=r;u<O;u+=E)q(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,O=r+n.nquad_smooth*E;for(u=r;u<O;u+=E)x(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes,O=E+n.uv_index_bytes*4,X=r+n.nquad_flat_uv*O;for(u=r;u<X;u+=O){q(u);J(u+E)}return X-r}(D);
|
||||
D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,O=E+n.uv_index_bytes*4,X=r+n.nquad_smooth_uv*O;for(u=r;u<X;u+=O){x(u);J(u+E)}return X-r}(D);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(e))},createModel:function(a,b,e){var d=function(g){var l=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(l,a.materials,g);(function(){var h,f,j,c,t;h=0;for(f=
|
||||
a.vertices.length;h<f;h+=3){j=a.vertices[h];c=a.vertices[h+1];t=a.vertices[h+2];THREE.Loader.prototype.v(l,j,c,t)}})();(function(){function h(x,B){THREE.Loader.prototype.f3(l,x[B],x[B+1],x[B+2],x[B+3])}function f(x,B){THREE.Loader.prototype.f3n(l,a.normals,x[B],x[B+1],x[B+2],x[B+3],x[B+4],x[B+5],x[B+6])}function j(x,B){THREE.Loader.prototype.f4(l,x[B],x[B+1],x[B+2],x[B+3],x[B+4])}function c(x,B){THREE.Loader.prototype.f4n(l,a.normals,x[B],x[B+1],x[B+2],x[B+3],x[B+4],x[B+5],x[B+6],x[B+7],x[B+8])}function t(x,
|
||||
B){var J,H,D;J=x[B];H=x[B+1];D=x[B+2];THREE.Loader.prototype.uv3(l,a.uvs[J*2],a.uvs[J*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[D*2],a.uvs[D*2+1])}function y(x,B){var J,H,D,n;J=x[B];H=x[B+1];D=x[B+2];n=x[B+3];THREE.Loader.prototype.uv4(l,a.uvs[J*2],a.uvs[J*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[D*2],a.uvs[D*2+1],a.uvs[n*2],a.uvs[n*2+1])}var s,q;s=0;for(q=a.triangles.length;s<q;s+=4)h(a.triangles,s);s=0;for(q=a.triangles_uv.length;s<q;s+=7){h(a.triangles_uv,s);t(a.triangles_uv,s+4)}s=0;for(q=a.triangles_n.length;s<
|
||||
q;s+=7)f(a.triangles_n,s);s=0;for(q=a.triangles_n_uv.length;s<q;s+=10){f(a.triangles_n_uv,s);t(a.triangles_n_uv,s+7)}s=0;for(q=a.quads.length;s<q;s+=5)j(a.quads,s);s=0;for(q=a.quads_uv.length;s<q;s+=9){j(a.quads_uv,s);y(a.quads_uv,s+5)}s=0;for(q=a.quads_n.length;s<q;s+=9)c(a.quads_n,s);s=0;for(q=a.quads_n_uv.length;s<q;s+=13){c(a.quads_n_uv,s);y(a.quads_n_uv,s+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
|
||||
d;b(new d(e))},v:function(a,b,e,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,d)))},f3:function(a,b,e,d,g){a.faces.push(new THREE.Face3(b,e,d,null,a.materials[g]))},f4:function(a,b,e,d,g,l){a.faces.push(new THREE.Face4(b,e,d,g,null,a.materials[l]))},f3n:function(a,b,e,d,g,l,h,f,j){l=a.materials[l];var c=b[f*3],t=b[f*3+1];f=b[f*3+2];var y=b[j*3],s=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(e,d,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(c,t,f),new THREE.Vector3(y,
|
||||
s,j)],l))},f4n:function(a,b,e,d,g,l,h,f,j,c,t){h=a.materials[h];var y=b[j*3],s=b[j*3+1];j=b[j*3+2];var r=b[c*3],w=b[c*3+1];c=b[c*3+2];var B=b[t*3],N=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(e,d,g,l,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(y,s,j),new THREE.Vector3(r,w,c),new THREE.Vector3(B,N,t)],h))},uv3:function(a,b,e,d,g,l,h){var f=[];f.push(new THREE.UV(b,e));f.push(new THREE.UV(d,g));f.push(new THREE.UV(l,h));a.uvs.push(f)},uv4:function(a,b,e,d,g,l,h,f,j){var c=[];
|
||||
s,j)],l))},f4n:function(a,b,e,d,g,l,h,f,j,c,t){h=a.materials[h];var y=b[j*3],s=b[j*3+1];j=b[j*3+2];var q=b[c*3],x=b[c*3+1];c=b[c*3+2];var B=b[t*3],J=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(e,d,g,l,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(y,s,j),new THREE.Vector3(q,x,c),new THREE.Vector3(B,J,t)],h))},uv3:function(a,b,e,d,g,l,h){var f=[];f.push(new THREE.UV(b,e));f.push(new THREE.UV(d,g));f.push(new THREE.UV(l,h));a.uvs.push(f)},uv4:function(a,b,e,d,g,l,h,f,j){var c=[];
|
||||
c.push(new THREE.UV(b,e));c.push(new THREE.UV(d,g));c.push(new THREE.UV(l,h));c.push(new THREE.UV(f,j));a.uvs.push(c)},init_materials:function(a,b,e){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],e)]},createMaterial:function(a,b){function e(l){l=Math.log(l)/Math.LN2;return Math.floor(l)==l}var d,g;if(a.map_diffuse&&b){g=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!e(this.width)||
|
||||
!e(this.height)){var l=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),h=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));d.map.image.width=l;d.map.image.height=h;d.map.image.getContext("2d").drawImage(this,0,0,l,h)}else d.map.image=this;d.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else d=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
|
||||
new THREE.MeshLambertMaterial({color:15658734});return d}};
|
||||
|
||||
@@ -12,7 +12,6 @@ THREE.Projector = function() {
|
||||
_line, _lineCount, _linePool = [],
|
||||
_particle, _particleCount, _particlePool = [],
|
||||
|
||||
_vector3 = new THREE.Vector3(),
|
||||
_vector4 = new THREE.Vector4(),
|
||||
_projScreenMatrix = new THREE.Matrix4(),
|
||||
_projScreenObjectMatrix = new THREE.Matrix4(),
|
||||
@@ -24,11 +23,13 @@ THREE.Projector = function() {
|
||||
|
||||
this.projectObjects = function ( scene, camera ) {
|
||||
|
||||
var o, ol, v, vl, f, fl, n, nl, objects, object;
|
||||
var o, ol, objects, object;
|
||||
|
||||
_renderList = [];
|
||||
_objectCount = 0;
|
||||
|
||||
_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix );
|
||||
|
||||
objects = scene.objects;
|
||||
|
||||
for ( o = 0, ol = objects.length; o < ol; o++ ) {
|
||||
@@ -41,10 +42,10 @@ THREE.Projector = function() {
|
||||
|
||||
_vector4.copy( object.position );
|
||||
_projScreenMatrix.multiplyVector4( _vector4 );
|
||||
_vector4.multiplyScalar( 1 / _vector4.w );
|
||||
// _vector4.multiplyScalar( 1 / _vector4.w );
|
||||
|
||||
_object.object = object;
|
||||
_object.z = _vector3.z;
|
||||
_object.z = _vector4.z;
|
||||
|
||||
_renderList.push( _object );
|
||||
|
||||
|
||||
@@ -73,6 +73,16 @@ THREE.WebGLRenderer2 = function () {
|
||||
_viewMatrixArray.set( camera.matrix.flatten() );
|
||||
_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
|
||||
|
||||
/*
|
||||
for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
|
||||
|
||||
object = scene.objects[ o ];
|
||||
|
||||
renderObject( object );
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
_renderList = _projector.projectObjects( scene, camera );
|
||||
|
||||
for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
|
||||
@@ -83,6 +93,7 @@ THREE.WebGLRenderer2 = function () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function renderObject( object ) {
|
||||
|
||||
var geometry, material, m, nl,
|
||||
|
||||
Reference in New Issue
Block a user