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