diff --git a/README.md b/README.md index 1a4692c4..2bb8d158 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=thre ### Featured projects ### +Lights Infinite beanstalk Mission Control ROME @@ -81,57 +82,60 @@ More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=thre Download the [minified library](http://mrdoob.github.com/three.js/build/Three.js) and include it in your html. - +```html + +``` This code creates a camera, then creates a scene, adds a cube on it, creates a <canvas> renderer and adds its viewport in the document.body element. - + } + +``` ### Change Log ### @@ -143,7 +147,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a & * Added `.depthWrite` and `.fog` to `Material`. ([alteredq](http://github.com/alteredq)) * Added `.applyMatrix` to `Geometry`. ([mrdoob](http://github.com/mrdoob)) * Improved postprocessing stack in `/examples/js/postprocessing`. ([alteredq](http://github.com/alteredq)) -* Added a realistic sking shading example. ([alteredq](http://github.com/alteredq)) +* Added a realistic skin shading example. ([alteredq](http://github.com/alteredq)) * Started of a GUI for composing scenes and autogenerate code. ([mrdoob](http://github.com/mrdoob)) * Added `.center()` to `GeometryUtils`. ([alteredq](http://github.com/alteredq)) * Fixed buggy scenegraph manipulation (adding/removing objects). ([jsermeno](http://github.com/jsermeno), [alteredq](http://github.com/alteredq) and [skython](http://github.com/skython)) diff --git a/build/Three.js b/build/Three.js index 475c9432..3afb377a 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,103 +1,102 @@ // Three.js r46dev - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Color=function(b){b!==void 0&&this.setHex(b);return this}; -THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;return this},setHSV:function(b,c,e){var f,h,k;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),h=b*6-f,b=e*(1-c),k=e*(1-c*h),c=e*(1-c*(1-h)),f){case 1:this.r=k;this.g=e;this.b=b;break;case 2:this.r=b;this.g=e;this.b=c;break;case 3:this.r=b;this.g=k;this.b=e;break;case 4:this.r=c;this.g=b;this.b=e;break;case 5:this.r= -e;this.g=b;this.b=k;break;case 6:case 0:this.r=e,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; -THREE.Vector2=function(b,c){this.x=b||0;this.y=c||0}; -THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this}, -divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, -equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.x=b||0;this.y=c||0;this.z=e||0}; -THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,c,e){this.x=b;this.y=c;this.z=e;return this},setX:function(b){this.x=b;return this},setY:function(b){this.y=b;return this},setZ:function(b){this.z=b;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this}, -addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){this.x/=b.x;this.y/=b.y;this.z/=b.z;return this}, +THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,e,c){this.r=b;this.g=e;this.b=c;return this},setHSV:function(b,e,c){var f,m,h;if(c==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),m=b*6-f,b=c*(1-e),h=c*(1-e*m),e=c*(1-e*(1-m)),f){case 1:this.r=h;this.g=c;this.b=b;break;case 2:this.r=b;this.g=c;this.b=e;break;case 3:this.r=b;this.g=h;this.b=c;break;case 4:this.r=e;this.g=b;this.b=c;break;case 5:this.r= +c;this.g=b;this.b=h;break;case 6:case 0:this.r=c,this.g=e,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; +THREE.Vector2=function(b,e){this.x=b||0;this.y=e||0}; +THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,e){this.x=b;this.y=e;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,e){this.x=b.x+e.x;this.y=b.y+e.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,e){this.x=b.x-e.x;this.y=b.y-e.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this}, +divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var e=this.x-b.x,b=this.y-b.y;return e*e+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, +equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,e,c){this.x=b||0;this.y=e||0;this.z=c||0}; +THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,e,c){this.x=b;this.y=e;this.z=c;return this},setX:function(b){this.x=b;return this},setY:function(b){this.y=b;return this},setZ:function(b){this.z=b;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,e){this.x=b.x+e.x;this.y=b.y+e.y;this.z=b.z+e.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this}, +addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,e){this.x=b.x-e.x;this.y=b.y-e.y;this.z=b.z-e.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,e){this.x=b.x*e.x;this.y=b.y*e.y;this.z=b.z*e.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){this.x/=b.x;this.y/=b.y;this.z/=b.z;return this}, divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)}, -cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13); -Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(b,c,e,f){this.x=b||0;this.y=c||0;this.z=e||0;this.w=f!==void 0?f:1}; -THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w!==void 0?b.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z- -c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&k+b<1}for(var f,h=[],k=0,m=b.children.length;kb.scale.x)return[];f={distance:k,point:b.position,face:null,object:b};h.push(f)}else if(b instanceof THREE.Mesh){k=c(this.origin, -this.direction,b.matrixWorld.getPosition());if(k==null||k>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return h;for(var n,t,u,w,o,x,v,z,y=b.geometry,A=y.vertices,k=0,m=y.faces.length;k0:x<0)))if(x=o.dot((new THREE.Vector3).sub(n,v))/x,v=v.addSelf(z.multiplyScalar(x)),f instanceof THREE.Face3)e(v,n,t,u)&&(f={distance:this.origin.distanceTo(v),point:v,face:f,object:b},h.push(f));else if(f instanceof THREE.Face4&&(e(v,n,t,w)||e(v,t,u,w)))f={distance:this.origin.distanceTo(v),point:v,face:f,object:b},h.push(f)}return h}}; -THREE.Rectangle=function(){function b(){k=f-c;m=h-e}var c,e,f,h,k,m,n=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return m};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(k,m,w,o){n=!1;c=k;e=m;f=w;h=o;b()};this.addPoint=function(k,m){n?(n=!1,c=k,e=m,f=k,h=m):(c=ck?f:k,h=h>m?h:m);b()};this.add3Points= -function(k,m,w,o,x,v){n?(n=!1,c=kw?k>x?k:x:w>x?w:x,h=m>o?m>v?m:v:o>v?o:v):(c=kw?k>x?k>f?k:f:x>f?x:f:w>x?w>f?w:f:x>f?x:f,h=m>o?m>v?m>h?m:h:v>h?v:h:o>v?o>h?o:h:v>h?v:h);b()};this.addRectangle=function(k){n?(n=!1,c=k.getLeft(),e=k.getTop(),f=k.getRight(),h=k.getBottom()):(c=ck.getRight()?f:k.getRight(),h=h> -k.getBottom()?h:k.getBottom());b()};this.inflate=function(k){c-=k;e-=k;f+=k;h+=k;b()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){n=!0;h=f=e=c=0;b()};this.isEmpty=function(){return n}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}}; -THREE.Matrix4=function(b,c,e,f,h,k,m,n,t,u,w,o,x,v,z,y){this.set(b!==void 0?b:1,c||0,e||0,f||0,h||0,k!==void 0?k:1,m||0,n||0,t||0,u||0,w!==void 0?w:1,o||0,x||0,v||0,z||0,y!==void 0?y:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,m,n,t,u,w,o,x,v,z,y){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=m;this.n24=n;this.n31=t;this.n32=u;this.n33=w;this.n34=o;this.n41=x;this.n42=v;this.n43=z;this.n44=y;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, -c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h; -b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+ -e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,t=b.n23,u=b.n24,w=b.n31,o=b.n32,x=b.n33,v=b.n34,z=b.n41,y=b.n42,A=b.n43,E=b.n44,F=c.n11,C=c.n12, -G=c.n13,J=c.n14,O=c.n21,K=c.n22,B=c.n23,N=c.n24,Y=c.n31,H=c.n32,T=c.n33,Q=c.n34,Z=c.n41,$=c.n42,S=c.n43,p=c.n44;this.n11=e*F+f*O+h*Y+k*Z;this.n12=e*C+f*K+h*H+k*$;this.n13=e*G+f*B+h*T+k*S;this.n14=e*J+f*N+h*Q+k*p;this.n21=m*F+n*O+t*Y+u*Z;this.n22=m*C+n*K+t*H+u*$;this.n23=m*G+n*B+t*T+u*S;this.n24=m*J+n*N+t*Q+u*p;this.n31=w*F+o*O+x*Y+v*Z;this.n32=w*C+o*K+x*H+v*$;this.n33=w*G+o*B+x*T+v*S;this.n34=w*J+o*N+x*Q+v*p;this.n41=z*F+y*O+A*Y+E*Z;this.n42=z*C+y*K+A*H+E*$;this.n43=z*G+y*B+A*T+E*S;this.n44=z*J+y* -N+A*Q+E*p;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*= -b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,h=this.n21,k=this.n22,m=this.n23,n=this.n24,t=this.n31,u=this.n32,w=this.n33,o=this.n34,x=this.n41,v=this.n42,z=this.n43,y=this.n44;return f*m*u*x-e*n*u*x-f*k*w*x+c*n*w*x+e*k*o*x-c*m*o*x-f*m*t*v+e*n*t*v+f*h*w*v-b*n*w*v-e*h*o*v+b*m*o*v+f*k*t*z-c*n*t*z-f*h*u*z+b*n*u*z+c*h*o*z-b*k*o*z-e*k*t*y+c*m*t*y+e*h*u*y-b*m*u*y-c*h*w*y+b*k*w*y}, -transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34; +cross:function(b,e){this.x=b.y*e.z-b.z*e.y;this.y=b.z*e.x-b.x*e.z;this.z=b.x*e.y-b.y*e.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var e=Math.cos(this.y);this.y=Math.asin(b.n13); +Math.abs(e)>1.0E-5?(this.x=Math.atan2(-b.n23/e,b.n33/e),this.z=Math.atan2(-b.n12/e,b.n11/e)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(b,e,c,f){this.x=b||0;this.y=e||0;this.z=c||0;this.w=f!==void 0?f:1}; +THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,e,c,f){this.x=b;this.y=e;this.z=c;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w!==void 0?b.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,e){this.x=b.x+e.x;this.y=b.y+e.y;this.z=b.z+e.z;this.w=b.w+e.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,e){this.x=b.x-e.x;this.y=b.y-e.y;this.z=b.z- +e.z;this.w=b.w-e.w;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, +normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,e){this.x+=(b.x-this.x)*e;this.y+=(b.y-this.y)*e;this.z+=(b.z-this.z)*e;this.w+=(b.w-this.w)*e;return this}};THREE.Ray=function(b,e){this.origin=b||new THREE.Vector3;this.direction=e||new THREE.Vector3}; +THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.children)},intersectObjects:function(b){var e,c,f=[];e=0;for(c=b.length;e0&&b>0&&h+b<1}for(var f,m=[],h=0,k=b.children.length;hb.scale.x)return[];f={distance:h,point:b.position,face:null,object:b};m.push(f)}else if(b instanceof THREE.Mesh){h=e(this.origin, +this.direction,b.matrixWorld.getPosition());if(h==null||h>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return m;var n,p,t,u,v,x,w,A,y=b.geometry,z=y.vertices;b.matrixRotationWorld.extractRotation(b.matrixWorld);h=0;for(k=y.faces.length;h0:x<0)))if(x=v.dot((new THREE.Vector3).sub(n,w))/x,w=w.addSelf(A.multiplyScalar(x)),f instanceof THREE.Face3)c(w,n,p,t)&&(f={distance:this.origin.distanceTo(w),point:w,face:f,object:b},m.push(f));else if(f instanceof THREE.Face4&&(c(w,n,p,u)||c(w,p,t,u)))f={distance:this.origin.distanceTo(w), +point:w,face:f,object:b},m.push(f)}return m}}; +THREE.Rectangle=function(){function b(){h=f-e;k=m-c}var e,c,f,m,h,k,n=!0;this.getX=function(){return e};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return e};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return m};this.set=function(h,k,u,v){n=!1;e=h;c=k;f=u;m=v;b()};this.addPoint=function(h,k){n?(n=!1,e=h,c=k,f=h,m=k):(e=eh?f:h,m=m>k?m:k);b()};this.add3Points= +function(h,k,u,v,x,w){n?(n=!1,e=hu?h>x?h:x:u>x?u:x,m=k>v?k>w?k:w:v>w?v:w):(e=hu?h>x?h>f?h:f:x>f?x:f:u>x?u>f?u:f:x>f?x:f,m=k>v?k>w?k>m?k:m:w>m?w:m:v>w?v>m?v:m:w>m?w:m);b()};this.addRectangle=function(h){n?(n=!1,e=h.getLeft(),c=h.getTop(),f=h.getRight(),m=h.getBottom()):(e=eh.getRight()?f:h.getRight(),m=m> +h.getBottom()?m:h.getBottom());b()};this.inflate=function(h){e-=h;c-=h;f+=h;m+=h;b()};this.minSelf=function(h){e=e>h.getLeft()?e:h.getLeft();c=c>h.getTop()?c:h.getTop();f=f=0&&Math.min(m,b.getBottom())-Math.max(c,b.getTop())>=0};this.empty=function(){n=!0;m=f=c=e=0;b()};this.isEmpty=function(){return n}};THREE.Matrix3=function(){this.m=[]}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,e=this.m;b=e[1];e[1]=e[3];e[3]=b;b=e[2];e[2]=e[6];e[6]=b;b=e[5];e[5]=e[7];e[7]=b;return this},transposeIntoArray:function(b){var e=this.m;b[0]=e[0];b[1]=e[3];b[2]=e[6];b[3]=e[1];b[4]=e[4];b[5]=e[7];b[6]=e[2];b[7]=e[5];b[8]=e[8];return this}}; +THREE.Matrix4=function(b,e,c,f,m,h,k,n,p,t,u,v,x,w,A,y){this.set(b!==void 0?b:1,e||0,c||0,f||0,m||0,h!==void 0?h:1,k||0,n||0,p||0,t||0,u!==void 0?u:1,v||0,x||0,w||0,A||0,y!==void 0?y:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,e,c,f,m,h,k,n,p,t,u,v,x,w,A,y){this.n11=b;this.n12=e;this.n13=c;this.n14=f;this.n21=m;this.n22=h;this.n23=k;this.n24=n;this.n31=p;this.n32=t;this.n33=u;this.n34=v;this.n41=x;this.n42=w;this.n43=A;this.n44=y;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, +e,c){var f=THREE.Matrix4.__v1,m=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,e).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(c,h).normalize());m.cross(h,f).normalize();this.n11=f.x;this.n12=m.x;this.n13=h.x;this.n21=f.y;this.n22=m.y;this.n23=h.y;this.n31=f.z;this.n32=m.z;this.n33=h.z;return this},multiply:function(b,e){var c=b.n11,f=b.n12,m=b.n13,h=b.n14,k=b.n21,n=b.n22,p=b.n23,t=b.n24,u=b.n31,v=b.n32,x=b.n33,w=b.n34,A=b.n41,y=b.n42,z=b.n43, +E=b.n44,C=e.n11,B=e.n12,G=e.n13,N=e.n14,I=e.n21,M=e.n22,Z=e.n23,J=e.n24,O=e.n31,L=e.n32,F=e.n33,aa=e.n34,Y=e.n41,Q=e.n42,P=e.n43,o=e.n44;this.n11=c*C+f*I+m*O+h*Y;this.n12=c*B+f*M+m*L+h*Q;this.n13=c*G+f*Z+m*F+h*P;this.n14=c*N+f*J+m*aa+h*o;this.n21=k*C+n*I+p*O+t*Y;this.n22=k*B+n*M+p*L+t*Q;this.n23=k*G+n*Z+p*F+t*P;this.n24=k*N+n*J+p*aa+t*o;this.n31=u*C+v*I+x*O+w*Y;this.n32=u*B+v*M+x*L+w*Q;this.n33=u*G+v*Z+x*F+w*P;this.n34=u*N+v*J+x*aa+w*o;this.n41=A*C+y*I+z*O+E*Y;this.n42=A*B+y*M+z*L+E*Q;this.n43=A* +G+y*Z+z*F+E*P;this.n44=A*N+y*J+z*aa+E*o;return this},multiplySelf:function(b){return this.multiply(this,b)},multiplyToArray:function(b,e,c){this.multiply(b,e);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b; +this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},multiplyVector3:function(b){var e=b.x,c=b.y,f=b.z,m=1/(this.n41*e+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*e+this.n12*c+this.n13*f+this.n14)*m;b.y=(this.n21*e+this.n22*c+this.n23*f+this.n24)*m;b.z=(this.n31*e+this.n32*c+this.n33*f+this.n34)*m;return b},multiplyVector4:function(b){var e=b.x,c=b.y,f=b.z,m=b.w;b.x=this.n11*e+this.n12*c+this.n13*f+this.n14*m;b.y=this.n21* +e+this.n22*c+this.n23*f+this.n24*m;b.z=this.n31*e+this.n32*c+this.n33*f+this.n34*m;b.w=this.n41*e+this.n42*c+this.n43*f+this.n44*m;return b},rotateAxis:function(b){var e=b.x,c=b.y,f=b.z;b.x=e*this.n11+c*this.n12+f*this.n13;b.y=e*this.n21+c*this.n22+f*this.n23;b.z=e*this.n31+c*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var e=new THREE.Vector4;e.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;e.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;e.z=this.n31*b.x+this.n32* +b.y+this.n33*b.z+this.n34*b.w;e.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return e},determinant:function(){var b=this.n11,e=this.n12,c=this.n13,f=this.n14,m=this.n21,h=this.n22,k=this.n23,n=this.n24,p=this.n31,t=this.n32,u=this.n33,v=this.n34,x=this.n41,w=this.n42,A=this.n43,y=this.n44;return f*k*t*x-c*n*t*x-f*h*u*x+e*n*u*x+c*h*v*x-e*k*v*x-f*k*p*w+c*n*p*w+f*m*u*w-b*n*u*w-c*m*v*w+b*k*v*w+f*h*p*A-e*n*p*A-f*m*t*A+b*n*t*A+e*m*v*A-b*h*v*A-c*h*p*y+e*k*p*y+c*m*t*y-b*k*t*y-e*m*u*y+b*h*u* +y},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34; b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11; -b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34; -b[c+15]=this.n44;return b},setTranslation:function(b,c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0, -0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),h=1-e,k=b.x,m=b.y,n=b.z,t=h*k,u=h*m;this.set(t*k+e,t*m-f*n,t*n+f*m,0,t*m+f*n,u*m+e,u*n-f*k,0,t*n-f*m,u*n+f*k,h*n*n+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var e=b.x,f=b.y,h=b.z,k=Math.cos(e),e=Math.sin(e),m=Math.cos(f),f=Math.sin(f),n=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var t= -m*n,u=m*h,w=f*n,o=f*h;this.n11=t+o*e;this.n12=w*e-u;this.n13=k*f;this.n21=k*h;this.n22=k*n;this.n23=-e;this.n31=u*e-w;this.n32=o+t*e;this.n33=k*m;break;case "ZXY":t=m*n;u=m*h;w=f*n;o=f*h;this.n11=t-o*e;this.n12=-k*h;this.n13=w+u*e;this.n21=u+w*e;this.n22=k*n;this.n23=o-t*e;this.n31=-k*f;this.n32=e;this.n33=k*m;break;case "ZYX":t=k*n;u=k*h;w=e*n;o=e*h;this.n11=m*n;this.n12=w*f-u;this.n13=t*f+o;this.n21=m*h;this.n22=o*f+t;this.n23=u*f-w;this.n31=-f;this.n32=e*m;this.n33=k*m;break;case "YZX":t=k*m;u= -k*f;w=e*m;o=e*f;this.n11=m*n;this.n12=o-t*h;this.n13=w*h+u;this.n21=h;this.n22=k*n;this.n23=-e*n;this.n31=-f*n;this.n32=u*h+w;this.n33=t-o*h;break;case "XZY":t=k*m;u=k*f;w=e*m;o=e*f;this.n11=m*n;this.n12=-h;this.n13=f*n;this.n21=t*h+o;this.n22=k*n;this.n23=u*h-w;this.n31=w*h-u;this.n32=e*n;this.n33=o*h+t;break;default:t=k*n,u=k*h,w=e*n,o=e*h,this.n11=m*n,this.n12=-m*h,this.n13=f,this.n21=u+w*f,this.n22=t-o*f,this.n23=-e*m,this.n31=o-t*f,this.n32=w+u*f,this.n33=k*m}return this},setRotationFromQuaternion:function(b){var c= -b.x,e=b.y,f=b.z,h=b.w,k=c+c,m=e+e,n=f+f,b=c*k,t=c*m;c*=n;var u=e*m;e*=n;f*=n;k*=h;m*=h;h*=n;this.n11=1-(u+f);this.n12=t-h;this.n13=c+m;this.n21=t+h;this.n22=1-(b+f);this.n23=e-k;this.n31=c-m;this.n32=e+k;this.n33=1-(b+u);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},compose:function(b,c,e){var f=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2; -f.identity();f.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(f,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);k.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length(); -e.y=h.length();e.z=k.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,h=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23= -b.n23*h;this.n33=b.n33*h}}; -THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,t=b.n23,u=b.n24,w=b.n31,o=b.n32,x=b.n33,v=b.n34,z=b.n41,y=b.n42,A=b.n43,E=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=t*v*y-u*x*y+u*o*A-n*v*A-t*o*E+n*x*E;c.n12=k*x*y-h*v*y-k*o*A+f*v*A+h*o*E-f*x*E;c.n13=h*u*y-k*t*y+k*n*A-f*u*A-h*n*E+f*t*E;c.n14=k*t*o-h*u*o-k*n*x+f*u*x+h*n*v-f*t*v;c.n21=u*x*z-t*v*z-u*w*A+m*v*A+t*w*E-m*x*E;c.n22=h*v*z-k*x*z+k*w*A-e*v*A-h*w*E+e*x*E;c.n23=k*t*z-h*u*z-k*m*A+e*u*A+h*m*E-e*t*E;c.n24= -h*u*w-k*t*w+k*m*x-e*u*x-h*m*v+e*t*v;c.n31=n*v*z-u*o*z+u*w*y-m*v*y-n*w*E+m*o*E;c.n32=k*o*z-f*v*z-k*w*y+e*v*y+f*w*E-e*o*E;c.n33=h*u*z-k*n*z+k*m*y-e*u*y-f*m*E+e*n*E;c.n34=k*n*w-f*u*w-k*m*o+e*u*o+f*m*v-e*n*v;c.n41=t*o*z-n*x*z-t*w*y+m*x*y+n*w*A-m*o*A;c.n42=f*x*z-h*o*z+h*w*y-e*x*y-f*w*A+e*o*A;c.n43=h*n*z-f*t*z-h*m*y+e*t*y+f*m*A-e*n*A;c.n44=f*t*w-h*n*w+h*m*o-e*t*o-f*m*x+e*n*x;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,m=-b.n33*b.n12+b.n32*b.n13,n=b.n33*b.n11-b.n31*b.n13,t=-b.n32*b.n11+b.n31*b.n12,u=b.n23*b.n12-b.n22*b.n13,w=-b.n23*b.n11+b.n21*b.n13,o=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*m+b.n31*u;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*m;e[4]=b*n;e[5]=b*t;e[6]=b*u;e[7]=b*w;e[8]=b*o;return c}; -THREE.Matrix4.makeFrustum=function(b,c,e,f,h,k){var m;m=new THREE.Matrix4;m.n11=2*h/(c-b);m.n12=0;m.n13=(c+b)/(c-b);m.n14=0;m.n21=0;m.n22=2*h/(f-e);m.n23=(f+e)/(f-e);m.n24=0;m.n31=0;m.n32=0;m.n33=-(k+h)/(k-h);m.n34=-2*k*h/(k-h);m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)}; -THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var m,n,t,u;m=new THREE.Matrix4;n=c-b;t=e-f;u=k-h;m.n11=2/n;m.n12=0;m.n13=0;m.n14=-((c+b)/n);m.n21=0;m.n22=2/t;m.n23=0;m.n24=-((e+f)/t);m.n31=0;m.n32=0;m.n33=-2/u;m.n34=-((k+h)/u);m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,e){b[e]=this.n11;b[e+1]=this.n21;b[e+2]=this.n31;b[e+3]=this.n41;b[e+4]=this.n12;b[e+5]=this.n22;b[e+6]=this.n32;b[e+7]=this.n42;b[e+8]=this.n13;b[e+9]=this.n23;b[e+10]=this.n33;b[e+11]=this.n43;b[e+12]=this.n14;b[e+13]=this.n24;b[e+14]=this.n34; +b[e+15]=this.n44;return b},setTranslation:function(b,e,c){this.set(1,0,0,b,0,1,0,e,0,0,1,c,0,0,0,1);return this},setScale:function(b,e,c){this.set(b,0,0,0,0,e,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var e=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,e,-b,0,0,b,e,0,0,0,0,1);return this},setRotationY:function(b){var e=Math.cos(b),b=Math.sin(b);this.set(e,0,b,0,0,1,0,0,-b,0,e,0,0,0,0,1);return this},setRotationZ:function(b){var e=Math.cos(b),b=Math.sin(b);this.set(e,-b,0,0,b,e,0,0, +0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,e){var c=Math.cos(e),f=Math.sin(e),m=1-c,h=b.x,k=b.y,n=b.z,p=m*h,t=m*k;this.set(p*h+c,p*k-f*n,p*n+f*k,0,p*k+f*n,t*k+c,t*n-f*h,0,p*n-f*k,t*n+f*h,m*n*n+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, +this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(b){var e=b.n11,c=b.n12,f=b.n13,m=b.n14,h=b.n21,k=b.n22,n=b.n23,p=b.n24,t=b.n31,u=b.n32,v=b.n33,x=b.n34,w=b.n41,A=b.n42,y=b.n43,z=b.n44;this.n11=n*x*A-p*v*A+p*u*y-k*x*y-n*u*z+k*v*z;this.n12=m*v*A-f*x*A-m*u*y+c*x*y+f*u*z-c*v*z;this.n13=f*p*A-m*n*A+m*k*y-c*p*y-f*k*z+c*n*z;this.n14=m*n*u-f*p*u-m*k*v+c*p*v+f*k*x-c*n*x;this.n21=p*v*w-n*x*w-p*t*y+h*x*y+n*t*z-h*v*z;this.n22=f*x*w-m*v*w+ +m*t*y-e*x*y-f*t*z+e*v*z;this.n23=m*n*w-f*p*w-m*h*y+e*p*y+f*h*z-e*n*z;this.n24=f*p*t-m*n*t+m*h*v-e*p*v-f*h*x+e*n*x;this.n31=k*x*w-p*u*w+p*t*A-h*x*A-k*t*z+h*u*z;this.n32=m*u*w-c*x*w-m*t*A+e*x*A+c*t*z-e*u*z;this.n33=f*p*w-m*k*w+m*h*A-e*p*A-c*h*z+e*k*z;this.n34=m*k*t-c*p*t-m*h*u+e*p*u+c*h*x-e*k*x;this.n41=n*u*w-k*v*w-n*t*A+h*v*A+k*t*y-h*u*y;this.n42=c*v*w-f*u*w+f*t*A-e*v*A-c*t*y+e*u*y;this.n43=f*k*w-c*n*w-f*h*A+e*n*A+c*h*y-e*k*y;this.n44=c*n*t-f*k*t+f*h*u-e*n*u-c*h*v+e*k*v;this.multiplyScalar(1/b.determinant()); +return this},setRotationFromEuler:function(b,e){var c=b.x,f=b.y,m=b.z,h=Math.cos(c),c=Math.sin(c),k=Math.cos(f),f=Math.sin(f),n=Math.cos(m),m=Math.sin(m);switch(e){case "YXZ":var p=k*n,t=k*m,u=f*n,v=f*m;this.n11=p+v*c;this.n12=u*c-t;this.n13=h*f;this.n21=h*m;this.n22=h*n;this.n23=-c;this.n31=t*c-u;this.n32=v+p*c;this.n33=h*k;break;case "ZXY":p=k*n;t=k*m;u=f*n;v=f*m;this.n11=p-v*c;this.n12=-h*m;this.n13=u+t*c;this.n21=t+u*c;this.n22=h*n;this.n23=v-p*c;this.n31=-h*f;this.n32=c;this.n33=h*k;break;case "ZYX":p= +h*n;t=h*m;u=c*n;v=c*m;this.n11=k*n;this.n12=u*f-t;this.n13=p*f+v;this.n21=k*m;this.n22=v*f+p;this.n23=t*f-u;this.n31=-f;this.n32=c*k;this.n33=h*k;break;case "YZX":p=h*k;t=h*f;u=c*k;v=c*f;this.n11=k*n;this.n12=v-p*m;this.n13=u*m+t;this.n21=m;this.n22=h*n;this.n23=-c*n;this.n31=-f*n;this.n32=t*m+u;this.n33=p-v*m;break;case "XZY":p=h*k;t=h*f;u=c*k;v=c*f;this.n11=k*n;this.n12=-m;this.n13=f*n;this.n21=p*m+v;this.n22=h*n;this.n23=t*m-u;this.n31=u*m-t;this.n32=c*n;this.n33=v*m+p;break;default:p=h*n,t=h* +m,u=c*n,v=c*m,this.n11=k*n,this.n12=-k*m,this.n13=f,this.n21=t+u*f,this.n22=p-v*f,this.n23=-c*k,this.n31=v-p*f,this.n32=u+t*f,this.n33=h*k}return this},setRotationFromQuaternion:function(b){var e=b.x,c=b.y,f=b.z,m=b.w,h=e+e,k=c+c,n=f+f,b=e*h,p=e*k;e*=n;var t=c*k;c*=n;f*=n;h*=m;k*=m;m*=n;this.n11=1-(t+f);this.n12=p-m;this.n13=e+k;this.n21=p+m;this.n22=1-(b+f);this.n23=c-h;this.n31=e-k;this.n32=c+h;this.n33=1-(b+t);return this},scale:function(b){var e=b.x,c=b.y,b=b.z;this.n11*=e;this.n12*=c;this.n13*= +b;this.n21*=e;this.n22*=c;this.n23*=b;this.n31*=e;this.n32*=c;this.n33*=b;this.n41*=e;this.n42*=c;this.n43*=b;return this},compose:function(b,e,c){var f=THREE.Matrix4.__m1,m=THREE.Matrix4.__m2;f.identity();f.setRotationFromQuaternion(e);m.setScale(c.x,c.y,c.z);this.multiply(f,m);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,e,c){var f=THREE.Matrix4.__v1,m=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);m.set(this.n12,this.n22,this.n32);h.set(this.n13, +this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;e=e instanceof THREE.Quaternion?e:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=f.length();c.y=m.length();c.z=h.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=c.x;f.n21/=c.x;f.n31/=c.x;f.n12/=c.y;f.n22/=c.y;f.n32/=c.y;f.n13/=c.z;f.n23/=c.z;f.n33/=c.z;e.setFromRotationMatrix(f);return[b,e,c]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34; +return this},extractRotation:function(b){var e=THREE.Matrix4.__v1,c=1/e.set(b.n11,b.n21,b.n31).length(),f=1/e.set(b.n12,b.n22,b.n32).length(),e=1/e.set(b.n13,b.n23,b.n33).length();this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*e;this.n23=b.n23*e;this.n33=b.n33*e;return this}}; +THREE.Matrix4.makeInvert3x3=function(b){var e=b.m33,c=e.m,f=b.n33*b.n22-b.n32*b.n23,m=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,n=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,t=b.n23*b.n12-b.n22*b.n13,u=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*t;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;c[0]=b*f;c[1]=b*m;c[2]=b*h;c[3]=b*k;c[4]=b*n;c[5]=b*p;c[6]=b*t;c[7]=b*u;c[8]=b*v;return e}; +THREE.Matrix4.makeFrustum=function(b,e,c,f,m,h){var k;k=new THREE.Matrix4;k.n11=2*m/(e-b);k.n12=0;k.n13=(e+b)/(e-b);k.n14=0;k.n21=0;k.n22=2*m/(f-c);k.n23=(f+c)/(f-c);k.n24=0;k.n31=0;k.n32=0;k.n33=-(h+m)/(h-m);k.n34=-2*h*m/(h-m);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,e,c,f){var m,b=c*Math.tan(b*Math.PI/360);m=-b;return THREE.Matrix4.makeFrustum(m*e,b*e,m,b,c,f)}; +THREE.Matrix4.makeOrtho=function(b,e,c,f,m,h){var k,n,p,t;k=new THREE.Matrix4;n=e-b;p=c-f;t=h-m;k.n11=2/n;k.n12=0;k.n13=0;k.n14=-((e+b)/n);k.n21=0;k.n22=2/p;k.n23=0;k.n24=-((c+f)/p);k.n31=0;k.n32=0;k.n33=-2/t;k.n34=-((h+m)/t);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3}; -THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(b){if(this.children.indexOf(b)=== --1){b.parent!==void 0&&b.parent.remove(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},remove:function(b){var c=this,e=this.children.indexOf(b);if(e!==-1){b.parent=void 0;for(this.children.splice(e,1);c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.removeChildRecurse(b)}},getChildByName:function(b,c){var e,f,h;e=0;for(f=this.children.length;e=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?e=Math.max(e,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?e=Math.max(e,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),fG&&m.positionScreen.z0&&K.z<1))ia=C[F]=C[F]||new THREE.RenderableParticle,F++,E=ia,E.x=K.x/K.w,E.y=K.y/K.w,E.z=K.z,E.rotation=U.rotation.z,E.scale.x=U.scale.x*Math.abs(E.x-(K.x+k.projectionMatrix.n11)/(K.w+k.projectionMatrix.n14)),E.scale.y=U.scale.y*Math.abs(E.y-(K.y+k.projectionMatrix.n22)/(K.w+k.projectionMatrix.n24)),E.materials=U.materials,J.push(E);h&&J.sort(c);return J}}; -THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),k=Math.cos(e),e=Math.sin(e),m=b*c,n=f*h;this.w=m*k-n*e;this.x=m*e+n*k;this.y=f*c*k+b*h*e;this.z=b*h*k-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e); -this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); -this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c= -this.x,e=this.y,f=this.z,h=this.w,k=b.x,m=b.y,n=b.z,b=b.w;this.x=c*b+h*k+e*n-f*m;this.y=e*b+h*m+f*k-c*n;this.z=f*b+h*n+c*m-e*k;this.w=h*b-c*k-e*m-f*n;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,f=b.y,h=b.z,k=this.x,m=this.y,n=this.z,t=this.w,u=t*e+m*h-n*f,w=t*f+n*e-k*h,o=t*h+k*f-m*e,e=-k* -e-m*f-n*h;c.x=u*t+e*-k+w*-n-o*-m;c.y=w*t+e*-m+o*-k-u*-n;c.z=o*t+e*-n+u*-m-w*-k;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;h=Math.sin((1-f)*k)/m;f=Math.sin(f*k)/m;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e}; -THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,f,h,k){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3}; -THREE.Face4=function(b,c,e,f,h,k,m){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materials=m instanceof Array?m:[m];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0}; -THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; -THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(b){var c=new THREE.Matrix4;c.extractRotation(b,new THREE.Vector3(1,1,1));for(var e=0,f=this.vertices.length;e0){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;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;u=this.points[e[0]];w=this.points[e[1]]; -o=this.points[e[2]];x=this.points[e[3]];n=m*m;t=m*n;f.x=c(u.x,w.x,o.x,x.x,m,n,t);f.y=c(u.y,w.y,o.y,x.y,m,n,t);f.z=c(u.z,w.z,o.z,x.z,m,n,t);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;b=0&&m>=0&&k>=0&&n>=0?!0:h<0&&m<0||k<0&&n<0?!1:(h<0?e=Math.max(e,h/(h-m)):m<0&&(f=Math.min(f,h/(h-m))),k<0?e=Math.max(e,k/(k-n)):n<0&&(f=Math.min(f,k/(k-n))),fL&&f.positionScreen.z0&&C.z<1))ra=z[y]=z[y]||new THREE.RenderableParticle,y++,A=ra,A.x=C.x/C.w,A.y=C.y/C.w,A.z=C.z,A.rotation=ca.rotation.z,A.scale.x=ca.scale.x*Math.abs(A.x-(C.x+J.projectionMatrix.n11)/(C.w+J.projectionMatrix.n14)), +A.scale.y=ca.scale.y*Math.abs(A.y-(C.y+J.projectionMatrix.n22)/(C.w+J.projectionMatrix.n24)),A.materials=ca.materials,E.elements.push(A);O&&E.elements.sort(e);return E}};THREE.Quaternion=function(b,e,c,f){this.set(b||0,e||0,c||0,f!==void 0?f:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,e,c,f){this.x=b;this.y=e;this.z=c;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var e=Math.PI/360,c=b.x*e,f=b.y*e,m=b.z*e,b=Math.cos(f),f=Math.sin(f),e=Math.cos(-m),m=Math.sin(-m),h=Math.cos(c),c=Math.sin(c),k=b*e,n=f*m;this.w=k*h-n*c;this.x=k*c+n*h;this.y=f*e*h+b*m*c;this.z=b*m*h-f*e*c;return this},setFromAxisAngle:function(b,e){var c=e/2,f=Math.sin(c); +this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(c);return this},setFromRotationMatrix:function(b){var e=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,e+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,e+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,e-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,e-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); +this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var e= +this.x,c=this.y,f=this.z,m=this.w,h=b.x,k=b.y,n=b.z,b=b.w;this.x=e*b+m*h+c*n-f*k;this.y=c*b+m*k+f*h-e*n;this.z=f*b+m*n+e*k-c*h;this.w=m*b-e*h-c*k-f*n;return this},multiply:function(b,e){this.x=b.x*e.w+b.y*e.z-b.z*e.y+b.w*e.x;this.y=-b.x*e.z+b.y*e.w+b.z*e.x+b.w*e.y;this.z=b.x*e.y-b.y*e.x+b.z*e.w+b.w*e.z;this.w=-b.x*e.x-b.y*e.y-b.z*e.z+b.w*e.w;return this},multiplyVector3:function(b,e){e||(e=b);var c=b.x,f=b.y,m=b.z,h=this.x,k=this.y,n=this.z,p=this.w,t=p*c+k*m-n*f,u=p*f+n*c-h*m,v=p*m+h*f-k*c,c=-h* +c-k*f-n*m;e.x=t*p+c*-h+u*-n-v*-k;e.y=u*p+c*-k+v*-h-t*-n;e.z=v*p+c*-n+t*-k-u*-h;return e}}; +THREE.Quaternion.slerp=function(b,e,c,f){var m=b.w*e.w+b.x*e.x+b.y*e.y+b.z*e.z;m<0?(c.w=-e.w,c.x=-e.x,c.y=-e.y,c.z=-e.z,m=-m):c.copy(e);if(Math.abs(m)>=1)return c.w=b.w,c.x=b.x,c.y=b.y,c.z=b.z,c;var h=Math.acos(m),m=Math.sqrt(1-m*m);if(Math.abs(m)<0.0010)return c.w=0.5*(b.w+e.w),c.x=0.5*(b.x+e.x),c.y=0.5*(b.y+e.y),c.z=0.5*(b.z+e.z),c;e=Math.sin((1-f)*h)/m;f=Math.sin(f*h)/m;c.w=b.w*e+c.w*f;c.x=b.x*e+c.x*f;c.y=b.y*e+c.y*f;c.z=b.z*e+c.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Face3=function(b,e,c,f,m,h){this.a=b;this.b=e;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=m instanceof THREE.Color?m:new THREE.Color;this.vertexColors=m instanceof Array?m:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,e,c,f,m,h,k){this.a=b;this.b=e;this.c=c;this.d=f;this.normal=m instanceof THREE.Vector3?m:new THREE.Vector3;this.vertexNormals=m instanceof Array?m:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,e){this.u=b||0;this.v=e||0}; +THREE.UV.prototype={constructor:THREE.UV,set:function(b,e){this.u=b;this.v=e;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; +THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(b){var e=new THREE.Matrix4;e.extractRotation(b,new THREE.Vector3(1,1,1));for(var c=0,f=this.vertices.length;c0){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 e=1,c=this.vertices.length;ethis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,e=0,c=this.vertices.length;ethis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;t=this.points[c[0]];u=this.points[c[1]]; +v=this.points[c[2]];x=this.points[c[3]];n=k*k;p=k*n;f.x=e(t.x,u.x,v.x,x.x,k,n,p);f.y=e(t.y,u.y,v.y,x.y,k,n,p);f.z=e(t.z,u.z,v.z,x.z,k,n,p);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, -this.LODs[f].object3D.visible=!0;else break;for(;f1){b=c.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, +this.LODs[f].object3D.visible=!0;else break;for(;f0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+ -Math.floor(z.b*255)+","+y+")"),v.fillRect(Math.floor(L.getX()),Math.floor(L.getY()),Math.floor(L.getWidth()),Math.floor(L.getHeight()))),L.empty())};this.render=function(b,t){function u(b){var c,e,f,k=b.lights;P.setRGB(0,0,0);ma.setRGB(0,0,0);ua.setRGB(0,0,0);b=0;for(c=k.length;b>1,xa=u.height>>1,m=k.scale.x*o,t=k.scale.y*x,p=m*w,n=t*xa,M.set(b.x-p,b.y-n,b.x+p,b.y+n),za.intersects(M)&&(v.save(),v.translate(b.x,b.y),v.rotate(-k.rotation),v.scale(m,-t),v.translate(-w,-xa),v.drawImage(u,0,0),v.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(p=k.scale.x*o,n=k.scale.y*x,M.set(b.x-p,b.y-n,b.x+p,b.y+n),za.intersects(M)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),v.save(),v.translate(b.x,b.y),v.rotate(-k.rotation),v.scale(p,n),m.program(v), -v.restore()))}function eb(b,k,h,m){c(m.opacity);e(m.blending);v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(k.positionScreen.x,k.positionScreen.y);v.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)v.lineWidth=G=b;b=m.linecap;if(J!=b)v.lineCap=J=b;b=m.linejoin;if(O!=b)v.lineJoin=O=b;f(m.color.getContextStyle());v.stroke();M.inflate(m.linewidth*2)}}function A(b,f,h,m,n,u,o,v,xa){k.info.render.vertices+=3;k.info.render.faces++;c(v.opacity);e(v.blending); -Q=b.positionScreen.x;Z=b.positionScreen.y;$=f.positionScreen.x;S=f.positionScreen.y;p=h.positionScreen.x;V=h.positionScreen.y;F(Q,Z,$,S,p,V);if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&(ra=o.uvs[0],ab(Q,Z,$,S,p,V,ra[m].u,ra[m].v,ra[n].u,ra[n].v,ra[u].u,ra[u].v,v.map));else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=t.matrixWorldInverse,oa.copy(o.vertexNormalsWorld[0]),sa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,ya= --(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(o.vertexNormalsWorld[1]),Ca=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Ga=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(o.vertexNormalsWorld[2]),Fa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Da=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,ab(Q,Z,$,S,p,V,sa,ya,Ca,Ga,Fa,Da,v.envMap)}else v.wireframe?C(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Na(v.color);else if(v instanceof THREE.MeshLambertMaterial)v.map&&!v.wireframe&& -(v.map.mapping instanceof THREE.UVMapping&&(ra=o.uvs[0],ab(Q,Z,$,S,p,V,ra[m].u,ra[m].v,ra[n].u,ra[n].v,ra[u].u,ra[u].v,v.map)),e(THREE.SubtractiveBlending)),fa?!v.wireframe&&v.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(W.r=U.r=ia.r=P.r,W.g=U.g=ia.g=P.g,W.b=U.b=ia.b=P.b,w(xa,o.v1.positionWorld,o.vertexNormalsWorld[0],W),w(xa,o.v2.positionWorld,o.vertexNormalsWorld[1],U),w(xa,o.v3.positionWorld,o.vertexNormalsWorld[2],ia),W.r=Math.max(0,Math.min(v.color.r*W.r,1)),W.g=Math.max(0,Math.min(v.color.g* -W.g,1)),W.b=Math.max(0,Math.min(v.color.b*W.b,1)),U.r=Math.max(0,Math.min(v.color.r*U.r,1)),U.g=Math.max(0,Math.min(v.color.g*U.g,1)),U.b=Math.max(0,Math.min(v.color.b*U.b,1)),ia.r=Math.max(0,Math.min(v.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(v.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(v.color.b*ia.b,1)),ja.r=(U.r+ia.r)*0.5,ja.g=(U.g+ia.g)*0.5,ja.b=(U.b+ia.b)*0.5,pa=Ya(W,U,ia,ja),Ua(Q,Z,$,S,p,V,0,0,1,0,0,1,pa)):(qa.r=P.r,qa.g=P.g,qa.b=P.b,w(xa,o.centroidWorld,o.normalWorld,qa),aa.r=Math.max(0,Math.min(v.color.r* -qa.r,1)),aa.g=Math.max(0,Math.min(v.color.g*qa.g,1)),aa.b=Math.max(0,Math.min(v.color.b*qa.b,1)),v.wireframe?C(aa,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Na(aa)):v.wireframe?C(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Na(v.color);else if(v instanceof THREE.MeshDepthMaterial)la=t.near,ca=t.far,W.r=W.g=W.b=1-Qa(b.positionScreen.z,la,ca),U.r=U.g=U.b=1-Qa(f.positionScreen.z,la,ca),ia.r=ia.g=ia.b=1-Qa(h.positionScreen.z,la,ca),ja.r=(U.r+ia.r)*0.5,ja.g=(U.g+ -ia.g)*0.5,ja.b=(U.b+ia.b)*0.5,pa=Ya(W,U,ia,ja),Ua(Q,Z,$,S,p,V,0,0,1,0,0,1,pa);else if(v instanceof THREE.MeshNormalMaterial)aa.r=Va(o.normalWorld.x),aa.g=Va(o.normalWorld.y),aa.b=Va(o.normalWorld.z),v.wireframe?C(aa,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Na(aa)}function z(b,f,h,m,n,u,v,o,xa){k.info.render.vertices+=4;k.info.render.faces++;c(o.opacity);e(o.blending);if(o.map||o.envMap)A(b,f,m,0,1,3,v,o,xa),A(n,h,u,1,2,3,v,o,xa);else if(Q=b.positionScreen.x,Z=b.positionScreen.y, -$=f.positionScreen.x,S=f.positionScreen.y,p=h.positionScreen.x,V=h.positionScreen.y,ea=m.positionScreen.x,da=m.positionScreen.y,ha=n.positionScreen.x,ga=n.positionScreen.y,ka=u.positionScreen.x,na=u.positionScreen.y,o instanceof THREE.MeshBasicMaterial)E(Q,Z,$,S,p,V,ea,da),o.wireframe?C(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color);else if(o instanceof THREE.MeshLambertMaterial)fa?!o.wireframe&&o.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==4?(W.r= -U.r=ia.r=ja.r=P.r,W.g=U.g=ia.g=ja.g=P.g,W.b=U.b=ia.b=ja.b=P.b,w(xa,v.v1.positionWorld,v.vertexNormalsWorld[0],W),w(xa,v.v2.positionWorld,v.vertexNormalsWorld[1],U),w(xa,v.v4.positionWorld,v.vertexNormalsWorld[3],ia),w(xa,v.v3.positionWorld,v.vertexNormalsWorld[2],ja),W.r=Math.max(0,Math.min(o.color.r*W.r,1)),W.g=Math.max(0,Math.min(o.color.g*W.g,1)),W.b=Math.max(0,Math.min(o.color.b*W.b,1)),U.r=Math.max(0,Math.min(o.color.r*U.r,1)),U.g=Math.max(0,Math.min(o.color.g*U.g,1)),U.b=Math.max(0,Math.min(o.color.b* -U.b,1)),ia.r=Math.max(0,Math.min(o.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(o.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(o.color.b*ia.b,1)),ja.r=Math.max(0,Math.min(o.color.r*ja.r,1)),ja.g=Math.max(0,Math.min(o.color.g*ja.g,1)),ja.b=Math.max(0,Math.min(o.color.b*ja.b,1)),pa=Ya(W,U,ia,ja),F(Q,Z,$,S,ea,da),Ua(Q,Z,$,S,ea,da,0,0,1,0,0,1,pa),F(ha,ga,p,V,ka,na),Ua(ha,ga,p,V,ka,na,1,0,1,1,0,1,pa)):(qa.r=P.r,qa.g=P.g,qa.b=P.b,w(xa,v.centroidWorld,v.normalWorld,qa),aa.r=Math.max(0,Math.min(o.color.r*qa.r, -1)),aa.g=Math.max(0,Math.min(o.color.g*qa.g,1)),aa.b=Math.max(0,Math.min(o.color.b*qa.b,1)),E(Q,Z,$,S,p,V,ea,da),o.wireframe?C(aa,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(aa)):(E(Q,Z,$,S,p,V,ea,da),o.wireframe?C(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color));else if(o instanceof THREE.MeshNormalMaterial)aa.r=Va(v.normalWorld.x),aa.g=Va(v.normalWorld.y),aa.b=Va(v.normalWorld.z),E(Q,Z,$,S,p,V,ea,da),o.wireframe?C(aa,o.wireframeLinewidth,o.wireframeLinecap, -o.wireframeLinejoin):Na(aa);else if(o instanceof THREE.MeshDepthMaterial)la=t.near,ca=t.far,W.r=W.g=W.b=1-Qa(b.positionScreen.z,la,ca),U.r=U.g=U.b=1-Qa(f.positionScreen.z,la,ca),ia.r=ia.g=ia.b=1-Qa(m.positionScreen.z,la,ca),ja.r=ja.g=ja.b=1-Qa(h.positionScreen.z,la,ca),pa=Ya(W,U,ia,ja),F(Q,Z,$,S,ea,da),Ua(Q,Z,$,S,ea,da,0,0,1,0,0,1,pa),F(ha,ga,p,V,ka,na),Ua(ha,ga,p,V,ka,na,1,0,1,1,0,1,pa)}function F(b,c,e,f,k,h){v.beginPath();v.moveTo(b,c);v.lineTo(e,f);v.lineTo(k,h);v.lineTo(b,c);v.closePath()}function E(b, -c,e,f,k,h,m,p){v.beginPath();v.moveTo(b,c);v.lineTo(e,f);v.lineTo(k,h);v.lineTo(m,p);v.lineTo(b,c);v.closePath()}function C(b,c,e,k){if(G!=c)v.lineWidth=G=c;if(J!=e)v.lineCap=J=e;if(O!=k)v.lineJoin=O=k;f(b.getContextStyle());v.stroke();M.inflate(c*2)}function Na(b){h(b.getContextStyle());v.fill()}function ab(b,c,e,f,k,m,p,n,t,o,u,xa,w){if(w.image.width!=0){if(w.needsUpdate==!0||ta[w.id]==void 0){var x=w.wrapS==THREE.RepeatWrapping,L=w.wrapT==THREE.RepeatWrapping;ta[w.id]=v.createPattern(w.image,x&& -L?"repeat":x&&!L?"repeat-x":!x&&L?"repeat-y":"no-repeat");w.needsUpdate=!1}h(ta[w.id]);var x=w.offset.x/w.repeat.x,L=w.offset.y/w.repeat.y,y=(w.image.width-1)*w.repeat.x,w=(w.image.height-1)*w.repeat.y,p=(p+x)*y,n=(n+L)*w,t=(t+x)*y,o=(o+L)*w,u=(u+x)*y,xa=(xa+L)*w;e-=b;f-=c;k-=b;m-=c;t-=p;o-=n;u-=p;xa-=n;x=1/(t*xa-u*o);w=(xa*e-o*k)*x;o=(xa*f-o*m)*x;e=(t*k-u*e)*x;f=(t*m-u*f)*x;b=b-w*p-e*n;c=c-o*p-f*n;v.save();v.transform(w,o,e,f,b,c);v.fill();v.restore()}}function Ua(b,c,e,f,k,h,m,p,n,t,o,u,w){var xa, -x;xa=w.width-1;x=w.height-1;m*=xa;p*=x;n*=xa;t*=x;o*=xa;u*=x;e-=b;f-=c;k-=b;h-=c;n-=m;t-=p;o-=m;u-=p;x=1/(n*u-o*t);xa=(u*e-t*k)*x;t=(u*f-t*h)*x;e=(n*k-o*e)*x;f=(n*h-o*f)*x;b=b-xa*m-e*p;c=c-t*m-f*p;v.save();v.transform(xa,t,e,f,b,c);v.clip();v.drawImage(w,0,0);v.restore()}function Ya(b,c,e,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(c.r*255),p=~~(c.g*255),c=~~(c.b*255),n=~~(e.r*255),t=~~(e.g*255),e=~~(e.b*255),o=~~(f.r*255),u=~~(f.g*255),f=~~(f.b*255);va[0]=k<0?0:k>255?255:k;va[1]=h<0?0: -h>255?255:h;va[2]=b<0?0:b>255?255:b;va[4]=m<0?0:m>255?255:m;va[5]=p<0?0:p>255?255:p;va[6]=c<0?0:c>255?255:c;va[8]=n<0?0:n>255?255:n;va[9]=t<0?0:t>255?255:t;va[10]=e<0?0:e>255?255:e;va[12]=o<0?0:o>255?255:o;va[13]=u<0?0:u>255?255:u;va[14]=f<0?0:f>255?255:f;Ia.putImageData(Ba,0,0);Ha.drawImage(Ea,0,0);return Ka}function Qa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Va(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Oa(b,c){var e=c.x-b.x,f=c.y-b.y,k=e*e+f*f;k!=0&&(k=1/Math.sqrt(k),e*=k,f*=k,c.x+= -e,c.y+=f,b.x-=e,b.y-=f)}var Za,bb,wa,Ja,Pa,Wa,$a,Aa;this.autoClear?this.clear():v.setTransform(1,0,0,-1,o,x);k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,t,this.sortElements);(fa=b.lights.length>0)&&u(b);Za=0;for(bb=m.length;Za0&&(e.r+=h.color.r*m,e.g+=h.color.g*m,e.b+=h.color.b*m)):h instanceof THREE.PointLight&&(Y.sub(h.position,c.centroidWorld),Y.normalize(),m=c.normalWorld.dot(Y)*h.intensity,m>0&&(e.r+=h.color.r*m,e.g+=h.color.g*m,e.b+=h.color.b*m))}function c(c,e,m,n,o,u){k.info.render.vertices+=3;k.info.render.faces++;Q=f(Z++); -Q.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");o instanceof THREE.MeshBasicMaterial?G.copy(o.color):o instanceof THREE.MeshLambertMaterial?C?(J.r=O.r,J.g=O.g,J.b=O.b,b(u,n,J),G.r=Math.max(0,Math.min(o.color.r*J.r,1)),G.g=Math.max(0,Math.min(o.color.g*J.g,1)),G.b=Math.max(0,Math.min(o.color.b*J.b,1))):G.copy(o.color):o instanceof THREE.MeshDepthMaterial?(N=1-o.__2near/(o.__farPlusNear- -n.z*o.__farMinusNear),G.setRGB(N,N,N)):o instanceof THREE.MeshNormalMaterial&&G.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));o.wireframe?Q.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):Q.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+o.opacity);t.appendChild(Q)}function e(c,e,m,n,o,u,v){k.info.render.vertices+= -4;k.info.render.faces++;Q=f(Z++);Q.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");u instanceof THREE.MeshBasicMaterial?G.copy(u.color):u instanceof THREE.MeshLambertMaterial?C?(J.r=O.r,J.g=O.g,J.b=O.b,b(v,o,J),G.r=Math.max(0,Math.min(u.color.r*J.r,1)),G.g=Math.max(0,Math.min(u.color.g*J.g,1)),G.b=Math.max(0,Math.min(u.color.b*J.b,1))): -G.copy(u.color):u instanceof THREE.MeshDepthMaterial?(N=1-u.__2near/(u.__farPlusNear-o.z*u.__farMinusNear),G.setRGB(N,N,N)):u instanceof THREE.MeshNormalMaterial&&G.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));u.wireframe?Q.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+u.wireframeLinewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: "+u.wireframeLinecap+"; stroke-linejoin: "+u.wireframeLinejoin):Q.setAttribute("style","fill: "+G.getContextStyle()+ -"; fill-opacity: "+u.opacity);t.appendChild(Q)}function f(b){H[b]==null&&(H[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),S==0&&H[b].setAttribute("shape-rendering","crispEdges"));return H[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,m=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),u,w,o,x,v,z,y,A,E=new THREE.Rectangle,F=new THREE.Rectangle,C=!1,G=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0), -K=new THREE.Color(0),B=new THREE.Color(0),N,Y=new THREE.Vector3,H=[],T=[],Q,Z,$,S=1;this.domElement=t;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":S=1;break;case "low":S=0}};this.setSize=function(b,c){u=b;w=c;o=u/2;x=w/2;t.setAttribute("viewBox",-o+" "+-x+" "+u+" "+w);t.setAttribute("width",u);t.setAttribute("height",w);E.set(-o,-x,o,x)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])}; -this.render=function(b,f){var h,u,w,G,H,N,J,W;this.autoClear&&this.clear();k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,f,this.sortElements);$=Z=0;if(C=b.lights.length>0){J=b.lights;O.setRGB(0,0,0);K.setRGB(0,0,0);B.setRGB(0,0,0);h=0;for(u=J.length;h 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 ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif", +THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Fog=function(b,e,c){this.color=new THREE.Color(b);this.near=e!==void 0?e:1;this.far=c!==void 0?c:1E3};THREE.FogExp2=function(b,e){this.color=new THREE.Color(b);this.density=e!==void 0?e:2.5E-4}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,e=new THREE.Projector,c,f,m,h;this.domElement=document.createElement("div");this.setSize=function(b,e){c=b;f=e;m=c/2;h=f/2};this.render=function(c,f){var p,t,u,v,x,w,A,y;b=e.projectScene(c,f);p=0;for(t=b.length;p0&&(c(THREE.NormalBlending),e(1),m("rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+E+")"),y.fillRect(Math.floor(V.getX()), +Math.floor(V.getY()),Math.floor(V.getWidth()),Math.floor(V.getHeight()))),V.empty())};this.render=function(b,ya){function u(b){var c,e,f,h;la.setRGB(0,0,0);za.setRGB(0,0,0);xa.setRGB(0,0,0);c=0;for(e=b.length;c> +1,u=t.height>>1,k=h.scale.x*w,p=h.scale.y*A,o=k*v,n=p*u,pa.set(b.x-o,b.y-n,b.x+o,b.y+n),U.intersects(pa)&&(y.save(),y.translate(b.x,b.y),y.rotate(-h.rotation),y.scale(k,-p),y.translate(-v,-u),y.drawImage(t,0,0),y.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(o=h.scale.x*w,n=h.scale.y*A,pa.set(b.x-o,b.y-n,b.x+o,b.y+n),U.intersects(pa)&&(f(k.color.getContextStyle()),m(k.color.getContextStyle()),y.save(),y.translate(b.x,b.y),y.rotate(-h.rotation),y.scale(o,n),k.program(y),y.restore()))} +function z(b,h,k,m){e(m.opacity);c(m.blending);y.beginPath();y.moveTo(b.positionScreen.x,b.positionScreen.y);y.lineTo(h.positionScreen.x,h.positionScreen.y);y.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(I!=b)y.lineWidth=I=b;b=m.linecap;if(M!=b)y.lineCap=M=b;b=m.linejoin;if(Z!=b)y.lineJoin=Z=b;f(m.color.getContextStyle());y.stroke();pa.inflate(m.linewidth*2)}}function B(b,f,m,k,n,t,u,w){h.info.render.vertices+=3;h.info.render.faces++;e(w.opacity);c(w.blending);Q=b.positionScreen.x; +P=b.positionScreen.y;o=f.positionScreen.x;T=f.positionScreen.y;$=m.positionScreen.x;da=m.positionScreen.y;E(Q,P,o,T,$,da);if(w instanceof THREE.MeshBasicMaterial)if(w.map)w.map.mapping instanceof THREE.UVMapping&&(ia=u.uvs[0],ab(Q,P,o,T,$,da,ia[k].u,ia[k].v,ia[n].u,ia[n].v,ia[t].u,ia[t].v,w.map));else if(w.envMap){if(w.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=ya.matrixWorldInverse,oa.copy(u.vertexNormalsWorld[k]),ua=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Ha=-(oa.x*b.n21+oa.y* +b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(u.vertexNormalsWorld[n]),Fa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Ea=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(u.vertexNormalsWorld[t]),Ja=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,ea=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,ab(Q,P,o,T,$,da,ua,Ha,Fa,Ea,Ja,ea,w.envMap)}else w.wireframe?G(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Oa(w.color);else if(w instanceof THREE.MeshLambertMaterial)w.map&&!w.wireframe&&(w.map.mapping instanceof +THREE.UVMapping&&(ia=u.uvs[0],ab(Q,P,o,T,$,da,ia[k].u,ia[k].v,ia[n].u,ia[n].v,ia[t].u,ia[t].v,w.map)),c(THREE.SubtractiveBlending)),R?!w.wireframe&&w.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3?(ha.r=fa.r=ga.r=la.r,ha.g=fa.g=ga.g=la.g,ha.b=fa.b=ga.b=la.b,v(p,u.v1.positionWorld,u.vertexNormalsWorld[0],ha),v(p,u.v2.positionWorld,u.vertexNormalsWorld[1],fa),v(p,u.v3.positionWorld,u.vertexNormalsWorld[2],ga),ha.r=Math.max(0,Math.min(w.color.r*ha.r,1)),ha.g=Math.max(0,Math.min(w.color.g* +ha.g,1)),ha.b=Math.max(0,Math.min(w.color.b*ha.b,1)),fa.r=Math.max(0,Math.min(w.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(w.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(w.color.b*fa.b,1)),ga.r=Math.max(0,Math.min(w.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(w.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(w.color.b*ga.b,1)),K.r=(fa.r+ga.r)*0.5,K.g=(fa.g+ga.g)*0.5,K.b=(fa.b+ga.b)*0.5,na=Xa(ha,fa,ga,K),N(Q,P,o,T,$,da,0,0,1,0,0,1,na)):(X.r=la.r,X.g=la.g,X.b=la.b,v(p,u.centroidWorld,u.normalWorld,X),X.r=Math.max(0, +Math.min(w.color.r*X.r,1)),X.g=Math.max(0,Math.min(w.color.g*X.g,1)),X.b=Math.max(0,Math.min(w.color.b*X.b,1)),w.wireframe?G(X,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Oa(X)):w.wireframe?G(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Oa(w.color);else if(w instanceof THREE.MeshDepthMaterial)wa=ya.near,ma=ya.far,ha.r=ha.g=ha.b=1-Ra(b.positionScreen.z,wa,ma),fa.r=fa.g=fa.b=1-Ra(f.positionScreen.z,wa,ma),ga.r=ga.g=ga.b=1-Ra(m.positionScreen.z,wa,ma),K.r=(fa.r+ +ga.r)*0.5,K.g=(fa.g+ga.g)*0.5,K.b=(fa.b+ga.b)*0.5,na=Xa(ha,fa,ga,K),N(Q,P,o,T,$,da,0,0,1,0,0,1,na);else if(w instanceof THREE.MeshNormalMaterial)X.r=Va(u.normalWorld.x),X.g=Va(u.normalWorld.y),X.b=Va(u.normalWorld.z),w.wireframe?G(X,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Oa(X)}function C(b,f,m,k,n,w,t,u,y){h.info.render.vertices+=4;h.info.render.faces++;e(u.opacity);c(u.blending);if(u.map||u.envMap)B(b,f,k,0,1,3,t,u,y),B(n,m,w,1,2,3,t,u,y);else if(Q=b.positionScreen.x,P=b.positionScreen.y, +o=f.positionScreen.x,T=f.positionScreen.y,$=m.positionScreen.x,da=m.positionScreen.y,ca=k.positionScreen.x,ra=k.positionScreen.y,qa=n.positionScreen.x,sa=n.positionScreen.y,va=w.positionScreen.x,ka=w.positionScreen.y,u instanceof THREE.MeshBasicMaterial)Ya(Q,P,o,T,$,da,ca,ra),u.wireframe?G(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Oa(u.color);else if(u instanceof THREE.MeshLambertMaterial)R?!u.wireframe&&u.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(ha.r= +fa.r=ga.r=K.r=la.r,ha.g=fa.g=ga.g=K.g=la.g,ha.b=fa.b=ga.b=K.b=la.b,v(p,t.v1.positionWorld,t.vertexNormalsWorld[0],ha),v(p,t.v2.positionWorld,t.vertexNormalsWorld[1],fa),v(p,t.v4.positionWorld,t.vertexNormalsWorld[3],ga),v(p,t.v3.positionWorld,t.vertexNormalsWorld[2],K),ha.r=Math.max(0,Math.min(u.color.r*ha.r,1)),ha.g=Math.max(0,Math.min(u.color.g*ha.g,1)),ha.b=Math.max(0,Math.min(u.color.b*ha.b,1)),fa.r=Math.max(0,Math.min(u.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(u.color.g*fa.g,1)),fa.b=Math.max(0, +Math.min(u.color.b*fa.b,1)),ga.r=Math.max(0,Math.min(u.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(u.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(u.color.b*ga.b,1)),K.r=Math.max(0,Math.min(u.color.r*K.r,1)),K.g=Math.max(0,Math.min(u.color.g*K.g,1)),K.b=Math.max(0,Math.min(u.color.b*K.b,1)),na=Xa(ha,fa,ga,K),E(Q,P,o,T,ca,ra),N(Q,P,o,T,ca,ra,0,0,1,0,0,1,na),E(qa,sa,$,da,va,ka),N(qa,sa,$,da,va,ka,1,0,1,1,0,1,na)):(X.r=la.r,X.g=la.g,X.b=la.b,v(p,t.centroidWorld,t.normalWorld,X),X.r=Math.max(0,Math.min(u.color.r* +X.r,1)),X.g=Math.max(0,Math.min(u.color.g*X.g,1)),X.b=Math.max(0,Math.min(u.color.b*X.b,1)),Ya(Q,P,o,T,$,da,ca,ra),u.wireframe?G(X,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Oa(X)):(Ya(Q,P,o,T,$,da,ca,ra),u.wireframe?G(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Oa(u.color));else if(u instanceof THREE.MeshNormalMaterial)X.r=Va(t.normalWorld.x),X.g=Va(t.normalWorld.y),X.b=Va(t.normalWorld.z),Ya(Q,P,o,T,$,da,ca,ra),u.wireframe?G(X,u.wireframeLinewidth,u.wireframeLinecap, +u.wireframeLinejoin):Oa(X);else if(u instanceof THREE.MeshDepthMaterial)wa=ya.near,ma=ya.far,ha.r=ha.g=ha.b=1-Ra(b.positionScreen.z,wa,ma),fa.r=fa.g=fa.b=1-Ra(f.positionScreen.z,wa,ma),ga.r=ga.g=ga.b=1-Ra(k.positionScreen.z,wa,ma),K.r=K.g=K.b=1-Ra(m.positionScreen.z,wa,ma),na=Xa(ha,fa,ga,K),E(Q,P,o,T,ca,ra),N(Q,P,o,T,ca,ra,0,0,1,0,0,1,na),E(qa,sa,$,da,va,ka),N(qa,sa,$,da,va,ka,1,0,1,1,0,1,na)}function E(b,c,e,f,h,m){y.beginPath();y.moveTo(b,c);y.lineTo(e,f);y.lineTo(h,m);y.lineTo(b,c);y.closePath()} +function Ya(b,c,e,f,h,m,k,o){y.beginPath();y.moveTo(b,c);y.lineTo(e,f);y.lineTo(h,m);y.lineTo(k,o);y.lineTo(b,c);y.closePath()}function G(b,c,e,h){if(I!=c)y.lineWidth=I=c;if(M!=e)y.lineCap=M=e;if(Z!=h)y.lineJoin=Z=h;f(b.getContextStyle());y.stroke();pa.inflate(c*2)}function Oa(b){m(b.getContextStyle());y.fill()}function ab(b,c,e,f,h,k,o,n,p,u,t,w,v){if(v.image.width!=0){if(v.needsUpdate==!0||ja[v.id]==void 0){var ya=v.wrapS==THREE.RepeatWrapping,x=v.wrapT==THREE.RepeatWrapping;ja[v.id]=y.createPattern(v.image, +ya&&x?"repeat":ya&&!x?"repeat-x":!ya&&x?"repeat-y":"no-repeat");v.needsUpdate=!1}m(ja[v.id]);var ya=v.offset.x/v.repeat.x,x=v.offset.y/v.repeat.y,z=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,o=(o+ya)*z,n=(n+x)*v,p=(p+ya)*z,u=(u+x)*v,t=(t+ya)*z,w=(w+x)*v;e-=b;f-=c;h-=b;k-=c;p-=o;u-=n;t-=o;w-=n;ya=1/(p*w-t*u);v=(w*e-u*h)*ya;u=(w*f-u*k)*ya;e=(p*h-t*e)*ya;f=(p*k-t*f)*ya;b=b-v*o-e*n;c=c-u*o-f*n;y.save();y.transform(v,u,e,f,b,c);y.fill();y.restore()}}function N(b,c,e,f,h,m,k,o,n,p,u,t, +w){var v,ya;v=w.width-1;ya=w.height-1;k*=v;o*=ya;n*=v;p*=ya;u*=v;t*=ya;e-=b;f-=c;h-=b;m-=c;n-=k;p-=o;u-=k;t-=o;ya=1/(n*t-u*p);v=(t*e-p*h)*ya;p=(t*f-p*m)*ya;e=(n*h-u*e)*ya;f=(n*m-u*f)*ya;b=b-v*k-e*o;c=c-p*k-f*o;y.save();y.transform(v,p,e,f,b,c);y.clip();y.drawImage(w,0,0);y.restore()}function Xa(b,c,e,f){var h=~~(b.r*255),m=~~(b.g*255),b=~~(b.b*255),k=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),n=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255),u=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);Da[0]=h<0?0:h>255?255:h; +Da[1]=m<0?0:m>255?255:m;Da[2]=b<0?0:b>255?255:b;Da[4]=k<0?0:k>255?255:k;Da[5]=o<0?0:o>255?255:o;Da[6]=c<0?0:c>255?255:c;Da[8]=n<0?0:n>255?255:n;Da[9]=p<0?0:p>255?255:p;Da[10]=e<0?0:e>255?255:e;Da[12]=u<0?0:u>255?255:u;Da[13]=t<0?0:t>255?255:t;Da[14]=f<0?0:f>255?255:f;Ba.putImageData(La,0,0);W.drawImage(Aa,0,0);return Ga}function Ra(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Va(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Pa(b,c){var e=c.x-b.x,f=c.y-b.y,h=e*e+f*f;h!=0&&(h=1/Math.sqrt(h),e*=h, +f*=h,c.x+=e,c.y+=f,b.x-=e,b.y-=f)}var Za,bb,ta,Ia,Qa,Wa,$a,Ca;this.autoClear?this.clear():y.setTransform(1,0,0,-1,w,A);h.info.render.vertices=0;h.info.render.faces=0;k=t.projectScene(b,ya,this.sortElements);n=k.elements;p=k.lights;(R=p.length>0)&&u(p);Za=0;for(bb=n.length;Za1?1:b}var h=this,k,n,p,t=new THREE.Projector,u=document.createElementNS("http://www.w3.org/2000/svg","svg"),v,x,w,A,y,z,E,C,B=new THREE.Rectangle,G=new THREE.Rectangle, +N=!1,I=new THREE.Color,M=new THREE.Color,Z=new THREE.Color,J=new THREE.Color,O,L=new THREE.Vector3,F=[],aa=[],Y,Q,P,o=1;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,c){v=b;x=c;w=v/2;A=x/2;u.setAttribute("viewBox",-w+" "+-A+" "+v+" "+x);u.setAttribute("width",v);u.setAttribute("height",x);B.set(-w,-A,w,A)};this.clear=function(){for(;u.childNodes.length> +0;)u.removeChild(u.childNodes[0])};this.render=function(b,f){var m,v,x,I,L,O,F,X;this.autoClear&&this.clear();h.info.render.vertices=0;h.info.render.faces=0;k=t.projectScene(b,f,this.sortElements);n=k.elements;p=k.lights;P=Q=0;if(N=p.length>0){m=p;M.setRGB(0,0,0);Z.setRGB(0,0,0);J.setRGB(0,0,0);v=0;for(x=m.length;v 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 ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\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 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\n}", lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif", lights_pars_fragment:"uniform 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 ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 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 + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;", @@ -202,7 +198,7 @@ morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInflu default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif", shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec4 shadowColor = vec4( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec4( vec3( ( 1.0 - shadowDarkness * shadow ) ), 1.0 );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif\n}\n}\ngl_FragColor = gl_FragColor * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif"}; -THREE.UniformsUtils={merge:function(b){var c,e,f,h={};for(c=0;c=0)c&&(p.bindBuffer(p.ARRAY_BUFFER,k.__webglVertexBuffer),p.vertexAttribPointer(b.position, -3,p.FLOAT,!1,0,0));else if(m.morphTargetBase){f=h.program.attributes;m.morphTargetBase!==-1?(p.bindBuffer(p.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[m.morphTargetBase]),p.vertexAttribPointer(f.position,3,p.FLOAT,!1,0,0)):f.position>=0&&(p.bindBuffer(p.ARRAY_BUFFER,k.__webglVertexBuffer),p.vertexAttribPointer(f.position,3,p.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var o=0,t=m.morphTargetForcedOrder,u=m.morphTargetInfluences;ov&&(w=x,v=u[w]);p.bindBuffer(p.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[w]);p.vertexAttribPointer(f["morphTarget"+o],3,p.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[o]=v;t[w]=1;v= --1;o++}}h.program.uniforms.morphTargetInfluences!==null&&p.uniform1fv(h.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(c){if(k.__webglCustomAttributes)for(n in k.__webglCustomAttributes)b[n]>=0&&(f=k.__webglCustomAttributes[n],p.bindBuffer(p.ARRAY_BUFFER,f.buffer),p.vertexAttribPointer(b[n],f.size,p.FLOAT,!1,0,0));b.color>=0&&(p.bindBuffer(p.ARRAY_BUFFER,k.__webglColorBuffer),p.vertexAttribPointer(b.color,3,p.FLOAT,!1,0,0));b.normal>=0&&(p.bindBuffer(p.ARRAY_BUFFER,k.__webglNormalBuffer), -p.vertexAttribPointer(b.normal,3,p.FLOAT,!1,0,0));b.tangent>=0&&(p.bindBuffer(p.ARRAY_BUFFER,k.__webglTangentBuffer),p.vertexAttribPointer(b.tangent,4,p.FLOAT,!1,0,0));b.uv>=0&&(k.__webglUVBuffer?(p.bindBuffer(p.ARRAY_BUFFER,k.__webglUVBuffer),p.vertexAttribPointer(b.uv,2,p.FLOAT,!1,0,0),p.enableVertexAttribArray(b.uv)):p.disableVertexAttribArray(b.uv));b.uv2>=0&&(k.__webglUV2Buffer?(p.bindBuffer(p.ARRAY_BUFFER,k.__webglUV2Buffer),p.vertexAttribPointer(b.uv2,2,p.FLOAT,!1,0,0),p.enableVertexAttribArray(b.uv2)): -p.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(p.bindBuffer(p.ARRAY_BUFFER,k.__webglSkinVertexABuffer),p.vertexAttribPointer(b.skinVertexA,4,p.FLOAT,!1,0,0),p.bindBuffer(p.ARRAY_BUFFER,k.__webglSkinVertexBBuffer),p.vertexAttribPointer(b.skinVertexB,4,p.FLOAT,!1,0,0),p.bindBuffer(p.ARRAY_BUFFER,k.__webglSkinIndicesBuffer),p.vertexAttribPointer(b.skinIndex,4,p.FLOAT,!1,0,0),p.bindBuffer(p.ARRAY_BUFFER,k.__webglSkinWeightsBuffer), -p.vertexAttribPointer(b.skinWeight,4,p.FLOAT,!1,0,0))}m instanceof THREE.Mesh?(h.wireframe?(p.lineWidth(h.wireframeLinewidth),c&&p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer),p.drawElements(p.LINES,k.__webglLineCount,p.UNSIGNED_SHORT,0)):(c&&p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),p.drawElements(p.TRIANGLES,k.__webglFaceCount,p.UNSIGNED_SHORT,0)),S.info.render.calls++,S.info.render.vertices+=k.__webglFaceCount,S.info.render.faces+=k.__webglFaceCount/3):m instanceof THREE.Line? -(m=m.type==THREE.LineStrip?p.LINE_STRIP:p.LINES,p.lineWidth(h.linewidth),p.drawArrays(m,0,k.__webglLineCount),S.info.render.calls++):m instanceof THREE.ParticleSystem?(p.drawArrays(p.POINTS,0,k.__webglParticleCount),S.info.render.calls++):m instanceof THREE.Ribbon&&(p.drawArrays(p.TRIANGLE_STRIP,0,k.__webglVertexCount),S.info.render.calls++)}}function h(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=p.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=p.createBuffer();b.hasPos&& -(p.bindBuffer(p.ARRAY_BUFFER,b.__webglVertexBuffer),p.bufferData(p.ARRAY_BUFFER,b.positionArray,p.DYNAMIC_DRAW),p.enableVertexAttribArray(c.attributes.position),p.vertexAttribPointer(c.attributes.position,3,p.FLOAT,!1,0,0));if(b.hasNormal){p.bindBuffer(p.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,k,h,m,n,o,t,u,v,w,x=b.count*3;for(w=0;w=0;e--)b[e].object==c&&b.splice(e,1)}function J(b){function c(b){var k=[];e=0;for(f=b.length;e65535&&(t[p].counter+=1,o=t[p].hash+"_"+t[p].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:n,vertices:0,numMorphTargets:u})),b.geometryGroups[o].faces.push(k),b.geometryGroups[o].vertices+=m;b.geometryGroupsList=[];for(var v in b.geometryGroups)b.geometryGroups[v].id=ka++,b.geometryGroupsList.push(b.geometryGroups[v])} -function O(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function K(b){if(b!=W){switch(b){case THREE.AdditiveBlending:p.blendEquation(p.FUNC_ADD);p.blendFunc(p.SRC_ALPHA,p.ONE);break;case THREE.SubtractiveBlending:p.blendEquation(p.FUNC_ADD);p.blendFunc(p.ZERO,p.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:p.blendEquation(p.FUNC_ADD);p.blendFunc(p.ZERO,p.SRC_COLOR);break;default:p.blendEquationSeparate(p.FUNC_ADD,p.FUNC_ADD),p.blendFuncSeparate(p.SRC_ALPHA, -p.ONE_MINUS_SRC_ALPHA,p.ONE,p.ONE_MINUS_SRC_ALPHA)}W=b}}function B(b,c,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(p.texParameteri(b,p.TEXTURE_WRAP_S,$(c.wrapS)),p.texParameteri(b,p.TEXTURE_WRAP_T,$(c.wrapT)),p.texParameteri(b,p.TEXTURE_MAG_FILTER,$(c.magFilter)),p.texParameteri(b,p.TEXTURE_MIN_FILTER,$(c.minFilter)),p.generateMipmap(b)):(p.texParameteri(b,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(b,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(b,p.TEXTURE_MAG_FILTER,Z(c.magFilter)), -p.texParameteri(b,p.TEXTURE_MIN_FILTER,Z(c.minFilter)))}function N(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=p.createTexture(),S.info.memory.textures++;p.activeTexture(p.TEXTURE0+c);p.bindTexture(p.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?p.texImage2D(p.TEXTURE_2D,0,$(b.format),b.image.width,b.image.height,0,$(b.format),p.UNSIGNED_BYTE,b.image.data):p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,b.image);B(p.TEXTURE_2D,b,b.image);b.needsUpdate= -!1}else p.activeTexture(p.TEXTURE0+c),p.bindTexture(p.TEXTURE_2D,b.__webglTexture)}function Y(b,c){p.bindRenderbuffer(p.RENDERBUFFER,b);c.depthBuffer&&!c.stencilBuffer?(p.renderbufferStorage(p.RENDERBUFFER,p.DEPTH_COMPONENT16,c.width,c.height),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_ATTACHMENT,p.RENDERBUFFER,b)):c.depthBuffer&&c.stencilBuffer?(p.renderbufferStorage(p.RENDERBUFFER,p.DEPTH_STENCIL,c.width,c.height),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_STENCIL_ATTACHMENT,p.RENDERBUFFER, -b)):p.renderbufferStorage(p.RENDERBUFFER,p.RGBA4,c.width,c.height)}function H(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglTexture=p.createTexture();if(c){b.__webglFramebuffer=[];b.__webglRenderbuffer=[];p.bindTexture(p.TEXTURE_CUBE_MAP,b.__webglTexture);B(p.TEXTURE_CUBE_MAP,b,b);for(var e=0;e<6;e++){b.__webglFramebuffer[e]=p.createFramebuffer();b.__webglRenderbuffer[e]= -p.createRenderbuffer();p.texImage2D(p.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,$(b.format),b.width,b.height,0,$(b.format),$(b.type),null);var f=b,k=p.TEXTURE_CUBE_MAP_POSITIVE_X+e;p.bindFramebuffer(p.FRAMEBUFFER,b.__webglFramebuffer[e]);p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,k,f.__webglTexture,0);Y(b.__webglRenderbuffer[e],b)}}else b.__webglFramebuffer=p.createFramebuffer(),b.__webglRenderbuffer=p.createRenderbuffer(),p.bindTexture(p.TEXTURE_2D,b.__webglTexture),B(p.TEXTURE_2D,b,b),p.texImage2D(p.TEXTURE_2D, -0,$(b.format),b.width,b.height,0,$(b.format),$(b.type),null),e=p.TEXTURE_2D,p.bindFramebuffer(p.FRAMEBUFFER,b.__webglFramebuffer),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,e,b.__webglTexture,0),p.bindRenderbuffer(p.RENDERBUFFER,b.__webglRenderbuffer),Y(b.__webglRenderbuffer,b);c?p.bindTexture(p.TEXTURE_CUBE_MAP,null):p.bindTexture(p.TEXTURE_2D,null);p.bindRenderbuffer(p.RENDERBUFFER,null);p.bindFramebuffer(p.FRAMEBUFFER,null)}b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer, -e=b.width,b=b.height,k=f=0):(c=null,e=ra,b=sa,f=ca,k=pa);c!=da&&(p.bindFramebuffer(p.FRAMEBUFFER,c),p.viewport(f,k,e,b),da=c)}function T(b){b instanceof THREE.WebGLRenderTargetCube?(p.bindTexture(p.TEXTURE_CUBE_MAP,b.__webglTexture),p.generateMipmap(p.TEXTURE_CUBE_MAP),p.bindTexture(p.TEXTURE_CUBE_MAP,null)):(p.bindTexture(p.TEXTURE_2D,b.__webglTexture),p.generateMipmap(p.TEXTURE_2D),p.bindTexture(p.TEXTURE_2D,null))}function Q(b,c){var e;b=="fragment"?e=p.createShader(p.FRAGMENT_SHADER):b=="vertex"&& -(e=p.createShader(p.VERTEX_SHADER));p.shaderSource(e,c);p.compileShader(e);if(!p.getShaderParameter(e,p.COMPILE_STATUS))return console.error(p.getShaderInfoLog(e)),console.error(c),null;return e}function Z(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return p.NEAREST;default:return p.LINEAR}}function $(b){switch(b){case THREE.RepeatWrapping:return p.REPEAT;case THREE.ClampToEdgeWrapping:return p.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return p.MIRRORED_REPEAT; -case THREE.NearestFilter:return p.NEAREST;case THREE.NearestMipMapNearestFilter:return p.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return p.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return p.LINEAR;case THREE.LinearMipMapNearestFilter:return p.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return p.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return p.BYTE;case THREE.UnsignedByteType:return p.UNSIGNED_BYTE;case THREE.ShortType:return p.SHORT;case THREE.UnsignedShortType:return p.UNSIGNED_SHORT; -case THREE.IntType:return p.INT;case THREE.UnsignedShortType:return p.UNSIGNED_INT;case THREE.FloatType:return p.FLOAT;case THREE.AlphaFormat:return p.ALPHA;case THREE.RGBFormat:return p.RGB;case THREE.RGBAFormat:return p.RGBA;case THREE.LuminanceFormat:return p.LUMINANCE;case THREE.LuminanceAlphaFormat:return p.LUMINANCE_ALPHA}return 0}var S=this,p,V=[],ea=null,da=null,ha=-1,ga=null,ka=0,na=null,aa=null,W=null,U=null,ia=null,ja=null,ta=null,la=null,ca=0,pa=0,ra=0,sa=0,ya=[new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Ga=new Float32Array(16),Fa=new Float32Array(16),Da=new THREE.Vector4,za={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},L=b.canvas!==void 0?b.canvas:document.createElement("canvas"),M=b.stencil!==void 0?b.stencil:!0,fa=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,qa=b.antialias!==void 0?b.antialias:!1,P=b.clearColor!== -void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ma=b.clearAlpha!==void 0?b.clearAlpha:0,ua=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=L;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar= -5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var oa,Ea=[],b=THREE.ShaderLib.depthRGBA,Ia=THREE.UniformsUtils.clone(b.uniforms),Ba=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Ia}),va=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Ia,morphTargets:!0});Ba._shadowPass=!0;va._shadowPass=!0;try{if(!(p=L.getContext("experimental-webgl",{antialias:qa,stencil:M, -preserveDrawingBuffer:fa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+p.getParameter(p.VERSION)+" | "+p.getParameter(p.VENDOR)+" | "+p.getParameter(p.RENDERER)+" | "+p.getParameter(p.SHADING_LANGUAGE_VERSION))}catch(Ka){console.error(Ka)}p.clearColor(0,0,0,1);p.clearDepth(1);p.clearStencil(0);p.enable(p.DEPTH_TEST);p.depthFunc(p.LEQUAL);p.frontFace(p.CCW);p.cullFace(p.BACK);p.enable(p.CULL_FACE);p.enable(p.BLEND);p.blendEquation(p.FUNC_ADD);p.blendFunc(p.SRC_ALPHA, -p.ONE_MINUS_SRC_ALPHA);p.clearColor(P.r,P.g,P.b,ma);this.context=p;var Ha=p.getParameter(p.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,X={};X.vertices=new Float32Array(16);X.faces=new Uint16Array(6);M=0;X.vertices[M++]=-1;X.vertices[M++]=-1;X.vertices[M++]=0;X.vertices[M++]=1;X.vertices[M++]=1;X.vertices[M++]=-1;X.vertices[M++]=1;X.vertices[M++]=1;X.vertices[M++]=1;X.vertices[M++]=1;X.vertices[M++]=1;X.vertices[M++]=0;X.vertices[M++]=-1;X.vertices[M++]=1;X.vertices[M++]=0;M=X.vertices[M++]=0;X.faces[M++]=0; -X.faces[M++]=1;X.faces[M++]=2;X.faces[M++]=0;X.faces[M++]=2;X.faces[M++]=3;X.vertexBuffer=p.createBuffer();X.elementBuffer=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,X.vertexBuffer);p.bufferData(p.ARRAY_BUFFER,X.vertices,p.STATIC_DRAW);p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,X.elementBuffer);p.bufferData(p.ELEMENT_ARRAY_BUFFER,X.faces,p.STATIC_DRAW);X.program=p.createProgram();p.attachShader(X.program,Q("fragment",THREE.ShaderLib.sprite.fragmentShader));p.attachShader(X.program,Q("vertex",THREE.ShaderLib.sprite.vertexShader)); -p.linkProgram(X.program);X.attributes={};X.uniforms={};X.attributes.position=p.getAttribLocation(X.program,"position");X.attributes.uv=p.getAttribLocation(X.program,"uv");X.uniforms.uvOffset=p.getUniformLocation(X.program,"uvOffset");X.uniforms.uvScale=p.getUniformLocation(X.program,"uvScale");X.uniforms.rotation=p.getUniformLocation(X.program,"rotation");X.uniforms.scale=p.getUniformLocation(X.program,"scale");X.uniforms.alignment=p.getUniformLocation(X.program,"alignment");X.uniforms.color=p.getUniformLocation(X.program, -"color");X.uniforms.map=p.getUniformLocation(X.program,"map");X.uniforms.opacity=p.getUniformLocation(X.program,"opacity");X.uniforms.useScreenCoordinates=p.getUniformLocation(X.program,"useScreenCoordinates");X.uniforms.affectedByDistance=p.getUniformLocation(X.program,"affectedByDistance");X.uniforms.screenPosition=p.getUniformLocation(X.program,"screenPosition");X.uniforms.modelViewMatrix=p.getUniformLocation(X.program,"modelViewMatrix");X.uniforms.projectionMatrix=p.getUniformLocation(X.program, -"projectionMatrix");var Xa=!1;this.setSize=function(b,c){L.width=b;L.height=c;this.setViewport(0,0,L.width,L.height)};this.setViewport=function(b,c,e,f){ca=b;pa=c;ra=e;sa=f;p.viewport(ca,pa,ra,sa)};this.setScissor=function(b,c,e,f){p.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?p.enable(p.SCISSOR_TEST):p.disable(p.SCISSOR_TEST)};this.setClearColorHex=function(b,c){P.setHex(b);ma=c;p.clearColor(P.r,P.g,P.b,ma)};this.setClearColor=function(b,c){P.copy(b);ma=c;p.clearColor(P.r,P.g,P.b,ma)}; -this.getClearColor=function(){return P};this.getClearAlpha=function(){return ma};this.clear=function(b,c,e){var f=0;if(b==void 0||b)f|=p.COLOR_BUFFER_BIT;if(c==void 0||c)f|=p.DEPTH_BUFFER_BIT;if(e==void 0||e)f|=p.STENCIL_BUFFER_BIT;p.clear(f)};this.getContext=function(){return p};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c= -b.geometry.geometryGroups[g];p.deleteBuffer(c.__webglVertexBuffer);p.deleteBuffer(c.__webglNormalBuffer);p.deleteBuffer(c.__webglTangentBuffer);p.deleteBuffer(c.__webglColorBuffer);p.deleteBuffer(c.__webglUVBuffer);p.deleteBuffer(c.__webglUV2Buffer);p.deleteBuffer(c.__webglSkinVertexABuffer);p.deleteBuffer(c.__webglSkinVertexBBuffer);p.deleteBuffer(c.__webglSkinIndicesBuffer);p.deleteBuffer(c.__webglSkinWeightsBuffer);p.deleteBuffer(c.__webglFaceBuffer);p.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var e= -0,f=c.numMorphTargets;e=0)e&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(m.morphTargetBase){f=h.program.attributes;m.morphTargetBase!== +-1?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[m.morphTargetBase]),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0)):f.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var p=0,t=m.morphTargetForcedOrder,w=m.morphTargetInfluences;pu&&(v=y,u=w[v]);o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[v]);o.vertexAttribPointer(f["morphTarget"+p],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[p]=u;t[v]=1;u=-1;p++}}h.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(h.program.uniforms.morphTargetInfluences, +m.__webglMorphTargetInfluences)}if(e){if(k.__webglCustomAttributes)for(n in k.__webglCustomAttributes)b[n]>=0&&(f=k.__webglCustomAttributes[n],o.bindBuffer(o.ARRAY_BUFFER,f.buffer),o.vertexAttribPointer(b[n],f.size,o.FLOAT,!1,0,0));b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER, +k.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(k.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUVBuffer),o.vertexAttribPointer(b.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv)):o.disableVertexAttribArray(b.uv));b.uv2>=0&&(k.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUV2Buffer),o.vertexAttribPointer(b.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv2)):o.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>= +0&&b.skinIndex>=0&&b.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexABuffer),o.vertexAttribPointer(b.skinVertexA,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexBBuffer),o.vertexAttribPointer(b.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinIndicesBuffer),o.vertexAttribPointer(b.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinWeightsBuffer),o.vertexAttribPointer(b.skinWeight,4,o.FLOAT,!1,0,0))}m instanceof THREE.Mesh?(h.wireframe? +(o.lineWidth(h.wireframeLinewidth),e&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer),o.drawElements(o.LINES,k.__webglLineCount,o.UNSIGNED_SHORT,0)):(e&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),o.drawElements(o.TRIANGLES,k.__webglFaceCount,o.UNSIGNED_SHORT,0)),P.info.render.calls++,P.info.render.vertices+=k.__webglFaceCount,P.info.render.faces+=k.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(h.linewidth),o.drawArrays(m, +0,k.__webglLineCount),P.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,k.__webglParticleCount),P.info.render.calls++):m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,k.__webglVertexCount),P.info.render.calls++)}}function m(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray, +o.DYNAMIC_DRAW),o.enableVertexAttribArray(c.attributes.position),o.vertexAttribPointer(c.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,h,k,m,n,p,t,w,u,v,y=b.count*3;for(v=0;v=0;e--)b[e].object==c&&b.splice(e,1)}function N(b){function c(b){var h=[];e=0;for(f=b.length;e65535&&(t[o].counter+=1,p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:n,vertices:0,numMorphTargets:w})),b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroups[u].id=qa++,b.geometryGroupsList.push(b.geometryGroups[u])} +function I(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(b){if(b!=ka){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA, +o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}ka=b}}function Z(b,c,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,Q(c.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,Q(c.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,Q(c.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,Q(c.minFilter)),o.generateMipmap(b)):(o.texParameteri(b,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_MAG_FILTER,Y(c.magFilter)), +o.texParameteri(b,o.TEXTURE_MIN_FILTER,Y(c.minFilter)))}function J(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=o.createTexture(),P.info.memory.textures++;o.activeTexture(o.TEXTURE0+c);o.bindTexture(o.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,Q(b.format),b.image.width,b.image.height,0,Q(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);Z(o.TEXTURE_2D,b,b.image);b.needsUpdate= +!1}else o.activeTexture(o.TEXTURE0+c),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function O(b,c){o.bindRenderbuffer(o.RENDERBUFFER,b);c.depthBuffer&&!c.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,c.width,c.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,b)):c.depthBuffer&&c.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,c.width,c.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER, +b)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,c.width,c.height)}function L(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglTexture=o.createTexture();if(c){b.__webglFramebuffer=[];b.__webglRenderbuffer=[];o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);Z(o.TEXTURE_CUBE_MAP,b,b);for(var e=0;e<6;e++){b.__webglFramebuffer[e]=o.createFramebuffer();b.__webglRenderbuffer[e]= +o.createRenderbuffer();o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null);var f=b,h=o.TEXTURE_CUBE_MAP_POSITIVE_X+e;o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer[e]);o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,f.__webglTexture,0);O(b.__webglRenderbuffer[e],b)}}else b.__webglFramebuffer=o.createFramebuffer(),b.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),Z(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D, +0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null),e=o.TEXTURE_2D,o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,e,b.__webglTexture,0),o.bindRenderbuffer(o.RENDERBUFFER,b.__webglRenderbuffer),O(b.__webglRenderbuffer,b);c?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer, +e=b.width,b=b.height,h=f=0):(c=null,e=ma,b=na,f=ja,h=wa);c!=da&&(o.bindFramebuffer(o.FRAMEBUFFER,c),o.viewport(f,h,e,b),da=c)}function F(b){b instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function aa(b,c){var e;b=="fragment"?e=o.createShader(o.FRAGMENT_SHADER):b=="vertex"&& +(e=o.createShader(o.VERTEX_SHADER));o.shaderSource(e,c);o.compileShader(e);if(!o.getShaderParameter(e,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(e)),console.error(c),null;return e}function Y(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT; +case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT; +case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var P=this,o,T=[],$=null,da=null,ca=-1,ra=null,qa=0,sa=null,va=null,ka=null,X=null,ha=null,fa=null,ga=null,K=null,ja=0,wa=0,ma=0,na=0,ia=[new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ua=new THREE.Matrix4,Ha=new Float32Array(16),Fa=new Float32Array(16),Ea=new THREE.Vector4,Ja={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ea=b.canvas!==void 0?b.canvas:document.createElement("canvas"),U=b.stencil!==void 0?b.stencil:!0,V=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,pa=b.antialias!==void 0?b.antialias:!1,R=b.clearColor!== +void 0?new THREE.Color(b.clearColor):new THREE.Color(0),la=b.clearAlpha!==void 0?b.clearAlpha:0,za=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=ea;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar= +5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var xa,oa=[],b=THREE.ShaderLib.depthRGBA,Aa=THREE.UniformsUtils.clone(b.uniforms),Ba=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Aa}),La=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Aa,morphTargets:!0});Ba._shadowPass=!0;La._shadowPass=!0;try{if(!(o=ea.getContext("experimental-webgl",{antialias:pa,stencil:U, +preserveDrawingBuffer:V})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Da){console.error(Da)}o.clearColor(0,0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA, +o.ONE_MINUS_SRC_ALPHA);o.clearColor(R.r,R.g,R.b,la);this.context=o;var Ga=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,W={};W.vertices=new Float32Array(16);W.faces=new Uint16Array(6);U=0;W.vertices[U++]=-1;W.vertices[U++]=-1;W.vertices[U++]=0;W.vertices[U++]=1;W.vertices[U++]=1;W.vertices[U++]=-1;W.vertices[U++]=1;W.vertices[U++]=1;W.vertices[U++]=1;W.vertices[U++]=1;W.vertices[U++]=1;W.vertices[U++]=0;W.vertices[U++]=-1;W.vertices[U++]=1;W.vertices[U++]=0;U=W.vertices[U++]=0;W.faces[U++]=0; +W.faces[U++]=1;W.faces[U++]=2;W.faces[U++]=0;W.faces[U++]=2;W.faces[U++]=3;W.vertexBuffer=o.createBuffer();W.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,W.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,W.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,W.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,W.faces,o.STATIC_DRAW);W.program=o.createProgram();o.attachShader(W.program,aa("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(W.program,aa("vertex",THREE.ShaderLib.sprite.vertexShader)); +o.linkProgram(W.program);W.attributes={};W.uniforms={};W.attributes.position=o.getAttribLocation(W.program,"position");W.attributes.uv=o.getAttribLocation(W.program,"uv");W.uniforms.uvOffset=o.getUniformLocation(W.program,"uvOffset");W.uniforms.uvScale=o.getUniformLocation(W.program,"uvScale");W.uniforms.rotation=o.getUniformLocation(W.program,"rotation");W.uniforms.scale=o.getUniformLocation(W.program,"scale");W.uniforms.alignment=o.getUniformLocation(W.program,"alignment");W.uniforms.color=o.getUniformLocation(W.program, +"color");W.uniforms.map=o.getUniformLocation(W.program,"map");W.uniforms.opacity=o.getUniformLocation(W.program,"opacity");W.uniforms.useScreenCoordinates=o.getUniformLocation(W.program,"useScreenCoordinates");W.uniforms.affectedByDistance=o.getUniformLocation(W.program,"affectedByDistance");W.uniforms.screenPosition=o.getUniformLocation(W.program,"screenPosition");W.uniforms.modelViewMatrix=o.getUniformLocation(W.program,"modelViewMatrix");W.uniforms.projectionMatrix=o.getUniformLocation(W.program, +"projectionMatrix");var Ka=!1;this.setSize=function(b,c){ea.width=b;ea.height=c;this.setViewport(0,0,ea.width,ea.height)};this.setViewport=function(b,c,e,f){ja=b;wa=c;ma=e;na=f;o.viewport(ja,wa,ma,na)};this.setScissor=function(b,c,e,f){o.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(b,c){R.setHex(b);la=c;o.clearColor(R.r,R.g,R.b,la)};this.setClearColor=function(b,c){R.copy(b);la=c;o.clearColor(R.r,R.g,R.b, +la)};this.getClearColor=function(){return R};this.getClearAlpha=function(){return la};this.clear=function(b,c,e){var f=0;if(b==void 0||b)f|=o.COLOR_BUFFER_BIT;if(c==void 0||c)f|=o.DEPTH_BUFFER_BIT;if(e==void 0||e)f|=o.STENCIL_BUFFER_BIT;o.clear(f)};this.getContext=function(){return o};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c= +b.geometry.geometryGroups[g];o.deleteBuffer(c.__webglVertexBuffer);o.deleteBuffer(c.__webglNormalBuffer);o.deleteBuffer(c.__webglTangentBuffer);o.deleteBuffer(c.__webglColorBuffer);o.deleteBuffer(c.__webglUVBuffer);o.deleteBuffer(c.__webglUV2Buffer);o.deleteBuffer(c.__webglSkinVertexABuffer);o.deleteBuffer(c.__webglSkinVertexBBuffer);o.deleteBuffer(c.__webglSkinIndicesBuffer);o.deleteBuffer(c.__webglSkinWeightsBuffer);o.deleteBuffer(c.__webglFaceBuffer);o.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var e= +0,f=c.numMorphTargets;e=0&&p.enableVertexAttribArray(x.position);x.color>=0&&p.enableVertexAttribArray(x.color);x.normal>=0&&p.enableVertexAttribArray(x.normal);x.tangent>=0&&p.enableVertexAttribArray(x.tangent);b.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(p.enableVertexAttribArray(x.skinVertexA), -p.enableVertexAttribArray(x.skinVertexB),p.enableVertexAttribArray(x.skinIndex),p.enableVertexAttribArray(x.skinWeight));if(b.attributes)for(h in b.attributes)x[h]!==void 0&&x[h]>=0&&p.enableVertexAttribArray(x[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h=0&&(p.enableVertexAttribArray(x[L]),b.numSupportedMorphTargets++);b.uniformsList=[];for(k in b.uniforms)b.uniformsList.push([b.uniforms[k],k])};this.clearTarget=function(b,c,e,f){H(b); -this.clear(c,e,f)};this.render=function(b,c,o,L){var M,fa,F,C,G,qa,B,la,J=b.lights,ca=b.fog;ha=-1;this.shadowMapEnabled&&y(b,c);S.info.render.calls=0;S.info.render.vertices=0;S.info.render.faces=0;if(c.matrixAutoUpdate){for(G=c;G.parent;)G=G.parent;G.update(void 0,!0)}b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Fa);c.projectionMatrix.flattenToArray(Ga);Ca.multiply(c.projectionMatrix,c.matrixWorldInverse);u(Ca);this.initWebGLObjects(b);H(o);(this.autoClear||L)&&this.clear(this.autoClearColor, -this.autoClearDepth,this.autoClearStencil);G=b.__webglObjects.length;for(L=0;L=0;L--)if(M=b.__webglObjects[L],M.render){B=M.object;la=M.buffer;F=M.opaque;k(B);for(M=0;M0||x.faceVertexUvs.length>0)m.__uvArray=new Float32Array(o*2);if(x.faceUvs.length>1||x.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(o*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray= -new Float32Array(o*4),m.__skinVertexBArray=new Float32Array(o*4),m.__skinIndexArray=new Float32Array(o*4),m.__skinWeightArray=new Float32Array(o*4);m.__faceArray=new Uint16Array(y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(z*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];x=0;for(L=m.numMorphTargets;x=0;h--)f[h]==k&&f.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0, -1)}e=0;for(f=b.__webglObjects.length;e0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglColorBuffer),p.bufferData(p.ARRAY_BUFFER,da,y));Ga&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglNormalBuffer),p.bufferData(p.ARRAY_BUFFER,ga,y));Da&&va.hasTangents&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglTangentBuffer),p.bufferData(p.ARRAY_BUFFER,ha,y));Ha&&ra>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglUVBuffer),p.bufferData(p.ARRAY_BUFFER,ia,y));Ha&&T>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglUV2Buffer),p.bufferData(p.ARRAY_BUFFER,Ea,y));Ca&&(p.bindBuffer(p.ELEMENT_ARRAY_BUFFER, -t.__webglFaceBuffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,Ba,y),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,ta,y));R>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinVertexABuffer),p.bufferData(p.ARRAY_BUFFER,ja,y),p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinVertexBBuffer),p.bufferData(p.ARRAY_BUFFER,sa,y),p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),p.bufferData(p.ARRAY_BUFFER,aa,y),p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),p.bufferData(p.ARRAY_BUFFER, -ea,y));z&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray,delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinVertexAArray,delete t.__skinVertexBArray,delete t.__skinIndexArray,delete t.__skinWeightArray)}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyTangents=!1;k.__dirtyColors=!1;C(m)}else if(h instanceof THREE.Ribbon){k= -h.geometry;if(k.__dirtyVertices||k.__dirtyColors){h=k;m=p.DYNAMIC_DRAW;n=x=z=z=void 0;u=h.vertices;o=h.colors;v=u.length;t=o.length;L=h.__vertexArray;y=h.__colorArray;M=h.__dirtyColors;if(h.__dirtyVertices){for(z=0;z=0&&o.enableVertexAttribArray(y.position);y.color>=0&&o.enableVertexAttribArray(y.color);y.normal>=0&&o.enableVertexAttribArray(y.normal);y.tangent>=0&&o.enableVertexAttribArray(y.tangent);b.skinning&&y.skinVertexA>=0&&y.skinVertexB>=0&&y.skinIndex>=0&&y.skinWeight>=0&&(o.enableVertexAttribArray(y.skinVertexA), +o.enableVertexAttribArray(y.skinVertexB),o.enableVertexAttribArray(y.skinIndex),o.enableVertexAttribArray(y.skinWeight));if(b.attributes)for(k in b.attributes)y[k]!==void 0&&y[k]>=0&&o.enableVertexAttribArray(y[k]);if(b.morphTargets)for(k=b.numSupportedMorphTargets=0;k=0&&(o.enableVertexAttribArray(y[z]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,c,e,f){L(b); +this.clear(c,e,f)};this.render=function(b,e,v,ea){var V,U,B,C,G,pa,K,I,la=b.lights,J=b.fog;ca=-1;this.shadowMapEnabled&&y(b,e);P.info.render.calls=0;P.info.render.vertices=0;P.info.render.faces=0;if(e.matrixAutoUpdate){for(G=e;G.parent;)G=G.parent;G.update(void 0,!0)}b.update(void 0,!1,e);THREE.Matrix4.makeInvert(e.matrixWorld,e.matrixWorldInverse);e.matrixWorldInverse.flattenToArray(Fa);e.projectionMatrix.flattenToArray(Ha);ua.multiply(e.projectionMatrix,e.matrixWorldInverse);t(ua);this.initWebGLObjects(b); +L(v);(this.autoClear||ea)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);G=b.__webglObjects.length;for(ea=0;ea=0;ea--)if(V=b.__webglObjects[ea],V.render){K=V.object;I=V.buffer;B=V.opaque;h(K);for(V=0;V0||y.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(y.faceUvs.length>1||y.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(n.geometry.skinWeights.length&& +n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(z*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(ea*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];y=0;for(x=m.numMorphTargets;y=0;k--)f[k]==h&&f.splice(k,1)}else(c instanceof THREE.MarchingCubes||c.immediateRenderCallback)&& +G(f.__webglObjectsImmediate,c);c.__webglActive=!1;b.__objectsRemoved.splice(0,1)}c=0;for(f=b.__webglObjects.length;c0&&(o.bindBuffer(o.ARRAY_BUFFER, +t.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,fa,z));va&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,ga,z));Ha&&ua.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,$,z));Ga&&Z>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,ha,z));Ga&&wa>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,xa,z));La&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer), +o.bufferData(o.ELEMENT_ARRAY_BUFFER,qa,z),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,Aa,z));S>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,na,z),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,da,z),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ka,z),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER, +ia,z));ea&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray,delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinVertexAArray,delete t.__skinVertexBArray,delete t.__skinIndexArray,delete t.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;B(m)}else if(k instanceof THREE.Ribbon){h= +k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=y=ea=ea=void 0;w=k.vertices;p=k.colors;u=w.length;t=p.length;x=k.__vertexArray;z=k.__colorArray;A=k.__dirtyColors;if(k.__dirtyVertices){for(ea=0;ea1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=m;c.v=k;return c}, -clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(b,c){var e,f,h=b.vertices.length,k=c instanceof THREE.Mesh?c.geometry:c,m=b.vertices,n=k.vertices,t=b.faces,u=k.faces,w=b.faceVertexUvs[0],k=k.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),e=c.matrix,f=new THREE.Matrix4,f.extractRotation(e,c.scale);for(var o=0,x=n.length;o1&&(f=1-f,h=1-h);k=1-f-h;m.copy(b);m.multiplyScalar(f);n.copy(c);n.multiplyScalar(h);m.addSelf(n);n.copy(e);n.multiplyScalar(k);m.addSelf(n);return m},randomPointInFace:function(b,c,e){var f,h,k;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,k=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,k);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;k=c.vertices[b.c].position;var c=c.vertices[b.d].position, -m;e?b._area1&&b._area2?(e=b._area1,m=b._area2):(e=THREE.GeometryUtils.triangleArea(f,h,c),m=THREE.GeometryUtils.triangleArea(h,k,c),b._area1=e,b._area2=m):(e=THREE.GeometryUtils.triangleArea(f,h,c),m=THREE.GeometryUtils.triangleArea(h,k,c));return THREE.GeometryUtils.random()*(e+m) -b?c(e,k-1):u[k]1&&(c-=1)}e===void 0&&(e={h:0,s:0,v:0});e.h=c;e.s=k;e.v=h;return e}, +clamp:function(b,e,c){return bc?c:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; +THREE.GeometryUtils={merge:function(b,e){var c,f,m=b.vertices.length,h=e instanceof THREE.Mesh?e.geometry:e,k=b.vertices,n=h.vertices,p=b.faces,t=h.faces,u=b.faceVertexUvs[0],h=h.faceVertexUvs[0];if(e instanceof THREE.Mesh)e.matrixAutoUpdate&&e.updateMatrix(),c=e.matrix,f=new THREE.Matrix4,f.extractRotation(c,e.scale);for(var v=0,x=n.length;v1&&(f=1-f,m=1-m);h=1-f-m;k.copy(b);k.multiplyScalar(f);n.copy(e);n.multiplyScalar(m);k.addSelf(n);n.copy(c);n.multiplyScalar(h);k.addSelf(n);return k},randomPointInFace:function(b,e,c){var f,m,h;if(b instanceof THREE.Face3)return f=e.vertices[b.a].position,m=e.vertices[b.b].position,h=e.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,m,h);else if(b instanceof THREE.Face4){f=e.vertices[b.a].position;m=e.vertices[b.b].position;h=e.vertices[b.c].position;var e=e.vertices[b.d].position, +k;c?b._area1&&b._area2?(c=b._area1,k=b._area2):(c=THREE.GeometryUtils.triangleArea(f,m,e),k=THREE.GeometryUtils.triangleArea(m,h,e),b._area1=c,b._area2=k):(c=THREE.GeometryUtils.triangleArea(f,m,e),k=THREE.GeometryUtils.triangleArea(m,h,e));return THREE.GeometryUtils.random()*(c+k) +b?c(e,h-1):t[h] 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif", THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}}; -THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPoint(c/b));return e};THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPointAt(c/b));return e}; -THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==b+1)return this.cacheArcLengths;var c=[],e,f=this.getPoint(0),h,k=0;c.push(0);for(h=1;h<=b;h++)e=this.getPoint(h/b),k+=e.distanceTo(f),c.push(k),f=e;return this.cacheArcLengths=c}; -THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,h=e.length,k;k=c?c:b*e[h-1];time=Date.now();for(var m=0,n=h-1,t;m<=n;)if(f=Math.floor(m+(n-m)/2),t=e[f]-k,t<0)m=f+1;else if(t>0)n=f-1;else{n=f;break}f=n;if(e[f]==k)return f/(h-1);m=e[f];return e=(f+(k-m)/(e[f+1]-m))/(h-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; -THREE.Curve.prototype.getTangent=function(b){var c=b-1.0E-4;b+=1.0E-4;c<0&&(c=0);b>1&&(b=1);var c=this.getPoint(c),b=this.getPoint(b),e=new THREE.Vector2;e.sub(b,c);return e.unit()};THREE.LineCurve=function(b,c){b instanceof THREE.Vector2?(this.v1=b,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(b,c,e,f){this.constructor(new THREE.Vector2(b,c),new THREE.Vector2(e,f))};THREE.LineCurve.prototype=new THREE.Curve; -THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(b).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(b){return this.getPoint(b)};THREE.LineCurve.prototype.getTangent=function(){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.normalize();return b}; -THREE.QuadraticBezierCurve=function(b,c,e){if(!(c instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),b=new THREE.Vector2(f[0],f[1]),c=new THREE.Vector2(f[2],f[3]),e=new THREE.Vector2(f[4],f[5]);this.v0=b;this.v1=c;this.v2=e};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; -THREE.QuadraticBezierCurve.prototype.getPoint=function(b){var c;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(c,b)};THREE.QuadraticBezierCurve.prototype.getTangent=function(b){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(b,this.v0.x,this.v1.x,this.v2.x);b=THREE.Curve.Utils.tangentQuadraticBezier(b,this.v0.y,this.v1.y,this.v2.y);c=new THREE.Vector2(c,b);c.normalize();return c}; -THREE.CubicBezierCurve=function(b,c,e,f){if(!(c instanceof THREE.Vector2))var h=Array.prototype.slice.call(arguments),b=new THREE.Vector2(h[0],h[1]),c=new THREE.Vector2(h[2],h[3]),e=new THREE.Vector2(h[4],h[5]),f=new THREE.Vector2(h[6],h[7]);this.v0=b;this.v1=c;this.v2=e;this.v3=f};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; -THREE.CubicBezierCurve.prototype.getPoint=function(b){var c;c=THREE.Shape.Utils.b3(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(c,b)};THREE.CubicBezierCurve.prototype.getTangent=function(b){var c;c=THREE.Curve.Utils.tangentCubicBezier(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Curve.Utils.tangentCubicBezier(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);c=new THREE.Vector2(c,b);c.normalize();return c}; +THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var e,c=[];for(e=0;e<=b;e++)c.push(this.getPoint(e/b));return c};THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var e,c=[];for(e=0;e<=b;e++)c.push(this.getPointAt(e/b));return c}; +THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==b+1)return this.cacheArcLengths;var e=[],c,f=this.getPoint(0),m,h=0;e.push(0);for(m=1;m<=b;m++)c=this.getPoint(m/b),h+=c.distanceTo(f),e.push(h),f=c;return this.cacheArcLengths=e}; +THREE.Curve.prototype.getUtoTmapping=function(b,e){var c=this.getLengths(),f=0,m=c.length,h;h=e?e:b*c[m-1];time=Date.now();for(var k=0,n=m-1,p;k<=n;)if(f=Math.floor(k+(n-k)/2),p=c[f]-h,p<0)k=f+1;else if(p>0)n=f-1;else{n=f;break}f=n;if(c[f]==h)return f/(m-1);k=c[f];return c=(f+(h-k)/(c[f+1]-k))/(m-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; +THREE.Curve.prototype.getTangent=function(b){var e=b-1.0E-4;b+=1.0E-4;e<0&&(e=0);b>1&&(b=1);var e=this.getPoint(e),b=this.getPoint(b),c=new THREE.Vector2;c.sub(b,e);return c.unit()};THREE.LineCurve=function(b,e){b instanceof THREE.Vector2?(this.v1=b,this.v2=e):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(b,e,c,f){this.constructor(new THREE.Vector2(b,e),new THREE.Vector2(c,f))};THREE.LineCurve.prototype=new THREE.Curve; +THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){var e=new THREE.Vector2;e.sub(this.v2,this.v1);e.multiplyScalar(b).addSelf(this.v1);return e};THREE.LineCurve.prototype.getPointAt=function(b){return this.getPoint(b)};THREE.LineCurve.prototype.getTangent=function(){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.normalize();return b}; +THREE.QuadraticBezierCurve=function(b,e,c){if(!(e instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),b=new THREE.Vector2(f[0],f[1]),e=new THREE.Vector2(f[2],f[3]),c=new THREE.Vector2(f[4],f[5]);this.v0=b;this.v1=e;this.v2=c};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; +THREE.QuadraticBezierCurve.prototype.getPoint=function(b){var e;e=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(e,b)};THREE.QuadraticBezierCurve.prototype.getTangent=function(b){var e;e=THREE.Curve.Utils.tangentQuadraticBezier(b,this.v0.x,this.v1.x,this.v2.x);b=THREE.Curve.Utils.tangentQuadraticBezier(b,this.v0.y,this.v1.y,this.v2.y);e=new THREE.Vector2(e,b);e.normalize();return e}; +THREE.CubicBezierCurve=function(b,e,c,f){if(!(e instanceof THREE.Vector2))var m=Array.prototype.slice.call(arguments),b=new THREE.Vector2(m[0],m[1]),e=new THREE.Vector2(m[2],m[3]),c=new THREE.Vector2(m[4],m[5]),f=new THREE.Vector2(m[6],m[7]);this.v0=b;this.v1=e;this.v2=c;this.v3=f};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; +THREE.CubicBezierCurve.prototype.getPoint=function(b){var e;e=THREE.Shape.Utils.b3(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(e,b)};THREE.CubicBezierCurve.prototype.getTangent=function(b){var e;e=THREE.Curve.Utils.tangentCubicBezier(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Curve.Utils.tangentCubicBezier(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);e=new THREE.Vector2(e,b);e.normalize();return e}; THREE.SplineCurve=function(b){this.points=b};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve; -THREE.SplineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2,e=[],f=this.points,h;h=(f.length-1)*b;b=Math.floor(h);h-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,h);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,h);return c};THREE.ArcCurve=function(b,c,e,f,h,k){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=h;this.aClockwise=k}; -THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(b){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(b=1-b);b=this.aStartAngle+b*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(b),this.aY+this.aRadius*Math.sin(b))}; -THREE.Curve.Utils={tangentQuadraticBezier:function(b,c,e,f){return 2*(1-b)*(e-c)+2*b*(f-e)},tangentCubicBezier:function(b,c,e,f,h){return-3*c*(1-b)*(1-b)+3*e*(1-b)*(1-b)-6*b*e*(1-b)+6*b*f*(1-b)-3*b*b*f+3*b*b*h},tangentSpline:function(b){return 6*b*b-6*b+(3*b*b-4*b+1)+(-6*b*b+6*b)+(3*b*b-2*b)},interpolate:function(b,c,e,f,h){var b=(e-b)*0.5,f=(f-c)*0.5,k=h*h;return(2*c-2*e+b+f)*h*k+(-3*c+3*e-2*b-f)*k+b*h+c}}; -THREE.Curve.create=function(b,c){b.prototype=new THREE.Curve;b.prototype.constructor=b;b.prototype.getPoint=c;return b};THREE.LineCurve3=THREE.Curve.create(function(b,c){this.v1=b;this.v2=c},function(b){var c=new THREE.Vector3;c.sub(v2,v1);c.multiplyScalar(b);c.addSelf(this.v1);return c}); -THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,c,e){this.v0=b;this.v1=c;this.v2=e},function(b){var c,e;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);e=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,e,b)}); -THREE.CubicBezierCurve3=THREE.Curve.create(function(b,c,e,f){this.v0=b;this.v1=c;this.v2=e;this.v3=f},function(b){var c,e;c=THREE.Shape.Utils.b3(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);e=THREE.Shape.Utils.b3(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=THREE.Shape.Utils.b3(b,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(c,e,b)}); -THREE.SplineCurve3=THREE.Curve.create(function(b){this.points=b},function(b){var c=new THREE.Vector3,e=[],f=this.points,h;h=(f.length-1)*b;b=Math.floor(h);h-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,h);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,h);c.z=THREE.Curve.Utils.interpolate(f[e[0]].z,f[e[1]].z,f[e[2]].z,f[e[3]].z,h);return c}); +THREE.SplineCurve.prototype.getPoint=function(b){var e=new THREE.Vector2,c=[],f=this.points,m;m=(f.length-1)*b;b=Math.floor(m);m-=b;c[0]=b==0?b:b-1;c[1]=b;c[2]=b>f.length-2?b:b+1;c[3]=b>f.length-3?b:b+2;e.x=THREE.Curve.Utils.interpolate(f[c[0]].x,f[c[1]].x,f[c[2]].x,f[c[3]].x,m);e.y=THREE.Curve.Utils.interpolate(f[c[0]].y,f[c[1]].y,f[c[2]].y,f[c[3]].y,m);return e};THREE.ArcCurve=function(b,e,c,f,m,h){this.aX=b;this.aY=e;this.aRadius=c;this.aStartAngle=f;this.aEndAngle=m;this.aClockwise=h}; +THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(b){var e=this.aEndAngle-this.aStartAngle;this.aClockwise||(b=1-b);b=this.aStartAngle+b*e;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(b),this.aY+this.aRadius*Math.sin(b))}; +THREE.Curve.Utils={tangentQuadraticBezier:function(b,e,c,f){return 2*(1-b)*(c-e)+2*b*(f-c)},tangentCubicBezier:function(b,e,c,f,m){return-3*e*(1-b)*(1-b)+3*c*(1-b)*(1-b)-6*b*c*(1-b)+6*b*f*(1-b)-3*b*b*f+3*b*b*m},tangentSpline:function(b){return 6*b*b-6*b+(3*b*b-4*b+1)+(-6*b*b+6*b)+(3*b*b-2*b)},interpolate:function(b,e,c,f,m){var b=(c-b)*0.5,f=(f-e)*0.5,h=m*m;return(2*e-2*c+b+f)*m*h+(-3*e+3*c-2*b-f)*h+b*m+e}}; +THREE.Curve.create=function(b,e){b.prototype=new THREE.Curve;b.prototype.constructor=b;b.prototype.getPoint=e;return b};THREE.LineCurve3=THREE.Curve.create(function(b,e){this.v1=b;this.v2=e},function(b){var e=new THREE.Vector3;e.sub(v2,v1);e.multiplyScalar(b);e.addSelf(this.v1);return e}); +THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,e,c){this.v0=b;this.v1=e;this.v2=c},function(b){var e,c;e=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(e,c,b)}); +THREE.CubicBezierCurve3=THREE.Curve.create(function(b,e,c,f){this.v0=b;this.v1=e;this.v2=c;this.v3=f},function(b){var e,c;e=THREE.Shape.Utils.b3(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=THREE.Shape.Utils.b3(b,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(e,c,b)}); +THREE.SplineCurve3=THREE.Curve.create(function(b){this.points=b},function(b){var e=new THREE.Vector3,c=[],f=this.points,m;m=(f.length-1)*b;b=Math.floor(m);m-=b;c[0]=b==0?b:b-1;c[1]=b;c[2]=b>f.length-2?b:b+1;c[3]=b>f.length-3?b:b+2;e.x=THREE.Curve.Utils.interpolate(f[c[0]].x,f[c[1]].x,f[c[2]].x,f[c[3]].x,m);e.y=THREE.Curve.Utils.interpolate(f[c[0]].y,f[c[1]].y,f[c[2]].y,f[c[3]].y,m);e.z=THREE.Curve.Utils.interpolate(f[c[0]].z,f[c[1]].z,f[c[2]].z,f[c[3]].z,m);return e}); THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(b){this.curves.push(b)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){}; -THREE.CurvePath.prototype.getPoint=function(b){for(var c=b*this.getLength(),e=this.getCurveLengths(),b=0;b=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null};THREE.CurvePath.prototype.getLength=function(){var b=this.getCurveLengths();return b[b.length-1]}; -THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var b=[],c=0,e,f=this.curves.length;for(e=0;ec)c=k.x;else if(k.xe)e=k.y;else if(k.y0?(m=e[e.length-1],v=m.x,z=m.y):(m=this.actions[f-1].args,v=m[m.length-2],z=m[m.length-1]);for(m=1;m<=b;m++)y=m/b,k=THREE.Shape.Utils.b2(y,v,o,n),y=THREE.Shape.Utils.b2(y,z,x, -t),e.push(new THREE.Vector2(k,y));break;case THREE.PathActions.BEZIER_CURVE_TO:n=k[4];t=k[5];o=k[0];x=k[1];u=k[2];w=k[3];e.length>0?(m=e[e.length-1],v=m.x,z=m.y):(m=this.actions[f-1].args,v=m[m.length-2],z=m[m.length-1]);for(m=1;m<=b;m++)y=m/b,k=THREE.Shape.Utils.b3(y,v,o,u,n),y=THREE.Shape.Utils.b3(y,z,x,w,t),e.push(new THREE.Vector2(k,y));break;case THREE.PathActions.CSPLINE_THRU:m=this.actions[f-1].args;m=[new THREE.Vector2(m[m.length-2],m[m.length-1])];y=b*k[0].length;m=m.concat(k[0]);k=new THREE.SplineCurve(m); -for(m=1;m<=y;m++)e.push(k.getPointAt(m/y));break;case THREE.PathActions.ARC:m=this.actions[f-1].args;n=k[0];t=k[1];u=k[2];o=k[3];y=k[4];x=!!k[5];w=m[m.length-2];v=m[m.length-1];m.length==0&&(w=v=0);z=y-o;var A=b*2;for(m=1;m<=A;m++)y=m/A,x||(y=1-y),y=o+y*z,k=w+n+u*Math.cos(y),y=v+t+u*Math.sin(y),e.push(new THREE.Vector2(k,y))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; -THREE.Path.prototype.nltransform=function(b,c,e,f,h,k){var m=this.getPoints(),n,t,u,w,o;n=0;for(t=m.length;n=e)return e=c[b]-e,b=this.curves[b],e=1-e/b.getLength(),b.getPointAt(e);b++}return null};THREE.CurvePath.prototype.getLength=function(){var b=this.getCurveLengths();return b[b.length-1]}; +THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var b=[],e=0,c,f=this.curves.length;for(c=0;ce)e=h.x;else if(h.xc)c=h.y;else if(h.y0?(k=c[c.length-1],w=k.x,A=k.y):(k=this.actions[f-1].args,w=k[k.length-2],A=k[k.length-1]);for(k=1;k<=b;k++)y=k/b,h=THREE.Shape.Utils.b2(y,w,v,n),y=THREE.Shape.Utils.b2(y,A,x, +p),c.push(new THREE.Vector2(h,y));break;case THREE.PathActions.BEZIER_CURVE_TO:n=h[4];p=h[5];v=h[0];x=h[1];t=h[2];u=h[3];c.length>0?(k=c[c.length-1],w=k.x,A=k.y):(k=this.actions[f-1].args,w=k[k.length-2],A=k[k.length-1]);for(k=1;k<=b;k++)y=k/b,h=THREE.Shape.Utils.b3(y,w,v,t,n),y=THREE.Shape.Utils.b3(y,A,x,u,p),c.push(new THREE.Vector2(h,y));break;case THREE.PathActions.CSPLINE_THRU:k=this.actions[f-1].args;k=[new THREE.Vector2(k[k.length-2],k[k.length-1])];y=b*h[0].length;k=k.concat(h[0]);h=new THREE.SplineCurve(k); +for(k=1;k<=y;k++)c.push(h.getPointAt(k/y));break;case THREE.PathActions.ARC:k=this.actions[f-1].args;n=h[0];p=h[1];t=h[2];v=h[3];y=h[4];x=!!h[5];u=k[k.length-2];w=k[k.length-1];k.length==0&&(u=w=0);A=y-v;var z=b*2;for(k=1;k<=z;k++)y=k/z,x||(y=1-y),y=v+y*A,h=u+n+t*Math.cos(y),y=w+p+t*Math.sin(y),c.push(new THREE.Vector2(h,y))}e&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(b,e){this.getBoundingBox();return this.getWrapPoints(this.getPoints(e),b)}; +THREE.Path.prototype.nltransform=function(b,e,c,f,m,h){var k=this.getPoints(),n,p,t,u,v;n=0;for(p=k.length;n=0?n-1:e.length-1;k=m-1>=0?m-1:u.length-1;var y=[u[m],e[n],e[h]];o=THREE.FontUtils.Triangulate.area(y);var A=[u[m],u[k],e[n]];x=THREE.FontUtils.Triangulate.area(A);v=n;w=m;n+=1;m+=-1;n< -0&&(n+=e.length);n%=e.length;m<0&&(m+=u.length);m%=u.length;h=n-1>=0?n-1:e.length-1;k=m-1>=0?m-1:u.length-1;y=[u[m],e[n],e[h]];y=THREE.FontUtils.Triangulate.area(y);A=[u[m],u[k],e[n]];A=THREE.FontUtils.Triangulate.area(A);o+x>y+A&&(n=v,m=w,n<0&&(n+=e.length),n%=e.length,m<0&&(m+=u.length),m%=u.length,h=n-1>=0?n-1:e.length-1,k=m-1>=0?m-1:u.length-1);o=e.slice(0,n);x=e.slice(n);v=u.slice(m);w=u.slice(0,m);k=[u[m],u[k],e[n]];z.push([u[m],e[n],e[h]]);z.push(k);e=o.concat(v).concat(w).concat(x)}return{shape:e, -isolatedPts:z,allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),k,m,n,t,u={};k=0;for(m=f.length;k=0?n-1:c.length-1;h=k-1>=0?k-1:t.length-1;var y=[t[k],c[n],c[m]];v=THREE.FontUtils.Triangulate.area(y);var z=[t[k],t[h],c[n]];x=THREE.FontUtils.Triangulate.area(z);w=n;u=k;n+=1;k+=-1;n< +0&&(n+=c.length);n%=c.length;k<0&&(k+=t.length);k%=t.length;m=n-1>=0?n-1:c.length-1;h=k-1>=0?k-1:t.length-1;y=[t[k],c[n],c[m]];y=THREE.FontUtils.Triangulate.area(y);z=[t[k],t[h],c[n]];z=THREE.FontUtils.Triangulate.area(z);v+x>y+z&&(n=w,k=u,n<0&&(n+=c.length),n%=c.length,k<0&&(k+=t.length),k%=t.length,m=n-1>=0?n-1:c.length-1,h=k-1>=0?k-1:t.length-1);v=c.slice(0,n);x=c.slice(n);w=t.slice(k);u=t.slice(0,k);h=[t[k],t[h],c[n]];A.push([t[k],c[n],c[m]]);A.push(h);c=v.concat(w).concat(u).concat(x)}return{shape:c, +isolatedPts:A,allpoints:f}},triangulateShape:function(b,e){var c=THREE.Shape.Utils.removeHoles(b,e),f=c.allpoints,m=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),h,k,n,p,t={};h=0;for(k=f.length;h1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",v,m.index-1).pos,this.points[1]=h,this.points[2]=k,this.points[3]=this.getNextKeyWith("pos",v,n.index+1).pos,f=f*0.33+0.33,h=this.interpolateCatmullRom(this.points,f),e.x=h[0],e.y=h[1],e.z=h[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== -"rot")THREE.Quaternion.slerp(h,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f}}if(this.JITCompile&&w[0][u]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];n=b[e[1]];t=b[e[2]];u=b[e[3]];e=h*h;m=h*e;f[0]=this.interpolate(k[0],n[0],t[0],u[0],h,e,m);f[1]=this.interpolate(k[1],n[1],t[1],u[1],h,e,m);f[2]=this.interpolate(k[2],n[2],t[2],u[2],h,e,m);return f}; -THREE.Animation.prototype.interpolate=function(b,c,e,f,h,k,m){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*m+(-3*(c-e)-2*b-f)*k+b*h+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]}; -THREE.CubeCamera=function(b,c,e,f){this.heightOffset=e;this.position=new THREE.Vector3(0,e,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,b,c);this.cameraNX=new THREE.PerspectiveCamera(90,1,b,c);this.cameraPY=new THREE.PerspectiveCamera(90,1,b,c);this.cameraNY=new THREE.PerspectiveCamera(90,1,b,c);this.cameraPZ=new THREE.PerspectiveCamera(90,1,b,c);this.cameraNZ=new THREE.PerspectiveCamera(90,1,b,c);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= +THREE.Animation.prototype.update=function(b){if(this.isPlaying){var e=["pos","rot","scl"],c,f,m,h,k,n,p,t,u=this.data.JIT.hierarchy,v,x;this.currentTime+=b*this.timeScale;x=this.currentTime;v=this.currentTime%=this.data.length;t=parseInt(Math.min(v*this.data.fps,this.data.length*this.data.fps),10);for(var w=0,A=this.hierarchy.length;w1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+w),f=f<0?0:1;if(c==="pos")if(c=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=m[0]+(h[0]-m[0])*f,c.y=m[1]+(h[1]-m[1])*f,c.z=m[2]+(h[2]-m[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",w,k.index-1).pos,this.points[1]=m,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",w,n.index+1).pos,f=f*0.33+0.33,m=this.interpolateCatmullRom(this.points,f),c.x=m[0],c.y=m[1],c.z=m[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(c=== +"rot")THREE.Quaternion.slerp(m,h,b.quaternion,f);else if(c==="scl")c=b.scale,c.x=m[0]+(h[0]-m[0])*f,c.y=m[1]+(h[1]-m[1])*f,c.z=m[2]+(h[2]-m[2])*f}}if(this.JITCompile&&u[0][t]===void 0){this.hierarchy[0].update(void 0,!0);for(w=0;wb.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];n=b[c[1]];p=b[c[2]];t=b[c[3]];c=m*m;k=m*c;f[0]=this.interpolate(h[0],n[0],p[0],t[0],m,c,k);f[1]=this.interpolate(h[1],n[1],p[1],t[1],m,c,k);f[2]=this.interpolate(h[2],n[2],p[2],t[2],m,c,k);return f}; +THREE.Animation.prototype.interpolate=function(b,e,c,f,m,h,k){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*k+(-3*(e-c)-2*b-f)*h+b*m+e};THREE.Animation.prototype.getNextKeyWith=function(b,e,c){var f=this.data.hierarchy[e].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==void 0)return f[c];return this.data.hierarchy[e].keys[f.length-1]}; +THREE.CubeCamera=function(b,e,c,f){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,b,e);this.cameraNX=new THREE.PerspectiveCamera(90,1,b,e);this.cameraPY=new THREE.PerspectiveCamera(90,1,b,e);this.cameraNY=new THREE.PerspectiveCamera(90,1,b,e);this.cameraPZ=new THREE.PerspectiveCamera(90,1,b,e);this.cameraNZ=new THREE.PerspectiveCamera(90,1,b,e);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ= new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(f,f,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(b){this.position.copy(b);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+= -1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(b,e){var c=this.renderTarget;c.activeCubeFace=0;b.render(e,this.cameraPX,c);c.activeCubeFace=1;b.render(e,this.cameraNX,c);c.activeCubeFace=2;b.render(e,this.cameraPY,c);c.activeCubeFace=3;b.render(e, -this.cameraNY,c);c.activeCubeFace=4;b.render(e,this.cameraPZ,c);c.activeCubeFace=5;b.render(e,this.cameraNZ,c)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; -THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(b,c,e,f,h,k,m){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(b/-2,b/2,c/2,c/-2,k,m);this.cameraP=new THREE.PerspectiveCamera(e,b/c,f,h);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; +1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(b,c){var e=this.renderTarget;e.activeCubeFace=0;b.render(c,this.cameraPX,e);e.activeCubeFace=1;b.render(c,this.cameraNX,e);e.activeCubeFace=2;b.render(c,this.cameraPY,e);e.activeCubeFace=3;b.render(c, +this.cameraNY,e);e.activeCubeFace=4;b.render(c,this.cameraPZ,e);e.activeCubeFace=5;b.render(c,this.cameraNZ,e)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; +THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(b,e,c,f,m,h,k){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(b/-2,b/2,e/2,e/-2,h,k);this.cameraP=new THREE.PerspectiveCamera(c,b/e,f,m);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.projectionMatrix=this.cameraP.projectionMatrix};THREE.CombinedCamera.prototype.toOrthographic=function(){this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix};THREE.CombinedCamera.prototype.setFov=function(b){this.cameraP.fov=b;this.cameraP.updateProjectionMatrix();this.toPerspective()}; -THREE.CombinedCamera.prototype.setLens=function(b,c){c||(c=43.25);var e=2*Math.atan(c/(b*2));e*=180/Math.PI;this.setFov(e);return e}; -THREE.FirstPersonControls=function(b,c){function e(b,e){return function(){e.apply(b,arguments)}}this.object=b;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.lastUpdate=(new Date).getTime();this.theta=this.phi=this.lon=this.lat= +THREE.CombinedCamera.prototype.setLens=function(b,e){e||(e=43.25);var c=2*Math.atan(e/(b*2));c*=180/Math.PI;this.setFov(c);return c}; +THREE.FirstPersonControls=function(b,e){function c(b,c){return function(){c.apply(b,arguments)}}this.object=b;this.target=new THREE.Vector3(0,0,0);this.domElement=e!==void 0?e:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.lastUpdate=(new Date).getTime();this.theta=this.phi=this.lon=this.lat= this.mouseY=this.mouseX=this.autoSpeedFactor=this.tdiff=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(b){this.domElement!==document&&this.domElement.focus();b.preventDefault();b.stopPropagation(); if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY= b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward= -!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.object.position.ythis.heightMax?this.heightMax:this.object.position.y)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&& -!this.moveBackward)&&this.object.translateZ(-(e+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(e);this.moveLeft&&this.object.translateX(-e);this.moveRight&&this.object.translateX(e);this.moveUp&&this.object.translateY(e);this.moveDown&&this.object.translateY(-e);e=this.tdiff*this.lookSpeed;this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon* -Math.PI/180;var b=this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax- -this.verticalMin)/(Math.PI-0)+this.verticalMin;b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup", -e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)}; -THREE.PathControls=function(b,c){function e(b){if((b*=2)<1)return 0.5*b*b;return-0.5*(--b*(b-2)-1)}function f(b,e){return function(){e.apply(b,arguments)}}function h(b,e,c,f){var k={name:c,fps:0.6,length:f,hierarchy:[]},h,m=e.getControlPointsArray(),n=e.getLength(),A=m.length,E=0;h=A-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[h]={time:f,pos:m[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;hthis.heightMax?this.heightMax:this.object.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&& +!this.moveBackward)&&this.object.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(c);this.moveLeft&&this.object.translateX(-c);this.moveRight&&this.object.translateX(c);this.moveUp&&this.object.translateY(c);this.moveDown&&this.object.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon* +Math.PI/180;var b=this.target,e=this.object.position;b.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=e.y+100*Math.cos(this.phi);b.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax- +this.verticalMin)/(Math.PI-0)+this.verticalMin;b=this.target;e=this.object.position;b.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=e.y+100*Math.cos(this.phi);b.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup", +c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; +THREE.PathControls=function(b,e){function c(b){if((b*=2)<1)return 0.5*b*b;return-0.5*(--b*(b-2)-1)}function f(b,c){return function(){c.apply(b,arguments)}}function m(b,c,e,f){var h={name:e,fps:0.6,length:f,hierarchy:[]},k,m=c.getControlPointsArray(),n=c.getLength(),z=m.length,E=0;k=z-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[k]={time:f,pos:m[k],rot:[0,0,0,1],scl:[1,1,1]};for(k=1;k=0?b:b+m;b=this.verticalAngleMap.srcRange; -c=this.verticalAngleMap.dstRange;var f=c[1]-c[0];this.phi=e(((this.phi-b[0])*(c[1]-c[0])/(b[1]-b[0])+c[0]-c[0])/f)*f+c[0];b=this.horizontalAngleMap.srcRange;c=this.horizontalAngleMap.dstRange;f=c[1]-c[0];this.theta=e(((this.theta-b[0])*(c[1]-c[0])/(b[1]-b[0])+c[0]-c[0])/f)*f+c[0];b=this.target.position;b.x=100*Math.sin(this.phi)*Math.cos(this.theta);b.y=100*Math.cos(this.phi);b.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(b){this.domElement=== -document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),e=new THREE.MeshLambertMaterial({color:65280}), -c=new THREE.CubeGeometry(10,10,20),m=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,b);b=new THREE.Mesh(m,e);b.position.set(0,10,0);this.animation=h(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(b)}else this.animation=h(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var b= -this.debugPath,e=this.spline,c=k(e,10),m=k(e,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(c,n);particleObj=new THREE.ParticleSystem(m,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.add(lineObj);particleObj.scale.set(1,1,1);b.add(particleObj);m=new THREE.SphereGeometry(1,16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i=0?b:b+k;b=this.verticalAngleMap.srcRange; +e=this.verticalAngleMap.dstRange;var f=e[1]-e[0];this.phi=c(((this.phi-b[0])*(e[1]-e[0])/(b[1]-b[0])+e[0]-e[0])/f)*f+e[0];b=this.horizontalAngleMap.srcRange;e=this.horizontalAngleMap.dstRange;f=e[1]-e[0];this.theta=c(((this.theta-b[0])*(e[1]-e[0])/(b[1]-b[0])+e[0]-e[0])/f)*f+e[0];b=this.target.position;b.x=100*Math.sin(this.phi)*Math.cos(this.theta);b.y=100*Math.cos(this.phi);b.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(b){this.domElement=== +document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),c=new THREE.MeshLambertMaterial({color:65280}), +e=new THREE.CubeGeometry(10,10,20),k=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(e,b);b=new THREE.Mesh(k,c);b.position.set(0,10,0);this.animation=m(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(b)}else this.animation=m(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var b= +this.debugPath,c=this.spline,e=h(c,10),k=h(c,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,n);particleObj=new THREE.ParticleSystem(k,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.add(lineObj);particleObj.scale.set(1,1,1);b.add(particleObj);k=new THREE.SphereGeometry(1,16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i0){var e=this.getContainerDimensions(),c=e.size[0]/2,m=e.size[1]/2;this.moveState.yawLeft=-(b.pageX-e.offset[0]-c)/c;this.moveState.pitchDown=(b.pageY-e.offset[1]-m)/m;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward= -!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,e=this.tdiff*this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*e,this.rotationVector.y*e,this.rotationVector.z*e, +!0;break;case 2:this.object.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),e=c.size[0]/2,k=c.size[1]/2;this.moveState.yawLeft=-(b.pageX-c.offset[0]-e)/e;this.moveState.pitchDown=(b.pageY-c.offset[1]-k)/k;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward= +!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff*this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c, 1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion);this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var b=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back}; this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0, -0]}};this.domElement.addEventListener("mousemove",e(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",e(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",e(this,this.mouseup),!1);this.domElement.addEventListener("keydown",e(this,this.keydown),!1);this.domElement.addEventListener("keyup",e(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; -THREE.RollControls=function(b,c){this.object=b;this.domElement=c!==void 0?c:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Matrix4,m=!1,n=1,t=0,u=0,w=0,o=0,x=0,v=window.innerWidth/2,z=window.innerHeight/2;this.update=function(){var b= -(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*o),this.rotateVertically(b*x));b=this.delta*this.movementSpeed;this.object.translateZ(-b*(t>0||this.autoForward&&!(t<0)?1:t));this.object.translateX(b*u);this.object.translateY(b*w);m&&(this.roll+=this.rollSpeed*this.delta*n);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y1?c.normalize():c.z=Math.sqrt(1-f*f);k.copy(this.object.position).subSelf(this.target);f=this.object.up.clone().setLength(c.y);f.addSelf(this.object.up.clone().crossSelf(k).setLength(c.x));f.addSelf(k.setLength(c.z));return f};this.rotateCamera=function(){var b=Math.acos(m.dot(n)/m.length()/n.length());if(b){var e=(new THREE.Vector3).cross(m,n).normalize(),c=new THREE.Quaternion;b*=this.rotateSpeed;c.setFromAxisAngle(e, --b);c.multiplyVector3(k);c.multiplyVector3(this.object.up);c.multiplyVector3(n);this.staticMoving?m=n:(c.setFromAxisAngle(e,b*(this.dynamicDampingFactor-1)),c.multiplyVector3(m))}};this.zoomCamera=function(){var b=1+(u.y-t.y)*this.zoomSpeed;b!==1&&b>0&&(k.multiplyScalar(b),this.staticMoving?t=u:t.y+=(u.y-t.y)*this.dynamicDampingFactor)};this.panCamera=function(){var b=o.clone().subSelf(w);if(b.lengthSq()){b.multiplyScalar(k.length()*this.panSpeed);var e=k.clone().crossSelf(this.object.up).setLength(b.x); -e.addSelf(this.object.up.clone().setLength(b.y));this.object.position.addSelf(e);this.target.addSelf(e);this.staticMoving?w=o:w.addSelf(b.sub(o,w).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.object.position.lengthSq()>this.maxDistance*this.maxDistance&&this.object.position.setLength(this.maxDistance),k.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,m,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-m,0)));for(n=0;nb&&(b+=Math.PI*2),anglec=(e+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(H=b.length;--H>=0;){ka=H;na=H-1;na<0&&(na=b.length- -1);for(var e=0,c=v+w*2,e=0;e=0;Q--){Z=Q/w;$=t*(1-Z);Z=u*Math.sin(Z*Math.PI/2);H=0;for(T=F.length;H0||this.autoForward&&!(p<0)?1:p));this.object.translateX(b*t);this.object.translateY(b*u);k&&(this.roll+=this.rollSpeed*this.delta*n);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +else if(this.forward.y1?f.normalize():f.z=Math.sqrt(1-h*h);k.copy(c.object.position).subSelf(c.target);h=c.object.up.clone().setLength(f.y);h.addSelf(c.object.up.clone().crossSelf(k).setLength(f.x));h.addSelf(k.setLength(f.z));return h};this.rotateCamera=function(){var b=Math.acos(n.dot(p)/n.length()/p.length());if(b){var e=(new THREE.Vector3).cross(n,p).normalize(),f=new THREE.Quaternion;b*=c.rotateSpeed;f.setFromAxisAngle(e,-b);f.multiplyVector3(k); +f.multiplyVector3(c.object.up);f.multiplyVector3(p);c.staticMoving?n=p:(f.setFromAxisAngle(e,b*(c.dynamicDampingFactor-1)),f.multiplyVector3(n))}};this.zoomCamera=function(){var b=1+(u.y-t.y)*c.zoomSpeed;b!==1&&b>0&&(k.multiplyScalar(b),c.staticMoving?t=u:t.y+=(u.y-t.y)*this.dynamicDampingFactor)};this.panCamera=function(){var b=x.clone().subSelf(v);if(b.lengthSq()){b.multiplyScalar(k.length()*c.panSpeed);var e=k.clone().crossSelf(c.object.up).setLength(b.x);e.addSelf(c.object.up.clone().setLength(b.y)); +c.object.position.addSelf(e);c.target.addSelf(e);c.staticMoving?v=x:v.addSelf(b.sub(x,v).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),k.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(n=0;nb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function m(b){for(L=b.length;--L>=0;){qa=L;sa=L-1;sa<0&&(sa=b.length- +1);for(var c=0,e=w+u*2,c=0;c=0;aa--){Y=aa/u;Q=p*(1-Y);Y=t*Math.sin(Y*Math.PI/2);L=0;for(F=C.length;L0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,n,x)))-1);u.push(w)}c.push(u)}for(var v,z,y,h=c.length,e=0;e0)for(f=0;f1&&(v= -this.vertices[m].position.clone(),z=this.vertices[t].position.clone(),y=this.vertices[u].position.clone(),v.normalize(),z.normalize(),y.normalize(),this.faces.push(new THREE.Face3(m,t,u,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([w,o,A]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(b,e,c){THREE.Geometry.call(this);for(var b=b||50,f,m=Math.PI,h=Math.max(3,e||8),k=Math.max(2,c||6),e=[],c=0;c0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,n,x)))-1);t.push(u)}e.push(t)}for(var w,A,y,m=e.length,c=0;c0)for(f=0;f1&&(w= +this.vertices[k].position.clone(),A=this.vertices[p].position.clone(),y=this.vertices[t].position.clone(),w.normalize(),A.normalize(),y.normalize(),this.faces.push(new THREE.Face3(k,p,t,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([u,v,z]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; -THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var f=e[e.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; +THREE.TextGeometry=function(b,e){var c=(new THREE.TextPath(b,e)).toShapes();e.amount=e.height!==void 0?e.height:50;if(e.bevelThickness===void 0)e.bevelThickness=10;if(e.bevelSize===void 0)e.bevelSize=8;if(e.bevelEnabled===void 0)e.bevelEnabled=!1;if(e.bend){var f=c[c.length-1].getBoundingBox().maxX;e.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,c,e)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; -THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c= -this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),k=h.length,m=[],b=0;b0)for(u=0;u2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return k}t=u;h<=t&&(t=0);u=t+1;h<=u&&(u=0);w=u+1;h<=w&&(w=0);var x;a:{x=b;var v=t,z=u,y=w,A=h,E=m,F=void 0,C=void 0,G=void 0, -J=void 0,O=void 0,K=void 0,B=void 0,N=void 0,Y=void 0,C=x[E[v]].x,G=x[E[v]].y,J=x[E[z]].x,O=x[E[z]].y,K=x[E[y]].x,B=x[E[y]].y;if(1.0E-10>(J-C)*(B-G)-(O-G)*(K-C))x=!1;else{for(F=0;F=0&&Q>=0&&$>=0){x=!1;break a}}x= -!0}}if(x){k.push([b[m[t]],b[m[u]],b[m[w]]]);n.push([m[t],m[u],m[w]]);t=u;for(w=u+1;w0;)this.smooth(b)}; -THREE.SubdivisionModifier.prototype.smooth=function(b){function c(b,e,c,f,n,t){var v=new THREE.Face4(b,e,c,f,null,n.color,n.material);if(m.useOldVertexColors){v.vertexColors=[];for(var u,p,w,x=0;x<4;x++){w=t[x];u=new THREE.Color;u.setRGB(0,0,0);for(var y=0;y0)for(t=0;t2;){if(v--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return h}p=t;m<=p&&(p=0);t=p+1;m<=t&&(t=0);u=t+1;m<=u&&(u=0);var x;a:{x=b;var w=p,A=t,y=u,z=m,E=k,C=void 0,B=void 0,G=void 0, +N=void 0,I=void 0,M=void 0,Z=void 0,J=void 0,O=void 0,B=x[E[w]].x,G=x[E[w]].y,N=x[E[A]].x,I=x[E[A]].y,M=x[E[y]].x,Z=x[E[y]].y;if(1.0E-10>(N-B)*(Z-G)-(I-G)*(M-B))x=!1;else{for(C=0;C=0&&aa>=0&&Q>=0){x=!1; +break a}}x=!0}}if(x){h.push([b[k[p]],b[k[t]],b[k[u]]]);n.push([k[p],k[t],k[u]]);p=t;for(u=t+1;u0;)this.smooth(b)}; +THREE.SubdivisionModifier.prototype.smooth=function(b){function e(b,c,e,f,n,p){var t=new THREE.Face4(b,c,e,f,null,n.color,n.material);if(k.useOldVertexColors){t.vertexColors=[];for(var u,o,w,x=0;x<4;x++){w=p[x];u=new THREE.Color;u.setRGB(0,0,0);for(var y=0;y>7)-127;f|=(h&127)<<16|k<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function h(b,e){var c=w(b,e),f=w(b,e+1),k=w(b,e+2);return(w(b,e+3)<<24)+(k<<16)+(f<<8)+c}function t(b,e){var c=w(b,e);return(w(b,e+1)<<8)+c}function u(b,e){var c=w(b,e);return c>127?c-256:c}function w(b,e){return b.charCodeAt(e)&255}function o(e){var c, -f,k;c=h(b,e);f=h(b,e+O);k=h(b,e+K);e=t(b,e+B);E.faces.push(new THREE.Face3(c,f,k,null,null,E.materials[e]))}function x(e){var c,f,k,m,o,p;c=h(b,e);f=h(b,e+O);k=h(b,e+K);m=t(b,e+B);o=h(b,e+N);p=h(b,e+Y);e=h(b,e+H);m=E.materials[m];var u=G[p*3],v=G[p*3+1];p=G[p*3+2];var w=G[e*3],x=G[e*3+1],e=G[e*3+2];E.faces.push(new THREE.Face3(c,f,k,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(u,v,p),new THREE.Vector3(w,x,e)],null,m))}function v(e){var c,f,k,m;c=h(b,e);f=h(b,e+T);k=h(b,e+Q);m=h(b, -e+Z);e=t(b,e+$);E.faces.push(new THREE.Face4(c,f,k,m,null,null,E.materials[e]))}function z(e){var c,f,k,m,o,u,v,w;c=h(b,e);f=h(b,e+T);k=h(b,e+Q);m=h(b,e+Z);o=t(b,e+$);u=h(b,e+S);v=h(b,e+p);w=h(b,e+V);e=h(b,e+ea);o=E.materials[o];var x=G[v*3],y=G[v*3+1];v=G[v*3+2];var L=G[w*3],M=G[w*3+1];w=G[w*3+2];var z=G[e*3],A=G[e*3+1],e=G[e*3+2];E.faces.push(new THREE.Face4(c,f,k,m,[new THREE.Vector3(G[u*3],G[u*3+1],G[u*3+2]),new THREE.Vector3(x,y,v),new THREE.Vector3(L,M,w),new THREE.Vector3(z,A,e)],null,o))} -function y(e){var c,f,k,m;c=h(b,e);f=h(b,e+da);k=h(b,e+ha);e=J[c*2];m=J[c*2+1];c=J[f*2];var o=E.faceVertexUvs[0];f=J[f*2+1];var p=J[k*2];k=J[k*2+1];var t=[];t.push(new THREE.UV(e,m));t.push(new THREE.UV(c,f));t.push(new THREE.UV(p,k));o.push(t)}function A(e){var c,f,k,m,o,p;c=h(b,e);f=h(b,e+ga);k=h(b,e+ka);m=h(b,e+na);e=J[c*2];o=J[c*2+1];c=J[f*2];p=J[f*2+1];f=J[k*2];var t=E.faceVertexUvs[0];k=J[k*2+1];var v=J[m*2];m=J[m*2+1];var u=[];u.push(new THREE.UV(e,o));u.push(new THREE.UV(c,p));u.push(new THREE.UV(f, -k));u.push(new THREE.UV(v,m));t.push(u)}var E=this,F=0,C,G=[],J=[],O,K,B,N,Y,H,T,Q,Z,$,S,p,V,ea,da,ha,ga,ka,na,aa,W,U,ia,ja,ta;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,f,e);C={signature:b.substr(F,8),header_bytes:w(b,F+8),vertex_coordinate_bytes:w(b,F+9),normal_coordinate_bytes:w(b,F+10),uv_coordinate_bytes:w(b,F+11),vertex_index_bytes:w(b,F+12),normal_index_bytes:w(b,F+13),uv_index_bytes:w(b,F+14),material_index_bytes:w(b,F+15),nvertices:h(b,F+16),nnormals:h(b,F+16+4),nuvs:h(b, -F+16+8),ntri_flat:h(b,F+16+12),ntri_smooth:h(b,F+16+16),ntri_flat_uv:h(b,F+16+20),ntri_smooth_uv:h(b,F+16+24),nquad_flat:h(b,F+16+28),nquad_smooth:h(b,F+16+32),nquad_flat_uv:h(b,F+16+36),nquad_smooth_uv:h(b,F+16+40)};F+=C.header_bytes;O=C.vertex_index_bytes;K=C.vertex_index_bytes*2;B=C.vertex_index_bytes*3;N=C.vertex_index_bytes*3+C.material_index_bytes;Y=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;H=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;T=C.vertex_index_bytes; -Q=C.vertex_index_bytes*2;Z=C.vertex_index_bytes*3;$=C.vertex_index_bytes*4;S=C.vertex_index_bytes*4+C.material_index_bytes;p=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;V=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;ea=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;da=C.uv_index_bytes;ha=C.uv_index_bytes*2;ga=C.uv_index_bytes;ka=C.uv_index_bytes*2;na=C.uv_index_bytes*3;e=C.vertex_index_bytes*3+C.material_index_bytes;ta=C.vertex_index_bytes* -4+C.material_index_bytes;aa=C.ntri_flat*e;W=C.ntri_smooth*(e+C.normal_index_bytes*3);U=C.ntri_flat_uv*(e+C.uv_index_bytes*3);ia=C.ntri_smooth_uv*(e+C.normal_index_bytes*3+C.uv_index_bytes*3);ja=C.nquad_flat*ta;e=C.nquad_smooth*(ta+C.normal_index_bytes*4);ta=C.nquad_flat_uv*(ta+C.uv_index_bytes*4);F+=function(e){for(var f,k,h,n=C.vertex_coordinate_bytes*3,o=e+C.nvertices*n;e=0){y=o.invBindMatrices[v];p.invBindMatrix=y;p.skinningMatrix=new THREE.Matrix4;p.skinningMatrix.multiply(p.world,y);p.weights=[];for(y=0;y1){o=new THREE.MeshFaceMaterial;for(j=0;j1?c[1].substr(0,e):"0";c[1].length=0,m=k.indexOf("(")>=0,n;if(h)f=k.split("."),k=f.shift(),f.shift();else if(m){n=k.split("(");k=n.shift(); -for(f=0;fe){u=t.output[p];break}m=u!==void 0?u instanceof THREE.Matrix4? -m.multiply(m,u):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);e=m;c.push({time:b,pos:[e.n14,e.n24,e.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b0&&(this[c.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};Y.prototype.create=function(){var b={},e=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var f=this[c];if(f instanceof N)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=la[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ga+f.init_from), -b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else c=="diffuse"?b.color=f.color.getHex():e||(b[c]=f.color.getHex());break;case "shininess":case "reflectivity":b[c]=this[c];break;case "transparency":if(e)b.transparent=!0,b.opacity=this[c],e=!0}b.shading=za;return this.material=new THREE.MeshLambertMaterial(b)};H.prototype.parse=function(b){for(var e=0;e=0,f=b.indexOf("(")>=0,k,h;if(c)e=b.split("."),b=e.shift(),h=e.shift();else if(f){k=b.split("(");b=k.shift();for(e=0;e>7)-127;f|=(k&127)<<16|h<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function m(b,c){var e=u(b,c),f=u(b,c+1),h=u(b,c+2);return(u(b,c+3)<<24)+(h<<16)+(f<<8)+e}function p(b,c){var e=u(b,c);return(u(b,c+1)<<8)+e}function t(b,c){var e=u(b,c);return e>127?e-256:e}function u(b,c){return b.charCodeAt(c)&255}function v(c){var e, +f,h;e=m(b,c);f=m(b,c+I);h=m(b,c+M);c=p(b,c+Z);E.faces.push(new THREE.Face3(e,f,h,null,null,E.materials[c]))}function x(c){var e,f,h,k,o,t;e=m(b,c);f=m(b,c+I);h=m(b,c+M);k=p(b,c+Z);o=m(b,c+J);t=m(b,c+O);c=m(b,c+L);k=E.materials[k];var u=G[t*3],v=G[t*3+1];t=G[t*3+2];var w=G[c*3],x=G[c*3+1],c=G[c*3+2];E.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(u,v,t),new THREE.Vector3(w,x,c)],null,k))}function w(c){var e,f,h,k;e=m(b,c);f=m(b,c+F);h=m(b,c+aa);k=m(b, +c+Y);c=p(b,c+Q);E.faces.push(new THREE.Face4(e,f,h,k,null,null,E.materials[c]))}function A(c){var e,f,h,k,t,u,v,w;e=m(b,c);f=m(b,c+F);h=m(b,c+aa);k=m(b,c+Y);t=p(b,c+Q);u=m(b,c+P);v=m(b,c+o);w=m(b,c+T);c=m(b,c+$);t=E.materials[t];var x=G[v*3],y=G[v*3+1];v=G[v*3+2];var z=G[w*3],A=G[w*3+1];w=G[w*3+2];var V=G[c*3],B=G[c*3+1],c=G[c*3+2];E.faces.push(new THREE.Face4(e,f,h,k,[new THREE.Vector3(G[u*3],G[u*3+1],G[u*3+2]),new THREE.Vector3(x,y,v),new THREE.Vector3(z,A,w),new THREE.Vector3(V,B,c)],null,t))} +function y(c){var e,f,h,k;e=m(b,c);f=m(b,c+da);h=m(b,c+ca);c=N[e*2];k=N[e*2+1];e=N[f*2];var o=E.faceVertexUvs[0];f=N[f*2+1];var p=N[h*2];h=N[h*2+1];var t=[];t.push(new THREE.UV(c,k));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,h));o.push(t)}function z(c){var e,f,h,k,o,p;e=m(b,c);f=m(b,c+ra);h=m(b,c+qa);k=m(b,c+sa);c=N[e*2];o=N[e*2+1];e=N[f*2];p=N[f*2+1];f=N[h*2];var t=E.faceVertexUvs[0];h=N[h*2+1];var u=N[k*2];k=N[k*2+1];var v=[];v.push(new THREE.UV(c,o));v.push(new THREE.UV(e,p));v.push(new THREE.UV(f, +h));v.push(new THREE.UV(u,k));t.push(v)}var E=this,C=0,B,G=[],N=[],I,M,Z,J,O,L,F,aa,Y,Q,P,o,T,$,da,ca,ra,qa,sa,va,ka,X,ha,fa,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,f,c);B={signature:b.substr(C,8),header_bytes:u(b,C+8),vertex_coordinate_bytes:u(b,C+9),normal_coordinate_bytes:u(b,C+10),uv_coordinate_bytes:u(b,C+11),vertex_index_bytes:u(b,C+12),normal_index_bytes:u(b,C+13),uv_index_bytes:u(b,C+14),material_index_bytes:u(b,C+15),nvertices:m(b,C+16),nnormals:m(b,C+16+4),nuvs:m(b, +C+16+8),ntri_flat:m(b,C+16+12),ntri_smooth:m(b,C+16+16),ntri_flat_uv:m(b,C+16+20),ntri_smooth_uv:m(b,C+16+24),nquad_flat:m(b,C+16+28),nquad_smooth:m(b,C+16+32),nquad_flat_uv:m(b,C+16+36),nquad_smooth_uv:m(b,C+16+40)};C+=B.header_bytes;I=B.vertex_index_bytes;M=B.vertex_index_bytes*2;Z=B.vertex_index_bytes*3;J=B.vertex_index_bytes*3+B.material_index_bytes;O=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;L=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;F=B.vertex_index_bytes; +aa=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;Q=B.vertex_index_bytes*4;P=B.vertex_index_bytes*4+B.material_index_bytes;o=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;T=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;$=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;da=B.uv_index_bytes;ca=B.uv_index_bytes*2;ra=B.uv_index_bytes;qa=B.uv_index_bytes*2;sa=B.uv_index_bytes*3;c=B.vertex_index_bytes*3+B.material_index_bytes;ga=B.vertex_index_bytes* +4+B.material_index_bytes;va=B.ntri_flat*c;ka=B.ntri_smooth*(c+B.normal_index_bytes*3);X=B.ntri_flat_uv*(c+B.uv_index_bytes*3);ha=B.ntri_smooth_uv*(c+B.normal_index_bytes*3+B.uv_index_bytes*3);fa=B.nquad_flat*ga;c=B.nquad_smooth*(ga+B.normal_index_bytes*4);ga=B.nquad_flat_uv*(ga+B.uv_index_bytes*4);C+=function(c){for(var f,h,m,n=B.vertex_coordinate_bytes*3,o=c+B.nvertices*n;c=0){y=o.invBindMatrices[v];p.invBindMatrix=y;p.skinningMatrix=new THREE.Matrix4;p.skinningMatrix.multiply(p.world,y);p.weights=[];for(y=0;y1){o=new THREE.MeshFaceMaterial;for(j=0;j1?c.add(o):c=o}}c.name=b.id||"";b.matrix.decompose(c.position,c.rotation, +c.scale);for(k=0;k1?e[1].substr(0,c):"0";e[1].length=0,m=h.indexOf("(")>=0,n;if(k)f=h.split("."), +h=f.shift(),f.shift();else if(m){n=h.split("(");h=n.shift();for(f=0;fc){t=p.output[o];break}m=t!==void 0?t instanceof THREE.Matrix4?m.multiply(m,t):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);c=m;e.push({time:b,pos:[c.n14,c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=e}this.updateMatrix();return this};v.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b0&&(this[e.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};O.prototype.create=function(){var b={},c=this.transparency!==void 0&&this.transparency<1,e;for(e in this)switch(e){case "ambient":case "emission":case "diffuse":case "specular":var f=this[e];if(f instanceof J)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source== +this.effect.surface.sid&&(f=K[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ha+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else e=="diffuse"?b.color=f.color.getHex():c||(b[e]=f.color.getHex());break;case "shininess":case "reflectivity":b[e]=this[e];break;case "transparency":if(c)b.transparent=!0,b.opacity=this[e],c=!0}b.shading=Ja;return this.material=new THREE.MeshLambertMaterial(b)};L.prototype.parse=function(b){for(var c= +0;c=0,f=b.indexOf("(")>=0,h,k;if(e)c=b.split("."),b=c.shift(),k=c.shift();else if(f){h=b.split("(");b=h.shift();for(c=0;c1&&(Y=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,Y);object.name=v;object.position.set(C[0],C[1],C[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=F.visible;V.scene.add(object);V.objects[v]=object;F.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),V.scene.collisions.colliders.push(b)); -if(F.castsShadow)b=new THREE.ShadowVolume(O),V.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},V.triggers[object.name]=b)}}else C=F.position,r=F.rotation,q=F.quaternion,s=F.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(C[0],C[1],C[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=F.visible!==void 0?F.visible:!1,V.scene.add(object),V.objects[v]=object,V.empties[v]=object,F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},V.triggers[object.name]=b)}function t(b){return function(c){V.geometries[b]=c;n();Z-=1;e.onLoadComplete();w()}}function u(b){return function(e){V.geometries[b]=e}}function w(){e.callbackProgress({totalModels:S,totalTextures:p,loadedModels:S-Z,loadedTextures:p-$},V);e.onLoadProgress();Z==0&&$==0&&c(V)}var o,x, -v,z,y,A,E,F,C,G,J,O,K,B,N,Y,H,T,Q,Z,$,S,p,V;T=b.data;N=new THREE.BinaryLoader;Q=new THREE.JSONLoader;$=Z=0;V={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in T.objects)if(F=T.objects[v],F.meshCollider){b=!0;break}if(b)V.scene.collisions=new THREE.CollisionSystem;if(T.transform){b=T.transform.position;G=T.transform.rotation;var ea=T.transform.scale;b&&V.scene.position.set(b[0],b[1],b[2]);G&&V.scene.rotation.set(G[0], -G[1],G[2]);ea&&V.scene.scale.set(ea[0],ea[1],ea[2]);(b||G||ea)&&V.scene.updateMatrix()}b=function(){$-=1;w();e.onLoadComplete()};for(y in T.cameras)G=T.cameras[y],G.type=="perspective"?K=new THREE.PerspectiveCamera(G.fov,G.aspect,G.near,G.far):G.type=="ortho"&&(K=new THREE.OrthographicCamera(G.left,G.right,G.top,G.bottom,G.near,G.far)),C=G.position,G=G.target,K.position.set(C[0],C[1],C[2]),K.target=new THREE.Vector3(G[0],G[1],G[2]),V.cameras[y]=K;for(z in T.lights)y=T.lights[z],K=y.color!==void 0? -y.color:16777215,G=y.intensity!==void 0?y.intensity:1,y.type=="directional"?(C=y.direction,H=new THREE.DirectionalLight(K,G),H.position.set(C[0],C[1],C[2]),H.position.normalize()):y.type=="point"?(C=y.position,d=y.distance,H=new THREE.PointLight(K,G,d),H.position.set(C[0],C[1],C[2])):y.type=="ambient"&&(H=new THREE.AmbientLight(K)),V.scene.add(H),V.lights[z]=H;for(A in T.fogs)z=T.fogs[A],z.type=="linear"?B=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(B=new THREE.FogExp2(0,z.density)),G=z.color, -B.color.setRGB(G[0],G[1],G[2]),V.fogs[A]=B;if(V.cameras&&T.defaults.camera)V.currentCamera=V.cameras[T.defaults.camera];if(V.fogs&&T.defaults.fog)V.scene.fog=V.fogs[T.defaults.fog];G=T.defaults.bgcolor;V.bgColor=new THREE.Color;V.bgColor.setRGB(G[0],G[1],G[2]);V.bgColorAlpha=T.defaults.bgalpha;for(o in T.geometries)if(A=T.geometries[o],A.type=="bin_mesh"||A.type=="ascii_mesh")Z+=1,e.onLoadStart();S=Z;for(o in T.geometries)A=T.geometries[o],A.type=="cube"?(O=new THREE.CubeGeometry(A.width,A.height, -A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides),V.geometries[o]=O):A.type=="plane"?(O=new THREE.PlaneGeometry(A.width,A.height,A.segmentsWidth,A.segmentsHeight),V.geometries[o]=O):A.type=="sphere"?(O=new THREE.SphereGeometry(A.radius,A.segmentsWidth,A.segmentsHeight),V.geometries[o]=O):A.type=="cylinder"?(O=new THREE.CylinderGeometry(A.topRad,A.botRad,A.height,A.radSegs,A.heightSegs),V.geometries[o]=O):A.type=="torus"?(O=new THREE.TorusGeometry(A.radius,A.tube,A.segmentsR, -A.segmentsT),V.geometries[o]=O):A.type=="icosahedron"?(O=new THREE.IcosahedronGeometry(A.subdivisions),V.geometries[o]=O):A.type=="bin_mesh"?N.load({model:f(A.url,T.urlBaseType),callback:t(o)}):A.type=="ascii_mesh"?Q.load({model:f(A.url,T.urlBaseType),callback:t(o)}):A.type=="embedded_mesh"&&(A=T.embeds[A.id])&&Q.createModel(A,u(o),"");for(E in T.textures)if(o=T.textures[E],o.url instanceof Array){$+=o.url.length;for(N=0;N=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,m=0;m>1^-(n&1);e[8*m+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=m=0;h=this.maxCount-3&&n(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(t=this.size-1);var x=Math.floor(u-n);x<1&&(x=1);u=Math.floor(u+n);u>this.size-1&&(u=this.size-1);var v=Math.floor(w-n);v<1&&(v=1);n=Math.floor(w+n);n>this.size-1&&(n=this.size- -1);for(var z,y,A,E,F,C;o0&&(this.field[A+z]+=E)}}};this.addPlaneX=function(b,c){var h,k,m,n,t,u=this.size,w=this.yd,o=this.zd,x=this.field,v=u*Math.sqrt(b/c);v>u&&(v=u);for(h=0;h0)for(k=0;kw&&(z=w);for(k=0;k0){t=k*o;for(h=0;hsize&&(dist=size);for(m=0;m0){t=zd*m;for(k=0;k1&&(O=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(I,O);object.name=w;object.position.set(B[0],B[1],B[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;T.scene.add(object);T.objects[w]=object;C.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),T.scene.collisions.colliders.push(b)); +if(C.castsShadow)b=new THREE.ShadowVolume(I),T.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;C.trigger&&C.trigger.toLowerCase()!="none"&&(b={type:C.trigger,object:C},T.triggers[object.name]=b)}}else B=C.position,r=C.rotation,q=C.quaternion,s=C.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(B[0],B[1],B[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], +s[1],s[2]),object.visible=C.visible!==void 0?C.visible:!1,T.scene.add(object),T.objects[w]=object,T.empties[w]=object,C.trigger&&C.trigger.toLowerCase()!="none"&&(b={type:C.trigger,object:C},T.triggers[object.name]=b)}function p(b){return function(e){T.geometries[b]=e;n();Y-=1;c.onLoadComplete();u()}}function t(b){return function(c){T.geometries[b]=c}}function u(){c.callbackProgress({totalModels:P,totalTextures:o,loadedModels:P-Y,loadedTextures:o-Q},T);c.onLoadProgress();Y==0&&Q==0&&e(T)}var v,x, +w,A,y,z,E,C,B,G,N,I,M,Z,J,O,L,F,aa,Y,Q,P,o,T;F=b.data;J=new THREE.BinaryLoader;aa=new THREE.JSONLoader;Q=Y=0;T={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in F.objects)if(C=F.objects[w],C.meshCollider){b=!0;break}if(b)T.scene.collisions=new THREE.CollisionSystem;if(F.transform){b=F.transform.position;G=F.transform.rotation;var $=F.transform.scale;b&&T.scene.position.set(b[0],b[1],b[2]);G&&T.scene.rotation.set(G[0], +G[1],G[2]);$&&T.scene.scale.set($[0],$[1],$[2]);(b||G||$)&&T.scene.updateMatrix()}b=function(){Q-=1;u();c.onLoadComplete()};for(y in F.cameras)G=F.cameras[y],G.type=="perspective"?M=new THREE.PerspectiveCamera(G.fov,G.aspect,G.near,G.far):G.type=="ortho"&&(M=new THREE.OrthographicCamera(G.left,G.right,G.top,G.bottom,G.near,G.far)),B=G.position,G=G.target,M.position.set(B[0],B[1],B[2]),M.target=new THREE.Vector3(G[0],G[1],G[2]),T.cameras[y]=M;for(A in F.lights)y=F.lights[A],M=y.color!==void 0?y.color: +16777215,G=y.intensity!==void 0?y.intensity:1,y.type=="directional"?(B=y.direction,L=new THREE.DirectionalLight(M,G),L.position.set(B[0],B[1],B[2]),L.position.normalize()):y.type=="point"?(B=y.position,d=y.distance,L=new THREE.PointLight(M,G,d),L.position.set(B[0],B[1],B[2])):y.type=="ambient"&&(L=new THREE.AmbientLight(M)),T.scene.add(L),T.lights[A]=L;for(z in F.fogs)A=F.fogs[z],A.type=="linear"?Z=new THREE.Fog(0,A.near,A.far):A.type=="exp2"&&(Z=new THREE.FogExp2(0,A.density)),G=A.color,Z.color.setRGB(G[0], +G[1],G[2]),T.fogs[z]=Z;if(T.cameras&&F.defaults.camera)T.currentCamera=T.cameras[F.defaults.camera];if(T.fogs&&F.defaults.fog)T.scene.fog=T.fogs[F.defaults.fog];G=F.defaults.bgcolor;T.bgColor=new THREE.Color;T.bgColor.setRGB(G[0],G[1],G[2]);T.bgColorAlpha=F.defaults.bgalpha;for(v in F.geometries)if(z=F.geometries[v],z.type=="bin_mesh"||z.type=="ascii_mesh")Y+=1,c.onLoadStart();P=Y;for(v in F.geometries)z=F.geometries[v],z.type=="cube"?(I=new THREE.CubeGeometry(z.width,z.height,z.depth,z.segmentsWidth, +z.segmentsHeight,z.segmentsDepth,null,z.flipped,z.sides),T.geometries[v]=I):z.type=="plane"?(I=new THREE.PlaneGeometry(z.width,z.height,z.segmentsWidth,z.segmentsHeight),T.geometries[v]=I):z.type=="sphere"?(I=new THREE.SphereGeometry(z.radius,z.segmentsWidth,z.segmentsHeight),T.geometries[v]=I):z.type=="cylinder"?(I=new THREE.CylinderGeometry(z.topRad,z.botRad,z.height,z.radSegs,z.heightSegs),T.geometries[v]=I):z.type=="torus"?(I=new THREE.TorusGeometry(z.radius,z.tube,z.segmentsR,z.segmentsT),T.geometries[v]= +I):z.type=="icosahedron"?(I=new THREE.IcosahedronGeometry(z.subdivisions),T.geometries[v]=I):z.type=="bin_mesh"?J.load({model:f(z.url,F.urlBaseType),callback:p(v)}):z.type=="ascii_mesh"?aa.load({model:f(z.url,F.urlBaseType),callback:p(v)}):z.type=="embedded_mesh"&&(z=F.embeds[z.id])&&aa.createModel(z,t(v),"");for(E in F.textures)if(v=F.textures[E],v.url instanceof Array){Q+=v.url.length;for(J=0;J=57344&&(e-=2048);e++;for(var c=new Float32Array(8*e),f=1,m=0;m<8;m++){for(var h=0,k=0;k>1^-(n&1);c[8*k+m]=h}f+=e}e=b.length-f;h=new Uint16Array(e);for(m=k=0;m=this.maxCount-3&&n(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;ethis.size-1&&(p=this.size-1);var x=Math.floor(t-n);x<1&&(x=1);t=Math.floor(t+n);t>this.size-1&&(t=this.size-1);var w=Math.floor(u-n);w<1&&(w=1);n=Math.floor(u+n);n>this.size-1&&(n=this.size- +1);for(var A,y,z,E,C,B;v0&&(this.field[z+A]+=E)}}};this.addPlaneX=function(b,e){var m,h,k,n,p,t=this.size,u=this.yd,v=this.zd,x=this.field,w=t*Math.sqrt(b/e);w>t&&(w=t);for(m=0;m0)for(h=0;hu&&(A=u);for(h=0;h0){p=h*v;for(m=0;msize&&(dist=size);for(k=0;k0){p=zd*k;for(h=0;hk?this.hits.push(h):this.hits.unshift(h),k=f;return this.hits}; -THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; -THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,k=0;k=n*h))return Number.MAX_VALUE;m/=n;n=THREE.CollisionSystem.__v3;n.copy(b.direction);n.multiplyScalar(m);n.addSelf(b.origin);Math.abs(k.x)> -Math.abs(k.y)?Math.abs(k.x)>Math.abs(k.z)?(b=n.y-c.y,k=e.y-c.y,h=f.y-c.y,n=n.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=n.x-c.x,k=e.x-c.x,h=f.x-c.x,n=n.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(k.y)>Math.abs(k.z)?(b=n.x-c.x,k=e.x-c.x,h=f.x-c.x,n=n.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=n.x-c.x,k=e.x-c.x,h=f.x-c.x,n=n.y-c.y,e=e.y-c.y,f=f.y-c.y);c=k*f-e*h;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-n*h)*c;if(!(f>=0))return Number.MAX_VALUE;c*=k*n-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return m}; -THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; -THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,h=0,k=0,m=0,n=0,t=0,u=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,u=!1,m=1);e.origin.yc.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y, -u=!1,n=1);e.origin.zc.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,u=!1,t=1);if(u)return-1;u=0;h>f&&(u=1,f=h);k>f&&(u=2,f=k);switch(u){case 0:n=e.origin.y+e.direction.y*f;if(nc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(m,0,0);break;case 1:m=e.origin.x+e.direction.x*f;if(mc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* -f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,n,0);break;case 2:m=e.origin.x+e.direction.x*f;if(mc.max.x)return Number.MAX_VALUE;n=e.origin.y+e.direction.y*f;if(nc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,t)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; -THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq=0)return Math.abs(f)-Math.sqrt(e);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; -THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,e=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c}; +2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.PlaneCollider=function(b,e){this.point=b;this.normal=e};THREE.SphereCollider=function(b,e){this.center=b;this.radius=e;this.radiusSq=e*e};THREE.BoxCollider=function(b,e){this.min=b;this.max=e;this.dynamic=!0;this.normal=new THREE.Vector3}; +THREE.MeshCollider=function(b,e){this.mesh=b;this.box=e;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(b){Array.prototype.push.apply(this.colliders,b.colliders);Array.prototype.push.apply(this.hits,b.hits)}; +THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var e,c,f,m,h=0;e=0;for(c=this.colliders.length;eh?this.hits.push(m):this.hits.unshift(m),h=f;return this.hits}; +THREE.CollisionSystem.prototype.rayCastNearest=function(b){var e=this.rayCastAll(b);if(e.length==0)return null;for(var c=0;e[c]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,e[c]);if(f.diste.length)return null;return e[c]}; +THREE.CollisionSystem.prototype.rayCast=function(b,e){if(e instanceof THREE.PlaneCollider)return this.rayPlane(b,e);else if(e instanceof THREE.SphereCollider)return this.raySphere(b,e);else if(e instanceof THREE.BoxCollider)return this.rayBox(b,e);else if(e instanceof THREE.MeshCollider&&e.box)return this.rayBox(b,e.box)}; +THREE.CollisionSystem.prototype.rayMesh=function(b,e){for(var c=this.makeRayLocal(b,e.mesh),f=Number.MAX_VALUE,m,h=0;h=n*m))return Number.MAX_VALUE;k/=n;n=THREE.CollisionSystem.__v3;n.copy(b.direction);n.multiplyScalar(k);n.addSelf(b.origin);Math.abs(h.x)> +Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=n.y-e.y,h=c.y-e.y,m=f.y-e.y,n=n.z-e.z,c=c.z-e.z,f=f.z-e.z):(b=n.x-e.x,h=c.x-e.x,m=f.x-e.x,n=n.y-e.y,c=c.y-e.y,f=f.y-e.y):Math.abs(h.y)>Math.abs(h.z)?(b=n.x-e.x,h=c.x-e.x,m=f.x-e.x,n=n.z-e.z,c=c.z-e.z,f=f.z-e.z):(b=n.x-e.x,h=c.x-e.x,m=f.x-e.x,n=n.y-e.y,c=c.y-e.y,f=f.y-e.y);e=h*f-c*m;if(e==0)return Number.MAX_VALUE;e=1/e;f=(b*f-n*m)*e;if(!(f>=0))return Number.MAX_VALUE;e*=h*n-c*b;if(!(e>=0))return Number.MAX_VALUE;if(!(1-f-e>=0))return Number.MAX_VALUE;return k}; +THREE.CollisionSystem.prototype.makeRayLocal=function(b,e){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(e.matrixWorld,c);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);c.multiplyVector3(f.origin);c.rotateAxis(f.direction);f.direction.normalize();return f}; +THREE.CollisionSystem.prototype.rayBox=function(b,e){var c;e.dynamic&&e.mesh&&e.mesh.matrixWorld?c=this.makeRayLocal(b,e.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(b.origin),c.direction.copy(b.direction));var f=0,m=0,h=0,k=0,n=0,p=0,t=!0;c.origin.xe.max.x&&(f=e.max.x-c.origin.x,f/=c.direction.x,t=!1,k=1);c.origin.ye.max.y&&(m=e.max.y-c.origin.y,m/=c.direction.y, +t=!1,n=1);c.origin.ze.max.z&&(h=e.max.z-c.origin.z,h/=c.direction.z,t=!1,p=1);if(t)return-1;t=0;m>f&&(t=1,f=m);h>f&&(t=2,f=h);switch(t){case 0:n=c.origin.y+c.direction.y*f;if(ne.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(ce.max.z)return Number.MAX_VALUE;e.normal.set(k,0,0);break;case 1:k=c.origin.x+c.direction.x*f;if(ke.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* +f;if(ce.max.z)return Number.MAX_VALUE;e.normal.set(0,n,0);break;case 2:k=c.origin.x+c.direction.x*f;if(ke.max.x)return Number.MAX_VALUE;n=c.origin.y+c.direction.y*f;if(ne.max.y)return Number.MAX_VALUE;e.normal.set(0,0,p)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,e){var c=b.direction.dot(e.normal),f=e.point.dot(e.normal);if(c<0)c=(f-b.origin.dot(e.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.raySphere=function(b,e){var c=e.center.clone().subSelf(b.origin);if(c.lengthSq=0)return Math.abs(f)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; +THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var e=b.geometry.boundingBox,c=new THREE.Vector3(e.x[0],e.y[0],e.z[0]),e=new THREE.Vector3(e.x[1],e.y[1],e.z[1]),c=new THREE.BoxCollider(c,e);c.mesh=b;return c};THREE.CollisionUtils.MeshAABB=function(b){var e=THREE.CollisionUtils.MeshOBB(b);e.min.addSelf(b.position);e.max.addSelf(b.position);e.dynamic=!1;return e}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.PerspectiveCamera,k=new THREE.PerspectiveCamera,m=new THREE.Matrix4,n=new THREE.Matrix4,t,u,w;h.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,b),x=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.PerspectiveCamera(53,1,1,1E4);v.position.z= -2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:x}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); -var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);o.width=b;o.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(t!==e.aspect||u!==e.near||w!==e.fov){t=e.aspect;u=e.near;w=e.fov;var E=e.projectionMatrix.clone(),F=125/30*0.5,C=F*u/125,G=u*Math.tan(w*Math.PI/360),J;m.n14=F;n.n14=-F;F=-G*t+C;J=G*t+C;E.n11=2*u/(J-F);E.n13=(J+F)/(J-F);h.projectionMatrix=E.clone();F=-G*t-C;J=G*t-C;E.n11=2*u/(J-F);E.n13= -(J+F)/(J-F);k.projectionMatrix=E.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(n);h.update(null,!0);h.position.copy(e.position);h.near=u;h.far=e.far;f.call(c,b,h,o,!0);k.matrix=e.matrixWorld.clone().multiplySelf(m);k.update(null,!0);k.position.copy(e.position);k.near=u;k.far=e.far;f.call(c,b,k,x,!0);f.call(c,z,v)}}; -if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,h,k,m=new THREE.PerspectiveCamera;m.target=new THREE.Vector3(0,0,0);var n=new THREE.PerspectiveCamera;n.target=new THREE.Vector3(0,0,0);c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;this.setSize=function(b,f){e.call(c,b,f);h=b/2;k=f};this.render=function(b,e){this.clear();m.fov=e.fov;m.aspect=0.5*e.aspect;m.near=e.near;m.far= -e.far;m.updateProjectionMatrix();m.position.copy(e.position);m.target.copy(e.target);m.translateX(c.separation);m.lookAt(m.target);n.projectionMatrix=m.projectionMatrix;n.position.copy(e.position);n.target.copy(e.target);n.translateX(-c.separation);n.lookAt(n.target);this.setViewport(0,0,h,k);f.call(c,b,m);this.setViewport(h,0,h,k);f.call(c,b,n,!1)}}; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var e=this,c=this.setSize,f=this.render,m=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,k=new THREE.Matrix4,n=new THREE.Matrix4,p,t,u;m.matrixAutoUpdate=h.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},v=new THREE.WebGLRenderTarget(512,512,b),x=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.PerspectiveCamera(53,1,1,1E4);w.position.z= +2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:v},mapRight:{type:"t",value:1,texture:x}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); +var A=new THREE.Scene;A.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){c.call(e,b,f);v.width=b;v.height=f;x.width=b;x.height=f};this.render=function(b,c){c.update(null,!0);if(p!==c.aspect||t!==c.near||u!==c.fov){p=c.aspect;t=c.near;u=c.fov;var E=c.projectionMatrix.clone(),C=125/30*0.5,B=C*t/125,G=t*Math.tan(u*Math.PI/360),N;k.n14=C;n.n14=-C;C=-G*p+B;N=G*p+B;E.n11=2*t/(N-C);E.n13=(N+C)/(N-C);m.projectionMatrix=E.clone();C=-G*p-B;N=G*p-B;E.n11=2*t/(N-C);E.n13= +(N+C)/(N-C);h.projectionMatrix=E.clone()}m.matrix=c.matrixWorld.clone().multiplySelf(n);m.update(null,!0);m.position.copy(c.position);m.near=t;m.far=c.far;f.call(e,b,m,v,!0);h.matrix=c.matrixWorld.clone().multiplySelf(k);h.update(null,!0);h.position.copy(c.position);h.near=t;h.far=c.far;f.call(e,b,h,x,!0);f.call(e,A,w)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var e=this,c=this.setSize,f=this.render,m,h,k=new THREE.PerspectiveCamera;k.target=new THREE.Vector3(0,0,0);var n=new THREE.PerspectiveCamera;n.target=new THREE.Vector3(0,0,0);e.separation=10;if(b&&b.separation!==void 0)e.separation=b.separation;this.setSize=function(b,f){c.call(e,b,f);m=b/2;h=f};this.render=function(b,c){this.clear();k.fov=c.fov;k.aspect=0.5*c.aspect;k.near=c.near;k.far= +c.far;k.updateProjectionMatrix();k.position.copy(c.position);k.target.copy(c.target);k.translateX(e.separation);k.lookAt(k.target);n.projectionMatrix=k.projectionMatrix;n.position.copy(c.position);n.target.copy(c.target);n.translateX(-e.separation);n.lookAt(n.target);this.setViewport(0,0,m,h);f.call(e,b,k);this.setViewport(m,0,m,h);f.call(e,b,n,!1)}}; diff --git a/build/custom/ThreeCanvas.js b/build/custom/ThreeCanvas.js index a4440c15..e0e2a720 100644 --- a/build/custom/ThreeCanvas.js +++ b/build/custom/ThreeCanvas.js @@ -14,82 +14,81 @@ Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12 THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b0&&a>0&&e+a<1}for(var d,f=[],e=0,g=a.children.length;ea.scale.x)return[];d={distance:e,point:a.position,face:null,object:a};f.push(d)}else if(a instanceof THREE.Mesh){e=b(this.origin, -this.direction,a.matrixWorld.getPosition());if(e==null||e>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return f;for(var h,m,k,l,i,n,j,r,t=a.geometry,w=t.vertices,e=0,g=t.faces.length;e0:n<0)))if(n=i.dot((new THREE.Vector3).sub(h,j))/n,j=j.addSelf(r.multiplyScalar(n)),d instanceof THREE.Face3)c(j,h,m,k)&&(d={distance:this.origin.distanceTo(j),point:j,face:d,object:a},f.push(d));else if(d instanceof THREE.Face4&&(c(j,h,m,l)||c(j,m,k,l)))d={distance:this.origin.distanceTo(j),point:j,face:d,object:a},f.push(d)}return f}}; -THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,l,i){h=!1;b=e;c=g;d=l;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= -function(e,g,l,i,n,j){h?(h=!1,b=el?e>n?e:n:l>n?l:n,f=g>i?g>j?g:j:i>j?i:j):(b=el?e>n?e>d?e:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,f=g>i?g>j?g>f?g:f:j>f?j:f:i>j?i>f?i:f:j>f?j:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> +this.direction,a.matrixWorld.getPosition());if(e==null||e>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return f;var h,l,m,j,i,o,n,p,k=a.geometry,v=k.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);e=0;for(g=k.faces.length;e0:o<0)))if(o=i.dot((new THREE.Vector3).sub(h,n))/o,n=n.addSelf(p.multiplyScalar(o)),d instanceof THREE.Face3)c(n,h,l,m)&&(d={distance:this.origin.distanceTo(n),point:n,face:d,object:a},f.push(d));else if(d instanceof THREE.Face4&&(c(n,h,l,j)||c(n,l,m,j)))d={distance:this.origin.distanceTo(n), +point:n,face:d,object:a},f.push(d)}return f}}; +THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,j,i){h=!1;b=e;c=g;d=j;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= +function(e,g,j,i,o,n){h?(h=!1,b=ej?e>o?e:o:j>o?j:o,f=g>i?g>n?g:n:i>n?i:n):(b=ej?e>o?e>d?e:d:o>d?o:d:j>o?j>d?j:d:o>d?o:d,f=g>i?g>n?g>f?g:f:n>f?n:f:i>n?i>f?i:f:n>f?n:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,f,e,g,h,m,k,l,i,n,j,r,t){this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,h||0,m||0,k||0,l!==void 0?l:1,i||0,n||0,j||0,r||0,t!==void 0?t:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,h,m,k,l,i,n,j,r,t){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=e;this.n23=g;this.n24=h;this.n31=m;this.n32=k;this.n33=l;this.n34=i;this.n41=n;this.n42=j;this.n43=r;this.n44=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, -b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,b).normalize();if(e.length()===0)e.z=1;d.cross(c,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(c,e).normalize());f.cross(e,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=e.x;this.n21=d.y;this.n22=f.y;this.n23=e.y;this.n31=d.z;this.n32=f.z;this.n33=e.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f; -a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ -c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,g=a.n21,h=a.n22,m=a.n23,k=a.n24,l=a.n31,i=a.n32,n=a.n33,j=a.n34,r=a.n41,t=a.n42,w=a.n43,u=a.n44,M=b.n11,R=b.n12, -B=b.n13,N=b.n14,O=b.n21,s=b.n22,o=b.n23,C=b.n24,D=b.n31,T=b.n32,U=b.n33,F=b.n34,K=b.n41,I=b.n42,J=b.n43,P=b.n44;this.n11=c*M+d*O+f*D+e*K;this.n12=c*R+d*s+f*T+e*I;this.n13=c*B+d*o+f*U+e*J;this.n14=c*N+d*C+f*F+e*P;this.n21=g*M+h*O+m*D+k*K;this.n22=g*R+h*s+m*T+k*I;this.n23=g*B+h*o+m*U+k*J;this.n24=g*N+h*C+m*F+k*P;this.n31=l*M+i*O+n*D+j*K;this.n32=l*R+i*s+n*T+j*I;this.n33=l*B+i*o+n*U+j*J;this.n34=l*N+i*C+n*F+j*P;this.n41=r*M+t*O+w*D+u*K;this.n42=r*R+t*s+w*T+u*I;this.n43=r*B+t*o+w*U+u*J;this.n44=r*N+t* -C+w*F+u*P;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,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,b=this.n12,c=this.n13,d=this.n14,f=this.n21,e=this.n22,g=this.n23,h=this.n24,m=this.n31,k=this.n32,l=this.n33,i=this.n34,n=this.n41,j=this.n42,r=this.n43,t=this.n44;return d*g*k*n-c*h*k*n-d*e*l*n+b*h*l*n+c*e*i*n-b*g*i*n-d*g*m*j+c*h*m*j+d*f*l*j-a*h*l*j-c*f*i*j+a*g*i*j+d*e*m*r-b*h*m*r-d*f*k*r+a*h*k*r+b*f*i*r-a*e*i*r-c*e*m*t+b*g*m*t+c*f*k*t-a*g*k*t-b*f*l*t+a*e*l*t}, -transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11; -a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34; -a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0, -0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,h=a.z,m=f*e,k=f*g;this.set(m*e+c,m*g-d*h,m*h+d*g,0,m*g+d*h,k*g+c,k*h-d*e,0,m*h-d*g,k*h+d*e,f*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,e=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var m= -g*h,k=g*f,l=d*h,i=d*f;this.n11=m+i*c;this.n12=l*c-k;this.n13=e*d;this.n21=e*f;this.n22=e*h;this.n23=-c;this.n31=k*c-l;this.n32=i+m*c;this.n33=e*g;break;case "ZXY":m=g*h;k=g*f;l=d*h;i=d*f;this.n11=m-i*c;this.n12=-e*f;this.n13=l+k*c;this.n21=k+l*c;this.n22=e*h;this.n23=i-m*c;this.n31=-e*d;this.n32=c;this.n33=e*g;break;case "ZYX":m=e*h;k=e*f;l=c*h;i=c*f;this.n11=g*h;this.n12=l*d-k;this.n13=m*d+i;this.n21=g*f;this.n22=i*d+m;this.n23=k*d-l;this.n31=-d;this.n32=c*g;this.n33=e*g;break;case "YZX":m=e*g;k= -e*d;l=c*g;i=c*d;this.n11=g*h;this.n12=i-m*f;this.n13=l*f+k;this.n21=f;this.n22=e*h;this.n23=-c*h;this.n31=-d*h;this.n32=k*f+l;this.n33=m-i*f;break;case "XZY":m=e*g;k=e*d;l=c*g;i=c*d;this.n11=g*h;this.n12=-f;this.n13=d*h;this.n21=m*f+i;this.n22=e*h;this.n23=k*f-l;this.n31=l*f-k;this.n32=c*h;this.n33=i*f+m;break;default:m=e*h,k=e*f,l=c*h,i=c*f,this.n11=g*h,this.n12=-g*f,this.n13=d,this.n21=k+l*d,this.n22=m-i*d,this.n23=-c*g,this.n31=i-m*d,this.n32=l+k*d,this.n33=e*g}return this},setRotationFromQuaternion:function(a){var b= -a.x,c=a.y,d=a.z,f=a.w,e=b+b,g=c+c,h=d+d,a=b*e,m=b*g;b*=h;var k=c*g;c*=h;d*=h;e*=f;g*=f;f*=h;this.n11=1-(k+d);this.n12=m-f;this.n13=b+g;this.n21=m+f;this.n22=1-(a+d);this.n23=c-e;this.n31=b-g;this.n32=c+e;this.n33=1-(a+k);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2; -d.identity();d.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(d,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);e.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length(); -c.y=f.length();c.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,f=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23= -a.n23*f;this.n33=a.n33*f}}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,g=a.n21,h=a.n22,m=a.n23,k=a.n24,l=a.n31,i=a.n32,n=a.n33,j=a.n34,r=a.n41,t=a.n42,w=a.n43,u=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=m*j*t-k*n*t+k*i*w-h*j*w-m*i*u+h*n*u;b.n12=e*n*t-f*j*t-e*i*w+d*j*w+f*i*u-d*n*u;b.n13=f*k*t-e*m*t+e*h*w-d*k*w-f*h*u+d*m*u;b.n14=e*m*i-f*k*i-e*h*n+d*k*n+f*h*j-d*m*j;b.n21=k*n*r-m*j*r-k*l*w+g*j*w+m*l*u-g*n*u;b.n22=f*j*r-e*n*r+e*l*w-c*j*w-f*l*u+c*n*u;b.n23=e*m*r-f*k*r-e*g*w+c*k*w+f*g*u-c*m*u;b.n24= -f*k*l-e*m*l+e*g*n-c*k*n-f*g*j+c*m*j;b.n31=h*j*r-k*i*r+k*l*t-g*j*t-h*l*u+g*i*u;b.n32=e*i*r-d*j*r-e*l*t+c*j*t+d*l*u-c*i*u;b.n33=f*k*r-e*h*r+e*g*t-c*k*t-d*g*u+c*h*u;b.n34=e*h*l-d*k*l-e*g*i+c*k*i+d*g*j-c*h*j;b.n41=m*i*r-h*n*r-m*l*t+g*n*t+h*l*w-g*i*w;b.n42=d*n*r-f*i*r+f*l*t-c*n*t-d*l*w+c*i*w;b.n43=f*h*r-d*m*r-f*g*t+c*m*t+d*g*w-c*h*w;b.n44=d*m*l-f*h*l+f*g*i-c*m*i-d*g*n+c*h*n;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*k;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*g;c[4]=a*h;c[5]=a*m;c[6]=a*k;c[7]=a*l;c[8]=a*i;return b}; +THREE.Matrix4=function(a,b,c,d,f,e,g,h,l,m,j,i,o,n,p,k){this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,h||0,l||0,m||0,j!==void 0?j:1,i||0,o||0,n||0,p||0,k!==void 0?k:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,h,l,m,j,i,o,n,p,k){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=e;this.n23=g;this.n24=h;this.n31=l;this.n32=m;this.n33=j;this.n34=i;this.n41=o;this.n42=n;this.n43=p;this.n44=k;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, +b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,b).normalize();if(e.length()===0)e.z=1;d.cross(c,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(c,e).normalize());f.cross(e,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=e.x;this.n21=d.y;this.n22=f.y;this.n23=e.y;this.n31=d.z;this.n32=f.z;this.n33=e.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,g=a.n21,h=a.n22,l=a.n23,m=a.n24,j=a.n31,i=a.n32,o=a.n33,n=a.n34,p=a.n41,k=a.n42,v=a.n43, +G=a.n44,I=b.n11,r=b.n12,M=b.n13,H=b.n14,N=b.n21,L=b.n22,O=b.n23,t=b.n24,x=b.n31,K=b.n32,R=b.n33,S=b.n34,P=b.n41,u=b.n42,A=b.n43,s=b.n44;this.n11=c*I+d*N+f*x+e*P;this.n12=c*r+d*L+f*K+e*u;this.n13=c*M+d*O+f*R+e*A;this.n14=c*H+d*t+f*S+e*s;this.n21=g*I+h*N+l*x+m*P;this.n22=g*r+h*L+l*K+m*u;this.n23=g*M+h*O+l*R+m*A;this.n24=g*H+h*t+l*S+m*s;this.n31=j*I+i*N+o*x+n*P;this.n32=j*r+i*L+o*K+n*u;this.n33=j*M+i*O+o*R+n*A;this.n34=j*H+i*t+o*S+n*s;this.n41=p*I+k*N+v*x+G*P;this.n42=p*r+k*L+v*K+G*u;this.n43=p*M+k* +O+v*R+G*A;this.n44=p*H+k*t+v*S+G*s;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;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},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22* +c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33* +a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,e=this.n22,g=this.n23,h=this.n24,l=this.n31,m=this.n32,j=this.n33,i=this.n34,o=this.n41,n=this.n42,p=this.n43,k=this.n44;return d*g*m*o-c*h*m*o-d*e*j*o+b*h*j*o+c*e*i*o-b*g*i*o-d*g*l*n+c*h*l*n+d*f*j*n-a*h*j*n-c*f*i*n+a*g*i*n+d*e*l*p-b*h*l*p-d*f*m*p+a*h*m*p+b*f*i*p-a*e*i*p-c*e*l*k+b*g*l*k+c*f*m*k-a*g*m*k-b*f*j*k+a*e*j*k},transpose:function(){var a; +a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; +a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a}, +setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this}, +setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,h=a.z,l=f*e,m=f*g;this.set(l*e+c,l*g-d*h,l*h+d*g,0,l*g+d*h,m*g+c,m*h-d*e,0,l*h-d*g,m*h+d*e,f*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, +this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,f=a.n14,e=a.n21,g=a.n22,h=a.n23,l=a.n24,m=a.n31,j=a.n32,i=a.n33,o=a.n34,n=a.n41,p=a.n42,k=a.n43,v=a.n44;this.n11=h*o*p-l*i*p+l*j*k-g*o*k-h*j*v+g*i*v;this.n12=f*i*p-d*o*p-f*j*k+c*o*k+d*j*v-c*i*v;this.n13=d*l*p-f*h*p+f*g*k-c*l*k-d*g*v+c*h*v;this.n14=f*h*j-d*l*j-f*g*i+c*l*i+d*g*o-c*h*o;this.n21=l*i*n-h*o*n-l*m*k+e*o*k+h*m*v-e*i*v;this.n22=d*o*n-f*i*n+ +f*m*k-b*o*k-d*m*v+b*i*v;this.n23=f*h*n-d*l*n-f*e*k+b*l*k+d*e*v-b*h*v;this.n24=d*l*m-f*h*m+f*e*i-b*l*i-d*e*o+b*h*o;this.n31=g*o*n-l*j*n+l*m*p-e*o*p-g*m*v+e*j*v;this.n32=f*j*n-c*o*n-f*m*p+b*o*p+c*m*v-b*j*v;this.n33=d*l*n-f*g*n+f*e*p-b*l*p-c*e*v+b*g*v;this.n34=f*g*m-c*l*m-f*e*j+b*l*j+c*e*o-b*g*o;this.n41=h*j*n-g*i*n-h*m*p+e*i*p+g*m*k-e*j*k;this.n42=c*i*n-d*j*n+d*m*p-b*i*p-c*m*k+b*j*k;this.n43=d*g*n-c*h*n-d*e*p+b*h*p+c*e*k-b*g*k;this.n44=c*h*m-d*g*m+d*e*j-b*h*j-c*e*i+b*g*i;this.multiplyScalar(1/a.determinant()); +return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,e=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var l=g*h,m=g*f,j=d*h,i=d*f;this.n11=l+i*c;this.n12=j*c-m;this.n13=e*d;this.n21=e*f;this.n22=e*h;this.n23=-c;this.n31=m*c-j;this.n32=i+l*c;this.n33=e*g;break;case "ZXY":l=g*h;m=g*f;j=d*h;i=d*f;this.n11=l-i*c;this.n12=-e*f;this.n13=j+m*c;this.n21=m+j*c;this.n22=e*h;this.n23=i-l*c;this.n31=-e*d;this.n32=c;this.n33=e*g;break;case "ZYX":l= +e*h;m=e*f;j=c*h;i=c*f;this.n11=g*h;this.n12=j*d-m;this.n13=l*d+i;this.n21=g*f;this.n22=i*d+l;this.n23=m*d-j;this.n31=-d;this.n32=c*g;this.n33=e*g;break;case "YZX":l=e*g;m=e*d;j=c*g;i=c*d;this.n11=g*h;this.n12=i-l*f;this.n13=j*f+m;this.n21=f;this.n22=e*h;this.n23=-c*h;this.n31=-d*h;this.n32=m*f+j;this.n33=l-i*f;break;case "XZY":l=e*g;m=e*d;j=c*g;i=c*d;this.n11=g*h;this.n12=-f;this.n13=d*h;this.n21=l*f+i;this.n22=e*h;this.n23=m*f-j;this.n31=j*f-m;this.n32=c*h;this.n33=i*f+l;break;default:l=e*h,m=e* +f,j=c*h,i=c*f,this.n11=g*h,this.n12=-g*f,this.n13=d,this.n21=m+j*d,this.n22=l-i*d,this.n23=-c*g,this.n31=i-l*d,this.n32=j+m*d,this.n33=e*g}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,e=b+b,g=c+c,h=d+d,a=b*e,l=b*g;b*=h;var m=c*g;c*=h;d*=h;e*=f;g*=f;f*=h;this.n11=1-(m+d);this.n12=l-f;this.n13=b+g;this.n21=l+f;this.n22=1-(a+d);this.n23=c-e;this.n31=b-g;this.n32=c+e;this.n33=1-(a+m);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*= +a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(d,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);e.set(this.n13, +this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=f.length();c.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34; +return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this}}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*m;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*g;c[4]=a*h;c[5]=a*l;c[6]=a*m;c[7]=a*j;c[8]=a*i;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,f,e){var g;g=new THREE.Matrix4;g.n11=2*f/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*f/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(e+f)/(e-f);g.n34=-2*e*f/(e-f);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var g,h,m,k;g=new THREE.Matrix4;h=b-a;m=c-d;k=e-f;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/m;g.n23=0;g.n24=-((c+d)/m);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((e+f)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var g,h,l,m;g=new THREE.Matrix4;h=b-a;l=c-d;m=e-f;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/l;g.n23=0;g.n24=-((c+d)/l);g.n31=0;g.n32=0;g.n33=-2/m;g.n34=-((e+f)/m);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(this.children.indexOf(a)=== --1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},remove:function(a){var b=this,c=this.children.indexOf(a);if(c!==-1){a.parent=void 0;for(this.children.splice(c,1);b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.removeChildRecurse(a)}},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c=0&&f>=0&&g>=0&&j>=0?!0:e<0&&f<0||g<0&&j<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-j)):j<0&&(d=Math.min(d,g/(g-j))),dJ&&g.positionScreen.z0&&s.z<1))v=R[M]=R[M]||new THREE.RenderableParticle,M++,u= -v,u.x=s.x/s.w,u.y=s.y/s.w,u.z=s.z,u.rotation=q.rotation.z,u.scale.x=q.scale.x*Math.abs(u.x-(s.x+e.projectionMatrix.n11)/(s.w+e.projectionMatrix.n14)),u.scale.y=q.scale.y*Math.abs(u.y-(s.y+e.projectionMatrix.n22)/(s.w+e.projectionMatrix.n24)),u.materials=q.materials,N.push(u);f&&N.sort(b);return N}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +-1)a.parent!==void 0&&a.parent.remove(a),a.parent=this,this.children.push(a)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d +K&&d.positionScreen.z0&&I.z<1))V=v[k]=v[k]||new THREE.RenderableParticle,k++,p=V,p.x=I.x/I.w,p.y=I.y/I.w,p.z=I.z,p.rotation=w.rotation.z,p.scale.x=w.scale.x*Math.abs(p.x-(I.x+t.projectionMatrix.n11)/(I.w+t.projectionMatrix.n14)),p.scale.y=w.scale.y*Math.abs(p.y-(I.y+t.projectionMatrix.n22)/(I.w+t.projectionMatrix.n24)),p.materials=w.materials,G.elements.push(p);x&&G.elements.sort(b);return G}}; +THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,h=d*f;this.w=g*e-h*c;this.x=g*c+h*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,m=this.w,k=m*c+g*f-h*d,l=m*d+h*c-e*f,i=m*f+e*d-g*c,c=-e* -c-g*d-h*f;b.x=k*m+c*-e+l*-h-i*-g;b.y=l*m+c*-g+i*-e-k*-h;b.z=i*m+c*-h+k*-g-l*-e;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),g=Math.sqrt(1-f*f);if(Math.abs(g)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c}; -THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3}; +this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,l=this.w,m=l*c+g*f-h*d,j=l*d+h*c-e*f,i=l*f+e*d-g*c,c=-e* +c-g*d-h*f;b.x=m*l+c*-e+j*-h-i*-g;b.y=j*l+c*-g+i*-e-m*-h;b.z=i*l+c*-h+m*-g-j*-e;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,f,u){h=a.vertices[b].position;l=a.vertices[c].position;m=a.vertices[d].position;j=g[e];i=g[f];o=g[u];n=l.x-h.x;p=m.x-h.x;k=l.y-h.y;v=m.y-h.y;G=l.z-h.z;I=m.z-h.z;r=i.u-j.u;M=o.u-j.u;H=i.v-j.v;N=o.v-j.v;L=1/(r*N-M*H);K.set((N*n-H*p)*L,(N*k-H*v)*L,(N*G-H*I)*L);R.set((r*p-M*n)*L,(r*v-M*k)*L,(r*I-M*G)*L);t[b].addSelf(K);t[c].addSelf(K);t[d].addSelf(K);x[b].addSelf(R); +x[c].addSelf(R);x[d].addSelf(R)}var b,c,d,f,e,g,h,l,m,j,i,o,n,p,k,v,G,I,r,M,H,N,L,O,t=[],x=[],K=new THREE.Vector3,R=new THREE.Vector3,S=new THREE.Vector3,P=new THREE.Vector3,u=new THREE.Vector3;b=0;for(c=this.vertices.length;b0){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 b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b* -255)+","+t+")"),j.fillRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()))),$.empty())};this.render=function(a,k){function l(a){var b,c,d,e=a.lights;aa.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);a=0;for(b=e.length;a>1,o=l.height>>1,g=e.scale.x*i,m=e.scale.y*n,h=g*p,k=m*o,Y.set(a.x-h,a.y-k,a.x+h,a.y+k),ka.intersects(Y)&&(j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(g,-m),j.translate(-p,-o),j.drawImage(l,0,0),j.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*i,k=e.scale.y*n,Y.set(a.x-h,a.y-k,a.x+h,a.y+k),ka.intersects(Y)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(h,k),g.program(j), -j.restore()))}function t(a,e,f,g){b(g.opacity);c(g.blending);j.beginPath();j.moveTo(a.positionScreen.x,a.positionScreen.y);j.lineTo(e.positionScreen.x,e.positionScreen.y);j.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)j.lineWidth=B=a;a=g.linecap;if(N!=a)j.lineCap=N=a;a=g.linejoin;if(O!=a)j.lineJoin=O=a;d(g.color.getContextStyle());j.stroke();Y.inflate(g.linewidth*2)}}function u(a,d,f,g,j,h,i,p,l){e.info.render.vertices+=3;e.info.render.faces++;b(p.opacity);c(p.blending); -F=a.positionScreen.x;K=a.positionScreen.y;I=d.positionScreen.x;J=d.positionScreen.y;P=f.positionScreen.x;Q=f.positionScreen.y;M(F,K,I,J,P,Q);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(W=i.uvs[0],Ca(F,K,I,J,P,Q,W[g].u,W[g].v,W[j].u,W[j].v,W[h].u,W[h].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,S.copy(i.vertexNormalsWorld[0]),Da=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Ea=-(S.x*a.n21+ -S.y*a.n22+S.z*a.n23)*0.5+0.5,S.copy(i.vertexNormalsWorld[1]),Fa=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Ga=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,S.copy(i.vertexNormalsWorld[2]),Ha=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Ia=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,Ca(F,K,I,J,P,Q,Da,Ea,Fa,Ga,Ha,Ia,p.envMap)}else p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof -THREE.UVMapping&&(W=i.uvs[0],Ca(F,K,I,J,P,Q,W[g].u,W[g].v,W[j].u,W[j].v,W[h].u,W[h].v,p.map)),c(THREE.SubtractiveBlending)),Aa?!p.wireframe&&p.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(x.r=q.r=v.r=aa.r,x.g=q.g=v.g=aa.g,x.b=q.b=v.b=aa.b,m(l,i.v1.positionWorld,i.vertexNormalsWorld[0],x),m(l,i.v2.positionWorld,i.vertexNormalsWorld[1],q),m(l,i.v3.positionWorld,i.vertexNormalsWorld[2],v),x.r=Math.max(0,Math.min(p.color.r*x.r,1)),x.g=Math.max(0,Math.min(p.color.g*x.g,1)),x.b=Math.max(0, -Math.min(p.color.b*x.b,1)),q.r=Math.max(0,Math.min(p.color.r*q.r,1)),q.g=Math.max(0,Math.min(p.color.g*q.g,1)),q.b=Math.max(0,Math.min(p.color.b*q.b,1)),v.r=Math.max(0,Math.min(p.color.r*v.r,1)),v.g=Math.max(0,Math.min(p.color.g*v.g,1)),v.b=Math.max(0,Math.min(p.color.b*v.b,1)),G.r=(q.r+v.r)*0.5,G.g=(q.g+v.g)*0.5,G.b=(q.b+v.b)*0.5,ba=wa(x,q,v,G),ma(F,K,I,J,P,Q,0,0,1,0,0,1,ba)):(ca.r=aa.r,ca.g=aa.g,ca.b=aa.b,m(l,i.centroidWorld,i.normalWorld,ca),z.r=Math.max(0,Math.min(p.color.r*ca.r,1)),z.g=Math.max(0, -Math.min(p.color.g*ca.g,1)),z.b=Math.max(0,Math.min(p.color.b*ca.b,1)),p.wireframe?ga(z,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(z)):p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color);else if(p instanceof THREE.MeshDepthMaterial)ea=k.near,Z=k.far,x.r=x.g=x.b=1-la(a.positionScreen.z,ea,Z),q.r=q.g=q.b=1-la(d.positionScreen.z,ea,Z),v.r=v.g=v.b=1-la(f.positionScreen.z,ea,Z),G.r=(q.r+v.r)*0.5,G.g=(q.g+v.g)*0.5,G.b=(q.b+v.b)*0.5,ba=wa(x, -q,v,G),ma(F,K,I,J,P,Q,0,0,1,0,0,1,ba);else if(p instanceof THREE.MeshNormalMaterial)z.r=na(i.normalWorld.x),z.g=na(i.normalWorld.y),z.b=na(i.normalWorld.z),p.wireframe?ga(z,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(z)}function w(a,d,f,g,j,h,i,p,l){e.info.render.vertices+=4;e.info.render.faces++;b(p.opacity);c(p.blending);if(p.map||p.envMap)u(a,d,g,0,1,3,i,p,l),u(j,f,h,1,2,3,i,p,l);else if(F=a.positionScreen.x,K=a.positionScreen.y,I=d.positionScreen.x,J=d.positionScreen.y,P=f.positionScreen.x, -Q=f.positionScreen.y,V=g.positionScreen.x,E=g.positionScreen.y,pa=j.positionScreen.x,y=j.positionScreen.y,L=h.positionScreen.x,H=h.positionScreen.y,p instanceof THREE.MeshBasicMaterial)R(F,K,I,J,P,Q,V,E),p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color);else if(p instanceof THREE.MeshLambertMaterial)Aa?!p.wireframe&&p.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==4?(x.r=q.r=v.r=G.r=aa.r,x.g=q.g=v.g=G.g=aa.g,x.b=q.b=v.b=G.b=aa.b,m(l,i.v1.positionWorld, -i.vertexNormalsWorld[0],x),m(l,i.v2.positionWorld,i.vertexNormalsWorld[1],q),m(l,i.v4.positionWorld,i.vertexNormalsWorld[3],v),m(l,i.v3.positionWorld,i.vertexNormalsWorld[2],G),x.r=Math.max(0,Math.min(p.color.r*x.r,1)),x.g=Math.max(0,Math.min(p.color.g*x.g,1)),x.b=Math.max(0,Math.min(p.color.b*x.b,1)),q.r=Math.max(0,Math.min(p.color.r*q.r,1)),q.g=Math.max(0,Math.min(p.color.g*q.g,1)),q.b=Math.max(0,Math.min(p.color.b*q.b,1)),v.r=Math.max(0,Math.min(p.color.r*v.r,1)),v.g=Math.max(0,Math.min(p.color.g* -v.g,1)),v.b=Math.max(0,Math.min(p.color.b*v.b,1)),G.r=Math.max(0,Math.min(p.color.r*G.r,1)),G.g=Math.max(0,Math.min(p.color.g*G.g,1)),G.b=Math.max(0,Math.min(p.color.b*G.b,1)),ba=wa(x,q,v,G),M(F,K,I,J,V,E),ma(F,K,I,J,V,E,0,0,1,0,0,1,ba),M(pa,y,P,Q,L,H),ma(pa,y,P,Q,L,H,1,0,1,1,0,1,ba)):(ca.r=aa.r,ca.g=aa.g,ca.b=aa.b,m(l,i.centroidWorld,i.normalWorld,ca),z.r=Math.max(0,Math.min(p.color.r*ca.r,1)),z.g=Math.max(0,Math.min(p.color.g*ca.g,1)),z.b=Math.max(0,Math.min(p.color.b*ca.b,1)),R(F,K,I,J,P,Q,V,E), -p.wireframe?ga(z,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(z)):(R(F,K,I,J,P,Q,V,E),p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color));else if(p instanceof THREE.MeshNormalMaterial)z.r=na(i.normalWorld.x),z.g=na(i.normalWorld.y),z.b=na(i.normalWorld.z),R(F,K,I,J,P,Q,V,E),p.wireframe?ga(z,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(z);else if(p instanceof THREE.MeshDepthMaterial)ea=k.near,Z=k.far,x.r=x.g=x.b=1-la(a.positionScreen.z, -ea,Z),q.r=q.g=q.b=1-la(d.positionScreen.z,ea,Z),v.r=v.g=v.b=1-la(g.positionScreen.z,ea,Z),G.r=G.g=G.b=1-la(f.positionScreen.z,ea,Z),ba=wa(x,q,v,G),M(F,K,I,J,V,E),ma(F,K,I,J,V,E,0,0,1,0,0,1,ba),M(pa,y,P,Q,L,H),ma(pa,y,P,Q,L,H,1,0,1,1,0,1,ba)}function M(a,b,c,d,e,f){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,f);j.lineTo(a,b);j.closePath()}function R(a,b,c,d,e,f,g,h){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,f);j.lineTo(g,h);j.lineTo(a,b);j.closePath()}function ga(a,b,c,e){if(B!= -b)j.lineWidth=B=b;if(N!=c)j.lineCap=N=c;if(O!=e)j.lineJoin=O=e;d(a.getContextStyle());j.stroke();Y.inflate(b*2)}function ha(a){f(a.getContextStyle());j.fill()}function Ca(a,b,c,d,e,g,h,i,l,k,m,o,n){if(n.image.width!=0){if(n.needsUpdate==!0||za[n.id]==void 0){var q=n.wrapS==THREE.RepeatWrapping,r=n.wrapT==THREE.RepeatWrapping;za[n.id]=j.createPattern(n.image,q&&r?"repeat":q&&!r?"repeat-x":!q&&r?"repeat-y":"no-repeat");n.needsUpdate=!1}f(za[n.id]);var q=n.offset.x/n.repeat.x,r=n.offset.y/n.repeat.y, -s=(n.image.width-1)*n.repeat.x,n=(n.image.height-1)*n.repeat.y,h=(h+q)*s,i=(i+r)*n,l=(l+q)*s,k=(k+r)*n,m=(m+q)*s,o=(o+r)*n;c-=a;d-=b;e-=a;g-=b;l-=h;k-=i;m-=h;o-=i;q=1/(l*o-m*k);n=(o*c-k*e)*q;k=(o*d-k*g)*q;c=(l*e-m*c)*q;d=(l*g-m*d)*q;a=a-n*h-c*i;b=b-k*h-d*i;j.save();j.transform(n,k,c,d,a,b);j.fill();j.restore()}}function ma(a,b,c,d,e,f,g,h,i,k,l,m,n){var o,q;o=n.width-1;q=n.height-1;g*=o;h*=q;i*=o;k*=q;l*=o;m*=q;c-=a;d-=b;e-=a;f-=b;i-=g;k-=h;l-=g;m-=h;q=1/(i*m-l*k);o=(m*c-k*e)*q;k=(m*d-k*f)*q;c=(i* -e-l*c)*q;d=(i*f-l*d)*q;a=a-o*g-c*h;b=b-k*g-d*h;j.save();j.transform(o,k,c,d,a,b);j.clip();j.drawImage(n,0,0);j.restore()}function wa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);da[0]=e<0?0:e>255?255:e;da[1]=f<0?0:f>255?255:f;da[2]=a<0?0:a>255?255:a;da[4]=g<0?0:g>255?255:g;da[5]=h<0?0:h>255?255:h;da[6]=b<0?0:b>255?255:b;da[8]=i<0?0:i>255?255:i;da[9]=j<0?0:j>255?255: -j;da[10]=c<0?0:c>255?255:c;da[12]=k<0?0:k>255?255:k;da[13]=l<0?0:l>255?255:l;da[14]=d<0?0:d>255?255:d;ra.putImageData(Ba,0,0);va.drawImage(qa,0,0);return sa}function la(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ia(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ja,A,fa,ja,oa,ya,X;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);e.info.render.vertices=0;e.info.render.faces=0; -g=h.projectScene(a,k,this.sortElements);(Aa=a.lights.length>0)&&l(a);xa=0;for(Ja=g.length;xa0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(v.r*255)+","+Math.floor(v.g*255)+","+Math.floor(v.b*255)+","+G+")"),k.fillRect(Math.floor(X.getX()), +Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight()))),X.empty())};this.render=function(a,j){function i(a){var b,c,d,e;Y.setRGB(0,0,0);ua.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(c=a.length;b>1,o=i.height>> +1,g=e.scale.x*n,l=e.scale.y*p,h=g*q,j=l*o,W.set(a.x-h,a.y-j,a.x+h,a.y+j),ma.intersects(W)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-l),k.translate(-q,-o),k.drawImage(i,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*n,j=e.scale.y*p,W.set(a.x-h,a.y-j,a.x+h,a.y+j),ma.intersects(W)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,j),g.program(k),k.restore()))}function v(a,e, +f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(N!=a)k.lineWidth=N=a;a=g.linecap;if(L!=a)k.lineCap=L=a;a=g.linejoin;if(O!=a)k.lineJoin=O=a;d(g.color.getContextStyle());k.stroke();W.inflate(g.linewidth*2)}}function G(a,d,f,g,h,k,i,q){e.info.render.vertices+=3;e.info.render.faces++;b(q.opacity);c(q.blending);u=a.positionScreen.x;A=a.positionScreen.y; +s=d.positionScreen.x;E=d.positionScreen.y;z=f.positionScreen.x;J=f.positionScreen.y;H(u,A,s,E,z,J);if(q instanceof THREE.MeshBasicMaterial)if(q.map)q.map.mapping instanceof THREE.UVMapping&&(Z=i.uvs[0],Da(u,A,s,E,z,J,Z[g].u,Z[g].v,Z[h].u,Z[h].v,Z[k].u,Z[k].v,q.map));else if(q.envMap){if(q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=j.matrixWorldInverse,T.copy(i.vertexNormalsWorld[g]),Ea=(T.x*a.n11+T.y*a.n12+T.z*a.n13)*0.5+0.5,Fa=-(T.x*a.n21+T.y*a.n22+T.z*a.n23)*0.5+0.5,T.copy(i.vertexNormalsWorld[h]), +Ga=(T.x*a.n11+T.y*a.n12+T.z*a.n13)*0.5+0.5,Ha=-(T.x*a.n21+T.y*a.n22+T.z*a.n23)*0.5+0.5,T.copy(i.vertexNormalsWorld[k]),Ia=(T.x*a.n11+T.y*a.n12+T.z*a.n13)*0.5+0.5,Ja=-(T.x*a.n21+T.y*a.n22+T.z*a.n23)*0.5+0.5,Da(u,A,s,E,z,J,Ea,Fa,Ga,Ha,Ia,Ja,q.envMap)}else q.wireframe?ia(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(q.color);else if(q instanceof THREE.MeshLambertMaterial)q.map&&!q.wireframe&&(q.map.mapping instanceof THREE.UVMapping&&(Z=i.uvs[0],Da(u,A,s,E,z,J,Z[g].u,Z[g].v, +Z[h].u,Z[h].v,Z[k].u,Z[k].v,q.map)),c(THREE.SubtractiveBlending)),Ba?!q.wireframe&&q.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(B.r=C.r=D.r=Y.r,B.g=C.g=D.g=Y.g,B.b=C.b=D.b=Y.b,o(l,i.v1.positionWorld,i.vertexNormalsWorld[0],B),o(l,i.v2.positionWorld,i.vertexNormalsWorld[1],C),o(l,i.v3.positionWorld,i.vertexNormalsWorld[2],D),B.r=Math.max(0,Math.min(q.color.r*B.r,1)),B.g=Math.max(0,Math.min(q.color.g*B.g,1)),B.b=Math.max(0,Math.min(q.color.b*B.b,1)),C.r=Math.max(0,Math.min(q.color.r* +C.r,1)),C.g=Math.max(0,Math.min(q.color.g*C.g,1)),C.b=Math.max(0,Math.min(q.color.b*C.b,1)),D.r=Math.max(0,Math.min(q.color.r*D.r,1)),D.g=Math.max(0,Math.min(q.color.g*D.g,1)),D.b=Math.max(0,Math.min(q.color.b*D.b,1)),Q.r=(C.r+D.r)*0.5,Q.g=(C.g+D.g)*0.5,Q.b=(C.b+D.b)*0.5,ca=xa(B,C,D,Q),oa(u,A,s,E,z,J,0,0,1,0,0,1,ca)):(y.r=Y.r,y.g=Y.g,y.b=Y.b,o(l,i.centroidWorld,i.normalWorld,y),y.r=Math.max(0,Math.min(q.color.r*y.r,1)),y.g=Math.max(0,Math.min(q.color.g*y.g,1)),y.b=Math.max(0,Math.min(q.color.b*y.b, +1)),q.wireframe?ia(y,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(y)):q.wireframe?ia(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(q.color);else if(q instanceof THREE.MeshDepthMaterial)ea=j.near,fa=j.far,B.r=B.g=B.b=1-na(a.positionScreen.z,ea,fa),C.r=C.g=C.b=1-na(d.positionScreen.z,ea,fa),D.r=D.g=D.b=1-na(f.positionScreen.z,ea,fa),Q.r=(C.r+D.r)*0.5,Q.g=(C.g+D.g)*0.5,Q.b=(C.b+D.b)*0.5,ca=xa(B,C,D,Q),oa(u,A,s,E,z,J,0,0,1,0,0,1,ca);else if(q instanceof THREE.MeshNormalMaterial)y.r= +pa(i.normalWorld.x),y.g=pa(i.normalWorld.y),y.b=pa(i.normalWorld.z),q.wireframe?ia(y,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(y)}function I(a,d,f,g,h,k,i,q,n){e.info.render.vertices+=4;e.info.render.faces++;b(q.opacity);c(q.blending);if(q.map||q.envMap)G(a,d,g,0,1,3,i,q,n),G(h,f,k,1,2,3,i,q,n);else if(u=a.positionScreen.x,A=a.positionScreen.y,s=d.positionScreen.x,E=d.positionScreen.y,z=f.positionScreen.x,J=f.positionScreen.y,w=g.positionScreen.x,V=g.positionScreen.y,$=h.positionScreen.x, +ga=h.positionScreen.y,ha=k.positionScreen.x,da=k.positionScreen.y,q instanceof THREE.MeshBasicMaterial)M(u,A,s,E,z,J,w,V),q.wireframe?ia(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(q.color);else if(q instanceof THREE.MeshLambertMaterial)Ba?!q.wireframe&&q.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==4?(B.r=C.r=D.r=Q.r=Y.r,B.g=C.g=D.g=Q.g=Y.g,B.b=C.b=D.b=Q.b=Y.b,o(l,i.v1.positionWorld,i.vertexNormalsWorld[0],B),o(l,i.v2.positionWorld,i.vertexNormalsWorld[1], +C),o(l,i.v4.positionWorld,i.vertexNormalsWorld[3],D),o(l,i.v3.positionWorld,i.vertexNormalsWorld[2],Q),B.r=Math.max(0,Math.min(q.color.r*B.r,1)),B.g=Math.max(0,Math.min(q.color.g*B.g,1)),B.b=Math.max(0,Math.min(q.color.b*B.b,1)),C.r=Math.max(0,Math.min(q.color.r*C.r,1)),C.g=Math.max(0,Math.min(q.color.g*C.g,1)),C.b=Math.max(0,Math.min(q.color.b*C.b,1)),D.r=Math.max(0,Math.min(q.color.r*D.r,1)),D.g=Math.max(0,Math.min(q.color.g*D.g,1)),D.b=Math.max(0,Math.min(q.color.b*D.b,1)),Q.r=Math.max(0,Math.min(q.color.r* +Q.r,1)),Q.g=Math.max(0,Math.min(q.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(q.color.b*Q.b,1)),ca=xa(B,C,D,Q),H(u,A,s,E,w,V),oa(u,A,s,E,w,V,0,0,1,0,0,1,ca),H($,ga,z,J,ha,da),oa($,ga,z,J,ha,da,1,0,1,1,0,1,ca)):(y.r=Y.r,y.g=Y.g,y.b=Y.b,o(l,i.centroidWorld,i.normalWorld,y),y.r=Math.max(0,Math.min(q.color.r*y.r,1)),y.g=Math.max(0,Math.min(q.color.g*y.g,1)),y.b=Math.max(0,Math.min(q.color.b*y.b,1)),M(u,A,s,E,z,J,w,V),q.wireframe?ia(y,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(y)):(M(u, +A,s,E,z,J,w,V),q.wireframe?ia(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(q.color));else if(q instanceof THREE.MeshNormalMaterial)y.r=pa(i.normalWorld.x),y.g=pa(i.normalWorld.y),y.b=pa(i.normalWorld.z),M(u,A,s,E,z,J,w,V),q.wireframe?ia(y,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ja(y);else if(q instanceof THREE.MeshDepthMaterial)ea=j.near,fa=j.far,B.r=B.g=B.b=1-na(a.positionScreen.z,ea,fa),C.r=C.g=C.b=1-na(d.positionScreen.z,ea,fa),D.r=D.g=D.b=1-na(g.positionScreen.z, +ea,fa),Q.r=Q.g=Q.b=1-na(f.positionScreen.z,ea,fa),ca=xa(B,C,D,Q),H(u,A,s,E,w,V),oa(u,A,s,E,w,V,0,0,1,0,0,1,ca),H($,ga,z,J,ha,da),oa($,ga,z,J,ha,da,1,0,1,1,0,1,ca)}function H(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function M(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ia(a,b,c,e){if(N!=b)k.lineWidth=N=b;if(L!=c)k.lineCap=L=c;if(O!=e)k.lineJoin=O=e;d(a.getContextStyle()); +k.stroke();W.inflate(b*2)}function ja(a){f(a.getContextStyle());k.fill()}function Da(a,b,c,d,e,g,h,i,j,l,n,o,m){if(m.image.width!=0){if(m.needsUpdate==!0||Aa[m.id]==void 0){var p=m.wrapS==THREE.RepeatWrapping,r=m.wrapT==THREE.RepeatWrapping;Aa[m.id]=k.createPattern(m.image,p&&r?"repeat":p&&!r?"repeat-x":!p&&r?"repeat-y":"no-repeat");m.needsUpdate=!1}f(Aa[m.id]);var p=m.offset.x/m.repeat.x,r=m.offset.y/m.repeat.y,s=(m.image.width-1)*m.repeat.x,m=(m.image.height-1)*m.repeat.y,h=(h+p)*s,i=(i+r)*m,j= +(j+p)*s,l=(l+r)*m,n=(n+p)*s,o=(o+r)*m;c-=a;d-=b;e-=a;g-=b;j-=h;l-=i;n-=h;o-=i;p=1/(j*o-n*l);m=(o*c-l*e)*p;l=(o*d-l*g)*p;c=(j*e-n*c)*p;d=(j*g-n*d)*p;a=a-m*h-c*i;b=b-l*h-d*i;k.save();k.transform(m,l,c,d,a,b);k.fill();k.restore()}}function oa(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;i*=o;j*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;i-=g;j-=h;l-=g;m-=h;p=1/(i*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;k.save();k.transform(o,j,c,d,a,b);k.clip(); +k.drawImage(n,0,0);k.restore()}function xa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);aa[0]=e<0?0:e>255?255:e;aa[1]=f<0?0:f>255?255:f;aa[2]=a<0?0:a>255?255:a;aa[4]=g<0?0:g>255?255:g;aa[5]=h<0?0:h>255?255:h;aa[6]=b<0?0:b>255?255:b;aa[8]=i<0?0:i>255?255:i;aa[9]=j<0?0:j>255?255:j;aa[10]=c<0?0:c>255?255:c;aa[12]=k<0?0:k>255?255:k;aa[13]=l<0?0:l>255?255:l;aa[14]=d<0? +0:d>255?255:d;sa.putImageData(Ca,0,0);wa.drawImage(ra,0,0);return ta}function na(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function pa(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ka(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var ya,Ka,F,ba,la,qa,za,U;this.autoClear?this.clear():k.setTransform(1,0,0,-1,n,p);e.info.render.vertices=0;e.info.render.faces=0;g=m.projectScene(a,j,this.sortElements);h=g.elements;l=g.lights;(Ba=l.length>0)&&i(l);ya= +0;for(Ka=h.length;ya1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12 THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b0&&a>0&&f+a<1}for(var d,e=[],g=0,f=a.children.length;ga.scale.x)return[];d={distance:g,point:a.position,face:null,object:a};e.push(d)}else if(a instanceof THREE.Mesh){g=b(this.origin, -this.direction,a.matrixWorld.getPosition());if(g==null||g>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return e;for(var h,k,i,j,l,n,m,p,q=a.geometry,s=q.vertices,g=0,f=q.faces.length;g0:n<0)))if(n=l.dot((new THREE.Vector3).sub(h,m))/n,m=m.addSelf(p.multiplyScalar(n)),d instanceof THREE.Face3)c(m,h,k,i)&&(d={distance:this.origin.distanceTo(m),point:m,face:d,object:a},e.push(d));else if(d instanceof THREE.Face4&&(c(m,h,k,j)||c(m,k,i,j)))d={distance:this.origin.distanceTo(m),point:m,face:d,object:a},e.push(d)}return e}}; -THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,l){h=!1;b=f;c=g;d=j;e=l;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,j,l,n,m){h?(h=!1,b=fj?f>n?f:n:j>n?j:n,e=g>l?g>m?g:m:l>m?l:m):(b=fj?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>l?g>m?g>e?g:e:m>e?m:e:l>m?l>e?l:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +this.direction,a.matrixWorld.getPosition());if(g==null||g>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return e;var h,k,l,i,j,n,m,p,q=a.geometry,s=q.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);g=0;for(f=q.faces.length;g0:n<0)))if(n=j.dot((new THREE.Vector3).sub(h,m))/n,m=m.addSelf(p.multiplyScalar(n)),d instanceof THREE.Face3)c(m,h,k,l)&&(d={distance:this.origin.distanceTo(m),point:m,face:d,object:a},e.push(d));else if(d instanceof THREE.Face4&&(c(m,h,k,i)||c(m,k,l,i)))d={distance:this.origin.distanceTo(m), +point:m,face:d,object:a},e.push(d)}return e}}; +THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,i,j){h=!1;b=f;c=g;d=i;e=j;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= +function(f,g,i,j,n,m){h?(h=!1,b=fi?f>n?f:n:i>n?i:n,e=g>j?g>m?g:m:j>m?j:m):(b=fi?f>n?f>d?f:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d,e=g>j?g>m?g>e?g:e:m>e?m:e:j>m?j>e?j:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,g,f,h,k,i,j,l,n,m,p,q){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,g!==void 0?g:1,f||0,h||0,k||0,i||0,j!==void 0?j:1,l||0,n||0,m||0,p||0,q!==void 0?q:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,k,i,j,l,n,m,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=k;this.n32=i;this.n33=j;this.n34=l;this.n41=n;this.n42=m;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, -b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e; -a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ -c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,i=a.n24,j=a.n31,l=a.n32,n=a.n33,m=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44,J=b.n11,M=b.n12, -C=b.n13,D=b.n14,H=b.n21,v=b.n22,o=b.n23,K=b.n24,z=b.n31,E=b.n32,F=b.n33,Q=b.n34,R=b.n41,S=b.n42,T=b.n43,U=b.n44;this.n11=c*J+d*H+e*z+g*R;this.n12=c*M+d*v+e*E+g*S;this.n13=c*C+d*o+e*F+g*T;this.n14=c*D+d*K+e*Q+g*U;this.n21=f*J+h*H+k*z+i*R;this.n22=f*M+h*v+k*E+i*S;this.n23=f*C+h*o+k*F+i*T;this.n24=f*D+h*K+k*Q+i*U;this.n31=j*J+l*H+n*z+m*R;this.n32=j*M+l*v+n*E+m*S;this.n33=j*C+l*o+n*F+m*T;this.n34=j*D+l*K+n*Q+m*U;this.n41=p*J+q*H+s*z+r*R;this.n42=p*M+q*v+s*E+r*S;this.n43=p*C+q*o+s*F+r*T;this.n44=p*D+q* -K+s*Q+r*U;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,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,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,h=this.n24,k=this.n31,i=this.n32,j=this.n33,l=this.n34,n=this.n41,m=this.n42,p=this.n43,q=this.n44;return d*f*i*n-c*h*i*n-d*g*j*n+b*h*j*n+c*g*l*n-b*f*l*n-d*f*k*m+c*h*k*m+d*e*j*m-a*h*j*m-c*e*l*m+a*f*l*m+d*g*k*p-b*h*k*p-d*e*i*p+a*h*i*p+b*e*l*p-a*g*l*p-c*g*k*q+b*f*k*q+c*e*i*q-a*f*i*q-b*e*j*q+a*g*j*q}, -transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11; -a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34; -a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0, -0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,f=a.y,h=a.z,k=e*g,i=e*f;this.set(k*g+c,k*f-d*h,k*h+d*f,0,k*f+d*h,i*f+c,i*h-d*g,0,k*h-d*f,i*h+d*g,e*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),f=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var k= -f*h,i=f*e,j=d*h,l=d*e;this.n11=k+l*c;this.n12=j*c-i;this.n13=g*d;this.n21=g*e;this.n22=g*h;this.n23=-c;this.n31=i*c-j;this.n32=l+k*c;this.n33=g*f;break;case "ZXY":k=f*h;i=f*e;j=d*h;l=d*e;this.n11=k-l*c;this.n12=-g*e;this.n13=j+i*c;this.n21=i+j*c;this.n22=g*h;this.n23=l-k*c;this.n31=-g*d;this.n32=c;this.n33=g*f;break;case "ZYX":k=g*h;i=g*e;j=c*h;l=c*e;this.n11=f*h;this.n12=j*d-i;this.n13=k*d+l;this.n21=f*e;this.n22=l*d+k;this.n23=i*d-j;this.n31=-d;this.n32=c*f;this.n33=g*f;break;case "YZX":k=g*f;i= -g*d;j=c*f;l=c*d;this.n11=f*h;this.n12=l-k*e;this.n13=j*e+i;this.n21=e;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=i*e+j;this.n33=k-l*e;break;case "XZY":k=g*f;i=g*d;j=c*f;l=c*d;this.n11=f*h;this.n12=-e;this.n13=d*h;this.n21=k*e+l;this.n22=g*h;this.n23=i*e-j;this.n31=j*e-i;this.n32=c*h;this.n33=l*e+k;break;default:k=g*h,i=g*e,j=c*h,l=c*e,this.n11=f*h,this.n12=-f*e,this.n13=d,this.n21=i+j*d,this.n22=k-l*d,this.n23=-c*f,this.n31=l-k*d,this.n32=j+i*d,this.n33=g*f}return this},setRotationFromQuaternion:function(a){var b= -a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,h=d+d,a=b*g,k=b*f;b*=h;var i=c*f;c*=h;d*=h;g*=e;f*=e;e*=h;this.n11=1-(i+d);this.n12=k-e;this.n13=b+f;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2; -d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length(); -c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23= -a.n23*e;this.n33=a.n33*e}}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,i=a.n24,j=a.n31,l=a.n32,n=a.n33,m=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=k*m*q-i*n*q+i*l*s-h*m*s-k*l*r+h*n*r;b.n12=g*n*q-e*m*q-g*l*s+d*m*s+e*l*r-d*n*r;b.n13=e*i*q-g*k*q+g*h*s-d*i*s-e*h*r+d*k*r;b.n14=g*k*l-e*i*l-g*h*n+d*i*n+e*h*m-d*k*m;b.n21=i*n*p-k*m*p-i*j*s+f*m*s+k*j*r-f*n*r;b.n22=e*m*p-g*n*p+g*j*s-c*m*s-e*j*r+c*n*r;b.n23=g*k*p-e*i*p-g*f*s+c*i*s+e*f*r-c*k*r;b.n24= -e*i*j-g*k*j+g*f*n-c*i*n-e*f*m+c*k*m;b.n31=h*m*p-i*l*p+i*j*q-f*m*q-h*j*r+f*l*r;b.n32=g*l*p-d*m*p-g*j*q+c*m*q+d*j*r-c*l*r;b.n33=e*i*p-g*h*p+g*f*q-c*i*q-d*f*r+c*h*r;b.n34=g*h*j-d*i*j-g*f*l+c*i*l+d*f*m-c*h*m;b.n41=k*l*p-h*n*p-k*j*q+f*n*q+h*j*s-f*l*s;b.n42=d*n*p-e*l*p+e*j*q-c*n*q-d*j*s+c*l*s;b.n43=e*h*p-d*k*p-e*f*q+c*k*q+d*f*s-c*h*s;b.n44=d*k*j-e*h*j+e*f*l-c*k*l-d*f*n+c*h*n;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*k;c[6]=a*i;c[7]=a*j;c[8]=a*l;return b}; +THREE.Matrix4=function(a,b,c,d,e,g,f,h,k,l,i,j,n,m,p,q){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,g!==void 0?g:1,f||0,h||0,k||0,l||0,i!==void 0?i:1,j||0,n||0,m||0,p||0,q!==void 0?q:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,k,l,i,j,n,m,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=k;this.n32=l;this.n33=i;this.n34=j;this.n41=n;this.n42=m;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, +b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,l=a.n24,i=a.n31,j=a.n32,n=a.n33,m=a.n34,p=a.n41,q=a.n42,s=a.n43, +x=a.n44,v=b.n11,o=b.n12,I=b.n13,B=b.n14,F=b.n21,G=b.n22,E=b.n23,z=b.n24,L=b.n31,M=b.n32,N=b.n33,H=b.n34,C=b.n41,u=b.n42,A=b.n43,r=b.n44;this.n11=c*v+d*F+e*L+g*C;this.n12=c*o+d*G+e*M+g*u;this.n13=c*I+d*E+e*N+g*A;this.n14=c*B+d*z+e*H+g*r;this.n21=f*v+h*F+k*L+l*C;this.n22=f*o+h*G+k*M+l*u;this.n23=f*I+h*E+k*N+l*A;this.n24=f*B+h*z+k*H+l*r;this.n31=i*v+j*F+n*L+m*C;this.n32=i*o+j*G+n*M+m*u;this.n33=i*I+j*E+n*N+m*A;this.n34=i*B+j*z+n*H+m*r;this.n41=p*v+q*F+s*L+x*C;this.n42=p*o+q*G+s*M+x*u;this.n43=p*I+q* +E+s*N+x*A;this.n44=p*B+q*z+s*H+x*r;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;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},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22* +c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33* +a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,h=this.n24,k=this.n31,l=this.n32,i=this.n33,j=this.n34,n=this.n41,m=this.n42,p=this.n43,q=this.n44;return d*f*l*n-c*h*l*n-d*g*i*n+b*h*i*n+c*g*j*n-b*f*j*n-d*f*k*m+c*h*k*m+d*e*i*m-a*h*i*m-c*e*j*m+a*f*j*m+d*g*k*p-b*h*k*p-d*e*l*p+a*h*l*p+b*e*j*p-a*g*j*p-c*g*k*q+b*f*k*q+c*e*l*q-a*f*l*q-b*e*i*q+a*g*i*q},transpose:function(){var a; +a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; +a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a}, +setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this}, +setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,f=a.y,h=a.z,k=e*g,l=e*f;this.set(k*g+c,k*f-d*h,k*h+d*f,0,k*f+d*h,l*f+c,l*h-d*g,0,k*h-d*f,l*h+d*g,e*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, +this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,e=a.n14,g=a.n21,f=a.n22,h=a.n23,k=a.n24,l=a.n31,i=a.n32,j=a.n33,n=a.n34,m=a.n41,p=a.n42,q=a.n43,s=a.n44;this.n11=h*n*p-k*j*p+k*i*q-f*n*q-h*i*s+f*j*s;this.n12=e*j*p-d*n*p-e*i*q+c*n*q+d*i*s-c*j*s;this.n13=d*k*p-e*h*p+e*f*q-c*k*q-d*f*s+c*h*s;this.n14=e*h*i-d*k*i-e*f*j+c*k*j+d*f*n-c*h*n;this.n21=k*j*m-h*n*m-k*l*q+g*n*q+h*l*s-g*j*s;this.n22=d*n*m-e*j*m+ +e*l*q-b*n*q-d*l*s+b*j*s;this.n23=e*h*m-d*k*m-e*g*q+b*k*q+d*g*s-b*h*s;this.n24=d*k*l-e*h*l+e*g*j-b*k*j-d*g*n+b*h*n;this.n31=f*n*m-k*i*m+k*l*p-g*n*p-f*l*s+g*i*s;this.n32=e*i*m-c*n*m-e*l*p+b*n*p+c*l*s-b*i*s;this.n33=d*k*m-e*f*m+e*g*p-b*k*p-c*g*s+b*f*s;this.n34=e*f*l-c*k*l-e*g*i+b*k*i+c*g*n-b*f*n;this.n41=h*i*m-f*j*m-h*l*p+g*j*p+f*l*q-g*i*q;this.n42=c*j*m-d*i*m+d*l*p-b*j*p-c*l*q+b*i*q;this.n43=d*f*m-c*h*m-d*g*p+b*h*p+c*g*q-b*f*q;this.n44=c*h*l-d*f*l+d*g*i-b*h*i-c*g*j+b*f*j;this.multiplyScalar(1/a.determinant()); +return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),f=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var k=f*h,l=f*e,i=d*h,j=d*e;this.n11=k+j*c;this.n12=i*c-l;this.n13=g*d;this.n21=g*e;this.n22=g*h;this.n23=-c;this.n31=l*c-i;this.n32=j+k*c;this.n33=g*f;break;case "ZXY":k=f*h;l=f*e;i=d*h;j=d*e;this.n11=k-j*c;this.n12=-g*e;this.n13=i+l*c;this.n21=l+i*c;this.n22=g*h;this.n23=j-k*c;this.n31=-g*d;this.n32=c;this.n33=g*f;break;case "ZYX":k= +g*h;l=g*e;i=c*h;j=c*e;this.n11=f*h;this.n12=i*d-l;this.n13=k*d+j;this.n21=f*e;this.n22=j*d+k;this.n23=l*d-i;this.n31=-d;this.n32=c*f;this.n33=g*f;break;case "YZX":k=g*f;l=g*d;i=c*f;j=c*d;this.n11=f*h;this.n12=j-k*e;this.n13=i*e+l;this.n21=e;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*e+i;this.n33=k-j*e;break;case "XZY":k=g*f;l=g*d;i=c*f;j=c*d;this.n11=f*h;this.n12=-e;this.n13=d*h;this.n21=k*e+j;this.n22=g*h;this.n23=l*e-i;this.n31=i*e-l;this.n32=c*h;this.n33=j*e+k;break;default:k=g*h,l=g* +e,i=c*h,j=c*e,this.n11=f*h,this.n12=-f*e,this.n13=d,this.n21=l+i*d,this.n22=k-j*d,this.n23=-c*f,this.n31=j-k*d,this.n32=i+l*d,this.n33=g*f}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,h=d+d,a=b*g,k=b*f;b*=h;var l=c*f;c*=h;d*=h;g*=e;f*=e;e*=h;this.n11=1-(l+d);this.n12=k-e;this.n13=b+f;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*= +a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13, +this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34; +return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this}}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,i=-a.n23*a.n11+a.n21*a.n13,j=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*k;c[6]=a*l;c[7]=a*i;c[8]=a*j;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,k,i;f=new THREE.Matrix4;h=b-a;k=c-d;i=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/k;f.n23=0;f.n24=-((c+d)/k);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,k,l;f=new THREE.Matrix4;h=b-a;k=c-d;l=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/k;f.n23=0;f.n24=-((c+d)/k);f.n31=0;f.n32=0;f.n33=-2/l;f.n34=-((g+e)/l);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(this.children.indexOf(a)=== --1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},remove:function(a){var b=this,c=this.children.indexOf(a);if(c!==-1){a.parent=void 0;for(this.children.splice(c,1);b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.removeChildRecurse(a)}},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dC&&f.positionScreen.z0&&v.z<1))L=M[J]=M[J]||new THREE.RenderableParticle,J++,r= -L,r.x=v.x/v.w,r.y=v.y/v.w,r.z=v.z,r.rotation=u.rotation.z,r.scale.x=u.scale.x*Math.abs(r.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),r.scale.y=u.scale.y*Math.abs(r.y-(v.y+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),r.materials=u.materials,D.push(r);g&&D.sort(b);return D}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +-1)a.parent!==void 0&&a.parent.remove(a),a.parent=this,this.children.push(a)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d +M&&d.positionScreen.z0&&v.z<1))J=s[q]=s[q]||new THREE.RenderableParticle,q++,p=J,p.x=v.x/v.w,p.y=v.y/v.w,p.z=v.z,p.rotation=t.rotation.z,p.scale.x=t.scale.x*Math.abs(p.x-(v.x+z.projectionMatrix.n11)/(v.w+z.projectionMatrix.n14)),p.scale.y=t.scale.y*Math.abs(p.y-(v.y+z.projectionMatrix.n22)/(v.w+z.projectionMatrix.n24)),p.materials=t.materials,x.elements.push(p);L&&x.elements.sort(b);return x}}; +THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,k=this.w,i=k*c+f*e-h*d,j=k*d+h*c-g*e,l=k*e+g*d-f*c,c=-g* -c-f*d-h*e;b.x=i*k+c*-g+j*-h-l*-f;b.y=j*k+c*-f+l*-g-i*-h;b.z=l*k+c*-h+i*-f-j*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c}; -THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,k=this.w,l=k*c+f*e-h*d,i=k*d+h*c-g*e,j=k*e+g*d-f*c,c=-g* +c-f*d-h*e;b.x=l*k+c*-g+i*-h-j*-f;b.y=i*k+c*-f+j*-g-l*-h;b.z=j*k+c*-h+l*-f-i*-g;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; -THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera; -THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)}; -THREE.Camera.prototype.update=function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(a=0;a1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=h;return b}, -clamp:function(a,b,c){return ac?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){var c,e,f=a.vertices.length,h=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,k=h.vertices,l=a.faces,m=h.faces,n=a.faceVertexUvs[0],h=h.faceVertexUvs[0];if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,e=new THREE.Matrix4,e.extractRotation(c,b.scale);for(var o=0,t=k.length;o1&&(e=1-e,f=1-f);h=1-e-f;g.copy(a);g.multiplyScalar(e);k.copy(b);k.multiplyScalar(f);g.addSelf(k);k.copy(c);k.multiplyScalar(h);g.addSelf(k);return g},randomPointInFace:function(a,b,c){var e,f,h;if(a instanceof THREE.Face3)return e=b.vertices[a.a].position,f=b.vertices[a.b].position,h=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,f,h);else if(a instanceof THREE.Face4){e=b.vertices[a.a].position;f=b.vertices[a.b].position;h=b.vertices[a.c].position;var b=b.vertices[a.d].position, -g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(e,f,b),g=THREE.GeometryUtils.triangleArea(f,h,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(e,f,b),g=THREE.GeometryUtils.triangleArea(f,h,b));return THREE.GeometryUtils.random()*(c+g) -a?c(b,g-1):m[g]1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=f;c.v=h;return c}, +clamp:function(a,c,b){return ab?b:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; +THREE.GeometryUtils={merge:function(a,c){var b,e,g=a.vertices.length,h=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,k=h.vertices,l=a.faces,m=h.faces,n=a.faceVertexUvs[0],h=h.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),b=c.matrix,e=new THREE.Matrix4,e.extractRotation(b,c.scale);for(var o=0,p=k.length;o1&&(e=1-e,g=1-g);h=1-e-g;f.copy(a);f.multiplyScalar(e);k.copy(c);k.multiplyScalar(g);f.addSelf(k);k.copy(b);k.multiplyScalar(h);f.addSelf(k);return f},randomPointInFace:function(a,c,b){var e,g,h;if(a instanceof THREE.Face3)return e=c.vertices[a.a].position,g=c.vertices[a.b].position,h=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,g,h);else if(a instanceof THREE.Face4){e=c.vertices[a.a].position;g=c.vertices[a.b].position;h=c.vertices[a.c].position;var c=c.vertices[a.d].position, +f;b?a._area1&&a._area2?(b=a._area1,f=a._area2):(b=THREE.GeometryUtils.triangleArea(e,g,c),f=THREE.GeometryUtils.triangleArea(g,h,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(e,g,c),f=THREE.GeometryUtils.triangleArea(g,h,c));return THREE.GeometryUtils.random()*(b+f) +a?b(c,f-1):m[f] 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif", THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}}; -THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c}; -THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var b=[],c,e=this.getPoint(0),f,h=0;b.push(0);for(f=1;f<=a;f++)c=this.getPoint(f/a),h+=c.distanceTo(e),b.push(h),e=c;return this.cacheArcLengths=b}; -THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),e=0,f=c.length,h;h=b?b:a*c[f-1];time=Date.now();for(var g=0,k=f-1,l;g<=k;)if(e=Math.floor(g+(k-g)/2),l=c[e]-h,l<0)g=e+1;else if(l>0)k=e-1;else{k=e;break}e=k;if(c[e]==h)return e/(f-1);g=c[e];return c=(e+(h-g)/(c[e+1]-g))/(f-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; -THREE.Curve.prototype.getTangent=function(a){var b=a-1.0E-4;a+=1.0E-4;b<0&&(b=0);a>1&&(a=1);var b=this.getPoint(b),a=this.getPoint(a),c=new THREE.Vector2;c.sub(a,b);return c.unit()};THREE.LineCurve=function(a,b){a instanceof THREE.Vector2?(this.v1=a,this.v2=b):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,b,c,e){this.constructor(new THREE.Vector2(a,b),new THREE.Vector2(c,e))};THREE.LineCurve.prototype=new THREE.Curve; -THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.multiplyScalar(a).addSelf(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a}; -THREE.QuadraticBezierCurve=function(a,b,c){if(!(b instanceof THREE.Vector2))var e=Array.prototype.slice.call(arguments),a=new THREE.Vector2(e[0],e[1]),b=new THREE.Vector2(e[2],e[3]),c=new THREE.Vector2(e[4],e[5]);this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; -THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b}; -THREE.CubicBezierCurve=function(a,b,c,e){if(!(b instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),a=new THREE.Vector2(f[0],f[1]),b=new THREE.Vector2(f[2],f[3]),c=new THREE.Vector2(f[4],f[5]),e=new THREE.Vector2(f[6],f[7]);this.v0=a;this.v1=b;this.v2=c;this.v3=e};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; -THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b}; +THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPoint(c/a));return b};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b}; +THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var c=[],b,e=this.getPoint(0),g,h=0;c.push(0);for(g=1;g<=a;g++)b=this.getPoint(g/a),h+=b.distanceTo(e),c.push(h),e=b;return this.cacheArcLengths=c}; +THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),e=0,g=b.length,h;h=c?c:a*b[g-1];time=Date.now();for(var f=0,k=g-1,l;f<=k;)if(e=Math.floor(f+(k-f)/2),l=b[e]-h,l<0)f=e+1;else if(l>0)k=e-1;else{k=e;break}e=k;if(b[e]==h)return e/(g-1);f=b[e];return b=(e+(h-f)/(b[e+1]-f))/(g-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; +THREE.Curve.prototype.getTangent=function(a){var c=a-1.0E-4;a+=1.0E-4;c<0&&(c=0);a>1&&(a=1);var c=this.getPoint(c),a=this.getPoint(a),b=new THREE.Vector2;b.sub(a,c);return b.unit()};THREE.LineCurve=function(a,c){a instanceof THREE.Vector2?(this.v1=a,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,c,b,e){this.constructor(new THREE.Vector2(a,c),new THREE.Vector2(b,e))};THREE.LineCurve.prototype=new THREE.Curve; +THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(a).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a}; +THREE.QuadraticBezierCurve=function(a,c,b){if(!(c instanceof THREE.Vector2))var e=Array.prototype.slice.call(arguments),a=new THREE.Vector2(e[0],e[1]),c=new THREE.Vector2(e[2],e[3]),b=new THREE.Vector2(e[4],e[5]);this.v0=a;this.v1=c;this.v2=b};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; +THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(c,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);c=new THREE.Vector2(c,a);c.normalize();return c}; +THREE.CubicBezierCurve=function(a,c,b,e){if(!(c instanceof THREE.Vector2))var g=Array.prototype.slice.call(arguments),a=new THREE.Vector2(g[0],g[1]),c=new THREE.Vector2(g[2],g[3]),b=new THREE.Vector2(g[4],g[5]),e=new THREE.Vector2(g[6],g[7]);this.v0=a;this.v1=c;this.v2=b;this.v3=e};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; +THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(c,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);c=new THREE.Vector2(c,a);c.normalize();return c}; THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve; -THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],e=this.points,f;f=(e.length-1)*a;a=Math.floor(f);f-=a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>e.length-2?a:a+1;c[3]=a>e.length-3?a:a+2;b.x=THREE.Curve.Utils.interpolate(e[c[0]].x,e[c[1]].x,e[c[2]].x,e[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(e[c[0]].y,e[c[1]].y,e[c[2]].y,e[c[3]].y,f);return b};THREE.ArcCurve=function(a,b,c,e,f,h){this.aX=a;this.aY=b;this.aRadius=c;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=h}; -THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*b;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))}; -THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,e){return 2*(1-a)*(c-b)+2*a*(e-c)},tangentCubicBezier:function(a,b,c,e,f){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*e*(1-a)-3*a*a*e+3*a*a*f},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,e,f){var a=(c-a)*0.5,e=(e-b)*0.5,h=f*f;return(2*b-2*c+a+e)*f*h+(-3*b+3*c-2*a-e)*h+a*f+b}}; -THREE.Curve.create=function(a,b){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(v2,v1);b.multiplyScalar(a);b.addSelf(this.v1);return b}); -THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)}); -THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,e){this.v0=a;this.v1=b;this.v2=c;this.v3=e},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)}); -THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a},function(a){var b=new THREE.Vector3,c=[],e=this.points,f;f=(e.length-1)*a;a=Math.floor(f);f-=a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>e.length-2?a:a+1;c[3]=a>e.length-3?a:a+2;b.x=THREE.Curve.Utils.interpolate(e[c[0]].x,e[c[1]].x,e[c[2]].x,e[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(e[c[0]].y,e[c[1]].y,e[c[2]].y,e[c[3]].y,f);b.z=THREE.Curve.Utils.interpolate(e[c[0]].z,e[c[1]].z,e[c[2]].z,e[c[3]].z,f);return b}); +THREE.SplineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2,b=[],e=this.points,g;g=(e.length-1)*a;a=Math.floor(g);g-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>e.length-2?a:a+1;b[3]=a>e.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(e[b[0]].x,e[b[1]].x,e[b[2]].x,e[b[3]].x,g);c.y=THREE.Curve.Utils.interpolate(e[b[0]].y,e[b[1]].y,e[b[2]].y,e[b[3]].y,g);return c};THREE.ArcCurve=function(a,c,b,e,g,h){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=e;this.aEndAngle=g;this.aClockwise=h}; +THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))}; +THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,e){return 2*(1-a)*(b-c)+2*a*(e-b)},tangentCubicBezier:function(a,c,b,e,g){return-3*c*(1-a)*(1-a)+3*b*(1-a)*(1-a)-6*a*b*(1-a)+6*a*e*(1-a)-3*a*a*e+3*a*a*g},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,c,b,e,g){var a=(b-a)*0.5,e=(e-c)*0.5,h=g*g;return(2*c-2*b+a+e)*g*h+(-3*c+3*b-2*a-e)*h+a*g+c}}; +THREE.Curve.create=function(a,c){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=c;return a};THREE.LineCurve3=THREE.Curve.create(function(a,c){this.v1=a;this.v2=c},function(a){var c=new THREE.Vector3;c.sub(v2,v1);c.multiplyScalar(a);c.addSelf(this.v1);return c}); +THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,c,b){this.v0=a;this.v1=c;this.v2=b},function(a){var c,b;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,b,a)}); +THREE.CubicBezierCurve3=THREE.Curve.create(function(a,c,b,e){this.v0=a;this.v1=c;this.v2=b;this.v3=e},function(a){var c,b;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(c,b,a)}); +THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a},function(a){var c=new THREE.Vector3,b=[],e=this.points,g;g=(e.length-1)*a;a=Math.floor(g);g-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>e.length-2?a:a+1;b[3]=a>e.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(e[b[0]].x,e[b[1]].x,e[b[2]].x,e[b[3]].x,g);c.y=THREE.Curve.Utils.interpolate(e[b[0]].y,e[b[1]].y,e[b[2]].y,e[b[3]].y,g);c.z=THREE.Curve.Utils.interpolate(e[b[0]].z,e[b[1]].z,e[b[2]].z,e[b[3]].z,g);return c}); THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){}; -THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getLength(),a.getPointAt(b);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; -THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,e=this.curves.length;for(c=0;cb)b=h.x;else if(h.xc)c=h.y;else if(h.y0?(g=c[c.length-1],u=g.x,v=g.y):(g=this.actions[e-1].args,u=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)y=g/a,h=THREE.Shape.Utils.b2(y,u,o,k),y=THREE.Shape.Utils.b2(y,v,t, -l),c.push(new THREE.Vector2(h,y));break;case THREE.PathActions.BEZIER_CURVE_TO:k=h[4];l=h[5];o=h[0];t=h[1];m=h[2];n=h[3];c.length>0?(g=c[c.length-1],u=g.x,v=g.y):(g=this.actions[e-1].args,u=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)y=g/a,h=THREE.Shape.Utils.b3(y,u,o,m,k),y=THREE.Shape.Utils.b3(y,v,t,n,l),c.push(new THREE.Vector2(h,y));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[e-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];y=a*h[0].length;g=g.concat(h[0]);h=new THREE.SplineCurve(g); -for(g=1;g<=y;g++)c.push(h.getPointAt(g/y));break;case THREE.PathActions.ARC:g=this.actions[e-1].args;k=h[0];l=h[1];m=h[2];o=h[3];y=h[4];t=!!h[5];n=g[g.length-2];u=g[g.length-1];g.length==0&&(n=u=0);v=y-o;var p=a*2;for(g=1;g<=p;g++)y=g/p,t||(y=1-y),y=o+y*v,h=n+k+m*Math.cos(y),y=u+l+m*Math.sin(y),c.push(new THREE.Vector2(h,y))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; -THREE.Path.prototype.nltransform=function(a,b,c,e,f,h){var g=this.getPoints(),k,l,m,n,o;k=0;for(l=g.length;k=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; +THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],c=0,b,e=this.curves.length;for(b=0;bc)c=h.x;else if(h.xb)b=h.y;else if(h.y0?(f=b[b.length-1],u=f.x,v=f.y):(f=this.actions[e-1].args,u=f[f.length-2],v=f[f.length-1]);for(f=1;f<=a;f++)y=f/a,h=THREE.Shape.Utils.b2(y,u,o,k),y=THREE.Shape.Utils.b2(y,v,p, +l),b.push(new THREE.Vector2(h,y));break;case THREE.PathActions.BEZIER_CURVE_TO:k=h[4];l=h[5];o=h[0];p=h[1];m=h[2];n=h[3];b.length>0?(f=b[b.length-1],u=f.x,v=f.y):(f=this.actions[e-1].args,u=f[f.length-2],v=f[f.length-1]);for(f=1;f<=a;f++)y=f/a,h=THREE.Shape.Utils.b3(y,u,o,m,k),y=THREE.Shape.Utils.b3(y,v,p,n,l),b.push(new THREE.Vector2(h,y));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[e-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];y=a*h[0].length;f=f.concat(h[0]);h=new THREE.SplineCurve(f); +for(f=1;f<=y;f++)b.push(h.getPointAt(f/y));break;case THREE.PathActions.ARC:f=this.actions[e-1].args;k=h[0];l=h[1];m=h[2];o=h[3];y=h[4];p=!!h[5];n=f[f.length-2];u=f[f.length-1];f.length==0&&(n=u=0);v=y-o;var t=a*2;for(f=1;f<=t;f++)y=f/t,p||(y=1-y),y=o+y*v,h=n+k+m*Math.cos(y),y=u+l+m*Math.sin(y),b.push(new THREE.Vector2(h,y))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; +THREE.Path.prototype.nltransform=function(a,c,b,e,g,h){var f=this.getPoints(),k,l,m,n,o;k=0;for(l=f.length;k=0?k-1:c.length-1;h=g-1>=0?g-1:m.length-1;var y=[m[g],c[k],c[f]];o=THREE.FontUtils.Triangulate.area(y);var p=[m[g],m[h],c[k]];t=THREE.FontUtils.Triangulate.area(p);u=k;n=g;k+=1;g+=-1;k< -0&&(k+=c.length);k%=c.length;g<0&&(g+=m.length);g%=m.length;f=k-1>=0?k-1:c.length-1;h=g-1>=0?g-1:m.length-1;y=[m[g],c[k],c[f]];y=THREE.FontUtils.Triangulate.area(y);p=[m[g],m[h],c[k]];p=THREE.FontUtils.Triangulate.area(p);o+t>y+p&&(k=u,g=n,k<0&&(k+=c.length),k%=c.length,g<0&&(g+=m.length),g%=m.length,f=k-1>=0?k-1:c.length-1,h=g-1>=0?g-1:m.length-1);o=c.slice(0,k);t=c.slice(k);u=m.slice(g);n=m.slice(0,g);h=[m[g],m[h],c[k]];v.push([m[g],c[k],c[f]]);v.push(h);c=o.concat(u).concat(n).concat(t)}return{shape:c, -isolatedPts:v,allpoints:e}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),e=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),h,g,k,l,m={};h=0;for(g=e.length;h=0?k-1:b.length-1;h=f-1>=0?f-1:m.length-1;var y=[m[f],b[k],b[g]];o=THREE.FontUtils.Triangulate.area(y);var t=[m[f],m[h],b[k]];p=THREE.FontUtils.Triangulate.area(t);u=k;n=f;k+=1;f+=-1;k< +0&&(k+=b.length);k%=b.length;f<0&&(f+=m.length);f%=m.length;g=k-1>=0?k-1:b.length-1;h=f-1>=0?f-1:m.length-1;y=[m[f],b[k],b[g]];y=THREE.FontUtils.Triangulate.area(y);t=[m[f],m[h],b[k]];t=THREE.FontUtils.Triangulate.area(t);o+p>y+t&&(k=u,f=n,k<0&&(k+=b.length),k%=b.length,f<0&&(f+=m.length),f%=m.length,g=k-1>=0?k-1:b.length-1,h=f-1>=0?f-1:m.length-1);o=b.slice(0,k);p=b.slice(k);u=m.slice(f);n=m.slice(0,f);h=[m[f],m[h],b[k]];v.push([m[f],b[k],b[g]]);v.push(h);b=o.concat(u).concat(n).concat(p)}return{shape:b, +isolatedPts:v,allpoints:e}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),e=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),h,f,k,l,m={};h=0;for(f=e.length;h1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",u,g.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),c.x=f[0],c.y=f[1],c.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(c=== -"rot")THREE.Quaternion.slerp(f,h,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e}}if(this.JITCompile&&n[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ua.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];k=a[c[1]];l=a[c[2]];m=a[c[3]];c=f*f;g=f*c;e[0]=this.interpolate(h[0],k[0],l[0],m[0],f,c,g);e[1]=this.interpolate(h[1],k[1],l[1],m[1],f,c,g);e[2]=this.interpolate(h[2],k[2],l[2],m[2],f,c,g);return e}; -THREE.Animation.prototype.interpolate=function(a,b,c,e,f,h,g){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*g+(-3*(b-c)-2*a-e)*h+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[e.length-1]}; -THREE.CubeCamera=function(a,b,c,e){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,e,g,h,f,k,l,m,n=this.data.JIT.hierarchy,o,p;this.currentTime+=a*this.timeScale;p=this.currentTime;o=this.currentTime%=this.data.length;m=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,v=this.hierarchy.length;u1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(h[0]-g[0])*e,b.y=g[1]+(h[1]-g[1])*e,b.z=g[2]+(h[2]-g[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",u,f.index-1).pos,this.points[1]=g,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,g=this.interpolateCatmullRom(this.points,e),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b=== +"rot")THREE.Quaternion.slerp(g,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=g[0]+(h[0]-g[0])*e,b.y=g[1]+(h[1]-g[1])*e,b.z=g[2]+(h[2]-g[2])*e}}if(this.JITCompile&&n[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ua.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];k=a[b[1]];l=a[b[2]];m=a[b[3]];b=g*g;f=g*b;e[0]=this.interpolate(h[0],k[0],l[0],m[0],g,b,f);e[1]=this.interpolate(h[1],k[1],l[1],m[1],g,b,f);e[2]=this.interpolate(h[2],k[2],l[2],m[2],g,b,f);return e}; +THREE.Animation.prototype.interpolate=function(a,c,b,e,g,h,f){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*f+(-3*(c-b)-2*a-e)*h+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]}; +THREE.CubeCamera=function(a,c,b,e){this.heightOffset=b;this.position=new THREE.Vector3(0,b,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ= new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(e,e,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+= -1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,c){var b=this.renderTarget;b.activeCubeFace=0;a.render(c,this.cameraPX,b);b.activeCubeFace=1;a.render(c,this.cameraNX,b);b.activeCubeFace=2;a.render(c,this.cameraPY,b);b.activeCubeFace=3;a.render(c, -this.cameraNY,b);b.activeCubeFace=4;a.render(c,this.cameraPZ,b);b.activeCubeFace=5;a.render(c,this.cameraNZ,b)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; -THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,b,c,e,f,h,g){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,h,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,e,f);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; +1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var e=this.renderTarget;e.activeCubeFace=0;a.render(b,this.cameraPX,e);e.activeCubeFace=1;a.render(b,this.cameraNX,e);e.activeCubeFace=2;a.render(b,this.cameraPY,e);e.activeCubeFace=3;a.render(b, +this.cameraNY,e);e.activeCubeFace=4;a.render(b,this.cameraPZ,e);e.activeCubeFace=5;a.render(b,this.cameraNZ,e)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; +THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,c,b,e,g,h,f){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,h,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,e,g);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.projectionMatrix=this.cameraP.projectionMatrix};THREE.CombinedCamera.prototype.toOrthographic=function(){this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix};THREE.CombinedCamera.prototype.setFov=function(a){this.cameraP.fov=a;this.cameraP.updateProjectionMatrix();this.toPerspective()}; -THREE.CombinedCamera.prototype.setLens=function(a,b){b||(b=43.25);var c=2*Math.atan(b/(a*2));c*=180/Math.PI;this.setFov(c);return c}; -THREE.FirstPersonControls=function(a,b){function c(a,c){return function(){c.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.lastUpdate=(new Date).getTime();this.theta=this.phi=this.lon=this.lat= +THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b}; +THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.lastUpdate=(new Date).getTime();this.theta=this.phi=this.lon=this.lat= this.mouseY=this.mouseX=this.autoSpeedFactor=this.tdiff=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation(); if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY= a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward= -!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.object.position.ythis.heightMax?this.heightMax:this.object.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&& -!this.moveBackward)&&this.object.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(c);this.moveLeft&&this.object.translateX(-c);this.moveRight&&this.object.translateX(c);this.moveUp&&this.object.translateY(c);this.moveDown&&this.object.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon* -Math.PI/180;var a=this.target,b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax- -this.verticalMin)/(Math.PI-0)+this.verticalMin;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup", -c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; -THREE.PathControls=function(a,b){function c(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function e(a,c){return function(){c.apply(a,arguments)}}function f(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},h,f=c.getControlPointsArray(),k=c.getLength(),p=f.length,z=0;h=p-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;hthis.heightMax?this.heightMax:this.object.position.y)-this.heightMin)*this.heightCoef:0;var b=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&& +!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&&this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);b=this.tdiff*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon* +Math.PI/180;var a=this.target,c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax- +this.verticalMin)/(Math.PI-0)+this.verticalMin;a=this.target;c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup", +b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)}; +THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function e(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,e){var f={name:c,fps:0.6,length:e,hierarchy:[]},h,g=b.getControlPointsArray(),k=b.getLength(),t=g.length,z=0;h=t-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:g[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h=0?a:a+g;a=this.verticalAngleMap.srcRange; -b=this.verticalAngleMap.dstRange;var e=b[1]-b[0];this.phi=c(((this.phi-a[0])*(b[1]-b[0])/(a[1]-a[0])+b[0]-b[0])/e)*e+b[0];a=this.horizontalAngleMap.srcRange;b=this.horizontalAngleMap.dstRange;e=b[1]-b[0];this.theta=c(((this.theta-a[0])*(b[1]-b[0])/(a[1]-a[0])+b[0]-b[0])/e)*e+b[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement=== -document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),c=new THREE.MeshLambertMaterial({color:65280}), -b=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(b,a);a=new THREE.Mesh(g,c);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=f(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= -this.debugPath,c=this.spline,b=h(c,10),g=h(c,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(b,k);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.add(lineObj);particleObj.scale.set(1,1,1);a.add(particleObj);g=new THREE.SphereGeometry(1,16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i=0?a:a+f;a=this.verticalAngleMap.srcRange; +c=this.verticalAngleMap.dstRange;var e=c[1]-c[0];this.phi=b(((this.phi-a[0])*(c[1]-c[0])/(a[1]-a[0])+c[0]-c[0])/e)*e+c[0];a=this.horizontalAngleMap.srcRange;c=this.horizontalAngleMap.dstRange;e=c[1]-c[0];this.theta=b(((this.theta-a[0])*(c[1]-c[0])/(a[1]-a[0])+c[0]-c[0])/e)*e+c[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement=== +document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), +c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=g(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= +this.debugPath,b=this.spline,c=h(b,10),f=h(b,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(c,k);particleObj=new THREE.ParticleSystem(f,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.add(lineObj);particleObj.scale.set(1,1,1);a.add(particleObj);f=new THREE.SphereGeometry(1,16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i0){var c=this.getContainerDimensions(),b=c.size[0]/2,g=c.size[1]/2;this.moveState.yawLeft=-(a.pageX-c.offset[0]-b)/b;this.moveState.pitchDown=(a.pageY-c.offset[1]-g)/g;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward= -!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,c=this.tdiff*this.rollSpeed;this.object.translateX(this.moveVector.x*a);this.object.translateY(this.moveVector.y*a);this.object.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c, +!0;break;case 2:this.object.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),c=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward= +!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,b=this.tdiff*this.rollSpeed;this.object.translateX(this.moveVector.x*a);this.object.translateY(this.moveVector.y*a);this.object.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*b,this.rotationVector.y*b,this.rotationVector.z*b, 1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion);this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back}; this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0, -0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; -THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var c=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Matrix4,g=!1,k=1,l=0,m=0,n=0,o=0,t=0,u=window.innerWidth/2,v=window.innerHeight/2;this.update=function(){var a= -(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*o),this.rotateVertically(a*t));a=this.delta*this.movementSpeed;this.object.translateZ(-a*(l>0||this.autoForward&&!(l<0)?1:l));this.object.translateX(a*m);this.object.translateY(a*n);g&&(this.roll+=this.rollSpeed*this.delta*k);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(l<0)?1:l));this.object.translateX(a*m);this.object.translateY(a*n);f&&(this.roll+=this.rollSpeed*this.delta*k);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +else if(this.forward.y1?b.normalize():b.z=Math.sqrt(1-e*e);h.copy(this.object.position).subSelf(this.target);e=this.object.up.clone().setLength(b.y);e.addSelf(this.object.up.clone().crossSelf(h).setLength(b.x));e.addSelf(h.setLength(b.z));return e};this.rotateCamera=function(){var a=Math.acos(g.dot(k)/g.length()/k.length());if(a){var c=(new THREE.Vector3).cross(g,k).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c, --a);b.multiplyVector3(h);b.multiplyVector3(this.object.up);b.multiplyVector3(k);this.staticMoving?g=k:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(g))}};this.zoomCamera=function(){var a=1+(m.y-l.y)*this.zoomSpeed;a!==1&&a>0&&(h.multiplyScalar(a),this.staticMoving?l=m:l.y+=(m.y-l.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=o.clone().subSelf(n);if(a.lengthSq()){a.multiplyScalar(h.length()*this.panSpeed);var c=h.clone().crossSelf(this.object.up).setLength(a.x); -c.addSelf(this.object.up.clone().setLength(a.y));this.object.position.addSelf(c);this.target.addSelf(c);this.staticMoving?n=o:n.addSelf(a.sub(o,n).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.object.position.lengthSq()>this.maxDistance*this.maxDistance&&this.object.position.setLength(this.maxDistance),h.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(k=0;k0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(k=0;ka&&(a+=Math.PI*2),anglec=(c+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(f).addSelf(k).subSelf(a).clone()}function f(a){for(C=a.length;--C>=0;){R=C;S=C-1;S<0&&(S=a.length- -1);for(var c=0,b=u+n*2,c=0;c=0;J--){M=J/n;N=l*(1-M);M=m*Math.sin(M*Math.PI/2);C=0;for(F=x.length;C1?e.normalize():e.z=Math.sqrt(1-h*h);f.copy(b.object.position).subSelf(b.target);h=b.object.up.clone().setLength(e.y);h.addSelf(b.object.up.clone().crossSelf(f).setLength(e.x));h.addSelf(f.setLength(e.z));return h};this.rotateCamera=function(){var a=Math.acos(k.dot(l)/k.length()/l.length());if(a){var c=(new THREE.Vector3).cross(k,l).normalize(),e=new THREE.Quaternion;a*=b.rotateSpeed;e.setFromAxisAngle(c,-a);e.multiplyVector3(f); +e.multiplyVector3(b.object.up);e.multiplyVector3(l);b.staticMoving?k=l:(e.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var a=1+(n.y-m.y)*b.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),b.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(f.length()*b.panSpeed);var c=f.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y)); +b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?o=p:o.addSelf(a.sub(p,o).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),f.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(k=0;k0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(k=0;ka&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(g).addSelf(k).subSelf(a).clone()}function g(a){for(C=a.length;--C>=0;){R=C;S=C-1;S<0&&(S=a.length- +1);for(var b=0,c=u+n*2,b=0;b=0;J--){M=J/n;N=l*(1-M);M=m*Math.sin(M*Math.PI/2);C=0;for(F=x.length;C0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,k,t)))-1);m.push(n)}b.push(m)}for(var u,v,y,f=b.length,c=0;c0)for(e=0;e1&&(u= -this.vertices[g].position.clone(),v=this.vertices[l].position.clone(),y=this.vertices[m].position.clone(),u.normalize(),v.normalize(),y.normalize(),this.faces.push(new THREE.Face3(g,l,m,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([n,o,p]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,e,g=Math.PI,h=Math.max(3,c||8),f=Math.max(2,b||6),c=[],b=0;b0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,k,p)))-1);m.push(n)}c.push(m)}for(var u,v,y,g=c.length,b=0;b0)for(e=0;e1&&(u= +this.vertices[f].position.clone(),v=this.vertices[l].position.clone(),y=this.vertices[m].position.clone(),u.normalize(),v.normalize(),y.normalize(),this.faces.push(new THREE.Face3(f,l,m,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([n,o,t]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; -THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=!1;if(b.bend){var e=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(e/2,120),new THREE.Vector2(e,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; +THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var e=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(e/2,120),new THREE.Vector2(e,0))}THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; -THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(a,b){return(new TextPath(a,b)).toShapes()},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b= -this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),h=f.length,g=[],a=0;a0)for(m=0;m2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return h}l=m;f<=l&&(l=0);m=l+1;f<=m&&(m=0);n=m+1;f<=n&&(n=0);var t;a:{t=a;var u=l,v=m,y=n,p=f,z=g,x=void 0,w=void 0,A=void 0, -D=void 0,B=void 0,E=void 0,I=void 0,G=void 0,K=void 0,w=t[z[u]].x,A=t[z[u]].y,D=t[z[v]].x,B=t[z[v]].y,E=t[z[y]].x,I=t[z[y]].y;if(1.0E-10>(D-w)*(I-A)-(B-A)*(E-w))t=!1;else{for(x=0;x=0&&J>=0&&N>=0){t=!1;break a}}t=!0}}if(t){h.push([a[g[l]], -a[g[m]],a[g[n]]]);k.push([g[l],g[m],g[n]]);l=m;for(n=m+1;n0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,c,b,e,k,l){var m=new THREE.Face4(a,c,b,e,null,k.color,k.material);if(g.useOldVertexColors){m.vertexColors=[];for(var n,p,u,t=0;t<4;t++){u=l[t];n=new THREE.Color;n.setRGB(0,0,0);for(var v=0;v0)for(m=0;m2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return h}l=m;g<=l&&(l=0);m=l+1;g<=m&&(m=0);n=m+1;g<=n&&(n=0);var p;a:{p=a;var u=l,v=m,y=n,t=g,z=f,x=void 0,w=void 0,A=void 0, +D=void 0,B=void 0,E=void 0,I=void 0,G=void 0,K=void 0,w=p[z[u]].x,A=p[z[u]].y,D=p[z[v]].x,B=p[z[v]].y,E=p[z[y]].x,I=p[z[y]].y;if(1.0E-10>(D-w)*(I-A)-(B-A)*(E-w))p=!1;else{for(x=0;x=0&&J>=0&&N>=0){p=!1;break a}}p=!0}}if(p){h.push([a[f[l]], +a[f[m]],a[f[n]]]);k.push([f[l],f[m],f[n]]);l=m;for(n=m+1;n0;)this.smooth(a)}; +THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,e,k,l){var m=new THREE.Face4(a,b,c,e,null,k.color,k.material);if(f.useOldVertexColors){m.vertexColors=[];for(var n,t,u,p=0;p<4;p++){u=l[p];n=new THREE.Color;n.setRGB(0,0,0);for(var v=0;v>7)-127;e|=(f&127)<<16|g<<8;if(e==0&&k==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,k)}function f(a,c){var b=n(a,c),e=n(a,c+1),g=n(a,c+2);return(n(a,c+3)<<24)+(g<<16)+(e<<8)+b}function l(a,c){var b=n(a,c);return(n(a,c+1)<<8)+b}function m(a,c){var b=n(a,c);return b>127?b-256:b}function n(a,c){return a.charCodeAt(c)&255}function o(c){var b, -e,g;b=f(a,c);e=f(a,c+B);g=f(a,c+E);c=l(a,c+I);z.faces.push(new THREE.Face3(b,e,g,null,null,z.materials[c]))}function t(c){var b,e,g,h,m,o;b=f(a,c);e=f(a,c+B);g=f(a,c+E);h=l(a,c+I);m=f(a,c+G);o=f(a,c+K);c=f(a,c+C);h=z.materials[h];var n=A[o*3],p=A[o*3+1];o=A[o*3+2];var t=A[c*3],u=A[c*3+1],c=A[c*3+2];z.faces.push(new THREE.Face3(b,e,g,[new THREE.Vector3(A[m*3],A[m*3+1],A[m*3+2]),new THREE.Vector3(n,p,o),new THREE.Vector3(t,u,c)],null,h))}function u(c){var b,e,g,h;b=f(a,c);e=f(a,c+F);g=f(a,c+J);h=f(a, -c+M);c=l(a,c+N);z.faces.push(new THREE.Face4(b,e,g,h,null,null,z.materials[c]))}function v(c){var b,e,g,h,m,o,n,p;b=f(a,c);e=f(a,c+F);g=f(a,c+J);h=f(a,c+M);m=l(a,c+N);o=f(a,c+L);n=f(a,c+O);p=f(a,c+H);c=f(a,c+Q);m=z.materials[m];var t=A[n*3],u=A[n*3+1];n=A[n*3+2];var la=A[p*3],ma=A[p*3+1];p=A[p*3+2];var na=A[c*3],v=A[c*3+1],c=A[c*3+2];z.faces.push(new THREE.Face4(b,e,g,h,[new THREE.Vector3(A[o*3],A[o*3+1],A[o*3+2]),new THREE.Vector3(t,u,n),new THREE.Vector3(la,ma,p),new THREE.Vector3(na,v,c)],null, -m))}function y(c){var b,e,g,h;b=f(a,c);e=f(a,c+P);g=f(a,c+T);c=D[b*2];h=D[b*2+1];b=D[e*2];var l=z.faceVertexUvs[0];e=D[e*2+1];var m=D[g*2];g=D[g*2+1];var o=[];o.push(new THREE.UV(c,h));o.push(new THREE.UV(b,e));o.push(new THREE.UV(m,g));l.push(o)}function p(c){var b,e,g,h,l,m;b=f(a,c);e=f(a,c+X);g=f(a,c+R);h=f(a,c+S);c=D[b*2];l=D[b*2+1];b=D[e*2];m=D[e*2+1];e=D[g*2];var o=z.faceVertexUvs[0];g=D[g*2+1];var n=D[h*2];h=D[h*2+1];var p=[];p.push(new THREE.UV(c,l));p.push(new THREE.UV(b,m));p.push(new THREE.UV(e, -g));p.push(new THREE.UV(n,h));o.push(p)}var z=this,x=0,w,A=[],D=[],B,E,I,G,K,C,F,J,M,N,L,O,H,Q,P,T,X,R,S,W,U,Z,Y,$,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,e,c);w={signature:a.substr(x,8),header_bytes:n(a,x+8),vertex_coordinate_bytes:n(a,x+9),normal_coordinate_bytes:n(a,x+10),uv_coordinate_bytes:n(a,x+11),vertex_index_bytes:n(a,x+12),normal_index_bytes:n(a,x+13),uv_index_bytes:n(a,x+14),material_index_bytes:n(a,x+15),nvertices:f(a,x+16),nnormals:f(a,x+16+4),nuvs:f(a,x+16+ -8),ntri_flat:f(a,x+16+12),ntri_smooth:f(a,x+16+16),ntri_flat_uv:f(a,x+16+20),ntri_smooth_uv:f(a,x+16+24),nquad_flat:f(a,x+16+28),nquad_smooth:f(a,x+16+32),nquad_flat_uv:f(a,x+16+36),nquad_smooth_uv:f(a,x+16+40)};x+=w.header_bytes;B=w.vertex_index_bytes;E=w.vertex_index_bytes*2;I=w.vertex_index_bytes*3;G=w.vertex_index_bytes*3+w.material_index_bytes;K=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;C=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;F=w.vertex_index_bytes; -J=w.vertex_index_bytes*2;M=w.vertex_index_bytes*3;N=w.vertex_index_bytes*4;L=w.vertex_index_bytes*4+w.material_index_bytes;O=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;H=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;Q=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;P=w.uv_index_bytes;T=w.uv_index_bytes*2;X=w.uv_index_bytes;R=w.uv_index_bytes*2;S=w.uv_index_bytes*3;c=w.vertex_index_bytes*3+w.material_index_bytes;V=w.vertex_index_bytes* -4+w.material_index_bytes;W=w.ntri_flat*c;U=w.ntri_smooth*(c+w.normal_index_bytes*3);Z=w.ntri_flat_uv*(c+w.uv_index_bytes*3);Y=w.ntri_smooth_uv*(c+w.normal_index_bytes*3+w.uv_index_bytes*3);$=w.nquad_flat*V;c=w.nquad_smooth*(V+w.normal_index_bytes*4);V=w.nquad_flat_uv*(V+w.uv_index_bytes*4);x+=function(c){for(var e,h,f,k=w.vertex_coordinate_bytes*3,l=c+w.nvertices*k;c=0){v=l.invBindMatrices[p];m.invBindMatrix=v;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,v);m.weights=[];for(v=0;v1){l=new THREE.MeshFaceMaterial;for(j=0;j1?b[1].substr(0,c):"0";b[1].length=0,h=g.indexOf("(")>=0,k;if(f)e=g.split("."),g=e.shift(),e.shift();else if(h){k=g.split("(");g=k.shift();for(e=0;ec){n=m.output[l];break}h=n!==void 0?n instanceof THREE.Matrix4?h.multiply(h,n):h.multiply(h,k.matrix):h.multiply(h,k.matrix)}else h=h.multiply(h,k.matrix);c=h;b.push({time:a,pos:[c.n14,c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=b}this.updateMatrix(); -return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[b.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};K.prototype.create=function(){var a={},c=this.transparency!== -void 0&&this.transparency<1,b;for(b in this)switch(b){case "ambient":case "emission":case "diffuse":case "specular":var e=this[b];if(e instanceof G)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=fa[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(ja+e.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else b=="diffuse"?a.color=e.color.getHex():c||(a[b]= -e.color.getHex());break;case "shininess":case "reflectivity":a[b]=this[b];break;case "transparency":if(c)a.transparent=!0,a.opacity=this[b],c=!0}a.shading=ka;return this.material=new THREE.MeshLambertMaterial(a)};C.prototype.parse=function(a){for(var c=0;c=0,e=a.indexOf("(")>=0,g,f;if(b)c=a.split("."),a=c.shift(),f=c.shift();else if(e){g=a.split("(");a=g.shift();for(c=0;c>7)-127;e|=(h&127)<<16|f<<8;if(e==0&&k==-127)return 0;return(1-2*(g>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,k)}function g(a,b){var c=n(a,b),e=n(a,b+1),f=n(a,b+2);return(n(a,b+3)<<24)+(f<<16)+(e<<8)+c}function l(a,b){var c=n(a,b);return(n(a,b+1)<<8)+c}function m(a,b){var c=n(a,b);return c>127?c-256:c}function n(a,b){return a.charCodeAt(b)&255}function o(b){var c, +e,f;c=g(a,b);e=g(a,b+B);f=g(a,b+E);b=l(a,b+I);z.faces.push(new THREE.Face3(c,e,f,null,null,z.materials[b]))}function p(b){var c,e,f,h,m,o;c=g(a,b);e=g(a,b+B);f=g(a,b+E);h=l(a,b+I);m=g(a,b+G);o=g(a,b+K);b=g(a,b+C);h=z.materials[h];var n=A[o*3],p=A[o*3+1];o=A[o*3+2];var t=A[b*3],u=A[b*3+1],b=A[b*3+2];z.faces.push(new THREE.Face3(c,e,f,[new THREE.Vector3(A[m*3],A[m*3+1],A[m*3+2]),new THREE.Vector3(n,p,o),new THREE.Vector3(t,u,b)],null,h))}function u(b){var c,e,f,h;c=g(a,b);e=g(a,b+F);f=g(a,b+J);h=g(a, +b+M);b=l(a,b+N);z.faces.push(new THREE.Face4(c,e,f,h,null,null,z.materials[b]))}function v(b){var c,e,f,h,m,o,n,p;c=g(a,b);e=g(a,b+F);f=g(a,b+J);h=g(a,b+M);m=l(a,b+N);o=g(a,b+L);n=g(a,b+O);p=g(a,b+H);b=g(a,b+Q);m=z.materials[m];var t=A[n*3],u=A[n*3+1];n=A[n*3+2];var la=A[p*3],ma=A[p*3+1];p=A[p*3+2];var na=A[b*3],v=A[b*3+1],b=A[b*3+2];z.faces.push(new THREE.Face4(c,e,f,h,[new THREE.Vector3(A[o*3],A[o*3+1],A[o*3+2]),new THREE.Vector3(t,u,n),new THREE.Vector3(la,ma,p),new THREE.Vector3(na,v,b)],null, +m))}function y(b){var c,e,f,h;c=g(a,b);e=g(a,b+P);f=g(a,b+T);b=D[c*2];h=D[c*2+1];c=D[e*2];var l=z.faceVertexUvs[0];e=D[e*2+1];var m=D[f*2];f=D[f*2+1];var o=[];o.push(new THREE.UV(b,h));o.push(new THREE.UV(c,e));o.push(new THREE.UV(m,f));l.push(o)}function t(b){var c,e,f,h,l,m;c=g(a,b);e=g(a,b+X);f=g(a,b+R);h=g(a,b+S);b=D[c*2];l=D[c*2+1];c=D[e*2];m=D[e*2+1];e=D[f*2];var o=z.faceVertexUvs[0];f=D[f*2+1];var n=D[h*2];h=D[h*2+1];var p=[];p.push(new THREE.UV(b,l));p.push(new THREE.UV(c,m));p.push(new THREE.UV(e, +f));p.push(new THREE.UV(n,h));o.push(p)}var z=this,x=0,w,A=[],D=[],B,E,I,G,K,C,F,J,M,N,L,O,H,Q,P,T,X,R,S,W,U,Z,Y,$,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,e,b);w={signature:a.substr(x,8),header_bytes:n(a,x+8),vertex_coordinate_bytes:n(a,x+9),normal_coordinate_bytes:n(a,x+10),uv_coordinate_bytes:n(a,x+11),vertex_index_bytes:n(a,x+12),normal_index_bytes:n(a,x+13),uv_index_bytes:n(a,x+14),material_index_bytes:n(a,x+15),nvertices:g(a,x+16),nnormals:g(a,x+16+4),nuvs:g(a,x+16+ +8),ntri_flat:g(a,x+16+12),ntri_smooth:g(a,x+16+16),ntri_flat_uv:g(a,x+16+20),ntri_smooth_uv:g(a,x+16+24),nquad_flat:g(a,x+16+28),nquad_smooth:g(a,x+16+32),nquad_flat_uv:g(a,x+16+36),nquad_smooth_uv:g(a,x+16+40)};x+=w.header_bytes;B=w.vertex_index_bytes;E=w.vertex_index_bytes*2;I=w.vertex_index_bytes*3;G=w.vertex_index_bytes*3+w.material_index_bytes;K=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;C=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;F=w.vertex_index_bytes; +J=w.vertex_index_bytes*2;M=w.vertex_index_bytes*3;N=w.vertex_index_bytes*4;L=w.vertex_index_bytes*4+w.material_index_bytes;O=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;H=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;Q=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;P=w.uv_index_bytes;T=w.uv_index_bytes*2;X=w.uv_index_bytes;R=w.uv_index_bytes*2;S=w.uv_index_bytes*3;b=w.vertex_index_bytes*3+w.material_index_bytes;V=w.vertex_index_bytes* +4+w.material_index_bytes;W=w.ntri_flat*b;U=w.ntri_smooth*(b+w.normal_index_bytes*3);Z=w.ntri_flat_uv*(b+w.uv_index_bytes*3);Y=w.ntri_smooth_uv*(b+w.normal_index_bytes*3+w.uv_index_bytes*3);$=w.nquad_flat*V;b=w.nquad_smooth*(V+w.normal_index_bytes*4);V=w.nquad_flat_uv*(V+w.uv_index_bytes*4);x+=function(b){for(var e,h,g,k=w.vertex_coordinate_bytes*3,l=b+w.nvertices*k;b=0){v=l.invBindMatrices[p];m.invBindMatrix=v;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,v);m.weights=[];for(v=0;v1){l=new THREE.MeshFaceMaterial;for(j=0;j1?b.add(l):b=l}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[1].length=0,g=f.indexOf("(")>=0,k;if(h)e=f.split("."),f=e.shift(),e.shift();else if(g){k=f.split("(");f=k.shift();for(e=0;eb){n=m.output[l];break}g=n!==void 0?n instanceof THREE.Matrix4?g.multiply(g,n):g.multiply(g,k.matrix):g.multiply(g,k.matrix)}else g=g.multiply(g,k.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};K.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var e=this[c];if(e instanceof G)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source== +this.effect.surface.sid&&(e=fa[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(ja+e.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=e.color.getHex():b||(a[c]=e.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=ka;return this.material=new THREE.MeshLambertMaterial(a)};C.prototype.parse=function(a){for(var b= +0;b=0,e=a.indexOf("(")>=0,f,h;if(c)b=a.split("."),a=b.shift(),h=b.shift();else if(e){f=a.split("(");a=f.shift();for(b=0;b1&&(K=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(B,K);object.name=u;object.position.set(w[0],w[1],w[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=x.visible;H.scene.add(object);H.objects[u]=object;x.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),H.scene.collisions.colliders.push(a)); if(x.castsShadow)a=new THREE.ShadowVolume(B),H.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},H.triggers[object.name]=a)}}else w=x.position,r=x.rotation,q=x.quaternion,s=x.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(w[0],w[1],w[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=x.visible!==void 0?x.visible:!1,H.scene.add(object),H.objects[u]=object,H.empties[u]=object,x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},H.triggers[object.name]=a)}function l(a){return function(b){H.geometries[a]=b;k();M-=1;c.onLoadComplete();n()}}function m(a){return function(c){H.geometries[a]=c}}function n(){c.callbackProgress({totalModels:L,totalTextures:O,loadedModels:L-M,loadedTextures:O-N},H);c.onLoadProgress();M==0&&N==0&&b(H)}var o,t, -u,v,y,p,z,x,w,A,D,B,E,I,G,K,C,F,J,M,N,L,O,H;F=a.data;G=new THREE.BinaryLoader;J=new THREE.JSONLoader;N=M=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(u in F.objects)if(x=F.objects[u],x.meshCollider){a=!0;break}if(a)H.scene.collisions=new THREE.CollisionSystem;if(F.transform){a=F.transform.position;A=F.transform.rotation;var Q=F.transform.scale;a&&H.scene.position.set(a[0],a[1],a[2]);A&&H.scene.rotation.set(A[0], -A[1],A[2]);Q&&H.scene.scale.set(Q[0],Q[1],Q[2]);(a||A||Q)&&H.scene.updateMatrix()}a=function(){N-=1;n();c.onLoadComplete()};for(y in F.cameras)A=F.cameras[y],A.type=="perspective"?E=new THREE.PerspectiveCamera(A.fov,A.aspect,A.near,A.far):A.type=="ortho"&&(E=new THREE.OrthographicCamera(A.left,A.right,A.top,A.bottom,A.near,A.far)),w=A.position,A=A.target,E.position.set(w[0],w[1],w[2]),E.target=new THREE.Vector3(A[0],A[1],A[2]),H.cameras[y]=E;for(v in F.lights)y=F.lights[v],E=y.color!==void 0?y.color: -16777215,A=y.intensity!==void 0?y.intensity:1,y.type=="directional"?(w=y.direction,C=new THREE.DirectionalLight(E,A),C.position.set(w[0],w[1],w[2]),C.position.normalize()):y.type=="point"?(w=y.position,d=y.distance,C=new THREE.PointLight(E,A,d),C.position.set(w[0],w[1],w[2])):y.type=="ambient"&&(C=new THREE.AmbientLight(E)),H.scene.add(C),H.lights[v]=C;for(p in F.fogs)v=F.fogs[p],v.type=="linear"?I=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(I=new THREE.FogExp2(0,v.density)),A=v.color,I.color.setRGB(A[0], -A[1],A[2]),H.fogs[p]=I;if(H.cameras&&F.defaults.camera)H.currentCamera=H.cameras[F.defaults.camera];if(H.fogs&&F.defaults.fog)H.scene.fog=H.fogs[F.defaults.fog];A=F.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(A[0],A[1],A[2]);H.bgColorAlpha=F.defaults.bgalpha;for(o in F.geometries)if(p=F.geometries[o],p.type=="bin_mesh"||p.type=="ascii_mesh")M+=1,c.onLoadStart();L=M;for(o in F.geometries)p=F.geometries[o],p.type=="cube"?(B=new THREE.CubeGeometry(p.width,p.height,p.depth,p.segmentsWidth, -p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides),H.geometries[o]=B):p.type=="plane"?(B=new THREE.PlaneGeometry(p.width,p.height,p.segmentsWidth,p.segmentsHeight),H.geometries[o]=B):p.type=="sphere"?(B=new THREE.SphereGeometry(p.radius,p.segmentsWidth,p.segmentsHeight),H.geometries[o]=B):p.type=="cylinder"?(B=new THREE.CylinderGeometry(p.topRad,p.botRad,p.height,p.radSegs,p.heightSegs),H.geometries[o]=B):p.type=="torus"?(B=new THREE.TorusGeometry(p.radius,p.tube,p.segmentsR,p.segmentsT),H.geometries[o]= -B):p.type=="icosahedron"?(B=new THREE.IcosahedronGeometry(p.subdivisions),H.geometries[o]=B):p.type=="bin_mesh"?G.load({model:e(p.url,F.urlBaseType),callback:l(o)}):p.type=="ascii_mesh"?J.load({model:e(p.url,F.urlBaseType),callback:l(o)}):p.type=="embedded_mesh"&&(p=F.embeds[p.id])&&J.createModel(p,m(o),"");for(z in F.textures)if(o=F.textures[z],o.url instanceof Array){N+=o.url.length;for(G=0;G=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,f=0;f<8;f++){for(var h=0,g=0;g>1^-(k&1);c[8*g+f]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(f=g=0;f=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(l=this.size-1);var t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var u=Math.floor(n-k);u<1&&(u=1);k=Math.floor(n+k);k>this.size-1&&(k=this.size- -1);for(var v,y,p,z,x,w;o0&&(this.field[p+v]+=z)}}};this.addPlaneX=function(a,b){var f,h,g,k,l,m=this.size,n=this.yd,o=this.zd,t=this.field,u=m*Math.sqrt(a/b);u>m&&(u=m);for(f=0;f0)for(h=0;hn&&(v=n);for(h=0;h0){l=h*o;for(f=0;fsize&&(dist=size);for(g=0;g0){l=zd*g;for(h=0;h=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),e=1,g=0;g<8;g++){for(var h=0,f=0;f>1^-(k&1);b[8*f+g]=h}e+=c}c=a.length-e;h=new Uint16Array(c);for(g=f=0;g=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(l=this.size-1);var p=Math.floor(m-k);p<1&&(p=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var u=Math.floor(n-k);u<1&&(u=1);k=Math.floor(n+k);k>this.size-1&&(k=this.size- +1);for(var v,y,t,z,x,w;o0&&(this.field[t+v]+=z)}}};this.addPlaneX=function(a,c){var g,h,f,k,l,m=this.size,n=this.yd,o=this.zd,p=this.field,u=m*Math.sqrt(a/c);u>m&&(u=m);for(g=0;g0)for(h=0;hn&&(v=n);for(h=0;h0){l=h*o;for(g=0;gsize&&(dist=size);for(f=0;f0){l=zd*f;for(h=0;hh?this.hits.push(f):this.hits.unshift(f),h=e;return this.hits}; -THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,b[c]);if(e.distb.length)return null;return b[c]}; -THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),e=Number.MAX_VALUE,f,h=0;h=k*f))return Number.MAX_VALUE;g/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(g);k.addSelf(a.origin);Math.abs(h.x)> -Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=k.y-b.y,h=c.y-b.y,f=e.y-b.y,k=k.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=k.x-b.x,h=c.x-b.x,f=e.x-b.x,k=k.y-b.y,c=c.y-b.y,e=e.y-b.y):Math.abs(h.y)>Math.abs(h.z)?(a=k.x-b.x,h=c.x-b.x,f=e.x-b.x,k=k.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=k.x-b.x,h=c.x-b.x,f=e.x-b.x,k=k.y-b.y,c=c.y-b.y,e=e.y-b.y);b=h*e-c*f;if(b==0)return Number.MAX_VALUE;b=1/b;e=(a*e-k*f)*b;if(!(e>=0))return Number.MAX_VALUE;b*=h*k-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-e-b>=0))return Number.MAX_VALUE;return g}; -THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);c.multiplyVector3(e.origin);c.rotateAxis(e.direction);e.direction.normalize();return e}; -THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var e=0,f=0,h=0,g=0,k=0,l=0,m=!0;c.origin.xb.max.x&&(e=b.max.x-c.origin.x,e/=c.direction.x,m=!1,g=1);c.origin.yb.max.y&&(f=b.max.y-c.origin.y,f/=c.direction.y, -m=!1,k=1);c.origin.zb.max.z&&(h=b.max.z-c.origin.z,h/=c.direction.z,m=!1,l=1);if(m)return-1;m=0;f>e&&(m=1,e=f);h>e&&(m=2,e=h);switch(m){case 0:k=c.origin.y+c.direction.y*e;if(kb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(g,0,0);break;case 1:g=c.origin.x+c.direction.x*e;if(gb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* -e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,k,0);break;case 2:g=c.origin.x+c.direction.x*e;if(gb.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*e;if(kb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,l)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),e=b.point.dot(b.normal);if(c<0)c=(e-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; -THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(e)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; -THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b}; +2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.PlaneCollider=function(a,c){this.point=a;this.normal=c};THREE.SphereCollider=function(a,c){this.center=a;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(a,c){this.min=a;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3}; +THREE.MeshCollider=function(a,c){this.mesh=a;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){Array.prototype.push.apply(this.colliders,a.colliders);Array.prototype.push.apply(this.hits,a.hits)}; +THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,e,g,h=0;c=0;for(b=this.colliders.length;ch?this.hits.push(g):this.hits.unshift(g),h=e;return this.hits}; +THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,c[b]);if(e.distc.length)return null;return c[b]}; +THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)}; +THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),e=Number.MAX_VALUE,g,h=0;h=k*g))return Number.MAX_VALUE;f/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(f);k.addSelf(a.origin);Math.abs(h.x)> +Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=k.y-c.y,h=b.y-c.y,g=e.y-c.y,k=k.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=k.x-c.x,h=b.x-c.x,g=e.x-c.x,k=k.y-c.y,b=b.y-c.y,e=e.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=k.x-c.x,h=b.x-c.x,g=e.x-c.x,k=k.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=k.x-c.x,h=b.x-c.x,g=e.x-c.x,k=k.y-c.y,b=b.y-c.y,e=e.y-c.y);c=h*e-b*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-k*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=h*k-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return f}; +THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);b.multiplyVector3(e.origin);b.rotateAxis(e.direction);e.direction.normalize();return e}; +THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;c.dynamic&&c.mesh&&c.mesh.matrixWorld?b=this.makeRayLocal(a,c.mesh):(b=THREE.CollisionSystem.__r,b.origin.copy(a.origin),b.direction.copy(a.direction));var e=0,g=0,h=0,f=0,k=0,l=0,m=!0;b.origin.xc.max.x&&(e=c.max.x-b.origin.x,e/=b.direction.x,m=!1,f=1);b.origin.yc.max.y&&(g=c.max.y-b.origin.y,g/=b.direction.y, +m=!1,k=1);b.origin.zc.max.z&&(h=c.max.z-b.origin.z,h/=b.direction.z,m=!1,l=1);if(m)return-1;m=0;g>e&&(m=1,e=g);h>e&&(m=2,e=h);switch(m){case 0:k=b.origin.y+b.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(f,0,0);break;case 1:f=b.origin.x+b.direction.x*e;if(fc.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z* +e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:f=b.origin.x+b.direction.x*e;if(fc.max.x)return Number.MAX_VALUE;k=b.origin.y+b.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,l)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),e=c.point.dot(c.normal);if(b<0)b=(e-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq=0)return Math.abs(e)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; +THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,e=this.render,f=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,g=new THREE.Matrix4,k=new THREE.Matrix4,l,m,n;f.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),t=new THREE.WebGLRenderTarget(512,512,a),u=new THREE.PerspectiveCamera(53,1,1,1E4);u.position.z= -2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:t}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); -var v=new THREE.Scene;v.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);o.width=a;o.height=e;t.width=a;t.height=e};this.render=function(a,c){c.update(null,!0);if(l!==c.aspect||m!==c.near||n!==c.fov){l=c.aspect;m=c.near;n=c.fov;var z=c.projectionMatrix.clone(),x=125/30*0.5,w=x*m/125,A=m*Math.tan(n*Math.PI/360),D;g.n14=x;k.n14=-x;x=-A*l+w;D=A*l+w;z.n11=2*m/(D-x);z.n13=(D+x)/(D-x);f.projectionMatrix=z.clone();x=-A*l-w;D=A*l-w;z.n11=2*m/(D-x);z.n13= -(D+x)/(D-x);h.projectionMatrix=z.clone()}f.matrix=c.matrixWorld.clone().multiplySelf(k);f.update(null,!0);f.position.copy(c.position);f.near=m;f.far=c.far;e.call(b,a,f,o,!0);h.matrix=c.matrixWorld.clone().multiplySelf(g);h.update(null,!0);h.position.copy(c.position);h.near=m;h.far=c.far;e.call(b,a,h,t,!0);e.call(b,v,u)}}; -if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,e=this.render,f,h,g=new THREE.PerspectiveCamera;g.target=new THREE.Vector3(0,0,0);var k=new THREE.PerspectiveCamera;k.target=new THREE.Vector3(0,0,0);b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;this.setSize=function(a,e){c.call(b,a,e);f=a/2;h=e};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far= -c.far;g.updateProjectionMatrix();g.position.copy(c.position);g.target.copy(c.target);g.translateX(b.separation);g.lookAt(g.target);k.projectionMatrix=g.projectionMatrix;k.position.copy(c.position);k.target.copy(c.target);k.translateX(-b.separation);k.lookAt(k.target);this.setViewport(0,0,f,h);e.call(b,a,g);this.setViewport(f,0,f,h);e.call(b,a,k,!1)}}; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var c=this,b=this.setSize,e=this.render,g=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,f=new THREE.Matrix4,k=new THREE.Matrix4,l,m,n;g.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),p=new THREE.WebGLRenderTarget(512,512,a),u=new THREE.PerspectiveCamera(53,1,1,1E4);u.position.z= +2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:p}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); +var v=new THREE.Scene;v.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);o.width=a;o.height=e;p.width=a;p.height=e};this.render=function(a,b){b.update(null,!0);if(l!==b.aspect||m!==b.near||n!==b.fov){l=b.aspect;m=b.near;n=b.fov;var z=b.projectionMatrix.clone(),x=125/30*0.5,w=x*m/125,A=m*Math.tan(n*Math.PI/360),D;f.n14=x;k.n14=-x;x=-A*l+w;D=A*l+w;z.n11=2*m/(D-x);z.n13=(D+x)/(D-x);g.projectionMatrix=z.clone();x=-A*l-w;D=A*l-w;z.n11=2*m/(D-x);z.n13= +(D+x)/(D-x);h.projectionMatrix=z.clone()}g.matrix=b.matrixWorld.clone().multiplySelf(k);g.update(null,!0);g.position.copy(b.position);g.near=m;g.far=b.far;e.call(c,a,g,o,!0);h.matrix=b.matrixWorld.clone().multiplySelf(f);h.update(null,!0);h.position.copy(b.position);h.near=m;h.far=b.far;e.call(c,a,h,p,!0);e.call(c,v,u)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,e=this.render,g,h,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var k=new THREE.PerspectiveCamera;k.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,e){b.call(c,a,e);g=a/2;h=e};this.render=function(a,b){this.clear();f.fov=b.fov;f.aspect=0.5*b.aspect;f.near=b.near;f.far= +b.far;f.updateProjectionMatrix();f.position.copy(b.position);f.target.copy(b.target);f.translateX(c.separation);f.lookAt(f.target);k.projectionMatrix=f.projectionMatrix;k.position.copy(b.position);k.target.copy(b.target);k.translateX(-c.separation);k.lookAt(k.target);this.setViewport(0,0,g,h);e.call(c,a,f);this.setViewport(g,0,g,h);e.call(c,a,k,!1)}}; diff --git a/build/custom/ThreeSVG.js b/build/custom/ThreeSVG.js index 2ff94c24..886a22cb 100644 --- a/build/custom/ThreeSVG.js +++ b/build/custom/ThreeSVG.js @@ -14,82 +14,81 @@ Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12 THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b0&&a>0&&e+a<1}for(var d,f=[],e=0,g=a.children.length;ea.scale.x)return[];d={distance:e,point:a.position,face:null,object:a};f.push(d)}else if(a instanceof THREE.Mesh){e=b(this.origin, -this.direction,a.matrixWorld.getPosition());if(e==null||e>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return f;for(var i,k,h,j,m,n,l,p,q=a.geometry,v=q.vertices,e=0,g=q.faces.length;e0:n<0)))if(n=m.dot((new THREE.Vector3).sub(i,l))/n,l=l.addSelf(p.multiplyScalar(n)),d instanceof THREE.Face3)c(l,i,k,h)&&(d={distance:this.origin.distanceTo(l),point:l,face:d,object:a},f.push(d));else if(d instanceof THREE.Face4&&(c(l,i,k,j)||c(l,k,h,j)))d={distance:this.origin.distanceTo(l),point:l,face:d,object:a},f.push(d)}return f}}; -THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,j,m){i=!1;b=e;c=g;d=j;f=m;a()};this.addPoint=function(e,g){i?(i=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= -function(e,g,j,m,n,l){i?(i=!1,b=ej?e>n?e:n:j>n?j:n,f=g>m?g>l?g:l:m>l?m:l):(b=ej?e>n?e>d?e:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,f=g>m?g>l?g>f?g:f:l>f?l:f:m>l?m>f?m:f:l>f?l:f);a()};this.addRectangle=function(e){i?(i=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> -e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){i=!0;f=d=c=b=0;a()};this.isEmpty=function(){return i}};THREE.Matrix3=function(){this.m=[]}; +this.direction,a.matrixWorld.getPosition());if(e==null||e>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return f;var h,k,n,j,i,m,l,q,p=a.geometry,s=p.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);e=0;for(g=p.faces.length;e0:m<0)))if(m=i.dot((new THREE.Vector3).sub(h,l))/m,l=l.addSelf(q.multiplyScalar(m)),d instanceof THREE.Face3)c(l,h,k,n)&&(d={distance:this.origin.distanceTo(l),point:l,face:d,object:a},f.push(d));else if(d instanceof THREE.Face4&&(c(l,h,k,j)||c(l,k,n,j)))d={distance:this.origin.distanceTo(l), +point:l,face:d,object:a},f.push(d)}return f}}; +THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,j,i){h=!1;b=e;c=g;d=j;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= +function(e,g,j,i,m,l){h?(h=!1,b=ej?e>m?e:m:j>m?j:m,f=g>i?g>l?g:l:i>l?i:l):(b=ej?e>m?e>d?e:d:m>d?m:d:j>m?j>d?j:d:m>d?m:d,f=g>i?g>l?g>f?g:f:l>f?l:f:i>l?i>f?i:f:l>f?l:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> +e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,f,e,g,i,k,h,j,m,n,l,p,q){this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,i||0,k||0,h||0,j!==void 0?j:1,m||0,n||0,l||0,p||0,q!==void 0?q:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,i,k,h,j,m,n,l,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=e;this.n23=g;this.n24=i;this.n31=k;this.n32=h;this.n33=j;this.n34=m;this.n41=n;this.n42=l;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, -b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,b).normalize();if(e.length()===0)e.z=1;d.cross(c,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(c,e).normalize());f.cross(e,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=e.x;this.n21=d.y;this.n22=f.y;this.n23=e.y;this.n31=d.z;this.n32=f.z;this.n33=e.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f; -a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ -c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,g=a.n21,i=a.n22,k=a.n23,h=a.n24,j=a.n31,m=a.n32,n=a.n33,l=a.n34,p=a.n41,q=a.n42,v=a.n43,u=a.n44,C=b.n11,K=b.n12, -t=b.n13,w=b.n14,z=b.n21,y=b.n22,o=b.n23,E=b.n24,D=b.n31,F=b.n32,G=b.n33,A=b.n34,M=b.n41,N=b.n42,O=b.n43,S=b.n44;this.n11=c*C+d*z+f*D+e*M;this.n12=c*K+d*y+f*F+e*N;this.n13=c*t+d*o+f*G+e*O;this.n14=c*w+d*E+f*A+e*S;this.n21=g*C+i*z+k*D+h*M;this.n22=g*K+i*y+k*F+h*N;this.n23=g*t+i*o+k*G+h*O;this.n24=g*w+i*E+k*A+h*S;this.n31=j*C+m*z+n*D+l*M;this.n32=j*K+m*y+n*F+l*N;this.n33=j*t+m*o+n*G+l*O;this.n34=j*w+m*E+n*A+l*S;this.n41=p*C+q*z+v*D+u*M;this.n42=p*K+q*y+v*F+u*N;this.n43=p*t+q*o+v*G+u*O;this.n44=p*w+q* -E+v*A+u*S;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,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,b=this.n12,c=this.n13,d=this.n14,f=this.n21,e=this.n22,g=this.n23,i=this.n24,k=this.n31,h=this.n32,j=this.n33,m=this.n34,n=this.n41,l=this.n42,p=this.n43,q=this.n44;return d*g*h*n-c*i*h*n-d*e*j*n+b*i*j*n+c*e*m*n-b*g*m*n-d*g*k*l+c*i*k*l+d*f*j*l-a*i*j*l-c*f*m*l+a*g*m*l+d*e*k*p-b*i*k*p-d*f*h*p+a*i*h*p+b*f*m*p-a*e*m*p-c*e*k*q+b*g*k*q+c*f*h*q-a*g*h*q-b*f*j*q+a*e*j*q}, -transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11; -a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34; -a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0, -0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,i=a.z,k=f*e,h=f*g;this.set(k*e+c,k*g-d*i,k*i+d*g,0,k*g+d*i,h*g+c,h*i-d*e,0,k*i-d*g,h*i+d*e,f*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,e=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),i=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var k= -g*i,h=g*f,j=d*i,m=d*f;this.n11=k+m*c;this.n12=j*c-h;this.n13=e*d;this.n21=e*f;this.n22=e*i;this.n23=-c;this.n31=h*c-j;this.n32=m+k*c;this.n33=e*g;break;case "ZXY":k=g*i;h=g*f;j=d*i;m=d*f;this.n11=k-m*c;this.n12=-e*f;this.n13=j+h*c;this.n21=h+j*c;this.n22=e*i;this.n23=m-k*c;this.n31=-e*d;this.n32=c;this.n33=e*g;break;case "ZYX":k=e*i;h=e*f;j=c*i;m=c*f;this.n11=g*i;this.n12=j*d-h;this.n13=k*d+m;this.n21=g*f;this.n22=m*d+k;this.n23=h*d-j;this.n31=-d;this.n32=c*g;this.n33=e*g;break;case "YZX":k=e*g;h= -e*d;j=c*g;m=c*d;this.n11=g*i;this.n12=m-k*f;this.n13=j*f+h;this.n21=f;this.n22=e*i;this.n23=-c*i;this.n31=-d*i;this.n32=h*f+j;this.n33=k-m*f;break;case "XZY":k=e*g;h=e*d;j=c*g;m=c*d;this.n11=g*i;this.n12=-f;this.n13=d*i;this.n21=k*f+m;this.n22=e*i;this.n23=h*f-j;this.n31=j*f-h;this.n32=c*i;this.n33=m*f+k;break;default:k=e*i,h=e*f,j=c*i,m=c*f,this.n11=g*i,this.n12=-g*f,this.n13=d,this.n21=h+j*d,this.n22=k-m*d,this.n23=-c*g,this.n31=m-k*d,this.n32=j+h*d,this.n33=e*g}return this},setRotationFromQuaternion:function(a){var b= -a.x,c=a.y,d=a.z,f=a.w,e=b+b,g=c+c,i=d+d,a=b*e,k=b*g;b*=i;var h=c*g;c*=i;d*=i;e*=f;g*=f;f*=i;this.n11=1-(h+d);this.n12=k-f;this.n13=b+g;this.n21=k+f;this.n22=1-(a+d);this.n23=c-e;this.n31=b-g;this.n32=c+e;this.n33=1-(a+h);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2; -d.identity();d.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(d,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);e.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length(); -c.y=f.length();c.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,f=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23= -a.n23*f;this.n33=a.n33*f}}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,g=a.n21,i=a.n22,k=a.n23,h=a.n24,j=a.n31,m=a.n32,n=a.n33,l=a.n34,p=a.n41,q=a.n42,v=a.n43,u=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=k*l*q-h*n*q+h*m*v-i*l*v-k*m*u+i*n*u;b.n12=e*n*q-f*l*q-e*m*v+d*l*v+f*m*u-d*n*u;b.n13=f*h*q-e*k*q+e*i*v-d*h*v-f*i*u+d*k*u;b.n14=e*k*m-f*h*m-e*i*n+d*h*n+f*i*l-d*k*l;b.n21=h*n*p-k*l*p-h*j*v+g*l*v+k*j*u-g*n*u;b.n22=f*l*p-e*n*p+e*j*v-c*l*v-f*j*u+c*n*u;b.n23=e*k*p-f*h*p-e*g*v+c*h*v+f*g*u-c*k*u;b.n24= -f*h*j-e*k*j+e*g*n-c*h*n-f*g*l+c*k*l;b.n31=i*l*p-h*m*p+h*j*q-g*l*q-i*j*u+g*m*u;b.n32=e*m*p-d*l*p-e*j*q+c*l*q+d*j*u-c*m*u;b.n33=f*h*p-e*i*p+e*g*q-c*h*q-d*g*u+c*i*u;b.n34=e*i*j-d*h*j-e*g*m+c*h*m+d*g*l-c*i*l;b.n41=k*m*p-i*n*p-k*j*q+g*n*q+i*j*v-g*m*v;b.n42=d*n*p-f*m*p+f*j*q-c*n*q-d*j*v+c*m*v;b.n43=f*i*p-d*k*p-f*g*q+c*k*q+d*g*v-c*i*v;b.n44=d*k*j-f*i*j+f*g*m-c*k*m-d*g*n+c*i*n;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,h=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*h;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*g;c[4]=a*i;c[5]=a*k;c[6]=a*h;c[7]=a*j;c[8]=a*m;return b}; +THREE.Matrix4=function(a,b,c,d,f,e,g,h,k,n,j,i,m,l,q,p){this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,h||0,k||0,n||0,j!==void 0?j:1,i||0,m||0,l||0,q||0,p!==void 0?p:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,h,k,n,j,i,m,l,q,p){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=e;this.n23=g;this.n24=h;this.n31=k;this.n32=n;this.n33=j;this.n34=i;this.n41=m;this.n42=l;this.n43=q;this.n44=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, +b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,b).normalize();if(e.length()===0)e.z=1;d.cross(c,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(c,e).normalize());f.cross(e,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=e.x;this.n21=d.y;this.n22=f.y;this.n23=e.y;this.n31=d.z;this.n32=f.z;this.n33=e.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,g=a.n21,h=a.n22,k=a.n23,n=a.n24,j=a.n31,i=a.n32,m=a.n33,l=a.n34,q=a.n41,p=a.n42,s=a.n43, +v=a.n44,x=b.n11,o=b.n12,C=b.n13,F=b.n14,r=b.n21,B=b.n22,H=b.n23,D=b.n24,y=b.n31,L=b.n32,G=b.n33,I=b.n34,w=b.n41,z=b.n42,J=b.n43,u=b.n44;this.n11=c*x+d*r+f*y+e*w;this.n12=c*o+d*B+f*L+e*z;this.n13=c*C+d*H+f*G+e*J;this.n14=c*F+d*D+f*I+e*u;this.n21=g*x+h*r+k*y+n*w;this.n22=g*o+h*B+k*L+n*z;this.n23=g*C+h*H+k*G+n*J;this.n24=g*F+h*D+k*I+n*u;this.n31=j*x+i*r+m*y+l*w;this.n32=j*o+i*B+m*L+l*z;this.n33=j*C+i*H+m*G+l*J;this.n34=j*F+i*D+m*I+l*u;this.n41=q*x+p*r+s*y+v*w;this.n42=q*o+p*B+s*L+v*z;this.n43=q*C+p* +H+s*G+v*J;this.n44=q*F+p*D+s*I+v*u;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;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},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22* +c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33* +a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,e=this.n22,g=this.n23,h=this.n24,k=this.n31,n=this.n32,j=this.n33,i=this.n34,m=this.n41,l=this.n42,q=this.n43,p=this.n44;return d*g*n*m-c*h*n*m-d*e*j*m+b*h*j*m+c*e*i*m-b*g*i*m-d*g*k*l+c*h*k*l+d*f*j*l-a*h*j*l-c*f*i*l+a*g*i*l+d*e*k*q-b*h*k*q-d*f*n*q+a*h*n*q+b*f*i*q-a*e*i*q-c*e*k*p+b*g*k*p+c*f*n*p-a*g*n*p-b*f*j*p+a*e*j*p},transpose:function(){var a; +a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; +a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a}, +setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this}, +setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,h=a.z,k=f*e,n=f*g;this.set(k*e+c,k*g-d*h,k*h+d*g,0,k*g+d*h,n*g+c,n*h-d*e,0,k*h-d*g,n*h+d*e,f*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, +this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,f=a.n14,e=a.n21,g=a.n22,h=a.n23,k=a.n24,n=a.n31,j=a.n32,i=a.n33,m=a.n34,l=a.n41,q=a.n42,p=a.n43,s=a.n44;this.n11=h*m*q-k*i*q+k*j*p-g*m*p-h*j*s+g*i*s;this.n12=f*i*q-d*m*q-f*j*p+c*m*p+d*j*s-c*i*s;this.n13=d*k*q-f*h*q+f*g*p-c*k*p-d*g*s+c*h*s;this.n14=f*h*j-d*k*j-f*g*i+c*k*i+d*g*m-c*h*m;this.n21=k*i*l-h*m*l-k*n*p+e*m*p+h*n*s-e*i*s;this.n22=d*m*l-f*i*l+ +f*n*p-b*m*p-d*n*s+b*i*s;this.n23=f*h*l-d*k*l-f*e*p+b*k*p+d*e*s-b*h*s;this.n24=d*k*n-f*h*n+f*e*i-b*k*i-d*e*m+b*h*m;this.n31=g*m*l-k*j*l+k*n*q-e*m*q-g*n*s+e*j*s;this.n32=f*j*l-c*m*l-f*n*q+b*m*q+c*n*s-b*j*s;this.n33=d*k*l-f*g*l+f*e*q-b*k*q-c*e*s+b*g*s;this.n34=f*g*n-c*k*n-f*e*j+b*k*j+c*e*m-b*g*m;this.n41=h*j*l-g*i*l-h*n*q+e*i*q+g*n*p-e*j*p;this.n42=c*i*l-d*j*l+d*n*q-b*i*q-c*n*p+b*j*p;this.n43=d*g*l-c*h*l-d*e*q+b*h*q+c*e*p-b*g*p;this.n44=c*h*n-d*g*n+d*e*j-b*h*j-c*e*i+b*g*i;this.multiplyScalar(1/a.determinant()); +return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,e=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var k=g*h,n=g*f,j=d*h,i=d*f;this.n11=k+i*c;this.n12=j*c-n;this.n13=e*d;this.n21=e*f;this.n22=e*h;this.n23=-c;this.n31=n*c-j;this.n32=i+k*c;this.n33=e*g;break;case "ZXY":k=g*h;n=g*f;j=d*h;i=d*f;this.n11=k-i*c;this.n12=-e*f;this.n13=j+n*c;this.n21=n+j*c;this.n22=e*h;this.n23=i-k*c;this.n31=-e*d;this.n32=c;this.n33=e*g;break;case "ZYX":k= +e*h;n=e*f;j=c*h;i=c*f;this.n11=g*h;this.n12=j*d-n;this.n13=k*d+i;this.n21=g*f;this.n22=i*d+k;this.n23=n*d-j;this.n31=-d;this.n32=c*g;this.n33=e*g;break;case "YZX":k=e*g;n=e*d;j=c*g;i=c*d;this.n11=g*h;this.n12=i-k*f;this.n13=j*f+n;this.n21=f;this.n22=e*h;this.n23=-c*h;this.n31=-d*h;this.n32=n*f+j;this.n33=k-i*f;break;case "XZY":k=e*g;n=e*d;j=c*g;i=c*d;this.n11=g*h;this.n12=-f;this.n13=d*h;this.n21=k*f+i;this.n22=e*h;this.n23=n*f-j;this.n31=j*f-n;this.n32=c*h;this.n33=i*f+k;break;default:k=e*h,n=e* +f,j=c*h,i=c*f,this.n11=g*h,this.n12=-g*f,this.n13=d,this.n21=n+j*d,this.n22=k-i*d,this.n23=-c*g,this.n31=i-k*d,this.n32=j+n*d,this.n33=e*g}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,e=b+b,g=c+c,h=d+d,a=b*e,k=b*g;b*=h;var n=c*g;c*=h;d*=h;e*=f;g*=f;f*=h;this.n11=1-(n+d);this.n12=k-f;this.n13=b+g;this.n21=k+f;this.n22=1-(a+d);this.n23=c-e;this.n31=b-g;this.n32=c+e;this.n33=1-(a+n);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*= +a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(d,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);e.set(this.n13, +this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=f.length();c.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34; +return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this}}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*n;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*g;c[4]=a*h;c[5]=a*k;c[6]=a*n;c[7]=a*j;c[8]=a*i;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,f,e){var g;g=new THREE.Matrix4;g.n11=2*f/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*f/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(e+f)/(e-f);g.n34=-2*e*f/(e-f);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var g,i,k,h;g=new THREE.Matrix4;i=b-a;k=c-d;h=e-f;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/k;g.n23=0;g.n24=-((c+d)/k);g.n31=0;g.n32=0;g.n33=-2/h;g.n34=-((e+f)/h);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var g,h,k,n;g=new THREE.Matrix4;h=b-a;k=c-d;n=e-f;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/k;g.n23=0;g.n24=-((c+d)/k);g.n31=0;g.n32=0;g.n33=-2/n;g.n34=-((e+f)/n);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(this.children.indexOf(a)=== --1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},remove:function(a){var b=this,c=this.children.indexOf(a);if(c!==-1){a.parent=void 0;for(this.children.splice(c,1);b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.removeChildRecurse(a)}},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c=0&&f>=0&&g>=0&&i>=0?!0:e<0&&f<0||g<0&&i<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-i)):i<0&&(d=Math.min(d,g/(g-i))),dt&&g.positionScreen.z0&&y.z<1))Q=K[C]=K[C]||new THREE.RenderableParticle,C++,u= -Q,u.x=y.x/y.w,u.y=y.y/y.w,u.z=y.z,u.rotation=B.rotation.z,u.scale.x=B.scale.x*Math.abs(u.x-(y.x+e.projectionMatrix.n11)/(y.w+e.projectionMatrix.n14)),u.scale.y=B.scale.y*Math.abs(u.y-(y.y+e.projectionMatrix.n22)/(y.w+e.projectionMatrix.n24)),u.materials=B.materials,w.push(u);f&&w.sort(b);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,i=d*f;this.w=g*e-i*c;this.x=g*c+i*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); +-1)a.parent!==void 0&&a.parent.remove(a),a.parent=this,this.children.push(a)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d +L&&d.positionScreen.z0&&x.z<1))P=s[p]=s[p]||new THREE.RenderableParticle,p++,q=P,q.x=x.x/x.w,q.y=x.y/x.w,q.z=x.z,q.rotation=A.rotation.z,q.scale.x=A.scale.x*Math.abs(q.x-(x.x+D.projectionMatrix.n11)/(x.w+D.projectionMatrix.n14)),q.scale.y=A.scale.y*Math.abs(q.y-(x.y+D.projectionMatrix.n22)/(x.w+D.projectionMatrix.n24)),q.materials=A.materials,v.elements.push(q);y&&v.elements.sort(b);return v}}; +THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,h=d*f;this.w=g*e-h*c;this.x=g*c+h*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+f*e+c*i-d*g;this.y=c*a+f*g+d*e-b*i;this.z=d*a+f*i+b*g-c*e;this.w=f*a-b*e-c*g-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,i=this.z,k=this.w,h=k*c+g*f-i*d,j=k*d+i*c-e*f,m=k*f+e*d-g*c,c=-e* -c-g*d-i*f;b.x=h*k+c*-e+j*-i-m*-g;b.y=j*k+c*-g+m*-e-h*-i;b.z=m*k+c*-i+h*-g-j*-e;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),g=Math.sqrt(1-f*f);if(Math.abs(g)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c}; -THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3}; +this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,k=this.w,n=k*c+g*f-h*d,j=k*d+h*c-e*f,i=k*f+e*d-g*c,c=-e* +c-g*d-h*f;b.x=n*k+c*-e+j*-h-i*-g;b.y=j*k+c*-g+i*-e-n*-h;b.z=i*k+c*-h+n*-g-j*-e;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,f,O){h=a.vertices[b].position;k=a.vertices[c].position;n=a.vertices[d].position;j=g[e];i=g[f];m=g[O];l=k.x-h.x;q=n.x-h.x;p=k.y-h.y;s=n.y-h.y;v=k.z-h.z;x=n.z-h.z;o=i.u-j.u;C=m.u-j.u;F=i.v-j.v;r=m.v-j.v;B=1/(o*r-C*F);L.set((r*l-F*q)*B,(r*p-F*s)*B,(r*v-F*x)*B);G.set((o*q-C*l)*B,(o*s-C*p)*B,(o*x-C*v)*B);D[b].addSelf(L);D[c].addSelf(L);D[d].addSelf(L);y[b].addSelf(G); +y[c].addSelf(G);y[d].addSelf(G)}var b,c,d,f,e,g,h,k,n,j,i,m,l,q,p,s,v,x,o,C,F,r,B,H,D=[],y=[],L=new THREE.Vector3,G=new THREE.Vector3,I=new THREE.Vector3,w=new THREE.Vector3,z=new THREE.Vector3;b=0;for(c=this.vertices.length;b0){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 b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g)):f instanceof THREE.PointLight&&(D.sub(f.position,b.centroidWorld),D.normalize(),g=b.normalWorld.dot(D)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g))}function b(b,c,g,i,h,j){e.info.render.vertices+=3;e.info.render.faces++;A=d(M++); -A.setAttribute("d","M "+b.positionScreen.x+" "+b.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+g.positionScreen.x+","+g.positionScreen.y+"z");h instanceof THREE.MeshBasicMaterial?t.copy(h.color):h instanceof THREE.MeshLambertMaterial?K?(w.r=z.r,w.g=z.g,w.b=z.b,a(j,i,w),t.r=Math.max(0,Math.min(h.color.r*w.r,1)),t.g=Math.max(0,Math.min(h.color.g*w.g,1)),t.b=Math.max(0,Math.min(h.color.b*w.b,1))):t.copy(h.color):h instanceof THREE.MeshDepthMaterial?(E=1-h.__2near/(h.__farPlusNear- -i.z*h.__farMinusNear),t.setRGB(E,E,E)):h instanceof THREE.MeshNormalMaterial&&t.setRGB(f(i.normalWorld.x),f(i.normalWorld.y),f(i.normalWorld.z));h.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+h.wireframeLinewidth+"; stroke-opacity: "+h.opacity+"; stroke-linecap: "+h.wireframeLinecap+"; stroke-linejoin: "+h.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+h.opacity);k.appendChild(A)}function c(b,c,g,i,h,j,l){e.info.render.vertices+= -4;e.info.render.faces++;A=d(M++);A.setAttribute("d","M "+b.positionScreen.x+" "+b.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+g.positionScreen.x+","+g.positionScreen.y+" L "+i.positionScreen.x+","+i.positionScreen.y+"z");j instanceof THREE.MeshBasicMaterial?t.copy(j.color):j instanceof THREE.MeshLambertMaterial?K?(w.r=z.r,w.g=z.g,w.b=z.b,a(l,h,w),t.r=Math.max(0,Math.min(j.color.r*w.r,1)),t.g=Math.max(0,Math.min(j.color.g*w.g,1)),t.b=Math.max(0,Math.min(j.color.b*w.b,1))): -t.copy(j.color):j instanceof THREE.MeshDepthMaterial?(E=1-j.__2near/(j.__farPlusNear-h.z*j.__farMinusNear),t.setRGB(E,E,E)):j instanceof THREE.MeshNormalMaterial&&t.setRGB(f(h.normalWorld.x),f(h.normalWorld.y),f(h.normalWorld.z));j.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+j.wireframeLinewidth+"; stroke-opacity: "+j.opacity+"; stroke-linecap: "+j.wireframeLinecap+"; stroke-linejoin: "+j.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+ -"; fill-opacity: "+j.opacity);k.appendChild(A)}function d(a){F[a]==null&&(F[a]=document.createElementNS("http://www.w3.org/2000/svg","path"),O==0&&F[a].setAttribute("shape-rendering","crispEdges"));return F[a]}function f(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var e=this,g=null,i=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,j,m,n,l,p,q,v,u=new THREE.Rectangle,C=new THREE.Rectangle,K=!1,t=new THREE.Color(16777215),w=new THREE.Color(16777215),z=new THREE.Color(0), -y=new THREE.Color(0),o=new THREE.Color(0),E,D=new THREE.Vector3,F=[],G=[],A,M,N,O=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(a){switch(a){case "high":O=1;break;case "low":O=0}};this.setSize=function(a,b){h=a;j=b;m=h/2;n=j/2;k.setAttribute("viewBox",-m+" "+-n+" "+h+" "+j);k.setAttribute("width",h);k.setAttribute("height",j);u.set(-m,-n,m,n)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; -this.render=function(a,d){var f,h,j,r,t,w,s,x;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;g=i.projectScene(a,d,this.sortElements);N=M=0;if(K=a.lights.length>0){s=a.lights;z.setRGB(0,0,0);y.setRGB(0,0,0);o.setRGB(0,0,0);f=0;for(h=s.length;f1?1:a}var e=this,g,h,k,n=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,m,l,q,p,s,v,x,o=new THREE.Rectangle,C=new THREE.Rectangle, +F=!1,r=new THREE.Color,B=new THREE.Color,H=new THREE.Color,D=new THREE.Color,y,L=new THREE.Vector3,G=[],I=[],w,z,J,u=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(a){switch(a){case "high":u=1;break;case "low":u=0}};this.setSize=function(a,b){i=a;m=b;l=i/2;q=m/2;j.setAttribute("viewBox",-l+" "+-q+" "+i+" "+m);j.setAttribute("width",i);j.setAttribute("height",m);o.set(-l,-q,l,q)};this.clear=function(){for(;j.childNodes.length> +0;)j.removeChild(j.childNodes[0])};this.render=function(a,d){var f,i,m,r,y,G,t,E;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;g=n.projectScene(a,d,this.sortElements);h=g.elements;k=g.lights;J=z=0;if(F=k.length>0){f=k;B.setRGB(0,0,0);H.setRGB(0,0,0);D.setRGB(0,0,0);i=0;for(m=f.length;i>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; +THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,d){this.r=b;this.g=c;this.b=d;return this},setHSV:function(b,c,d){var e,h,i;if(d==0)this.r=this.g=this.b=0;else switch(e=Math.floor(b*6),h=b*6-e,b=d*(1-c),i=d*(1-c*h),c=d*(1-c*(1-h)),e){case 1:this.r=i;this.g=d;this.b=b;break;case 2:this.r=b;this.g=d;this.b=c;break;case 3:this.r=b;this.g=i;this.b=d;break;case 4:this.r=c;this.g=b;this.b=d;break;case 5:this.r= +d;this.g=b;this.b=i;break;case 6:case 0:this.r=d,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; THREE.Vector2=function(b,c){this.x=b||0;this.y=c||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this}, divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, -equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.x=b||0;this.y=c||0;this.z=e||0}; -THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,c,e){this.x=b;this.y=c;this.z=e;return this},setX:function(b){this.x=b;return this},setY:function(b){this.y=b;return this},setZ:function(b){this.z=b;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this}, +equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,d){this.x=b||0;this.y=c||0;this.z=d||0}; +THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,c,d){this.x=b;this.y=c;this.z=d;return this},setX:function(b){this.x=b;return this},setY:function(b){this.y=b;return this},setZ:function(b){this.z=b;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this}, addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){this.x/=b.x;this.y/=b.y;this.z/=b.z;return this}, divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)}, cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13); -Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(b,c,e,d){this.x=b||0;this.y=c||0;this.z=e||0;this.w=d!==void 0?d:1}; -THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,e,d){this.x=b;this.y=c;this.z=e;this.w=d;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w!==void 0?b.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z- +Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(b,c,d,e){this.x=b||0;this.y=c||0;this.z=d||0;this.w=e!==void 0?e:1}; +THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w!==void 0?b.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z- c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,d=[];c=0;for(e=b.length;c0&&b>0&&i+b<1}for(var d,h=[],i=0,j=b.children.length;ib.scale.x)return[];d={distance:i,point:b.position,face:null,object:b};h.push(d)}else if(b instanceof THREE.Mesh){i=c(this.origin, -this.direction,b.matrixWorld.getPosition());if(i==null||i>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return h;for(var k,n,p,q,m,r,t,A,y=b.geometry,J=y.vertices,i=0,j=y.faces.length;i0:r<0)))if(r=m.dot((new THREE.Vector3).sub(k,t))/r,t=t.addSelf(A.multiplyScalar(r)),d instanceof THREE.Face3)e(t,k,n,p)&&(d={distance:this.origin.distanceTo(t),point:t,face:d,object:b},h.push(d));else if(d instanceof THREE.Face4&&(e(t,k,n,q)||e(t,n,p,q)))d={distance:this.origin.distanceTo(t),point:t,face:d,object:b},h.push(d)}return h}}; -THREE.Rectangle=function(){function b(){i=d-c;j=h-e}var c,e,d,h,i,j,k=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(i,j,q,m){k=!1;c=i;e=j;d=q;h=m;b()};this.addPoint=function(i,j){k?(k=!1,c=i,e=j,d=i,h=j):(c=ci?d:i,h=h>j?h:j);b()};this.add3Points= -function(i,j,q,m,r,t){k?(k=!1,c=iq?i>r?i:r:q>r?q:r,h=j>m?j>t?j:t:m>t?m:t):(c=iq?i>r?i>d?i:d:r>d?r:d:q>r?q>d?q:d:r>d?r:d,h=j>m?j>t?j>h?j:h:t>h?t:h:m>t?m>h?m:h:t>h?t:h);b()};this.addRectangle=function(i){k?(k=!1,c=i.getLeft(),e=i.getTop(),d=i.getRight(),h=i.getBottom()):(c=ci.getRight()?d:i.getRight(),h=h> -i.getBottom()?h:i.getBottom());b()};this.inflate=function(i){c-=i;e-=i;d+=i;h+=i;b()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();e=e>i.getTop()?e:i.getTop();d=d=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){k=!0;h=d=e=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]}; +THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.children)},intersectObjects:function(b){var c,d,e=[];c=0;for(d=b.length;c0&&b>0&&i+b<1}for(var e,h=[],i=0,j=b.children.length;ib.scale.x)return[];e={distance:i,point:b.position,face:null,object:b};h.push(e)}else if(b instanceof THREE.Mesh){i=c(this.origin, +this.direction,b.matrixWorld.getPosition());if(i==null||i>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return h;var k,s,p,o,n,q,v,y,D=b.geometry,E=D.vertices;b.matrixRotationWorld.extractRotation(b.matrixWorld);i=0;for(j=D.faces.length;i0:q<0)))if(q=n.dot((new THREE.Vector3).sub(k,v))/q,v=v.addSelf(y.multiplyScalar(q)),e instanceof THREE.Face3)d(v,k,s,p)&&(e={distance:this.origin.distanceTo(v),point:v,face:e,object:b},h.push(e));else if(e instanceof THREE.Face4&&(d(v,k,s,o)||d(v,s,p,o)))e={distance:this.origin.distanceTo(v), +point:v,face:e,object:b},h.push(e)}return h}}; +THREE.Rectangle=function(){function b(){i=e-c;j=h-d}var c,d,e,h,i,j,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(i,j,o,n){k=!1;c=i;d=j;e=o;h=n;b()};this.addPoint=function(i,j){k?(k=!1,c=i,d=j,e=i,h=j):(c=ci?e:i,h=h>j?h:j);b()};this.add3Points= +function(i,j,o,n,q,v){k?(k=!1,c=io?i>q?i:q:o>q?o:q,h=j>n?j>v?j:v:n>v?n:v):(c=io?i>q?i>e?i:e:q>e?q:e:o>q?o>e?o:e:q>e?q:e,h=j>n?j>v?j>h?j:h:v>h?v:h:n>v?n>h?n:h:v>h?v:h);b()};this.addRectangle=function(i){k?(k=!1,c=i.getLeft(),d=i.getTop(),e=i.getRight(),h=i.getBottom()):(c=ci.getRight()?e:i.getRight(),h=h> +i.getBottom()?h:i.getBottom());b()};this.inflate=function(i){c-=i;d-=i;e+=i;h+=i;b()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();d=d>i.getTop()?d:i.getTop();e=e=0&&Math.min(h,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;h=e=d=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]}; THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}}; -THREE.Matrix4=function(b,c,e,d,h,i,j,k,n,p,q,m,r,t,A,y){this.set(b!==void 0?b:1,c||0,e||0,d||0,h||0,i!==void 0?i:1,j||0,k||0,n||0,p||0,q!==void 0?q:1,m||0,r||0,t||0,A||0,y!==void 0?y:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,d,h,i,j,k,n,p,q,m,r,t,A,y){this.n11=b;this.n12=c;this.n13=e;this.n14=d;this.n21=h;this.n22=i;this.n23=j;this.n24=k;this.n31=n;this.n32=p;this.n33=q;this.n34=m;this.n41=r;this.n42=t;this.n43=A;this.n44=y;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, -c,e){var d=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,c).normalize();if(i.length()===0)i.z=1;d.cross(e,i).normalize();d.length()===0&&(i.x+=1.0E-4,d.cross(e,i).normalize());h.cross(i,d).normalize();this.n11=d.x;this.n12=h.x;this.n13=i.x;this.n21=d.y;this.n22=h.y;this.n23=i.y;this.n31=d.z;this.n32=h.z;this.n33=i.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,d=b.z,h=1/(this.n41*c+this.n42*e+this.n43*d+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*d+this.n14)*h; -b.y=(this.n21*c+this.n22*e+this.n23*d+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*d+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,d=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*d+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*d+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*d+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*d+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,d=b.z;b.x=c*this.n11+e*this.n12+d*this.n13;b.y=c*this.n21+e*this.n22+d*this.n23;b.z=c*this.n31+ -e*this.n32+d*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,d=b.n12,h=b.n13,i=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,q=b.n31,m=b.n32,r=b.n33,t=b.n34,A=b.n41,y=b.n42,J=b.n43,F=b.n44,xa=c.n11,ya= -c.n12,ja=c.n13,ta=c.n14,ha=c.n21,G=c.n22,v=c.n23,T=c.n24,L=c.n31,V=c.n32,la=c.n33,Z=c.n34,Ca=c.n41,$=c.n42,M=c.n43,f=c.n44;this.n11=e*xa+d*ha+h*L+i*Ca;this.n12=e*ya+d*G+h*V+i*$;this.n13=e*ja+d*v+h*la+i*M;this.n14=e*ta+d*T+h*Z+i*f;this.n21=j*xa+k*ha+n*L+p*Ca;this.n22=j*ya+k*G+n*V+p*$;this.n23=j*ja+k*v+n*la+p*M;this.n24=j*ta+k*T+n*Z+p*f;this.n31=q*xa+m*ha+r*L+t*Ca;this.n32=q*ya+m*G+r*V+t*$;this.n33=q*ja+m*v+r*la+t*M;this.n34=q*ta+m*T+r*Z+t*f;this.n41=A*xa+y*ha+J*L+F*Ca;this.n42=A*ya+y*G+J*V+F*$;this.n43= -A*ja+y*v+J*la+F*M;this.n44=A*ta+y*T+J*Z+F*f;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*= -b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,d=this.n14,h=this.n21,i=this.n22,j=this.n23,k=this.n24,n=this.n31,p=this.n32,q=this.n33,m=this.n34,r=this.n41,t=this.n42,A=this.n43,y=this.n44;return d*j*p*r-e*k*p*r-d*i*q*r+c*k*q*r+e*i*m*r-c*j*m*r-d*j*n*t+e*k*n*t+d*h*q*t-b*k*q*t-e*h*m*t+b*j*m*t+d*i*n*A-c*k*n*A-d*h*p*A+b*k*p*A+c*h*m*A-b*i*m*A-e*i*n*y+c*j* -n*y+e*h*p*y-b*j*p*y-c*h*q*y+b*i*q*y},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32; +THREE.Matrix4=function(b,c,d,e,h,i,j,k,s,p,o,n,q,v,y,D){this.set(b!==void 0?b:1,c||0,d||0,e||0,h||0,i!==void 0?i:1,j||0,k||0,s||0,p||0,o!==void 0?o:1,n||0,q||0,v||0,y||0,D!==void 0?D:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,d,e,h,i,j,k,s,p,o,n,q,v,y,D){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=h;this.n22=i;this.n23=j;this.n24=k;this.n31=s;this.n32=p;this.n33=o;this.n34=n;this.n41=q;this.n42=v;this.n43=y;this.n44=D;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, +c,d){var e=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,c).normalize();if(i.length()===0)i.z=1;e.cross(d,i).normalize();e.length()===0&&(i.x+=1.0E-4,e.cross(d,i).normalize());h.cross(i,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=i.x;this.n21=e.y;this.n22=h.y;this.n23=i.y;this.n31=e.z;this.n32=h.z;this.n33=i.z;return this},multiply:function(b,c){var d=b.n11,e=b.n12,h=b.n13,i=b.n14,j=b.n21,k=b.n22,s=b.n23,p=b.n24,o=b.n31,n=b.n32,q=b.n33,v=b.n34,y=b.n41,D=b.n42,E=b.n43, +H=b.n44,ia=c.n11,B=c.n12,va=c.n13,ka=c.n14,sa=c.n21,N=c.n22,Y=c.n23,R=c.n24,ra=c.n31,aa=c.n32,la=c.n33,Z=c.n34,X=c.n41,x=c.n42,F=c.n43,f=c.n44;this.n11=d*ia+e*sa+h*ra+i*X;this.n12=d*B+e*N+h*aa+i*x;this.n13=d*va+e*Y+h*la+i*F;this.n14=d*ka+e*R+h*Z+i*f;this.n21=j*ia+k*sa+s*ra+p*X;this.n22=j*B+k*N+s*aa+p*x;this.n23=j*va+k*Y+s*la+p*F;this.n24=j*ka+k*R+s*Z+p*f;this.n31=o*ia+n*sa+q*ra+v*X;this.n32=o*B+n*N+q*aa+v*x;this.n33=o*va+n*Y+q*la+v*F;this.n34=o*ka+n*R+q*Z+v*f;this.n41=y*ia+D*sa+E*ra+H*X;this.n42= +y*B+D*N+E*aa+H*x;this.n43=y*va+D*Y+E*la+H*F;this.n44=y*ka+D*R+E*Z+H*f;return this},multiplySelf:function(b){return this.multiply(this,b)},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*= +b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,h=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*h;b.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*h;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,h=b.w;b.x=this.n11*c+this.n12*d+this.n13* +e+this.n14*h;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*h;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*h;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*h;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+d*this.n32+e*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24* +b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},determinant:function(){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,h=this.n21,i=this.n22,j=this.n23,k=this.n24,s=this.n31,p=this.n32,o=this.n33,n=this.n34,q=this.n41,v=this.n42,y=this.n43,D=this.n44;return e*j*p*q-d*k*p*q-e*i*o*q+c*k*o*q+d*i*n*q-c*j*n*q-e*j*s*v+d*k*s*v+e*h*o*v-b*k*o*v-d*h*n*v+b*j*n*v+e*i*s*y-c*k*s*y-e*h*p*y+b*k*p*y+c*h*n*y-b*i*n*y-d*i*s*D+c*j*s*D+ +d*h*p*D-b*j*p*D-c*h*o*D+b*i*o*D},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32; b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]= this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]= -this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0, -0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),d=Math.sin(c),h=1-e,i=b.x,j=b.y,k=b.z,n=h*i,p=h*j;this.set(n*i+e,n*j-d*k,n*k+d*j,0,n*j+d*k,p*j+e,p*k-d*i,0,n*k-d*j,p*k+d*i,h*k*k+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var e=b.x,d=b.y,h=b.z,i=Math.cos(e),e=Math.sin(e),j=Math.cos(d),d=Math.sin(d),k=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var n= -j*k,p=j*h,q=d*k,m=d*h;this.n11=n+m*e;this.n12=q*e-p;this.n13=i*d;this.n21=i*h;this.n22=i*k;this.n23=-e;this.n31=p*e-q;this.n32=m+n*e;this.n33=i*j;break;case "ZXY":n=j*k;p=j*h;q=d*k;m=d*h;this.n11=n-m*e;this.n12=-i*h;this.n13=q+p*e;this.n21=p+q*e;this.n22=i*k;this.n23=m-n*e;this.n31=-i*d;this.n32=e;this.n33=i*j;break;case "ZYX":n=i*k;p=i*h;q=e*k;m=e*h;this.n11=j*k;this.n12=q*d-p;this.n13=n*d+m;this.n21=j*h;this.n22=m*d+n;this.n23=p*d-q;this.n31=-d;this.n32=e*j;this.n33=i*j;break;case "YZX":n=i*j;p= -i*d;q=e*j;m=e*d;this.n11=j*k;this.n12=m-n*h;this.n13=q*h+p;this.n21=h;this.n22=i*k;this.n23=-e*k;this.n31=-d*k;this.n32=p*h+q;this.n33=n-m*h;break;case "XZY":n=i*j;p=i*d;q=e*j;m=e*d;this.n11=j*k;this.n12=-h;this.n13=d*k;this.n21=n*h+m;this.n22=i*k;this.n23=p*h-q;this.n31=q*h-p;this.n32=e*k;this.n33=m*h+n;break;default:n=i*k,p=i*h,q=e*k,m=e*h,this.n11=j*k,this.n12=-j*h,this.n13=d,this.n21=p+q*d,this.n22=n-m*d,this.n23=-e*j,this.n31=m-n*d,this.n32=q+p*d,this.n33=i*j}return this},setRotationFromQuaternion:function(b){var c= -b.x,e=b.y,d=b.z,h=b.w,i=c+c,j=e+e,k=d+d,b=c*i,n=c*j;c*=k;var p=e*j;e*=k;d*=k;i*=h;j*=h;h*=k;this.n11=1-(p+d);this.n12=n-h;this.n13=c+j;this.n21=n+h;this.n22=1-(b+d);this.n23=e-i;this.n31=c-j;this.n32=e+i;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},compose:function(b,c,e){var d=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2; -d.identity();d.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(d,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var d=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);i.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=d.length(); -e.y=h.length();e.z=i.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=e.x;d.n21/=e.x;d.n31/=e.x;d.n12/=e.y;d.n22/=e.y;d.n32/=e.y;d.n13/=e.z;d.n23/=e.z;d.n33/=e.z;c.setFromRotationMatrix(d);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,d=1/c.y,h=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*d;this.n22=b.n22*d;this.n32=b.n32*d;this.n13=b.n13*h;this.n23= -b.n23*h;this.n33=b.n33*h}}; -THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,d=b.n12,h=b.n13,i=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,q=b.n31,m=b.n32,r=b.n33,t=b.n34,A=b.n41,y=b.n42,J=b.n43,F=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*t*y-p*r*y+p*m*J-k*t*J-n*m*F+k*r*F;c.n12=i*r*y-h*t*y-i*m*J+d*t*J+h*m*F-d*r*F;c.n13=h*p*y-i*n*y+i*k*J-d*p*J-h*k*F+d*n*F;c.n14=i*n*m-h*p*m-i*k*r+d*p*r+h*k*t-d*n*t;c.n21=p*r*A-n*t*A-p*q*J+j*t*J+n*q*F-j*r*F;c.n22=h*t*A-i*r*A+i*q*J-e*t*J-h*q*F+e*r*F;c.n23=i*n*A-h*p*A-i*j*J+e*p*J+h*j*F-e*n*F;c.n24= -h*p*q-i*n*q+i*j*r-e*p*r-h*j*t+e*n*t;c.n31=k*t*A-p*m*A+p*q*y-j*t*y-k*q*F+j*m*F;c.n32=i*m*A-d*t*A-i*q*y+e*t*y+d*q*F-e*m*F;c.n33=h*p*A-i*k*A+i*j*y-e*p*y-d*j*F+e*k*F;c.n34=i*k*q-d*p*q-i*j*m+e*p*m+d*j*t-e*k*t;c.n41=n*m*A-k*r*A-n*q*y+j*r*y+k*q*J-j*m*J;c.n42=d*r*A-h*m*A+h*q*y-e*r*y-d*q*J+e*m*J;c.n43=h*k*A-d*n*A-h*j*y+e*n*y+d*j*J-e*k*J;c.n44=d*n*q-h*k*q+h*j*m-e*n*m-d*j*r+e*k*r;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,d=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,q=-b.n23*b.n11+b.n21*b.n13,m=b.n22*b.n11-b.n21*b.n12,b=b.n11*d+b.n21*j+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*d;e[1]=b*h;e[2]=b*i;e[3]=b*j;e[4]=b*k;e[5]=b*n;e[6]=b*p;e[7]=b*q;e[8]=b*m;return c}; -THREE.Matrix4.makeFrustum=function(b,c,e,d,h,i){var j;j=new THREE.Matrix4;j.n11=2*h/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*h/(d-e);j.n23=(d+e)/(d-e);j.n24=0;j.n31=0;j.n32=0;j.n33=-(i+h)/(i-h);j.n34=-2*i*h/(i-h);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,e,d){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,d)}; -THREE.Matrix4.makeOrtho=function(b,c,e,d,h,i){var j,k,n,p;j=new THREE.Matrix4;k=c-b;n=e-d;p=i-h;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/n;j.n23=0;j.n24=-((e+d)/n);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((i+h)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0, +0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),h=1-d,i=b.x,j=b.y,k=b.z,s=h*i,p=h*j;this.set(s*i+d,s*j-e*k,s*k+e*j,0,s*j+e*k,p*j+d,p*k-e*i,0,s*k-e*j,p*k+e*i,h*k*k+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, +this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(b){var c=b.n11,d=b.n12,e=b.n13,h=b.n14,i=b.n21,j=b.n22,k=b.n23,s=b.n24,p=b.n31,o=b.n32,n=b.n33,q=b.n34,v=b.n41,y=b.n42,D=b.n43,E=b.n44;this.n11=k*q*y-s*n*y+s*o*D-j*q*D-k*o*E+j*n*E;this.n12=h*n*y-e*q*y-h*o*D+d*q*D+e*o*E-d*n*E;this.n13=e*s*y-h*k*y+h*j*D-d*s*D-e*j*E+d*k*E;this.n14=h*k*o-e*s*o-h*j*n+d*s*n+e*j*q-d*k*q;this.n21=s*n*v-k*q*v-s*p*D+i*q*D+k*p*E-i*n*E;this.n22=e*q*v-h*n*v+ +h*p*D-c*q*D-e*p*E+c*n*E;this.n23=h*k*v-e*s*v-h*i*D+c*s*D+e*i*E-c*k*E;this.n24=e*s*p-h*k*p+h*i*n-c*s*n-e*i*q+c*k*q;this.n31=j*q*v-s*o*v+s*p*y-i*q*y-j*p*E+i*o*E;this.n32=h*o*v-d*q*v-h*p*y+c*q*y+d*p*E-c*o*E;this.n33=e*s*v-h*j*v+h*i*y-c*s*y-d*i*E+c*j*E;this.n34=h*j*p-d*s*p-h*i*o+c*s*o+d*i*q-c*j*q;this.n41=k*o*v-j*n*v-k*p*y+i*n*y+j*p*D-i*o*D;this.n42=d*n*v-e*o*v+e*p*y-c*n*y-d*p*D+c*o*D;this.n43=e*j*v-d*k*v-e*i*y+c*k*y+d*i*D-c*j*D;this.n44=d*k*p-e*j*p+e*i*o-c*k*o-d*i*n+c*j*n;this.multiplyScalar(1/b.determinant()); +return this},setRotationFromEuler:function(b,c){var d=b.x,e=b.y,h=b.z,i=Math.cos(d),d=Math.sin(d),j=Math.cos(e),e=Math.sin(e),k=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var s=j*k,p=j*h,o=e*k,n=e*h;this.n11=s+n*d;this.n12=o*d-p;this.n13=i*e;this.n21=i*h;this.n22=i*k;this.n23=-d;this.n31=p*d-o;this.n32=n+s*d;this.n33=i*j;break;case "ZXY":s=j*k;p=j*h;o=e*k;n=e*h;this.n11=s-n*d;this.n12=-i*h;this.n13=o+p*d;this.n21=p+o*d;this.n22=i*k;this.n23=n-s*d;this.n31=-i*e;this.n32=d;this.n33=i*j;break;case "ZYX":s= +i*k;p=i*h;o=d*k;n=d*h;this.n11=j*k;this.n12=o*e-p;this.n13=s*e+n;this.n21=j*h;this.n22=n*e+s;this.n23=p*e-o;this.n31=-e;this.n32=d*j;this.n33=i*j;break;case "YZX":s=i*j;p=i*e;o=d*j;n=d*e;this.n11=j*k;this.n12=n-s*h;this.n13=o*h+p;this.n21=h;this.n22=i*k;this.n23=-d*k;this.n31=-e*k;this.n32=p*h+o;this.n33=s-n*h;break;case "XZY":s=i*j;p=i*e;o=d*j;n=d*e;this.n11=j*k;this.n12=-h;this.n13=e*k;this.n21=s*h+n;this.n22=i*k;this.n23=p*h-o;this.n31=o*h-p;this.n32=d*k;this.n33=n*h+s;break;default:s=i*k,p=i* +h,o=d*k,n=d*h,this.n11=j*k,this.n12=-j*h,this.n13=e,this.n21=p+o*e,this.n22=s-n*e,this.n23=-d*j,this.n31=n-s*e,this.n32=o+p*e,this.n33=i*j}return this},setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,h=b.w,i=c+c,j=d+d,k=e+e,b=c*i,s=c*j;c*=k;var p=d*j;d*=k;e*=k;i*=h;j*=h;h*=k;this.n11=1-(p+e);this.n12=s-h;this.n13=c+j;this.n21=s+h;this.n22=1-(b+e);this.n23=d-i;this.n31=c-j;this.n32=d+i;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*= +b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},compose:function(b,c,d){var e=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2;e.identity();e.setRotationFromQuaternion(c);h.setScale(d.x,d.y,d.z);this.multiply(e,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,d){var e=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;e.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);i.set(this.n13, +this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;d=d instanceof THREE.Vector3?d:new THREE.Vector3;d.x=e.length();d.y=h.length();d.z=i.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;e=THREE.Matrix4.__m1;e.copy(this);e.n11/=d.x;e.n21/=d.x;e.n31/=d.x;e.n12/=d.y;e.n22/=d.y;e.n32/=d.y;e.n13/=d.z;e.n23/=d.z;e.n33/=d.z;c.setFromRotationMatrix(e);return[b,c,d]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34; +return this},extractRotation:function(b){var c=THREE.Matrix4.__v1,d=1/c.set(b.n11,b.n21,b.n31).length(),e=1/c.set(b.n12,b.n22,b.n32).length(),c=1/c.set(b.n13,b.n23,b.n33).length();this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*c;this.n23=b.n23*c;this.n33=b.n33*c;return this}}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,s=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,n=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*j+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*h;d[2]=b*i;d[3]=b*j;d[4]=b*k;d[5]=b*s;d[6]=b*p;d[7]=b*o;d[8]=b*n;return c}; +THREE.Matrix4.makeFrustum=function(b,c,d,e,h,i){var j;j=new THREE.Matrix4;j.n11=2*h/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*h/(e-d);j.n23=(e+d)/(e-d);j.n24=0;j.n31=0;j.n32=0;j.n33=-(i+h)/(i-h);j.n34=-2*i*h/(i-h);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,d,e){var h,b=d*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,d,e)}; +THREE.Matrix4.makeOrtho=function(b,c,d,e,h,i){var j,k,s,p;j=new THREE.Matrix4;k=c-b;s=d-e;p=i-h;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/s;j.n23=0;j.n24=-((d+e)/s);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((i+h)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(b){if(this.children.indexOf(b)=== --1){b.parent!==void 0&&b.parent.remove(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},remove:function(b){var c=this,e=this.children.indexOf(b);if(e!==-1){b.parent=void 0;for(this.children.splice(e,1);c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.removeChildRecurse(b)}},getChildByName:function(b,c){var e,d,h;e=0;for(d=this.children.length;e=0&&i>=0&&h>=0&&j>=0?!0:f<0&&i<0||h<0&&j<0?!1:(f<0?e=Math.max(e,f/(f-i)):i<0&&(d=Math.min(d,f/(f-i))),h<0?e=Math.max(e,h/(h-j)):j<0&&(d=Math.min(d,h/(h-j))),dM&&j.positionScreen.z0&&G.z<1))za=ya[xa]=ya[xa]||new THREE.RenderableParticle,xa++,F=za,F.x=G.x/G.w,F.y=G.y/G.w,F.z=G.z,F.rotation=P.rotation.z,F.scale.x=P.scale.x*Math.abs(F.x-(G.x+i.projectionMatrix.n11)/(G.w+i.projectionMatrix.n14)),F.scale.y=P.scale.y*Math.abs(F.y-(G.y+i.projectionMatrix.n22)/(G.w+i.projectionMatrix.n24)),F.materials=P.materials,ta.push(F);h&&ta.sort(c);return ta}}; -THREE.Quaternion=function(b,c,e,d){this.set(b||0,c||0,e||0,d!==void 0?d:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,d){this.x=b;this.y=c;this.z=e;this.w=d;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,e=b.x*c,d=b.y*c,h=b.z*c,b=Math.cos(d),d=Math.sin(d),c=Math.cos(-h),h=Math.sin(-h),i=Math.cos(e),e=Math.sin(e),j=b*c,k=d*h;this.w=j*i-k*e;this.x=j*e+k*i;this.y=d*c*i+b*h*e;this.z=b*h*i-d*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,d=Math.sin(e); -this.x=b.x*d;this.y=b.y*d;this.z=b.z*d;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); +-1)b.parent!==void 0&&b.parent.remove(b),b.parent=this,this.children.push(b)},remove:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var d,e,h;d=0;for(e=this.children.length;d=0&&h>=0&&j>=0&&k>=0?!0:i<0&&h<0||j<0&&k<0?!1:(i<0?d=Math.max(d,i/(i-h)):h<0&&(e=Math.min(e,i/(i-h))),j<0?d=Math.max(d,j/(j-k)):k<0&&(e=Math.min(e,j/(j-k))),eaa&&e.positionScreen.z0&&ia.z<1))oa=E[D]=E[D]||new THREE.RenderableParticle,D++,y=oa,y.x=ia.x/ia.w,y.y=ia.y/ia.w,y.z=ia.z,y.rotation=J.rotation.z,y.scale.x=J.scale.x*Math.abs(y.x-(ia.x+R.projectionMatrix.n11)/(ia.w+R.projectionMatrix.n14)),y.scale.y=J.scale.y*Math.abs(y.y-(ia.y+R.projectionMatrix.n22)/ +(ia.w+R.projectionMatrix.n24)),y.materials=J.materials,H.elements.push(y);ra&&H.elements.sort(c);return H}};THREE.Quaternion=function(b,c,d,e){this.set(b||0,c||0,d||0,e!==void 0?e:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,d=b.x*c,e=b.y*c,h=b.z*c,b=Math.cos(e),e=Math.sin(e),c=Math.cos(-h),h=Math.sin(-h),i=Math.cos(d),d=Math.sin(d),j=b*c,k=e*h;this.w=j*i-k*d;this.x=j*d+k*i;this.y=e*c*i+b*h*d;this.z=b*h*i-e*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,e=Math.sin(d); +this.x=b.x*e;this.y=b.y*e;this.z=b.z*e;this.w=Math.cos(d);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c= -this.x,e=this.y,d=this.z,h=this.w,i=b.x,j=b.y,k=b.z,b=b.w;this.x=c*b+h*i+e*k-d*j;this.y=e*b+h*j+d*i-c*k;this.z=d*b+h*k+c*j-e*i;this.w=h*b-c*i-e*j-d*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,d=b.y,h=b.z,i=this.x,j=this.y,k=this.z,n=this.w,p=n*e+j*h-k*d,q=n*d+k*e-i*h,m=n*h+i*d-j*e,e=-i* -e-j*d-k*h;c.x=p*n+e*-i+q*-k-m*-j;c.y=q*n+e*-j+m*-i-p*-k;c.z=m*n+e*-k+p*-j-q*-i;return c}};THREE.Quaternion.slerp=function(b,c,e,d){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),j=Math.sqrt(1-h*h);if(Math.abs(j)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;h=Math.sin((1-d)*i)/j;d=Math.sin(d*i)/j;e.w=b.w*h+c.w*d;e.x=b.x*h+c.x*d;e.y=b.y*h+c.y*d;e.z=b.z*h+c.z*d;return e}; -THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,d,h,i){this.a=b;this.b=c;this.c=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3}; -THREE.Face4=function(b,c,e,d,h,i,j){this.a=b;this.b=c;this.c=e;this.d=d;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0}; +this.x,d=this.y,e=this.z,h=this.w,i=b.x,j=b.y,k=b.z,b=b.w;this.x=c*b+h*i+d*k-e*j;this.y=d*b+h*j+e*i-c*k;this.z=e*b+h*k+c*j-d*i;this.w=h*b-c*i-d*j-e*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,e=b.y,h=b.z,i=this.x,j=this.y,k=this.z,s=this.w,p=s*d+j*h-k*e,o=s*e+k*d-i*h,n=s*h+i*e-j*d,d=-i* +d-j*e-k*h;c.x=p*s+d*-i+o*-k-n*-j;c.y=o*s+d*-j+n*-i-p*-k;c.z=n*s+d*-k+p*-j-o*-i;return c}}; +THREE.Quaternion.slerp=function(b,c,d,e){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;h<0?(d.w=-c.w,d.x=-c.x,d.y=-c.y,d.z=-c.z,h=-h):d.copy(c);if(Math.abs(h)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var i=Math.acos(h),h=Math.sqrt(1-h*h);if(Math.abs(h)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;c=Math.sin((1-e)*i)/h;e=Math.sin(e*i)/h;d.w=b.w*c+d.w*e;d.x=b.x*c+d.x*e;d.y=b.y*c+d.y*e;d.z=b.z*c+d.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Face3=function(b,c,d,e,h,i){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,c,d,e,h,i,j){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; -THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(b){var c=new THREE.Matrix4;c.extractRotation(b,new THREE.Vector3(1,1,1));for(var e=0,d=this.vertices.length;e0){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;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z< -this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?i:i+1;e[3]=i>this.points.length-3?i:i+2;p=this.points[e[0]];q=this.points[e[1]]; -m=this.points[e[2]];r=this.points[e[3]];k=j*j;n=j*k;d.x=c(p.x,q.x,m.x,r.x,j,k,n);d.y=c(p.y,q.y,m.y,r.y,j,k,n);d.z=c(p.z,q.z,m.z,r.z,j,k,n);return d};this.getControlPointsArray=function(){var b,c,e=this.points.length,d=[];for(b=0;b0){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;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z< +this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,d=this.vertices.length;cthis.points.length-2?i:i+1;d[3]=i>this.points.length-3?i:i+2;p=this.points[d[0]];o=this.points[d[1]]; +n=this.points[d[2]];q=this.points[d[3]];k=j*j;s=j*k;e.x=c(p.x,o.x,n.x,q.x,j,k,s);e.y=c(p.y,o.y,n.y,q.y,j,k,s);e.z=c(p.z,o.z,n.z,q.z,j,k,s);return e};this.getControlPointsArray=function(){var b,c,d=this.points.length,e=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d=this.LODs[d].visibleAtDistance)this.LODs[d-1].object3D.visible=!1, -this.LODs[d].object3D.visible=!0;else break;for(;d1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1, +this.LODs[e].object3D.visible=!0;else break;for(;e= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec4( vec3( ( 1.0 - shadowDarkness * shadow ) ), 1.0 );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif\n}\n}\ngl_FragColor = gl_FragColor * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif"}; -THREE.UniformsUtils={merge:function(b){var c,e,d,h={};for(c=0;c=0)c&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(b.position,3,f.FLOAT,!1,0,0));else if(j.morphTargetBase){d=i.program.attributes;j.morphTargetBase!== --1?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),f.vertexAttribPointer(d.position,3,f.FLOAT,!1,0,0)):d.position>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(d.position,3,f.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var n=0,x=j.morphTargetForcedOrder,p=j.morphTargetInfluences;nq&&(m=t,q=p[m]);f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m]);f.vertexAttribPointer(d["morphTarget"+n],3,f.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[n]=q;x[m]=1;q=-1;n++}}i.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(i.program.uniforms.morphTargetInfluences, -j.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(k in h.__webglCustomAttributes)b[k]>=0&&(d=h.__webglCustomAttributes[k],f.bindBuffer(f.ARRAY_BUFFER,d.buffer),f.vertexAttribPointer(b[k],d.size,f.FLOAT,!1,0,0));b.color>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));b.normal>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglNormalBuffer),f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));b.tangent>=0&&(f.bindBuffer(f.ARRAY_BUFFER, +THREE.WebGLRenderer=function(b){function c(b,c,d){var e,i,h,j=b.vertices,T=j.length,r=b.colors,k=r.length,C=b.__vertexArray,I=b.__colorArray,o=b.__sortArray,K=b.__dirtyVertices,s=b.__dirtyColors,n=b.__webglCustomAttributes,p,q;if(n)for(p in n)n[p].offset=0;if(d.sortParticles){Ba.multiplySelf(d.matrixWorld);for(e=0;e=0)c&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(b.position,3,f.FLOAT,!1,0,0));else if(j.morphTargetBase){e=i.program.attributes;j.morphTargetBase!== +-1?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),f.vertexAttribPointer(e.position,3,f.FLOAT,!1,0,0)):e.position>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(e.position,3,f.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var o=0,r=j.morphTargetForcedOrder,n=j.morphTargetInfluences;oC&&(s=p,C=n[s]);f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[s]);f.vertexAttribPointer(e["morphTarget"+o],3,f.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[o]=C;r[s]=1;C=-1;o++}}i.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(i.program.uniforms.morphTargetInfluences, +j.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(k in h.__webglCustomAttributes)b[k]>=0&&(e=h.__webglCustomAttributes[k],f.bindBuffer(f.ARRAY_BUFFER,e.buffer),f.vertexAttribPointer(b[k],e.size,f.FLOAT,!1,0,0));b.color>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));b.normal>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglNormalBuffer),f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));b.tangent>=0&&(f.bindBuffer(f.ARRAY_BUFFER, h.__webglTangentBuffer),f.vertexAttribPointer(b.tangent,4,f.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUVBuffer),f.vertexAttribPointer(b.uv,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv)):f.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUV2Buffer),f.vertexAttribPointer(b.uv2,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv2)):f.disableVertexAttribArray(b.uv2));i.skinning&&b.skinVertexA>=0&&b.skinVertexB>= 0&&b.skinIndex>=0&&b.skinWeight>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexABuffer),f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0))}j instanceof THREE.Mesh?(i.wireframe? -(f.lineWidth(i.wireframeLinewidth),c&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),f.drawElements(f.LINES,h.__webglLineCount,f.UNSIGNED_SHORT,0)):(c&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),f.drawElements(f.TRIANGLES,h.__webglFaceCount,f.UNSIGNED_SHORT,0)),M.info.render.calls++,M.info.render.vertices+=h.__webglFaceCount,M.info.render.faces+=h.__webglFaceCount/3):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?f.LINE_STRIP:f.LINES,f.lineWidth(i.linewidth),f.drawArrays(j, -0,h.__webglLineCount),M.info.render.calls++):j instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,h.__webglParticleCount),M.info.render.calls++):j instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,h.__webglVertexCount),M.info.render.calls++)}}function h(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=f.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=f.createBuffer();b.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,b.positionArray, -f.DYNAMIC_DRAW),f.enableVertexAttribArray(c.attributes.position),f.vertexAttribPointer(c.attributes.position,3,f.FLOAT,!1,0,0));if(b.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==THREE.FlatShading){var e,h,i,j,k,x,n,p,q,m,C=b.count*3;for(m=0;m=0;f--)b[f].object==c&&b.splice(f,1)}function ta(b){function c(b){var e=[];f=0;for(d=b.length;f65535&&(m[k].counter+=1,n=m[k].hash+"_"+m[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(e),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var q in b.geometryGroups)b.geometryGroups[q].id=R++,b.geometryGroupsList.push(b.geometryGroups[q])}function ha(b,c,f){b.push({buffer:c,object:f, -opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(b){if(b!=ia){switch(b){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}ia= -b}}function v(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(f.texParameteri(b,f.TEXTURE_WRAP_S,$(c.wrapS)),f.texParameteri(b,f.TEXTURE_WRAP_T,$(c.wrapT)),f.texParameteri(b,f.TEXTURE_MAG_FILTER,$(c.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,$(c.minFilter)),f.generateMipmap(b)):(f.texParameteri(b,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_MAG_FILTER,Ca(c.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,Ca(c.minFilter)))} -function T(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=f.createTexture(),M.info.memory.textures++;f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?f.texImage2D(f.TEXTURE_2D,0,$(b.format),b.image.width,b.image.height,0,$(b.format),f.UNSIGNED_BYTE,b.image.data):f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,b.image);v(f.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else f.activeTexture(f.TEXTURE0+c),f.bindTexture(f.TEXTURE_2D, -b.__webglTexture)}function L(b,c){f.bindRenderbuffer(f.RENDERBUFFER,b);c.depthBuffer&&!c.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,c.width,c.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,b)):c.depthBuffer&&c.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,c.width,c.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,b)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,c.width,c.height)} -function V(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglTexture=f.createTexture();if(c){b.__webglFramebuffer=[];b.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,b.__webglTexture);v(f.TEXTURE_CUBE_MAP,b,b);for(var d=0;d<6;d++){b.__webglFramebuffer[d]=f.createFramebuffer();b.__webglRenderbuffer[d]=f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+ -d,0,$(b.format),b.width,b.height,0,$(b.format),$(b.type),null);var e=b,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+d;f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer[d]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,e.__webglTexture,0);L(b.__webglRenderbuffer[d],b)}}else b.__webglFramebuffer=f.createFramebuffer(),b.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,b.__webglTexture),v(f.TEXTURE_2D,b,b),f.texImage2D(f.TEXTURE_2D,0,$(b.format),b.width,b.height,0,$(b.format), -$(b.type),null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,b.__webglTexture,0),f.bindRenderbuffer(f.RENDERBUFFER,b.__webglRenderbuffer),L(b.__webglRenderbuffer,b);c?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,d=b.width,b=b.height,h=e=0):(c=null, -d=va,b=Ka,e=Aa,h=Da);c!=aa&&(f.bindFramebuffer(f.FRAMEBUFFER,c),f.viewport(e,h,d,b),aa=c)}function la(b){b instanceof THREE.WebGLRenderTargetCube?(f.bindTexture(f.TEXTURE_CUBE_MAP,b.__webglTexture),f.generateMipmap(f.TEXTURE_CUBE_MAP),f.bindTexture(f.TEXTURE_CUBE_MAP,null)):(f.bindTexture(f.TEXTURE_2D,b.__webglTexture),f.generateMipmap(f.TEXTURE_2D),f.bindTexture(f.TEXTURE_2D,null))}function Z(b,c){var d;b=="fragment"?d=f.createShader(f.FRAGMENT_SHADER):b=="vertex"&&(d=f.createShader(f.VERTEX_SHADER)); -f.shaderSource(d,c);f.compileShader(d);if(!f.getShaderParameter(d,f.COMPILE_STATUS))return console.error(f.getShaderInfoLog(d)),console.error(c),null;return d}function Ca(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function $(b){switch(b){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT; +(f.lineWidth(i.wireframeLinewidth),c&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),f.drawElements(f.LINES,h.__webglLineCount,f.UNSIGNED_SHORT,0)):(c&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),f.drawElements(f.TRIANGLES,h.__webglFaceCount,f.UNSIGNED_SHORT,0)),F.info.render.calls++,F.info.render.vertices+=h.__webglFaceCount,F.info.render.faces+=h.__webglFaceCount/3):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?f.LINE_STRIP:f.LINES,f.lineWidth(i.linewidth),f.drawArrays(j, +0,h.__webglLineCount),F.info.render.calls++):j instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,h.__webglParticleCount),F.info.render.calls++):j instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,h.__webglVertexCount),F.info.render.calls++)}}function h(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=f.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=f.createBuffer();b.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,b.positionArray, +f.DYNAMIC_DRAW),f.enableVertexAttribArray(c.attributes.position),f.vertexAttribPointer(c.attributes.position,3,f.FLOAT,!1,0,0));if(b.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==THREE.FlatShading){var e,h,i,j,k,r,o,n,s,p,K=b.count*3;for(p=0;p=0;f--)b[f].object==c&&b.splice(f,1)}function ka(b){function c(b){var e=[];f=0;for(d=b.length;f65535&&(o[k].counter+=1,n=o[k].hash+"_"+o[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(e),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var s in b.geometryGroups)b.geometryGroups[s].id=za++,b.geometryGroupsList.push(b.geometryGroups[s])} +function sa(b,c,f){b.push({buffer:c,object:f,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function N(b){if(b!=Aa){switch(b){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA, +f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}Aa=b}}function Y(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(f.texParameteri(b,f.TEXTURE_WRAP_S,x(c.wrapS)),f.texParameteri(b,f.TEXTURE_WRAP_T,x(c.wrapT)),f.texParameteri(b,f.TEXTURE_MAG_FILTER,x(c.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,x(c.minFilter)),f.generateMipmap(b)):(f.texParameteri(b,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_MAG_FILTER,X(c.magFilter)), +f.texParameteri(b,f.TEXTURE_MIN_FILTER,X(c.minFilter)))}function R(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=f.createTexture(),F.info.memory.textures++;f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?f.texImage2D(f.TEXTURE_2D,0,x(b.format),b.image.width,b.image.height,0,x(b.format),f.UNSIGNED_BYTE,b.image.data):f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,b.image);Y(f.TEXTURE_2D,b,b.image);b.needsUpdate= +!1}else f.activeTexture(f.TEXTURE0+c),f.bindTexture(f.TEXTURE_2D,b.__webglTexture)}function ra(b,c){f.bindRenderbuffer(f.RENDERBUFFER,b);c.depthBuffer&&!c.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,c.width,c.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,b)):c.depthBuffer&&c.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,c.width,c.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER, +b)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,c.width,c.height)}function aa(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglTexture=f.createTexture();if(c){b.__webglFramebuffer=[];b.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,b.__webglTexture);Y(f.TEXTURE_CUBE_MAP,b,b);for(var d=0;d<6;d++){b.__webglFramebuffer[d]=f.createFramebuffer();b.__webglRenderbuffer[d]= +f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,x(b.format),b.width,b.height,0,x(b.format),x(b.type),null);var e=b,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+d;f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer[d]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,e.__webglTexture,0);ra(b.__webglRenderbuffer[d],b)}}else b.__webglFramebuffer=f.createFramebuffer(),b.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,b.__webglTexture),Y(f.TEXTURE_2D,b,b),f.texImage2D(f.TEXTURE_2D, +0,x(b.format),b.width,b.height,0,x(b.format),x(b.type),null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,b.__webglTexture,0),f.bindRenderbuffer(f.RENDERBUFFER,b.__webglRenderbuffer),ra(b.__webglRenderbuffer,b);c?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer, +d=b.width,b=b.height,h=e=0):(c=null,d=Sa,b=Ha,e=Wa,h=Xa);c!=W&&(f.bindFramebuffer(f.FRAMEBUFFER,c),f.viewport(e,h,d,b),W=c)}function la(b){b instanceof THREE.WebGLRenderTargetCube?(f.bindTexture(f.TEXTURE_CUBE_MAP,b.__webglTexture),f.generateMipmap(f.TEXTURE_CUBE_MAP),f.bindTexture(f.TEXTURE_CUBE_MAP,null)):(f.bindTexture(f.TEXTURE_2D,b.__webglTexture),f.generateMipmap(f.TEXTURE_2D),f.bindTexture(f.TEXTURE_2D,null))}function Z(b,c){var d;b=="fragment"?d=f.createShader(f.FRAGMENT_SHADER):b=="vertex"&& +(d=f.createShader(f.VERTEX_SHADER));f.shaderSource(d,c);f.compileShader(d);if(!f.getShaderParameter(d,f.COMPILE_STATUS))return console.error(f.getShaderInfoLog(d)),console.error(c),null;return d}function X(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function x(b){switch(b){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT; case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT; -case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var M=this,f,Ha=[],Za=null,aa=null,na=-1,D=null,R=0,U=null,W=null,ia=null,P=null,za=null,Ma=null,Sa=null,Ta=null,Aa=0,Da=0,va=0,Ka=0,X=[new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ea=new THREE.Matrix4,Wa=new Float32Array(16),Xa=new Float32Array(16),Ja=new THREE.Vector4,ab={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Fa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Q=b.stencil!==void 0?b.stencil:!0,fb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,gb=b.antialias!==void 0?b.antialias:!1,wa=b.clearColor!== -void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ba=b.clearAlpha!==void 0?b.clearAlpha:0,$a=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Fa;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar= -5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var sa,Va=[],b=THREE.ShaderLib.depthRGBA,db=THREE.UniformsUtils.clone(b.uniforms),Ya=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:db}),bb=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:db,morphTargets:!0});Ya._shadowPass=!0;bb._shadowPass=!0;try{if(!(f=Fa.getContext("experimental-webgl",{antialias:gb,stencil:Q, -preserveDrawingBuffer:fb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(hb){console.error(hb)}f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA, -f.ONE_MINUS_SRC_ALPHA);f.clearColor(wa.r,wa.g,wa.b,Ba);this.context=f;var eb=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,u={};u.vertices=new Float32Array(16);u.faces=new Uint16Array(6);Q=0;u.vertices[Q++]=-1;u.vertices[Q++]=-1;u.vertices[Q++]=0;u.vertices[Q++]=1;u.vertices[Q++]=1;u.vertices[Q++]=-1;u.vertices[Q++]=1;u.vertices[Q++]=1;u.vertices[Q++]=1;u.vertices[Q++]=1;u.vertices[Q++]=1;u.vertices[Q++]=0;u.vertices[Q++]=-1;u.vertices[Q++]=1;u.vertices[Q++]=0;Q=u.vertices[Q++]=0;u.faces[Q++]= -0;u.faces[Q++]=1;u.faces[Q++]=2;u.faces[Q++]=0;u.faces[Q++]=2;u.faces[Q++]=3;u.vertexBuffer=f.createBuffer();u.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,u.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,u.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,u.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,u.faces,f.STATIC_DRAW);u.program=f.createProgram();f.attachShader(u.program,Z("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(u.program,Z("vertex",THREE.ShaderLib.sprite.vertexShader)); +case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var F=this,f,S=[],O=null,W=null,J=-1,oa=null,za=0,La=null,Ja=null,Aa=null,xa=null,ya=null,$a=null,ab=null,bb=null,Wa=0,Xa=0,Sa=0,Ha=0,ta=[new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ba=new THREE.Matrix4,Ta=new Float32Array(16),Ua=new Float32Array(16),Ea=new THREE.Vector4,Za={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ca=b.canvas!==void 0?b.canvas:document.createElement("canvas"),V=b.stencil!==void 0?b.stencil:!0,gb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,hb=b.antialias!==void 0?b.antialias:!1,ca=b.clearColor!== +void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Da=b.clearAlpha!==void 0?b.clearAlpha:0,Ya=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ca;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar= +5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var U,Ka=[],b=THREE.ShaderLib.depthRGBA,eb=THREE.UniformsUtils.clone(b.uniforms),Va=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:eb}),cb=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:eb,morphTargets:!0});Va._shadowPass=!0;cb._shadowPass=!0;try{if(!(f=Ca.getContext("experimental-webgl",{antialias:hb,stencil:V, +preserveDrawingBuffer:gb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(ib){console.error(ib)}f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA, +f.ONE_MINUS_SRC_ALPHA);f.clearColor(ca.r,ca.g,ca.b,Da);this.context=f;var fb=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,u={};u.vertices=new Float32Array(16);u.faces=new Uint16Array(6);V=0;u.vertices[V++]=-1;u.vertices[V++]=-1;u.vertices[V++]=0;u.vertices[V++]=1;u.vertices[V++]=1;u.vertices[V++]=-1;u.vertices[V++]=1;u.vertices[V++]=1;u.vertices[V++]=1;u.vertices[V++]=1;u.vertices[V++]=1;u.vertices[V++]=0;u.vertices[V++]=-1;u.vertices[V++]=1;u.vertices[V++]=0;V=u.vertices[V++]=0;u.faces[V++]= +0;u.faces[V++]=1;u.faces[V++]=2;u.faces[V++]=0;u.faces[V++]=2;u.faces[V++]=3;u.vertexBuffer=f.createBuffer();u.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,u.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,u.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,u.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,u.faces,f.STATIC_DRAW);u.program=f.createProgram();f.attachShader(u.program,Z("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(u.program,Z("vertex",THREE.ShaderLib.sprite.vertexShader)); f.linkProgram(u.program);u.attributes={};u.uniforms={};u.attributes.position=f.getAttribLocation(u.program,"position");u.attributes.uv=f.getAttribLocation(u.program,"uv");u.uniforms.uvOffset=f.getUniformLocation(u.program,"uvOffset");u.uniforms.uvScale=f.getUniformLocation(u.program,"uvScale");u.uniforms.rotation=f.getUniformLocation(u.program,"rotation");u.uniforms.scale=f.getUniformLocation(u.program,"scale");u.uniforms.alignment=f.getUniformLocation(u.program,"alignment");u.uniforms.color=f.getUniformLocation(u.program, "color");u.uniforms.map=f.getUniformLocation(u.program,"map");u.uniforms.opacity=f.getUniformLocation(u.program,"opacity");u.uniforms.useScreenCoordinates=f.getUniformLocation(u.program,"useScreenCoordinates");u.uniforms.affectedByDistance=f.getUniformLocation(u.program,"affectedByDistance");u.uniforms.screenPosition=f.getUniformLocation(u.program,"screenPosition");u.uniforms.modelViewMatrix=f.getUniformLocation(u.program,"modelViewMatrix");u.uniforms.projectionMatrix=f.getUniformLocation(u.program, -"projectionMatrix");var cb=!1;this.setSize=function(b,c){Fa.width=b;Fa.height=c;this.setViewport(0,0,Fa.width,Fa.height)};this.setViewport=function(b,c,d,e){Aa=b;Da=c;va=d;Ka=e;f.viewport(Aa,Da,va,Ka)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(b,c){wa.setHex(b);Ba=c;f.clearColor(wa.r,wa.g,wa.b,Ba)};this.setClearColor=function(b,c){wa.copy(b);Ba=c;f.clearColor(wa.r,wa.g, -wa.b,Ba)};this.getClearColor=function(){return wa};this.getClearAlpha=function(){return Ba};this.clear=function(b,c,d){var e=0;if(b==void 0||b)e|=f.COLOR_BUFFER_BIT;if(c==void 0||c)e|=f.DEPTH_BUFFER_BIT;if(d==void 0||d)e|=f.STENCIL_BUFFER_BIT;f.clear(e)};this.getContext=function(){return f};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c= +"projectionMatrix");var db=!1;this.setSize=function(b,c){Ca.width=b;Ca.height=c;this.setViewport(0,0,Ca.width,Ca.height)};this.setViewport=function(b,c,d,e){Wa=b;Xa=c;Sa=d;Ha=e;f.viewport(Wa,Xa,Sa,Ha)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(b,c){ca.setHex(b);Da=c;f.clearColor(ca.r,ca.g,ca.b,Da)};this.setClearColor=function(b,c){ca.copy(b);Da=c;f.clearColor(ca.r,ca.g, +ca.b,Da)};this.getClearColor=function(){return ca};this.getClearAlpha=function(){return Da};this.clear=function(b,c,d){var e=0;if(b==void 0||b)e|=f.COLOR_BUFFER_BIT;if(c==void 0||c)e|=f.DEPTH_BUFFER_BIT;if(d==void 0||d)e|=f.STENCIL_BUFFER_BIT;f.clear(e)};this.getContext=function(){return f};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c= b.geometry.geometryGroups[g];f.deleteBuffer(c.__webglVertexBuffer);f.deleteBuffer(c.__webglNormalBuffer);f.deleteBuffer(c.__webglTangentBuffer);f.deleteBuffer(c.__webglColorBuffer);f.deleteBuffer(c.__webglUVBuffer);f.deleteBuffer(c.__webglUV2Buffer);f.deleteBuffer(c.__webglSkinVertexABuffer);f.deleteBuffer(c.__webglSkinVertexBBuffer);f.deleteBuffer(c.__webglSkinIndicesBuffer);f.deleteBuffer(c.__webglSkinWeightsBuffer);f.deleteBuffer(c.__webglFaceBuffer);f.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d= -0,e=c.numMorphTargets;d=0&&f.enableVertexAttribArray(C.position);C.color>=0&&f.enableVertexAttribArray(C.color);C.normal>=0&&f.enableVertexAttribArray(C.normal);C.tangent>=0&&f.enableVertexAttribArray(C.tangent);b.skinning&&C.skinVertexA>=0&&C.skinVertexB>=0&&C.skinIndex>=0&&C.skinWeight>=0&&(f.enableVertexAttribArray(C.skinVertexA), -f.enableVertexAttribArray(C.skinVertexB),f.enableVertexAttribArray(C.skinIndex),f.enableVertexAttribArray(C.skinWeight));if(b.attributes)for(i in b.attributes)C[i]!==void 0&&C[i]>=0&&f.enableVertexAttribArray(C[i]);if(b.morphTargets)for(i=b.numSupportedMorphTargets=0;i=0&&(f.enableVertexAttribArray(C[u]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,c,d,f){V(b); -this.clear(c,d,f)};this.render=function(b,c,m,u){var I,Ia,v,S,x,Ua,E,Qa,Ra=b.lights,C=b.fog;na=-1;this.shadowMapEnabled&&y(b,c);M.info.render.calls=0;M.info.render.vertices=0;M.info.render.faces=0;if(c.matrixAutoUpdate){for(x=c;x.parent;)x=x.parent;x.update(void 0,!0)}b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Xa);c.projectionMatrix.flattenToArray(Wa);Ea.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Ea);this.initWebGLObjects(b);V(m);(this.autoClear||u)&&this.clear(this.autoClearColor, -this.autoClearDepth,this.autoClearStencil);x=b.__webglObjects.length;for(u=0;u=0;u--)if(I=b.__webglObjects[u],I.render){E=I.object;Qa=I.buffer;v=I.opaque;i(E);for(I=0;I0||u.faceVertexUvs.length>0)j.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(n*2)}if(k.geometry.skinWeights.length&&k.geometry.skinIndices.length)j.__skinVertexAArray= -new Float32Array(n*4),j.__skinVertexBArray=new Float32Array(n*4),j.__skinIndexArray=new Float32Array(n*4),j.__skinWeightArray=new Float32Array(n*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(A*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];u=0;for(t=j.numMorphTargets;u=0;i--)e[i]==h&&e.splice(i,1)}else(d instanceof THREE.MarchingCubes||d.immediateRenderCallback)&&ja(e.__webglObjectsImmediate,d);d.__webglActive= -!1;b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,ra,v));Ca&&(f.bindBuffer(f.ARRAY_BUFFER, -m.__webglNormalBuffer),f.bufferData(f.ARRAY_BUFFER,W,v));Da&&ua.hasTangents&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglTangentBuffer),f.bufferData(f.ARRAY_BUFFER,ca,v));va&&$>0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,la,v));va&&aa>0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,na,v));Aa&&(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,ia,v),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer), -f.bufferData(f.ELEMENT_ARRAY_BUFFER,X,v));w>0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,da,v),f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,ea,v),f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,fa,v),f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ga,v));A&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray,delete m.__tangentArray, -delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;ya(j)}else if(i instanceof THREE.Ribbon){h=i.geometry;if(h.__dirtyVertices||h.__dirtyColors){i=h;j=f.DYNAMIC_DRAW;k=u=A=A=void 0;p=i.vertices;n= -i.colors;q=p.length;m=n.length;t=i.__vertexArray;v=i.__colorArray;y=i.__dirtyColors;if(i.__dirtyVertices){for(A=0;A=0&&f.enableVertexAttribArray(q.position);q.color>=0&&f.enableVertexAttribArray(q.color);q.normal>=0&&f.enableVertexAttribArray(q.normal);q.tangent>=0&&f.enableVertexAttribArray(q.tangent);b.skinning&&q.skinVertexA>=0&&q.skinVertexB>=0&&q.skinIndex>=0&&q.skinWeight>=0&&(f.enableVertexAttribArray(q.skinVertexA), +f.enableVertexAttribArray(q.skinVertexB),f.enableVertexAttribArray(q.skinIndex),f.enableVertexAttribArray(q.skinWeight));if(b.attributes)for(i in b.attributes)q[i]!==void 0&&q[i]>=0&&f.enableVertexAttribArray(q[i]);if(b.morphTargets)for(i=b.numSupportedMorphTargets=0;i=0&&(f.enableVertexAttribArray(q[u]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,c,d,f){aa(b); +this.clear(c,d,f)};this.render=function(b,c,n,u){var G,Ga,B,T,r,x,C,I,Ra=b.lights,K=b.fog;J=-1;this.shadowMapEnabled&&D(b,c);F.info.render.calls=0;F.info.render.vertices=0;F.info.render.faces=0;if(c.matrixAutoUpdate){for(r=c;r.parent;)r=r.parent;r.update(void 0,!0)}b.update(void 0,!1,c);THREE.Matrix4.makeInvert(c.matrixWorld,c.matrixWorldInverse);c.matrixWorldInverse.flattenToArray(Ua);c.projectionMatrix.flattenToArray(Ta);Ba.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Ba);this.initWebGLObjects(b); +aa(n);(this.autoClear||u)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);r=b.__webglObjects.length;for(u=0;u=0;u--)if(G=b.__webglObjects[u],G.render){C=G.object;I=G.buffer;B=G.opaque;i(C);for(G=0;G0||s.faceVertexUvs.length>0)j.__uvArray=new Float32Array(n*2);if(s.faceUvs.length>1||s.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(n*2)}if(k.geometry.skinWeights.length&& +k.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(n*4),j.__skinVertexBArray=new Float32Array(n*4),j.__skinIndexArray=new Float32Array(n*4),j.__skinWeightArray=new Float32Array(n*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(y*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];s=0;for(u=j.numMorphTargets;s=0;i--)e[i]==h&&e.splice(i,1)}else(d instanceof THREE.MarchingCubes||d.immediateRenderCallback)&& +va(e.__webglObjectsImmediate,d);d.__webglActive=!1;b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d0&&(f.bindBuffer(f.ARRAY_BUFFER,r.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER, +qa,v));Ba&&(f.bindBuffer(f.ARRAY_BUFFER,r.__webglNormalBuffer),f.bufferData(f.ARRAY_BUFFER,aa,v));Ca&&ua.hasTangents&&(f.bindBuffer(f.ARRAY_BUFFER,r.__webglTangentBuffer),f.bufferData(f.ARRAY_BUFFER,da,v));xa&&Y>0&&(f.bindBuffer(f.ARRAY_BUFFER,r.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,oa,v));xa&&Z>0&&(f.bindBuffer(f.ARRAY_BUFFER,r.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,ra,v));Aa&&(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,r.__webglFaceBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,la,v),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, +r.__webglLineBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,wa,v));w>0&&(f.bindBuffer(f.ARRAY_BUFFER,r.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,ea,v),f.bindBuffer(f.ARRAY_BUFFER,r.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,fa,v),f.bindBuffer(f.ARRAY_BUFFER,r.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,ga,v),f.bindBuffer(f.ARRAY_BUFFER,r.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ha,v));y&&(delete r.__inittedArrays,delete r.__colorArray,delete r.__normalArray, +delete r.__tangentArray,delete r.__uvArray,delete r.__uv2Array,delete r.__faceArray,delete r.__vertexArray,delete r.__lineArray,delete r.__skinVertexAArray,delete r.__skinVertexBArray,delete r.__skinIndexArray,delete r.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;B(j)}else if(i instanceof THREE.Ribbon){h=i.geometry;if(h.__dirtyVertices||h.__dirtyColors){i=h;j=f.DYNAMIC_DRAW;k=s=y=y= +void 0;o=i.vertices;n=i.colors;p=o.length;r=n.length;u=i.__vertexArray;v=i.__colorArray;x=i.__dirtyColors;if(i.__dirtyVertices){for(y=0;y - @@ -49,7 +48,7 @@ var camera, scene, renderer, particle1, particle2, particle2, light1, light2, light3, - mesh; + loader, mesh; init(); animate(); @@ -58,7 +57,8 @@ var container = document.getElementById( 'container' ); - camera = new THREE.PerspectiveCamera( 65, window.innerWidth / window.innerHeight, 1, 1000 ); + camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 ); + camera.position.y = - 6; camera.position.z = 100; scene = new THREE.Scene(); @@ -96,9 +96,14 @@ particle3.scale.x = particle3.scale.y = particle3.scale.z = 0.5; scene.add( particle3 ); - mesh = new THREE.Mesh( new WaltHead(), new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ) ); - mesh.overdraw = true; - scene.add( mesh ); + loader = new THREE.JSONLoader(); + loader.load( 'obj/WaltHeadLo.js', function ( geometry ) { + + mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ) ); + mesh.overdraw = true; + scene.add( mesh ); + + } ); renderer = new THREE.CanvasRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); @@ -119,7 +124,7 @@ var time = new Date().getTime() * 0.0005; - mesh.rotation.y -= 0.01; + if ( mesh ) mesh.rotation.y -= 0.01; particle1.position.x = Math.sin( time * 0.7 ) * 30; particle1.position.y = Math.cos( time * 0.5 ) * 40; diff --git a/examples/canvas_lights_pointlights_smooth.html b/examples/canvas_lights_pointlights_smooth.html index 5b2faefd..00459662 100644 --- a/examples/canvas_lights_pointlights_smooth.html +++ b/examples/canvas_lights_pointlights_smooth.html @@ -40,7 +40,6 @@ - @@ -49,7 +48,7 @@ var camera, scene, renderer, particle1, particle2, particle2, light1, light2, light3, - geometry, mesh; + loader, mesh; init(); animate(); @@ -58,7 +57,8 @@ var container = document.getElementById( 'container' ); - camera = new THREE.PerspectiveCamera( 65, window.innerWidth / window.innerHeight, 1, 1000 ); + camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 ); + camera.position.y = - 6; camera.position.z = 100; scene = new THREE.Scene(); @@ -96,12 +96,16 @@ particle3.scale.x = particle3.scale.y = particle3.scale.z = 0.5; scene.add( particle3 ); - geometry = new WaltHead(); - geometry.computeVertexNormals(); + loader = new THREE.JSONLoader(); + loader.load( 'obj/WaltHeadLo.js', function ( geometry ) { - mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) ); - mesh.overdraw = true; - scene.add( mesh ); + geometry.computeVertexNormals(); + + mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff } ) ); + mesh.overdraw = true; + scene.add( mesh ); + + } ); renderer = new THREE.CanvasRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); @@ -123,7 +127,7 @@ var time = new Date().getTime() * 0.0005; - mesh.rotation.y -= 0.01; + if ( mesh ) mesh.rotation.y -= 0.01; particle1.position.x = Math.sin( time * 0.7 ) * 30; particle1.position.y = Math.cos( time * 0.5 ) * 40; diff --git a/examples/canvas_materials_depth.html b/examples/canvas_materials_depth.html index 026b19e1..eae52136 100644 --- a/examples/canvas_materials_depth.html +++ b/examples/canvas_materials_depth.html @@ -26,7 +26,7 @@ var camera, scene, renderer; - var cube, plane, target = new THREE.Vector3(); + var cube, plane, objects = []; var targetRotation = 0; var targetRotationOnMouseDown = 0; @@ -37,19 +37,15 @@ var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; - var moveForward = false, - moveBackwards = false, - moveUp = false, - moveDown = false, - moveLeft = false, - moveRight = false, + var moveForward = false; + var moveBackwards = false; + var moveLeft = false; + var moveRight = false; + var moveUp = false; + var moveDown = false; - yawLeft = false, - yawRight = false, - pitchUp = false, - pitchDown = false, - rollLeft = false, - rollRight = false; + var targetMoveLeft = false; + var targetMoveRight = false; var debugContext; @@ -65,6 +61,7 @@ camera.position.x = 1000; camera.position.y = 1000; camera.position.z = 1000; + camera.target = new THREE.Vector3( 0, 150, 0 ); scene = new THREE.Scene(); @@ -86,7 +83,7 @@ geometry = new THREE.CubeGeometry( 100, 100, 100 ); material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ); - for (var i = 0; i < 20; i ++ ) { + for ( var i = 0; i < 20; i ++ ) { cube = new THREE.Mesh( geometry, material ); cube.overdraw = true; @@ -98,7 +95,9 @@ cube.rotation.y = Math.random() * 200 - 100; cube.rotation.z = Math.random() * 200 - 100; - scene.add(cube); + scene.add( cube ); + + objects.push( cube ); } @@ -146,18 +145,16 @@ function onDocumentKeyDown( event ) { - switch( event.keyCode ) { + switch ( event.keyCode ) { case 38: moveForward = true; break; // up case 40: moveBackwards = true; break; // down case 37: moveLeft = true; break; // left case 39: moveRight = true; break; // right - case 65: yawLeft = true; break; // a - case 68: yawRight = true; break; // d - case 87: moveUp/*pitchUp*/ = true; break; // w - case 83: moveDown/*pitchDown*/ = true; break; // s - case 90: rollLeft = true; break; // z - case 67: rollRight = true; break; // c + case 87: moveUp = true; break; // w + case 83: moveDown = true; break; // s + case 65: targetMoveLeft = true; break; // a + case 68: targetMoveRight = true; break; // d } @@ -165,18 +162,16 @@ function onDocumentKeyUp( event ) { - switch( event.keyCode ) { + switch ( event.keyCode ) { case 38: moveForward = false; break; // up case 40: moveBackwards = false; break; // down case 37: moveLeft = false; break; // left case 39: moveRight = false; break; // right - case 65: yawLeft = false; break; // a - case 68: yawRight = false; break; // d - case 87: moveUp/*pitchUp*/ = false; break; // w - case 83: moveDown/*pitchDown*/ = false; break; // s - case 90: rollLeft = false; break; // z - case 67: rollRight = false; break; // c + case 87: moveUp = false; break; // w + case 83: moveDown = false; break; // s + case 65: targetMoveLeft = false; break; // a + case 68: targetMoveRight = false; break; // d } @@ -195,25 +190,19 @@ function render() { - if ( moveForward ) camera.position.z -= 10; // camera.moveZ( 10 ); - if ( moveBackwards ) camera.position.z += 10; // camera.moveZ( - 10 ); + if ( moveForward ) camera.position.z -= 10; + if ( moveBackwards ) camera.position.z += 10; - if ( moveUp ) camera.position.y += 10; // camera.moveZ( 10 ); - if ( moveDown ) camera.position.y -= 10; // camera.moveZ( - 10 ); + if ( moveLeft ) camera.position.x -= 10; + if ( moveRight ) camera.position.x += 10; - if ( moveLeft ) camera.position.x -= 10; // camera.moveX( - 10 ); - if ( moveRight ) camera.position.x += 10; // camera.moveX( 10 ); + if ( moveUp ) camera.position.y += 10; + if ( moveDown ) camera.position.y -= 10; - if ( pitchUp ) camera.rotation.x += 0.01; // camera.rotateX( 1 ); - if ( pitchDown ) camera.rotation.x -= 0.01; // camera.rotateX( - 1 ); + if ( targetMoveLeft ) camera.target.x -= 10; + if ( targetMoveRight ) camera.target.x += 10; - if ( yawLeft ) target.x -= 10; // camera.rotation.y += 0.01; // camera.rotateY( 1 ); - if ( yawRight ) target.x += 10; // camera.rotation.y -= 0.01; // camera.rotateY( - 1 ); - - if ( rollLeft ) camera.rotation.z += 0.01; // camera.rotateZ( 1 ); - if ( rollRight ) camera.rotation.z -= 0.01; // camera.rotateZ( - 1 ); - - camera.lookAt( target ); + camera.lookAt( camera.target ); debugContext.clearRect( - 256, - 256, 512, 512 ); @@ -228,14 +217,14 @@ // camera debugContext.moveTo( camera.position.x * 0.1, camera.position.z * 0.1 ); - debugContext.lineTo( target.x * 0.1, target.z * 0.1 ); + debugContext.lineTo( camera.target.x * 0.1, camera.target.z * 0.1 ); debugContext.rect( camera.position.x * 0.1 - 5, camera.position.z * 0.1 - 5, 10, 10 ); - debugContext.rect( target.x * 0.1 - 5, target.z * 0.1 - 5, 10, 10 ); + debugContext.rect( camera.target.x * 0.1 - 5, camera.target.z * 0.1 - 5, 10, 10 ); debugContext.rect( - 50, - 50, 100, 100 ); - for ( var i = 1; i < scene.objects.length; i++ ) { + for ( var i = 0; i < objects.length; i++ ) { - var object = scene.objects[i]; + var object = objects[ i ]; object.rotation.x += 0.01; object.rotation.y += 0.005; diff --git a/examples/canvas_materials_normal.html b/examples/canvas_materials_normal.html index 30b8c547..d9b2e15f 100644 --- a/examples/canvas_materials_normal.html +++ b/examples/canvas_materials_normal.html @@ -39,15 +39,14 @@ Walt Disney head by David OReilly - - + - - - - - - + @@ -69,8 +69,6 @@ xr.style.position = 'absolute'; xr.style.top = '0px'; xr.style.width = '1px'; - xr.style.borderLeft = '1px solid #e0e0e0'; - // xr.style.backgroundColor = '#ffffff'; xr.style.cursor = 'col-resize'; xr.addEventListener( 'mousedown', function ( event ) { @@ -133,22 +131,6 @@ switch ( extension ) { - case 'dae': - - var parser = new DOMParser(); - var xml = parser.parseFromString( contents, 'text/xml' ); - - var loader = new THREE.ColladaLoader(); - loader.parse( xml, function ( collada ) { - - // console.log( collada ); - - signals.added.dispatch( collada.scene ); - - } ); - - break; - case 'js': var blob = new BlobBuilder(); @@ -157,7 +139,7 @@ var url = URL.createObjectURL( blob.getBlob() ); var loader = new THREE.JSONLoader(); - loader.load( { model: url, callback: function ( geometry ) { + loader.load( url, function ( geometry ) { geometry.gui = { paremeters: { @@ -174,10 +156,28 @@ signals.added.dispatch( mesh ); - } } ); + } ); break; + case 'dae': + + var parser = new DOMParser(); + var xml = parser.parseFromString( contents, 'text/xml' ); + + var loader = new THREE.ColladaLoader(); + loader.parse( xml, function ( collada ) { + + // console.log( collada ); + + signals.added.dispatch( collada.scene ); + + } ); + + break; + + + } }; @@ -201,12 +201,12 @@ function update() { - ui.setSize( window.innerWidth * xhalf, window.innerHeight ); + ui.setSize( Math.floor( window.innerWidth * xhalf ), window.innerHeight ); - code.setPosition( window.innerWidth * xhalf, 0 ); - code.setSize( window.innerWidth - ( window.innerWidth * xhalf ), window.innerHeight ); + code.setPosition( Math.floor( window.innerWidth * xhalf ), 0 ); + code.setSize( window.innerWidth - Math.floor( window.innerWidth * xhalf ), window.innerHeight ); - xr.style.left = ( window.innerWidth * xhalf ) + 'px'; + xr.style.left = Math.floor( window.innerWidth * xhalf ) + 'px'; xr.style.height = window.innerHeight + 'px'; } diff --git a/gui/js/Code.js b/gui/js/Code.js index 3d1994de..00db2979 100644 --- a/gui/js/Code.js +++ b/gui/js/Code.js @@ -28,7 +28,7 @@ var Code = function () { temp = temp.firstChild.nodeValue; temp = temp.replace("js/Three.js", "../build/Three.js"); temp = temp.replace("js/RequestAnimationFrame.js", "../examples/js/RequestAnimationFrame.js"); - aaa = temp; + console.log('test', temp); var opener = window.open('','myconsole', @@ -97,6 +97,7 @@ var Code = function () { '', '\trenderer = new THREE.WebGLRenderer()', + '\trenderer.setSize( window.innerWidth, window.innerHeight );', '\tdocument.body.appendChild( renderer.domElement );', '', '}', @@ -111,7 +112,6 @@ var Code = function () { 'function render() {', '', '\trenderer.render( scene, camera );', - '\trenderer.setSize( window.innerWidth, window.innerHeight );', '', '}' diff --git a/gui/js/UI.Viewport.js b/gui/js/UI.Viewport.js new file mode 100644 index 00000000..5cb0d53f --- /dev/null +++ b/gui/js/UI.Viewport.js @@ -0,0 +1,254 @@ +UI.Viewport = function () { + + var _width, _height; + var _isMouseDown = false; + var _snapToAxis = null; + + var _HOVERED, _SELECTED; + var _offset = new THREE.Vector3(); + + // + + var _domElement = document.createElement( 'div' ); + _domElement.style.position = 'absolute'; + _domElement.style.backgroundColor = '#808080'; + + // + + var _camera = new THREE.PerspectiveCamera( 50, 1, 1, 5000 ); + _camera.position.x = 500; + _camera.position.y = 250; + _camera.position.z = 500; + _camera.lookAt( new THREE.Vector3() ); + + var _controls = new THREE.TrackballControls( _camera ); + _controls.rotateSpeed = 1.0; + _controls.zoomSpeed = 1.2; + _controls.panSpeed = 0.8; + _controls.noZoom = false; + _controls.noPan = false; + _controls.staticMoving = true; + _controls.dynamicDampingFactor = 0.3; + + // guides + + var _sceneHelpers = new THREE.Scene(); + + var _grid = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x606060, wireframe: true, transparent: true } ) ); + _grid.rotation.x = Math.PI / 2; + _sceneHelpers.add( _grid ); + + // + + var _scene = new THREE.Scene(); + + /* + var light = new THREE.AmbientLight( 0x404040 ); + _scene.add( light ); + + var light = new THREE.DirectionalLight( 0xffffff ); + light.position.set( 1000, 1000, - 1000 ); + light.position.normalize(); + _scene.add( light ); + */ + + var _plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.25, transparent: true, wireframe: true } ) ); + _plane.visible = false; + _sceneHelpers.add( _plane ); + + var _projector = new THREE.Projector(); + + var _renderer = new THREE.WebGLRenderer(); + _renderer.autoClear = false; + _renderer.domElement.addEventListener( 'mousedown', function ( event ) { + + event.preventDefault(); + + _isMouseDown = true; + + var vector = new THREE.Vector3( ( event.clientX / _width ) * 2 - 1, - ( event.clientY / _height ) * 2 + 1, 0.5 ); + _projector.unprojectVector( vector, _camera ); + + var ray = new THREE.Ray( _camera.position, vector.subSelf( _camera.position ).normalize() ); + var intersects = ray.intersectScene( _scene ); + + if ( intersects.length ) { + + _SELECTED = intersects[ 0 ].object; + + _controls.enabled = false; + + var intersects = ray.intersectObject( _plane ); + _offset.copy( intersects[ 0 ].point ).subSelf( _plane.position ); + + } + + }, false ); + _renderer.domElement.addEventListener( 'mousemove', function ( event ) { + + event.preventDefault(); + + var vector = new THREE.Vector3( ( event.clientX / _width ) * 2 - 1, - ( event.clientY / _height ) * 2 + 1, 0.5 ); + _projector.unprojectVector( vector, _camera ); + + var ray = new THREE.Ray( _camera.position, vector.subSelf( _camera.position ).normalize() ); + var intersects = ray.intersectScene( _scene ); + + if ( _SELECTED ) { + + var intersects = ray.intersectObject( _plane ); + _SELECTED.position.copy( intersects[ 0 ].point.subSelf( _offset ) ); + + switch ( _snapToAxis ) { + + case 'x': + _SELECTED.position.y = _plane.position.y; + _SELECTED.position.z = _plane.position.z; + break; + + case 'y': + _SELECTED.position.x = _plane.position.x; + _SELECTED.position.z = _plane.position.z; + break; + + case 'z': + _SELECTED.position.x = _plane.position.x; + _SELECTED.position.y = _plane.position.y; + break; + + } + + _render(); + + signals.updated.dispatch( _scene ); + + return; + + } + + if ( intersects.length ) { + + _HOVERED = intersects[ 0 ].object; + + _plane.position.set( 0, 0, 0 ); + _plane.lookAt( _camera.position ); + _plane.position.copy( _HOVERED.position ); + + } else { + + _HOVERED = null; + + } + + _render(); + + }, false ); + _renderer.domElement.addEventListener( 'mouseup', function ( event ) { + + // event.preventDefault(); + + _isMouseDown = false; + _snapToAxis = null; + + _controls.enabled = true; + + if ( _SELECTED ) { + + _plane.position.copy( _SELECTED.position ); + _SELECTED = null; + + } + + }, false ); + /* + _renderer.domElement.addEventListener( 'mousewheel', function ( event ) { + + if ( event.wheelDeltaY ) { + + event.preventDefault(); + + var vector = _camera.position.clone(); + var amount = event.wheelDeltaY * 0.2; + + if ( vector.length() - amount < 10 ) return; + + vector.normalize().multiplyScalar( amount ); + _camera.position.subSelf( vector ); + + _render(); + + } + + }, false ); + */ + document.addEventListener( 'keydown', function ( event ) { + + if ( _isMouseDown ) { + + // console.log( event.keyCode ); + + switch ( event.keyCode ) { + + case 88: // x + _snapToAxis = 'x'; + break; + + case 89: // y + _snapToAxis = 'y'; + break; + + case 90: // z + _snapToAxis = 'z'; + break; + + } + + } + + }, false ); + _domElement.appendChild( _renderer.domElement ); + + // signals + + signals.added.add( function ( object ) { + + _scene.add( object ); + _render(); + + signals.updated.dispatch( _scene ); + + } ); + + // + + this.getDOMElement = function () { + + return _domElement; + + }; + + this.setSize = function ( width, height ) { + + _width = width; + _height = height; + + _camera.aspect = width / height; + _camera.updateProjectionMatrix(); + + _renderer.setSize( width, height ); + + _render(); + + }; + + var _render = function () { + + _controls.update(); + + _renderer.clear(); + _renderer.render( _sceneHelpers, _camera ); + _renderer.render( _scene, _camera ); + + }; + +} diff --git a/gui/js/UI.Viewports.js b/gui/js/UI.Viewports.js deleted file mode 100644 index c24b825e..00000000 --- a/gui/js/UI.Viewports.js +++ /dev/null @@ -1,432 +0,0 @@ -UI.Viewports = function () { - - var _width, _height; - var _xhalf = 0.5, _yhalf = 0.5; - - var _HOVERED, _SELECTED; - var _offset = new THREE.Vector3(); - - // - - var _domElement = document.createElement( 'div' ); - _domElement.style.position = 'absolute'; - _domElement.style.backgroundColor = '#808080'; - - // - - var _views = [ - { x: null, y: null, width: null, height: null, camera: null }, - { x: null, y: null, width: null, height: null, camera: null }, - { x: null, y: null, width: null, height: null, camera: null }, - { x: null, y: null, width: null, height: null, camera: null } - ]; - - _views[ 0 ].camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, - 2000, 2000 ); // top - _views[ 0 ].camera.position.y = 1000; - _views[ 0 ].camera.rotation.x = - Math.PI / 2; - - _views[ 1 ].camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, - 2000, 2000 ); // front - _views[ 1 ].camera.position.z = 1000; - - _views[ 2 ].camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, - 2000, 2000 ); // left - _views[ 2 ].camera.position.x = - 1000; - _views[ 2 ].camera.rotation.y = - Math.PI / 2; - - _views[ 3 ].camera = new THREE.PerspectiveCamera( 50, 1, 1, 5000 ); // perspective - _views[ 3 ].camera.position.x = 1000; - _views[ 3 ].camera.position.y = 1000; - _views[ 3 ].camera.position.z = 1000; - - // guides - - var _sceneHelpers = new THREE.Scene(); - - var _grid = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x606060, wireframe: true, transparent: true } ) ); - _grid.rotation.x = Math.PI / 2; - _sceneHelpers.add( _grid ); - - // - - var _scene = new THREE.Scene(); - - /* - var light = new THREE.AmbientLight( 0x404040 ); - _scene.add( light ); - - var light = new THREE.DirectionalLight( 0xffffff ); - light.position.set( 1000, 1000, - 1000 ); - light.position.normalize(); - _scene.add( light ); - */ - - var _plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.25, transparent: true, wireframe: true } ) ); - _plane.visible = false; - _sceneHelpers.add( _plane ); - - var _projector = new THREE.Projector(); - - var _renderer = new THREE.WebGLRenderer( /*{ antialias: true }*/ ); - _renderer.autoClear = false; - _renderer.domElement.addEventListener( 'mousedown', function ( event ) { - - event.preventDefault(); - - var mouse = getViewportMouse( event.clientX, event.clientY ); - - var camera = _views[ mouse.view ].camera; - var vector = new THREE.Vector3( mouse.x * 2 - 1, - mouse.y * 2 + 1, 0.5 ); - _projector.unprojectVector( vector, camera ); - - var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() ); - var intersects = ray.intersectScene( _scene ); - - if ( intersects.length ) { - - _SELECTED = intersects[ 0 ].object; - - var intersects = ray.intersectObject( _plane ); - _offset.copy( intersects[ 0 ].point ).subSelf( _plane.position ); - - } - - }, false ); - _renderer.domElement.addEventListener( 'mousemove', function ( event ) { - - event.preventDefault(); - - var mouse = getViewportMouse( event.clientX, event.clientY ); - - var camera = _views[ mouse.view ].camera; - var vector = new THREE.Vector3( mouse.x * 2 - 1, - mouse.y * 2 + 1, 0.5 ); - _projector.unprojectVector( vector, camera ); - - var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() ); - var intersects = ray.intersectScene( _scene ); - - if ( _SELECTED ) { - - var intersects = ray.intersectObject( _plane ); - _SELECTED.position.copy( intersects[ 0 ].point.subSelf( _offset ) ); - - _render(); - - signals.updated.dispatch( _scene ); - - return; - - } - - if ( intersects.length ) { - - _HOVERED = intersects[ 0 ].object; - - _plane.position.set( 0, 0, 0 ); - _plane.lookAt( camera.position ); - _plane.position.copy( _HOVERED.position ); - - _render(); - - } else { - - _HOVERED = null; - - } - - }, false ); - _renderer.domElement.addEventListener( 'mouseup', function ( event ) { - - event.preventDefault(); - - if ( _SELECTED ) { - - _plane.position.copy( _SELECTED.position ); - _SELECTED = null; - - } - - }, false ); - _renderer.domElement.addEventListener( 'mousewheel', function ( event ) { - - if ( event.wheelDeltaY ) { - - event.preventDefault(); - - var mouse = getViewportMouse( event.clientX, event.clientY ); - var camera = _views[ mouse.view ].camera; - var vector = camera.position.clone(); - var amount = event.wheelDeltaY * 0.2; - - if ( vector.length() - amount < 10 ) return; - - vector.normalize().multiplyScalar( amount ); - camera.position.subSelf( vector ); - - _render(); - - } - - }, false ); - _domElement.appendChild( _renderer.domElement ); - - // - - var _xr = document.createElement( 'div' ); - _xr.style.position = 'absolute'; - _xr.style.top = '0px'; - _xr.style.width = '1px'; - _xr.style.borderLeft = '1px solid #808080'; - _xr.style.borderRight = '1px solid #808080'; - _xr.style.backgroundColor = '#404040'; - _xr.style.cursor = 'col-resize'; - _xr.addEventListener( 'mousedown', function ( event ) { - - event.preventDefault(); - - document.body.style.cursor = 'col-resize'; - document.addEventListener( 'mousemove', onMouseMove, false ); - document.addEventListener( 'mouseup', onMouseUp, false ); - - function onMouseMove( event ) { - - event.preventDefault(); - - _xhalf = Math.max( 0, Math.min( 1, event.clientX / _width ) ); - - _updateViews(); - _updateCameras(); - _render(); - - } - - function onMouseUp( event ) { - - document.body.style.cursor = 'auto'; - document.removeEventListener( 'mousemove', onMouseMove, false ); - document.removeEventListener( 'mouseup', onMouseUp, false ); - - } - - }, false ); - _xr.addEventListener( 'dblclick', function ( event ) { - - _xhalf = 0.5; - - _updateViews(); - _updateCameras(); - _render(); - - }, false ); - _domElement.appendChild( _xr ); - - var _yr = document.createElement( 'div' ); - _yr.style.position = 'absolute'; - _yr.style.height = '1px'; - _yr.style.borderTop = '1px solid #808080'; - _yr.style.borderBottom = '1px solid #808080'; - _yr.style.backgroundColor = '#404040'; - _yr.style.cursor = 'row-resize'; - _yr.addEventListener( 'mousedown', function ( event ) { - - event.preventDefault(); - - document.body.style.cursor = 'row-resize'; - document.addEventListener( 'mousemove', onMouseMove, false ); - document.addEventListener( 'mouseup', onMouseUp, false ); - - function onMouseMove( event ) { - - event.preventDefault(); - - _yhalf = Math.max( 0, Math.min( 1, event.clientY / _height ) ); - - _updateViews(); - _updateCameras(); - _render(); - - } - - function onMouseUp( event ) { - - document.body.style.cursor = 'auto'; - document.removeEventListener( 'mousemove', onMouseMove, false ); - document.removeEventListener( 'mouseup', onMouseUp, false ); - - } - - }, false ); - _yr.addEventListener( 'dblclick', function ( event ) { - - _yhalf = 0.5; - - _updateViews(); - _updateCameras(); - _render(); - - }, false ); - _domElement.appendChild( _yr ); - - function getViewportMouse( x, y ) { - - var width = _views[ 0 ].width; - var height = _views[ 0 ].height; - - if ( x < width && y < height ) { - - return { - - view: 0, - x: x / _views[ 0 ].width, - y: y / _views[ 0 ].height - - }; - - } else if ( x > width && y < height ) { - - return { - - view: 1, - x: ( x - _views[ 1 ].x ) / _views[ 1 ].width, - y: y / _views[ 1 ].height - - }; - - } else if ( x < width && y > height ) { - - return { - - view: 2, - x: x / _views[ 2 ].width, - y: ( y - _views[ 2 ].y ) / _views[ 2 ].height - - }; - - } else if ( x > width && y > height ) { - - return { - - view: 3, - x: ( x - _views[ 3 ].x ) / _views[ 3 ].width, - y: ( y - _views[ 3 ].y ) / _views[ 3 ].height - - }; - - } - - } - - // signals - - signals.added.add( function ( object ) { - - _scene.add( object ); - _render(); - - signals.updated.dispatch( _scene ); - - } ); - - // - - this.getDOMElement = function () { - - return _domElement; - - }; - - this.setSize = function ( width, height ) { - - _width = width; - _height = height; - - _updateViews(); - _updateCameras(); - - _renderer.setSize( _width, _height ); - - _render(); - - }; - - var _updateViews = function () { - - _views[ 0 ].x = 0; - _views[ 0 ].y = 0; - _views[ 0 ].width = _width * _xhalf; - _views[ 0 ].height = _height * _yhalf; - - _views[ 1 ].x = _width * _xhalf; - _views[ 1 ].y = 0; - _views[ 1 ].width = _width - _width * _xhalf; - _views[ 1 ].height = _height * _yhalf; - - _views[ 2 ].x = 0; - _views[ 2 ].y = _height * _yhalf; - _views[ 2 ].width = _width * _xhalf; - _views[ 2 ].height = _height - _height * _yhalf; - - _views[ 3 ].x = _width * _xhalf; - _views[ 3 ].y = _height * _yhalf; - _views[ 3 ].width = _width - _width * _xhalf; - _views[ 3 ].height = _height - _height * _yhalf; - - }; - - var _updateCameras = function () { - - _views[ 0 ].camera.left = _views[ 0 ].width / - 2; - _views[ 0 ].camera.right = _views[ 0 ].width / 2; - _views[ 0 ].camera.top = _views[ 0 ].height / 2; - _views[ 0 ].camera.bottom = _views[ 0 ].height / - 2; - _views[ 0 ].camera.updateProjectionMatrix(); - - _views[ 1 ].camera.left = _views[ 1 ].width / - 2; - _views[ 1 ].camera.right = _views[ 1 ].width / 2; - _views[ 1 ].camera.top = _views[ 1 ].height / 2; - _views[ 1 ].camera.bottom = _views[ 1 ].height / - 2; - _views[ 1 ].camera.updateProjectionMatrix(); - - _views[ 2 ].camera.left = _views[ 2 ].width / - 2; - _views[ 2 ].camera.right = _views[ 2 ].width / 2; - _views[ 2 ].camera.top = _views[ 2 ].height / 2; - _views[ 2 ].camera.bottom = _views[ 2 ].height / - 2; - _views[ 2 ].camera.updateProjectionMatrix(); - - _views[ 3 ].camera.aspect = _views[ 3 ].width / _views[ 3 ].height; - _views[ 3 ].camera.updateProjectionMatrix(); - - - }; - - var _render = function () { - - _xr.style.left = ( _width * _xhalf ) + 'px'; - _xr.style.height = _height + 'px'; - - _yr.style.top = ( _height * _yhalf ) + 'px'; - _yr.style.width = _width + 'px'; - - // - - _views[ 3 ].camera.lookAt( _scene.position ); - - _renderer.clear(); - - _renderer.setViewport( 0, _height - _height * _yhalf, _views[ 0 ].width, _views[ 0 ].height ); - _renderer.render( _sceneHelpers, _views[ 0 ].camera ); - _renderer.render( _scene, _views[ 0 ].camera ); - - _renderer.setViewport( _width * _xhalf, _height - _height * _yhalf, _views[ 1 ].width, _views[ 1 ].height ); - _renderer.render( _sceneHelpers, _views[ 1 ].camera ); - _renderer.render( _scene, _views[ 1 ].camera ); - - _renderer.setViewport( 0, 0, _views[ 2 ].width, _views[ 2 ].height ); - _renderer.render( _sceneHelpers, _views[ 2 ].camera ); - _renderer.render( _scene, _views[ 2 ].camera ); - - _renderer.setViewport( _width * _xhalf, 0, _views[ 3 ].width, _views[ 3 ].height ); - _renderer.render( _sceneHelpers, _views[ 3 ].camera ); - _renderer.render( _scene, _views[ 3 ].camera ); - - }; - -} diff --git a/gui/js/UI.js b/gui/js/UI.js index 270a6989..69f63b5d 100644 --- a/gui/js/UI.js +++ b/gui/js/UI.js @@ -3,8 +3,8 @@ var UI = function () { var _domElement = document.createElement( 'div' ); _domElement.style.position = 'absolute'; - var _viewports = new UI.Viewports(); - _domElement.appendChild( _viewports.getDOMElement() ); + var _viewport = new UI.Viewport(); + _domElement.appendChild( _viewport.getDOMElement() ); var _toolbar = new UI.Toolbar(); _domElement.appendChild( _toolbar.getDOMElement() ); @@ -20,7 +20,7 @@ var UI = function () { _domElement.style.width = width + 'px'; _domElement.style.height = height + 'px'; - _viewports.setSize( width, height - 50 ); + _viewport.setSize( width, height - 50 ); _toolbar.setPosition( 0, height - 50 ); _toolbar.setSize( width, 50 ); diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js index 16ec310a..057b97f8 100644 --- a/src/cameras/Camera.js +++ b/src/cameras/Camera.js @@ -15,7 +15,10 @@ THREE.Camera = function () { THREE.Object3D.call( this ); this.matrixWorldInverse = new THREE.Matrix4(); + this.projectionMatrix = new THREE.Matrix4(); + this.projectionMatrixInverse = new THREE.Matrix4(); + }; @@ -34,38 +37,4 @@ THREE.Camera.prototype.lookAt = function ( vector ) { } -} - -THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camera ) { - - this.matrixAutoUpdate && this.updateMatrix(); - - if ( forceUpdate || this.matrixWorldNeedsUpdate ) { - - if ( parentMatrixWorld ) { - - this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); - - } else { - - this.matrixWorld.copy( this.matrix ); - - } - - this.matrixWorldNeedsUpdate = false; - forceUpdate = true; - - THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse ); - - } - - - // update children - - for ( var i = 0; i < this.children.length; i ++ ) { - - this.children[ i ].update( this.matrixWorld, forceUpdate, camera ); - - } - }; diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index fe2b6584..25bb0dc2 100644 --- a/src/core/Matrix4.js +++ b/src/core/Matrix4.js @@ -102,6 +102,72 @@ THREE.Matrix4.prototype = { }, + multiply: function ( a, b ) { + + var a11 = a.n11, a12 = a.n12, a13 = a.n13, a14 = a.n14, + a21 = a.n21, a22 = a.n22, a23 = a.n23, a24 = a.n24, + a31 = a.n31, a32 = a.n32, a33 = a.n33, a34 = a.n34, + a41 = a.n41, a42 = a.n42, a43 = a.n43, a44 = a.n44, + + b11 = b.n11, b12 = b.n12, b13 = b.n13, b14 = b.n14, + b21 = b.n21, b22 = b.n22, b23 = b.n23, b24 = b.n24, + b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34, + b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44; + + this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; + this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; + this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; + this.n14 = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; + + this.n21 = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; + this.n22 = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; + this.n23 = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; + this.n24 = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; + + this.n31 = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; + this.n32 = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; + this.n33 = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; + this.n34 = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; + + this.n41 = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; + this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; + this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; + this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; + + return this; + + }, + + multiplySelf: function ( m ) { + + return this.multiply( this, m ); + + }, + + multiplyToArray: function ( a, b, r ) { + + this.multiply( a, b ); + + r[ 0 ] = this.n11; r[ 1 ] = this.n21; r[ 2 ] = this.n31; r[ 3 ] = this.n41; + r[ 4 ] = this.n12; r[ 5 ] = this.n22; r[ 6 ] = this.n32; r[ 7 ] = this.n42; + r[ 8 ] = this.n13; r[ 9 ] = this.n23; r[ 10 ] = this.n33; r[ 11 ] = this.n43; + r[ 12 ] = this.n14; r[ 13 ] = this.n24; r[ 14 ] = this.n34; r[ 15 ] = this.n44; + + return this; + + }, + + multiplyScalar: function ( s ) { + + this.n11 *= s; this.n12 *= s; this.n13 *= s; this.n14 *= s; + this.n21 *= s; this.n22 *= s; this.n23 *= s; this.n24 *= s; + this.n31 *= s; this.n32 *= s; this.n33 *= s; this.n34 *= s; + this.n41 *= s; this.n42 *= s; this.n43 *= s; this.n44 *= s; + + return this; + + }, + multiplyVector3: function ( v ) { var vx = v.x, vy = v.y, vz = v.z, @@ -156,74 +222,6 @@ THREE.Matrix4.prototype = { }, - multiply: function ( a, b ) { - - var a11 = a.n11, a12 = a.n12, a13 = a.n13, a14 = a.n14, - a21 = a.n21, a22 = a.n22, a23 = a.n23, a24 = a.n24, - a31 = a.n31, a32 = a.n32, a33 = a.n33, a34 = a.n34, - a41 = a.n41, a42 = a.n42, a43 = a.n43, a44 = a.n44, - - b11 = b.n11, b12 = b.n12, b13 = b.n13, b14 = b.n14, - b21 = b.n21, b22 = b.n22, b23 = b.n23, b24 = b.n24, - b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34, - b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44; - - this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; - this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; - this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; - this.n14 = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; - - this.n21 = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; - this.n22 = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; - this.n23 = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; - this.n24 = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; - - this.n31 = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; - this.n32 = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; - this.n33 = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; - this.n34 = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; - - this.n41 = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; - this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; - this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; - this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; - - return this; - - }, - - multiplyToArray: function ( a, b, r ) { - - this.multiply( a, b ); - - r[ 0 ] = this.n11; r[ 1 ] = this.n21; r[ 2 ] = this.n31; r[ 3 ] = this.n41; - r[ 4 ] = this.n12; r[ 5 ] = this.n22; r[ 6 ] = this.n32; r[ 7 ] = this.n42; - r[ 8 ] = this.n13; r[ 9 ] = this.n23; r[ 10 ] = this.n33; r[ 11 ] = this.n43; - r[ 12 ] = this.n14; r[ 13 ] = this.n24; r[ 14 ] = this.n34; r[ 15 ] = this.n44; - - return this; - - }, - - multiplySelf: function ( m ) { - - this.multiply( this, m ); - - return this; - - }, - - multiplyScalar: function ( s ) { - - this.n11 *= s; this.n12 *= s; this.n13 *= s; this.n14 *= s; - this.n21 *= s; this.n22 *= s; this.n23 *= s; this.n24 *= s; - this.n31 *= s; this.n32 *= s; this.n33 *= s; this.n34 *= s; - this.n41 *= s; this.n42 *= s; this.n43 *= s; this.n44 *= s; - - return this; - - }, - determinant: function () { var n11 = this.n11, n12 = this.n12, n13 = this.n13, n14 = this.n14, @@ -448,7 +446,7 @@ THREE.Matrix4.prototype = { }, - setPosition: function( v ) { + setPosition: function ( v ) { this.n14 = v.x; this.n24 = v.y; @@ -458,58 +456,58 @@ THREE.Matrix4.prototype = { }, - getPosition: function() { + getPosition: function () { - if ( ! this.position ) { - - this.position = new THREE.Vector3(); - - } - - this.position.set( this.n14, this.n24, this.n34 ); - - return this.position; + return THREE.Matrix4.__v1.set( this.n14, this.n24, this.n34 ); }, - getColumnX: function() { + getColumnX: function () { - if ( ! this.columnX ) { + return THREE.Matrix4.__v1.set( this.n11, this.n21, this.n31 ); - this.columnX = new THREE.Vector3(); - - } - - this.columnX.set( this.n11, this.n21, this.n31 ); - - return this.columnX; }, - getColumnY: function() { + getColumnY: function () { - if ( ! this.columnY ) { - - this.columnY = new THREE.Vector3(); - - } - - this.columnY.set( this.n12, this.n22, this.n32 ); - - return this.columnY; + return THREE.Matrix4.__v1.set( this.n12, this.n22, this.n32 ); }, getColumnZ: function() { - if ( ! this.columnZ ) { + return THREE.Matrix4.__v1.set( this.n13, this.n23, this.n33 ); - this.columnZ = new THREE.Vector3(); + }, - } + getInverse: function ( m ) { - this.columnZ.set( this.n13, this.n23, this.n33 ); + // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm - return this.columnZ; + var n11 = m.n11, n12 = m.n12, n13 = m.n13, n14 = m.n14, + n21 = m.n21, n22 = m.n22, n23 = m.n23, n24 = m.n24, + n31 = m.n31, n32 = m.n32, n33 = m.n33, n34 = m.n34, + n41 = m.n41, n42 = m.n42, n43 = m.n43, n44 = m.n44; + + this.n11 = n23*n34*n42 - n24*n33*n42 + n24*n32*n43 - n22*n34*n43 - n23*n32*n44 + n22*n33*n44; + this.n12 = n14*n33*n42 - n13*n34*n42 - n14*n32*n43 + n12*n34*n43 + n13*n32*n44 - n12*n33*n44; + this.n13 = n13*n24*n42 - n14*n23*n42 + n14*n22*n43 - n12*n24*n43 - n13*n22*n44 + n12*n23*n44; + this.n14 = n14*n23*n32 - n13*n24*n32 - n14*n22*n33 + n12*n24*n33 + n13*n22*n34 - n12*n23*n34; + this.n21 = n24*n33*n41 - n23*n34*n41 - n24*n31*n43 + n21*n34*n43 + n23*n31*n44 - n21*n33*n44; + this.n22 = n13*n34*n41 - n14*n33*n41 + n14*n31*n43 - n11*n34*n43 - n13*n31*n44 + n11*n33*n44; + this.n23 = n14*n23*n41 - n13*n24*n41 - n14*n21*n43 + n11*n24*n43 + n13*n21*n44 - n11*n23*n44; + this.n24 = n13*n24*n31 - n14*n23*n31 + n14*n21*n33 - n11*n24*n33 - n13*n21*n34 + n11*n23*n34; + this.n31 = n22*n34*n41 - n24*n32*n41 + n24*n31*n42 - n21*n34*n42 - n22*n31*n44 + n21*n32*n44; + this.n32 = n14*n32*n41 - n12*n34*n41 - n14*n31*n42 + n11*n34*n42 + n12*n31*n44 - n11*n32*n44; + this.n33 = n13*n24*n41 - n14*n22*n41 + n14*n21*n42 - n11*n24*n42 - n12*n21*n44 + n11*n22*n44; + this.n34 = n14*n22*n31 - n12*n24*n31 - n14*n21*n32 + n11*n24*n32 + n12*n21*n34 - n11*n22*n34; + this.n41 = n23*n32*n41 - n22*n33*n41 - n23*n31*n42 + n21*n33*n42 + n22*n31*n43 - n21*n32*n43; + this.n42 = n12*n33*n41 - n13*n32*n41 + n13*n31*n42 - n11*n33*n42 - n12*n31*n43 + n11*n32*n43; + this.n43 = n13*n22*n41 - n12*n23*n41 - n13*n21*n42 + n11*n23*n42 + n12*n21*n43 - n11*n22*n43; + this.n44 = n12*n23*n31 - n13*n22*n31 + n13*n21*n32 - n11*n23*n32 - n12*n21*n33 + n11*n22*n33; + this.multiplyScalar( 1 / m.determinant() ); + + return this; }, @@ -742,61 +740,36 @@ THREE.Matrix4.prototype = { this.n24 = m.n24; this.n34 = m.n34; + return this; + }, - extractRotation: function ( m, s ) { + extractRotation: function ( m ) { - var invScaleX = 1 / s.x, invScaleY = 1 / s.y, invScaleZ = 1 / s.z; + var vector = THREE.Matrix4.__v1; - this.n11 = m.n11 * invScaleX; - this.n21 = m.n21 * invScaleX; - this.n31 = m.n31 * invScaleX; + var scaleX = 1 / vector.set( m.n11, m.n21, m.n31 ).length(); + var scaleY = 1 / vector.set( m.n12, m.n22, m.n32 ).length(); + var scaleZ = 1 / vector.set( m.n13, m.n23, m.n33 ).length(); - this.n12 = m.n12 * invScaleY; - this.n22 = m.n22 * invScaleY; - this.n32 = m.n32 * invScaleY; + this.n11 = m.n11 * scaleX; + this.n21 = m.n21 * scaleX; + this.n31 = m.n31 * scaleX; - this.n13 = m.n13 * invScaleZ; - this.n23 = m.n23 * invScaleZ; - this.n33 = m.n33 * invScaleZ; + this.n12 = m.n12 * scaleY; + this.n22 = m.n22 * scaleY; + this.n32 = m.n32 * scaleY; + + this.n13 = m.n13 * scaleZ; + this.n23 = m.n23 * scaleZ; + this.n33 = m.n33 * scaleZ; + + return this; } }; -THREE.Matrix4.makeInvert = function ( m1, m2 ) { - - // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm - - var n11 = m1.n11, n12 = m1.n12, n13 = m1.n13, n14 = m1.n14, - n21 = m1.n21, n22 = m1.n22, n23 = m1.n23, n24 = m1.n24, - n31 = m1.n31, n32 = m1.n32, n33 = m1.n33, n34 = m1.n34, - n41 = m1.n41, n42 = m1.n42, n43 = m1.n43, n44 = m1.n44; - - if ( m2 === undefined ) m2 = new THREE.Matrix4(); - - m2.n11 = n23*n34*n42 - n24*n33*n42 + n24*n32*n43 - n22*n34*n43 - n23*n32*n44 + n22*n33*n44; - m2.n12 = n14*n33*n42 - n13*n34*n42 - n14*n32*n43 + n12*n34*n43 + n13*n32*n44 - n12*n33*n44; - m2.n13 = n13*n24*n42 - n14*n23*n42 + n14*n22*n43 - n12*n24*n43 - n13*n22*n44 + n12*n23*n44; - m2.n14 = n14*n23*n32 - n13*n24*n32 - n14*n22*n33 + n12*n24*n33 + n13*n22*n34 - n12*n23*n34; - m2.n21 = n24*n33*n41 - n23*n34*n41 - n24*n31*n43 + n21*n34*n43 + n23*n31*n44 - n21*n33*n44; - m2.n22 = n13*n34*n41 - n14*n33*n41 + n14*n31*n43 - n11*n34*n43 - n13*n31*n44 + n11*n33*n44; - m2.n23 = n14*n23*n41 - n13*n24*n41 - n14*n21*n43 + n11*n24*n43 + n13*n21*n44 - n11*n23*n44; - m2.n24 = n13*n24*n31 - n14*n23*n31 + n14*n21*n33 - n11*n24*n33 - n13*n21*n34 + n11*n23*n34; - m2.n31 = n22*n34*n41 - n24*n32*n41 + n24*n31*n42 - n21*n34*n42 - n22*n31*n44 + n21*n32*n44; - m2.n32 = n14*n32*n41 - n12*n34*n41 - n14*n31*n42 + n11*n34*n42 + n12*n31*n44 - n11*n32*n44; - m2.n33 = n13*n24*n41 - n14*n22*n41 + n14*n21*n42 - n11*n24*n42 - n12*n21*n44 + n11*n22*n44; - m2.n34 = n14*n22*n31 - n12*n24*n31 - n14*n21*n32 + n11*n24*n32 + n12*n21*n34 - n11*n22*n34; - m2.n41 = n23*n32*n41 - n22*n33*n41 - n23*n31*n42 + n21*n33*n42 + n22*n31*n43 - n21*n32*n43; - m2.n42 = n12*n33*n41 - n13*n32*n41 + n13*n31*n42 - n11*n33*n42 - n12*n31*n43 + n11*n32*n43; - m2.n43 = n13*n22*n41 - n12*n23*n41 - n13*n21*n42 + n11*n23*n42 + n12*n21*n43 - n11*n22*n43; - m2.n44 = n12*n23*n31 - n13*n22*n31 + n13*n21*n32 - n11*n23*n32 - n12*n21*n33 + n11*n22*n33; - m2.multiplyScalar( 1 / m1.determinant() ); - - return m2; - -}; - THREE.Matrix4.makeInvert3x3 = function ( m1 ) { // input: THREE.Matrix4, output: THREE.Matrix3 diff --git a/src/core/Object3D.js b/src/core/Object3D.js index b812ec86..976e490c 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -4,7 +4,7 @@ * @author alteredq / http://alteredqualia.com/ */ -THREE.Object3D = function() { +THREE.Object3D = function () { this.name = ''; @@ -101,7 +101,7 @@ THREE.Object3D.prototype = { if ( this.children.indexOf( object ) === - 1 ) { - if( object.parent !== undefined ) { + if ( object.parent !== undefined ) { object.parent.remove( object ); @@ -110,50 +110,18 @@ THREE.Object3D.prototype = { object.parent = this; this.children.push( object ); - // add to scene - - var scene = this; - - while ( scene.parent !== undefined ) { - - scene = scene.parent; - - } - - if ( scene !== undefined && scene instanceof THREE.Scene ) { - - scene.addChildRecurse( object ); - - } - } }, remove: function ( object ) { - var scene = this; + var index = this.children.indexOf( object ); - var childIndex = this.children.indexOf( object ); - - if ( childIndex !== - 1 ) { + if ( index !== - 1 ) { object.parent = undefined; - this.children.splice( childIndex, 1 ); - - // remove from scene - - while ( scene.parent !== undefined ) { - - scene = scene.parent; - - } - - if ( scene !== undefined && scene instanceof THREE.Scene ) { - - scene.removeChildRecurse( object ); - - } + this.children.splice( index, 1 ); } @@ -216,17 +184,17 @@ THREE.Object3D.prototype = { }, - update: function ( parentMatrixWorld, forceUpdate, camera ) { + updateMatrixWorld: function ( force ) { this.matrixAutoUpdate && this.updateMatrix(); // update matrixWorld - if ( this.matrixWorldNeedsUpdate || forceUpdate ) { + if ( this.matrixWorldNeedsUpdate || force ) { - if ( parentMatrixWorld ) { + if ( this.parent ) { - this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); + this.matrixWorld.multiply( this.parent.matrixWorld, this.matrix ); } else { @@ -234,11 +202,9 @@ THREE.Object3D.prototype = { } - this.matrixRotationWorld.extractRotation( this.matrixWorld, this.scale ); - this.matrixWorldNeedsUpdate = false; - forceUpdate = true; + force = true; } @@ -246,26 +212,10 @@ THREE.Object3D.prototype = { for ( var i = 0, l = this.children.length; i < l; i ++ ) { - this.children[ i ].update( this.matrixWorld, forceUpdate, camera ); + this.children[ i ].updateMatrixWorld( force ); } - }, - - // DEPRECATED - - addChild: function ( child ) { - - console.warn( 'DEPRECATED: Object3D.addChild() is now Object3D.add().' ); - this.add( child ); - - }, - - removeChild: function ( child ) { - - console.warn( 'DEPRECATED: Object3D.removeChild() is now Object3D.remove().' ); - this.remove( child ); - } }; diff --git a/src/core/Projector.js b/src/core/Projector.js index 84cef916..ed9d8ac6 100644 --- a/src/core/Projector.js +++ b/src/core/Projector.js @@ -6,16 +6,16 @@ THREE.Projector = function() { - var _object, _objectCount, _objectPool = [], - _vertex, _vertexCount, _vertexPool = [], + var _vertex, _vertexCount, _vertexPool = [], _face, _face3Count, _face3Pool = [], _face4Count, _face4Pool = [], _line, _lineCount, _linePool = [], _particle, _particleCount, _particlePool = [], - _objectList = [], _renderList = [], + _renderData = { objects: [], lights: [], elements: [] }, - _vector3 = new THREE.Vector4(), + _vector3 = new THREE.Vector3(), _vector4 = new THREE.Vector4(), + _projScreenMatrix = new THREE.Matrix4(), _projScreenObjectMatrix = new THREE.Matrix4(), @@ -36,20 +36,24 @@ THREE.Projector = function() { this.projectVector = function ( vector, camera ) { + camera.matrixWorldInverse.getInverse( camera.matrixWorld ); + _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); _projScreenMatrix.multiplyVector3( vector ); return vector; - + }; this.unprojectVector = function ( vector, camera ) { - _projScreenMatrix.multiply( camera.matrixWorld, THREE.Matrix4.makeInvert( camera.projectionMatrix ) ); + camera.projectionMatrixInverse.getInverse( camera.projectionMatrix ); + + _projScreenMatrix.multiply( camera.matrixWorld, camera.projectionMatrixInverse ); _projScreenMatrix.multiplyVector3( vector ); return vector; - + }; /** @@ -73,77 +77,81 @@ THREE.Projector = function() { end.subSelf( vector ).normalize(); return new THREE.Ray( vector, end ); - - }; - - this.projectObjects = function ( scene, camera, sort ) { - - var o, ol, objects, object, matrix; - - _objectList.length = 0; - _objectCount = 0; - - objects = scene.objects; - - for ( o = 0, ol = objects.length; o < ol; o ++ ) { - - object = objects[ o ]; - - if ( !object.visible || ( object instanceof THREE.Mesh && ( object.frustumCulled && !isInFrustum( object ) ) ) ) continue; - - _object = getNextObjectInPool(); - - _vector3.copy( object.position ); - _projScreenMatrix.multiplyVector3( _vector3 ); - - _object.object = object; - _object.z = _vector3.z; - - _objectList.push( _object ); - - } - - sort && _objectList.sort( painterSort ); - - return _objectList; }; - // TODO: Rename to projectElements? + this.projectGraph = function ( object ) { + + _renderData.objects.length = 0; + _renderData.lights.length = 0; + + var projectObject = function ( object ) { + + if ( object.visible == false ) return; + + if ( object instanceof THREE.Particle || object instanceof THREE.Line || + ( object instanceof THREE.Mesh && ( !object.frustumCulled || isInFrustum( object ) ) ) ) { + + _renderData.objects.push( object ); + + } else if ( object instanceof THREE.Light ) { + + _renderData.lights.push( object ); + + } + + for ( var c = 0, cl = object.children.length; c < cl; c ++ ) { + + projectObject( object.children[ c ] ); + + } + + }; + + projectObject( object ); + + return _renderData; + + }; this.projectScene = function ( scene, camera, sort ) { var near = camera.near, far = camera.far, - o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, objects, object, + o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, object, objectMatrix, objectMatrixRotation, objectMaterials, objectOverdraw, geometry, vertices, vertex, vertexPositionScreen, faces, face, faceVertexNormals, normal, faceVertexUvs, uvs, v1, v2, v3, v4; - _renderList.length = 0; - _face3Count = 0; _face4Count = 0; _lineCount = 0; _particleCount = 0; - camera.matrixAutoUpdate && camera.update( undefined, true ); + _renderData.elements.length = 0; - scene.update( undefined, false, camera ); + if ( camera.parent == null ) { + + console.warn( "Camera is not on the Scene. Adding it..." ); + scene.add( camera ); + + } + + scene.updateMatrixWorld(); + + camera.matrixWorldInverse.getInverse( camera.matrixWorld ); _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); + computeFrustum( _projScreenMatrix ); - objects = this.projectObjects( scene, camera, true ); + _renderData = this.projectGraph( scene ); - for ( o = 0, ol = objects.length; o < ol; o++ ) { + for ( o = 0, ol = _renderData.objects.length; o < ol; o++ ) { - object = objects[ o ].object; - - if ( !object.visible ) continue; + object = _renderData.objects[ o ]; objectMatrix = object.matrixWorld; - objectMatrixRotation = object.matrixRotationWorld; objectMaterials = object.materials; objectOverdraw = object.overdraw; @@ -157,6 +165,8 @@ THREE.Projector = function() { faces = geometry.faces; faceVertexUvs = geometry.faceVertexUvs; + objectMatrixRotation = object.matrixRotationWorld.extractRotation( object.matrixWorld ); + for ( v = 0, vl = vertices.length; v < vl; v ++ ) { _vertex = getNextVertexInPool(); @@ -269,7 +279,7 @@ THREE.Projector = function() { _face.z = _face.centroidScreen.z; - _renderList.push( _face ); + _renderData.elements.push( _face ); } @@ -308,7 +318,7 @@ THREE.Projector = function() { _line.materials = object.materials; - _renderList.push( _line ); + _renderData.elements.push( _line ); } } @@ -334,7 +344,7 @@ THREE.Projector = function() { _particle.materials = object.materials; - _renderList.push( _particle ); + _renderData.elements.push( _particle ); } @@ -342,24 +352,14 @@ THREE.Projector = function() { } - sort && _renderList.sort( painterSort ); + sort && _renderData.elements.sort( painterSort ); - return _renderList; + return _renderData; }; // Pools - function getNextObjectInPool() { - - var object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject(); - - _objectCount ++; - - return object; - - } - function getNextVertexInPool() { var vertex = _vertexPool[ _vertexCount ] = _vertexPool[ _vertexCount ] || new THREE.RenderableVertex(); diff --git a/src/core/Quaternion.js b/src/core/Quaternion.js index 67e22799..eb22b32e 100644 --- a/src/core/Quaternion.js +++ b/src/core/Quaternion.js @@ -207,8 +207,17 @@ THREE.Quaternion.prototype = { THREE.Quaternion.slerp = function ( qa, qb, qm, t ) { + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + var cosHalfTheta = qa.w * qb.w + qa.x * qb.x + qa.y * qb.y + qa.z * qb.z; + if (cosHalfTheta < 0) { + qm.w = -qb.w; qm.x = -qb.x; qm.y = -qb.y; qm.z = -qb.z; + cosHalfTheta = -cosHalfTheta; + } else { + qm.copy(qb); + } + if ( Math.abs( cosHalfTheta ) >= 1.0 ) { qm.w = qa.w; qm.x = qa.x; qm.y = qa.y; qm.z = qa.z; @@ -233,10 +242,10 @@ THREE.Quaternion.slerp = function ( qa, qb, qm, t ) { var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; - qm.w = ( qa.w * ratioA + qb.w * ratioB ); - qm.x = ( qa.x * ratioA + qb.x * ratioB ); - qm.y = ( qa.y * ratioA + qb.y * ratioB ); - qm.z = ( qa.z * ratioA + qb.z * ratioB ); + qm.w = ( qa.w * ratioA + qm.w * ratioB ); + qm.x = ( qa.x * ratioA + qm.x * ratioB ); + qm.y = ( qa.y * ratioA + qm.y * ratioB ); + qm.z = ( qa.z * ratioA + qm.z * ratioB ); return qm; diff --git a/src/core/Ray.js b/src/core/Ray.js index ab864165..444b7e33 100644 --- a/src/core/Ray.js +++ b/src/core/Ray.js @@ -15,7 +15,7 @@ THREE.Ray.prototype = { intersectScene: function ( scene ) { - return this.intersectObjects( scene.objects ); + return this.intersectObjects( scene.children ); }, @@ -90,6 +90,8 @@ THREE.Ray.prototype = { objMatrix, intersectPoint; + object.matrixRotationWorld.extractRotation( object.matrixWorld ); + for ( f = 0, fl = geometry.faces.length; f < fl; f ++ ) { face = geometry.faces[ f ]; diff --git a/src/extras/controls/TrackballControls.js b/src/extras/controls/TrackballControls.js index abf4086d..c98589e7 100644 --- a/src/extras/controls/TrackballControls.js +++ b/src/extras/controls/TrackballControls.js @@ -4,12 +4,16 @@ THREE.TrackballControls = function ( object, domElement ) { - this.object = object; + var _this = this, + STATE = { NONE : -1, ROTATE : 0, ZOOM : 1, PAN : 2 }; + this.object = object; this.domElement = ( domElement !== undefined ) ? domElement : document; // API + this.enabled = true; + this.screen = { width: window.innerWidth, height: window.innerHeight, offsetLeft: 0, offsetTop: 0 }; this.radius = ( this.screen.width + this.screen.height ) / 4; @@ -33,7 +37,7 @@ THREE.TrackballControls = function ( object, domElement ) { this.target = new THREE.Vector3( 0, 0, 0 ); var _keyPressed = false, - _state = this.STATE.NONE, + _state = STATE.NONE, _eye = new THREE.Vector3(), @@ -62,8 +66,8 @@ THREE.TrackballControls = function ( object, domElement ) { this.getMouseOnScreen = function( clientX, clientY ) { return new THREE.Vector2( - ( clientX - this.screen.offsetLeft ) / this.radius * 0.5, - ( clientY - this.screen.offsetTop ) / this.radius * 0.5 + ( clientX - _this.screen.offsetLeft ) / _this.radius * 0.5, + ( clientY - _this.screen.offsetTop ) / _this.radius * 0.5 ); }; @@ -71,8 +75,8 @@ THREE.TrackballControls = function ( object, domElement ) { this.getMouseProjectionOnBall = function( clientX, clientY ) { var mouseOnBall = new THREE.Vector3( - ( clientX - this.screen.width * 0.5 - this.screen.offsetLeft ) / this.radius, - ( this.screen.height * 0.5 + this.screen.offsetTop - clientY ) / this.radius, + ( clientX - _this.screen.width * 0.5 - _this.screen.offsetLeft ) / _this.radius, + ( _this.screen.height * 0.5 + _this.screen.offsetTop - clientY ) / _this.radius, 0.0 ); @@ -88,10 +92,10 @@ THREE.TrackballControls = function ( object, domElement ) { } - _eye.copy( this.object.position ).subSelf( this.target ); + _eye.copy( _this.object.position ).subSelf( _this.target ); - var projection = this.object.up.clone().setLength( mouseOnBall.y ); - projection.addSelf( this.object.up.clone().crossSelf( _eye ).setLength( mouseOnBall.x ) ); + var projection = _this.object.up.clone().setLength( mouseOnBall.y ); + projection.addSelf( _this.object.up.clone().crossSelf( _eye ).setLength( mouseOnBall.x ) ); projection.addSelf( _eye.setLength( mouseOnBall.z ) ); return projection; @@ -107,22 +111,22 @@ THREE.TrackballControls = function ( object, domElement ) { var axis = ( new THREE.Vector3() ).cross( _rotateStart, _rotateEnd ).normalize(), quaternion = new THREE.Quaternion(); - angle *= this.rotateSpeed; + angle *= _this.rotateSpeed; quaternion.setFromAxisAngle( axis, -angle ); quaternion.multiplyVector3( _eye ); - quaternion.multiplyVector3( this.object.up ); + quaternion.multiplyVector3( _this.object.up ); quaternion.multiplyVector3( _rotateEnd ); - if ( this.staticMoving ) { + if ( _this.staticMoving ) { _rotateStart = _rotateEnd; } else { - quaternion.setFromAxisAngle( axis, angle * ( this.dynamicDampingFactor - 1.0 ) ); + quaternion.setFromAxisAngle( axis, angle * ( _this.dynamicDampingFactor - 1.0 ) ); quaternion.multiplyVector3( _rotateStart ); } @@ -133,13 +137,13 @@ THREE.TrackballControls = function ( object, domElement ) { this.zoomCamera = function() { - var factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * this.zoomSpeed; + var factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed; if ( factor !== 1.0 && factor > 0.0 ) { _eye.multiplyScalar( factor ); - if ( this.staticMoving ) { + if ( _this.staticMoving ) { _zoomStart = _zoomEnd; @@ -159,21 +163,21 @@ THREE.TrackballControls = function ( object, domElement ) { if ( mouseChange.lengthSq() ) { - mouseChange.multiplyScalar( _eye.length() * this.panSpeed ); + mouseChange.multiplyScalar( _eye.length() * _this.panSpeed ); - var pan = _eye.clone().crossSelf( this.object.up ).setLength( mouseChange.x ); - pan.addSelf( this.object.up.clone().setLength( mouseChange.y ) ); + var pan = _eye.clone().crossSelf( _this.object.up ).setLength( mouseChange.x ); + pan.addSelf( _this.object.up.clone().setLength( mouseChange.y ) ); - this.object.position.addSelf( pan ); - this.target.addSelf( pan ); + _this.object.position.addSelf( pan ); + _this.target.addSelf( pan ); - if ( this.staticMoving ) { + if ( _this.staticMoving ) { _panStart = _panEnd; } else { - _panStart.addSelf( mouseChange.sub( _panEnd, _panStart ).multiplyScalar( this.dynamicDampingFactor ) ); + _panStart.addSelf( mouseChange.sub( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) ); } @@ -183,17 +187,17 @@ THREE.TrackballControls = function ( object, domElement ) { this.checkDistances = function() { - if ( !this.noZoom || !this.noPan ) { + if ( !_this.noZoom || !_this.noPan ) { - if ( this.object.position.lengthSq() > this.maxDistance * this.maxDistance ) { + if ( _this.object.position.lengthSq() > _this.maxDistance * _this.maxDistance ) { - this.object.position.setLength( this.maxDistance ); + _this.object.position.setLength( _this.maxDistance ); } - if ( _eye.lengthSq() < this.minDistance * this.minDistance ) { + if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) { - this.object.position.add( this.target, _eye.setLength( this.minDistance ) ); + _this.object.position.add( _this.target, _eye.setLength( _this.minDistance ) ); } @@ -203,27 +207,27 @@ THREE.TrackballControls = function ( object, domElement ) { this.update = function() { - _eye.copy( this.object.position ).subSelf( this.target ); + _eye.copy( _this.object.position ).subSelf( this.target ); - this.rotateCamera(); + _this.rotateCamera(); - if ( !this.noZoom ) { + if ( !_this.noZoom ) { - this.zoomCamera(); + _this.zoomCamera(); } - if ( !this.noPan ) { + if ( !_this.noPan ) { - this.panCamera(); + _this.panCamera(); } - this.object.position.add( this.target, _eye ); + _this.object.position.add( _this.target, _eye ); - this.checkDistances(); + _this.checkDistances(); - this.object.lookAt( this.target ); + _this.object.lookAt( _this.target ); }; @@ -232,25 +236,27 @@ THREE.TrackballControls = function ( object, domElement ) { function keydown( event ) { - if ( _state !== this.STATE.NONE ) { + if ( ! _this.enabled ) return; + + if ( _state !== STATE.NONE ) { return; - } else if ( event.keyCode === this.keys[ this.STATE.ROTATE ] ) { + } else if ( event.keyCode === _this.keys[ STATE.ROTATE ] ) { - _state = this.STATE.ROTATE; + _state = STATE.ROTATE; - } else if ( event.keyCode === this.keys[ this.STATE.ZOOM ] && !this.noZoom ) { + } else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && !_this.noZoom ) { - _state = this.STATE.ZOOM; + _state = STATE.ZOOM; - } else if ( event.keyCode === this.keys[ this.STATE.PAN ] && !this.noPan ) { + } else if ( event.keyCode === _this.keys[ STATE.PAN ] && !_this.noPan ) { - _state = this.STATE.PAN; + _state = STATE.PAN; } - if ( _state !== this.STATE.NONE ) { + if ( _state !== STATE.NONE ) { _keyPressed = true; @@ -260,9 +266,11 @@ THREE.TrackballControls = function ( object, domElement ) { function keyup( event ) { - if ( _state !== this.STATE.NONE ) { + if ( ! _this.enabled ) return; - _state = this.STATE.NONE; + if ( _state !== STATE.NONE ) { + + _state = STATE.NONE; } @@ -270,24 +278,26 @@ THREE.TrackballControls = function ( object, domElement ) { function mousedown( event ) { + if ( ! _this.enabled ) return; + event.preventDefault(); event.stopPropagation(); - if ( _state === this.STATE.NONE ) { + if ( _state === STATE.NONE ) { _state = event.button; - if ( _state === this.STATE.ROTATE ) { + if ( _state === STATE.ROTATE ) { - _rotateStart = _rotateEnd = this.getMouseProjectionOnBall( event.clientX, event.clientY ); + _rotateStart = _rotateEnd = _this.getMouseProjectionOnBall( event.clientX, event.clientY ); - } else if ( _state === this.STATE.ZOOM && !this.noZoom ) { + } else if ( _state === STATE.ZOOM && !_this.noZoom ) { - _zoomStart = _zoomEnd = this.getMouseOnScreen( event.clientX, event.clientY ); + _zoomStart = _zoomEnd = _this.getMouseOnScreen( event.clientX, event.clientY ); } else if ( !this.noPan ) { - _panStart = _panEnd = this.getMouseOnScreen( event.clientX, event.clientY ); + _panStart = _panEnd = _this.getMouseOnScreen( event.clientX, event.clientY ); } @@ -297,31 +307,33 @@ THREE.TrackballControls = function ( object, domElement ) { function mousemove( event ) { + if ( ! _this.enabled ) return; + if ( _keyPressed ) { - _rotateStart = _rotateEnd = this.getMouseProjectionOnBall( event.clientX, event.clientY ); - _zoomStart = _zoomEnd = this.getMouseOnScreen( event.clientX, event.clientY ); - _panStart = _panEnd = this.getMouseOnScreen( event.clientX, event.clientY ); + _rotateStart = _rotateEnd = _this.getMouseProjectionOnBall( event.clientX, event.clientY ); + _zoomStart = _zoomEnd = _this.getMouseOnScreen( event.clientX, event.clientY ); + _panStart = _panEnd = _this.getMouseOnScreen( event.clientX, event.clientY ); _keyPressed = false; } - if ( _state === this.STATE.NONE ) { + if ( _state === STATE.NONE ) { return; - } else if ( _state === this.STATE.ROTATE ) { + } else if ( _state === STATE.ROTATE ) { - _rotateEnd = this.getMouseProjectionOnBall( event.clientX, event.clientY ); + _rotateEnd = _this.getMouseProjectionOnBall( event.clientX, event.clientY ); - } else if ( _state === this.STATE.ZOOM && !this.noZoom ) { + } else if ( _state === STATE.ZOOM && !_this.noZoom ) { - _zoomEnd = this.getMouseOnScreen( event.clientX, event.clientY ); + _zoomEnd = _this.getMouseOnScreen( event.clientX, event.clientY ); - } else if ( _state === this.STATE.PAN && !this.noPan ) { + } else if ( _state === STATE.PAN && !_this.noPan ) { - _panEnd = this.getMouseOnScreen( event.clientX, event.clientY ); + _panEnd = _this.getMouseOnScreen( event.clientX, event.clientY ); } @@ -329,32 +341,22 @@ THREE.TrackballControls = function ( object, domElement ) { function mouseup( event ) { + if ( ! _this.enabled ) return; + event.preventDefault(); event.stopPropagation(); - _state = this.STATE.NONE; - - }; - - function bind( scope, fn ) { - - return function () { - - fn.apply( scope, arguments ); - - }; + _state = STATE.NONE; }; this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); - this.domElement.addEventListener( 'mousemove', bind( this, mousemove ), false ); - this.domElement.addEventListener( 'mousedown', bind( this, mousedown ), false ); - this.domElement.addEventListener( 'mouseup', bind( this, mouseup ), false ); + this.domElement.addEventListener( 'mousemove', mousemove, false ); + this.domElement.addEventListener( 'mousedown', mousedown, false ); + this.domElement.addEventListener( 'mouseup', mouseup, false ); - window.addEventListener( 'keydown', bind( this, keydown ), false ); - window.addEventListener( 'keyup', bind( this, keyup ), false ); + window.addEventListener( 'keydown', keydown, false ); + window.addEventListener( 'keyup', keyup, false ); }; - -THREE.TrackballControls.prototype.STATE = { NONE : -1, ROTATE : 0, ZOOM : 1, PAN : 2 }; diff --git a/src/extras/geometries/OctahedronGeometry.js b/src/extras/geometries/OctahedronGeometry.js index 7a856bd0..0b27bd74 100644 --- a/src/extras/geometries/OctahedronGeometry.js +++ b/src/extras/geometries/OctahedronGeometry.js @@ -13,7 +13,7 @@ THREE.OctahedronGeometry = function ( radius, detail ) { THREE.Geometry.call( this ); - detail = isFinite(detail) ? detail : 3; // allow a zero value + detail = detail || 0; var that = this; // ugly scope hack diff --git a/src/extras/loaders/ColladaLoader.js b/src/extras/loaders/ColladaLoader.js index 6d564595..b26544c2 100644 --- a/src/extras/loaders/ColladaLoader.js +++ b/src/extras/loaders/ColladaLoader.js @@ -517,10 +517,6 @@ THREE.ColladaLoader = function () { var morphController; var i; - obj.name = node.id || ""; - obj.matrixAutoUpdate = false; - obj.matrix = node.matrix; - // FIXME: controllers for ( i = 0; i < node.controllers.length; i ++ ) { @@ -676,15 +672,19 @@ THREE.ColladaLoader = function () { } else { mesh = new THREE.Mesh( geom, material ); + // mesh.geom.name = geometry.id; } - obj.add( mesh ); + node.geometries.length > 1 ? obj.add( mesh ) : obj = mesh; } } + obj.name = node.id || ""; + node.matrix.decompose( obj.position, obj.rotation, obj.scale ); + for ( i = 0; i < node.nodes.length; i ++ ) { obj.add( createSceneGraph( node.nodes[i], node ) ); diff --git a/src/extras/loaders/SceneLoader.js b/src/extras/loaders/SceneLoader.js index e0698639..1b3e2429 100644 --- a/src/extras/loaders/SceneLoader.js +++ b/src/extras/loaders/SceneLoader.js @@ -760,6 +760,9 @@ THREE.SceneLoader.prototype = { scope.callbackSync( result ); + // just in case there are no async elements: + async_callback_gate(); + }; }, diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 46fc0b40..54d6854d 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -5,7 +5,7 @@ THREE.CanvasRenderer = function ( parameters ) { var _this = this, - _renderList = null, + _renderData, _elements, _lights, _projector = new THREE.Projector(), parameters = parameters || {}, @@ -33,11 +33,11 @@ THREE.CanvasRenderer = function ( parameters ) { _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y, _v5x, _v5y, _v6x, _v6y, - _color = new THREE.Color( 0x000000 ), - _color1 = new THREE.Color( 0x000000 ), - _color2 = new THREE.Color( 0x000000 ), - _color3 = new THREE.Color( 0x000000 ), - _color4 = new THREE.Color( 0x000000 ), + _color = new THREE.Color(), + _color1 = new THREE.Color(), + _color2 = new THREE.Color(), + _color3 = new THREE.Color(), + _color4 = new THREE.Color(), _patterns = [], @@ -51,7 +51,6 @@ THREE.CanvasRenderer = function ( parameters ) { _bboxRect = new THREE.Rectangle(), _enableLighting = false, - _light = new THREE.Color(), _ambientLight = new THREE.Color(), _directionalLights = new THREE.Color(), _pointLights = new THREE.Color(), @@ -181,24 +180,26 @@ THREE.CanvasRenderer = function ( parameters ) { _this.info.render.vertices = 0; _this.info.render.faces = 0; - _renderList = _projector.projectScene( scene, camera, this.sortElements ); + _renderData = _projector.projectScene( scene, camera, this.sortElements ); + _elements = _renderData.elements; + _lights = _renderData.lights; /* DEBUG _context.fillStyle = 'rgba( 0, 255, 255, 0.5 )'; _context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() ); */ - _enableLighting = scene.lights.length > 0; + _enableLighting = _lights.length > 0; if ( _enableLighting ) { - calculateLights( scene ); + calculateLights( _lights ); } - for ( e = 0, el = _renderList.length; e < el; e++ ) { + for ( e = 0, el = _elements.length; e < el; e++ ) { - element = _renderList[ e ]; + element = _elements[ e ]; _bboxRect.empty(); @@ -369,10 +370,9 @@ THREE.CanvasRenderer = function ( parameters ) { // - function calculateLights( scene ) { + function calculateLights( lights ) { - var l, ll, light, lightColor, - lights = scene.lights; + var l, ll, light, lightColor; _ambientLight.setRGB( 0, 0, 0 ); _directionalLights.setRGB( 0, 0, 0 ); @@ -411,10 +411,9 @@ THREE.CanvasRenderer = function ( parameters ) { } - function calculateLight( scene, position, normal, color ) { + function calculateLight( lights, position, normal, color ) { - var l, ll, light, lightColor, - amount, lights = scene.lights; + var l, ll, light, lightColor, lightPosition, amount; for ( l = 0, ll = lights.length; l < ll; l ++ ) { @@ -423,7 +422,9 @@ THREE.CanvasRenderer = function ( parameters ) { if ( light instanceof THREE.DirectionalLight ) { - amount = normal.dot( light.position ); + lightPosition = light.matrixWorld.getPosition(); + + amount = normal.dot( lightPosition ); if ( amount <= 0 ) continue; @@ -435,11 +436,13 @@ THREE.CanvasRenderer = function ( parameters ) { } else if ( light instanceof THREE.PointLight ) { - amount = normal.dot( _vector3.sub( light.position, position ).normalize() ); + lightPosition = light.matrixWorld.getPosition(); + + amount = normal.dot( _vector3.sub( lightPosition, position ).normalize() ); if ( amount <= 0 ) continue; - amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( light.position ) / light.distance, 1 ); + amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 ); if ( amount == 0 ) continue; @@ -595,15 +598,15 @@ THREE.CanvasRenderer = function ( parameters ) { var cameraMatrix = camera.matrixWorldInverse; - _vector3.copy( element.vertexNormalsWorld[ 0 ] ); + _vector3.copy( element.vertexNormalsWorld[ uv1 ] ); _uv1x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5; _uv1y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5; - _vector3.copy( element.vertexNormalsWorld[ 1 ] ); + _vector3.copy( element.vertexNormalsWorld[ uv2 ] ); _uv2x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5; _uv2y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5; - _vector3.copy( element.vertexNormalsWorld[ 2 ] ); + _vector3.copy( element.vertexNormalsWorld[ uv3 ] ); _uv3x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5; _uv3y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5; @@ -645,9 +648,9 @@ THREE.CanvasRenderer = function ( parameters ) { _color1.g = _color2.g = _color3.g = _ambientLight.g; _color1.b = _color2.b = _color3.b = _ambientLight.b; - calculateLight( scene, element.v1.positionWorld, element.vertexNormalsWorld[ 0 ], _color1 ); - calculateLight( scene, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); - calculateLight( scene, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 ); + calculateLight( _lights, element.v1.positionWorld, element.vertexNormalsWorld[ 0 ], _color1 ); + calculateLight( _lights, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); + calculateLight( _lights, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 ); _color1.r = Math.max( 0, Math.min( material.color.r * _color1.r, 1 ) ); _color1.g = Math.max( 0, Math.min( material.color.g * _color1.g, 1 ) ); @@ -671,15 +674,15 @@ THREE.CanvasRenderer = function ( parameters ) { } else { - _light.r = _ambientLight.r; - _light.g = _ambientLight.g; - _light.b = _ambientLight.b; + _color.r = _ambientLight.r; + _color.g = _ambientLight.g; + _color.b = _ambientLight.b; - calculateLight( scene, element.centroidWorld, element.normalWorld, _light ); + calculateLight( _lights, element.centroidWorld, element.normalWorld, _color ); - _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); - _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); - _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); + _color.r = Math.max( 0, Math.min( material.color.r * _color.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) ); material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color ); @@ -762,10 +765,10 @@ THREE.CanvasRenderer = function ( parameters ) { _color1.g = _color2.g = _color3.g = _color4.g = _ambientLight.g; _color1.b = _color2.b = _color3.b = _color4.b = _ambientLight.b; - calculateLight( scene, element.v1.positionWorld, element.vertexNormalsWorld[ 0 ], _color1 ); - calculateLight( scene, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); - calculateLight( scene, element.v4.positionWorld, element.vertexNormalsWorld[ 3 ], _color3 ); - calculateLight( scene, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color4 ); + calculateLight( _lights, element.v1.positionWorld, element.vertexNormalsWorld[ 0 ], _color1 ); + calculateLight( _lights, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); + calculateLight( _lights, element.v4.positionWorld, element.vertexNormalsWorld[ 3 ], _color3 ); + calculateLight( _lights, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color4 ); _color1.r = Math.max( 0, Math.min( material.color.r * _color1.r, 1 ) ); _color1.g = Math.max( 0, Math.min( material.color.g * _color1.g, 1 ) ); @@ -795,15 +798,15 @@ THREE.CanvasRenderer = function ( parameters ) { } else { - _light.r = _ambientLight.r; - _light.g = _ambientLight.g; - _light.b = _ambientLight.b; + _color.r = _ambientLight.r; + _color.g = _ambientLight.g; + _color.b = _ambientLight.b; - calculateLight( scene, element.centroidWorld, element.normalWorld, _light ); + calculateLight( _lights, element.centroidWorld, element.normalWorld, _color ); - _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); - _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); - _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); + _color.r = Math.max( 0, Math.min( material.color.r * _color.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) ); drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y ); diff --git a/src/renderers/Projector.js b/src/renderers/Projector.js deleted file mode 100644 index e90aa90c..00000000 --- a/src/renderers/Projector.js +++ /dev/null @@ -1,499 +0,0 @@ -/** - * @author mr.doob / http://mrdoob.com/ - * @author supereggbert / http://www.paulbrunt.co.uk/ - * @author julianwa / https://github.com/julianwa - */ - -THREE.Projector = function() { - - var _object, _objectCount, _objectPool = [], - _vertex, _vertexCount, _vertexPool = [], - _face, _face3Count, _face3Pool = [], _face4Count, _face4Pool = [], - _line, _lineCount, _linePool = [], - _particle, _particleCount, _particlePool = [], - - _objectList = [], _renderList = [], - - _vector3 = new THREE.Vector4(), - _vector4 = new THREE.Vector4(), - _projScreenMatrix = new THREE.Matrix4(), - _projScreenObjectMatrix = new THREE.Matrix4(), - - _frustum = [ - new THREE.Vector4(), - new THREE.Vector4(), - new THREE.Vector4(), - new THREE.Vector4(), - new THREE.Vector4(), - new THREE.Vector4() - ], - - _clippedVertex1PositionScreen = new THREE.Vector4(), - _clippedVertex2PositionScreen = new THREE.Vector4(), - - _face3VertexNormals; - - - this.projectVector = function ( vector, camera ) { - - _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); - _projScreenMatrix.multiplyVector3( vector ); - - return vector; - - }; - - this.unprojectVector = function ( vector, camera ) { - - _projScreenMatrix.multiply( camera.matrixWorld, THREE.Matrix4.makeInvert( camera.projectionMatrix ) ); - _projScreenMatrix.multiplyVector3( vector ); - - return vector; - - }; - - this.projectObjects = function ( scene, camera, sort ) { - - var o, ol, objects, object, matrix; - - _objectList.length = 0; - _objectCount = 0; - - objects = scene.objects; - - for ( o = 0, ol = objects.length; o < ol; o ++ ) { - - object = objects[ o ]; - - if ( !object.visible || ( object instanceof THREE.Mesh && !( object.frustumCulled && isInFrustum( object ) ) ) ) continue; - - _object = getNextObjectInPool(); - - _vector3.copy( object.position ); - _projScreenMatrix.multiplyVector3( _vector3 ); - - _object.object = object; - _object.z = _vector3.z; - - _objectList.push( _object ); - - } - - sort && _objectList.sort( painterSort ); - - return _objectList; - - }; - - // TODO: Rename to projectElements? - - this.projectScene = function ( scene, camera, sort ) { - - var near = camera.near, far = camera.far, - o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, objects, object, - objectMatrix, objectMatrixRotation, objectMaterials, objectOverdraw, - geometry, vertices, vertex, vertexPositionScreen, - faces, face, faceVertexNormals, normal, faceVertexUvs, uvs, - v1, v2, v3, v4; - - _renderList.length = 0; - - _face3Count = 0; - _face4Count = 0; - _lineCount = 0; - _particleCount = 0; - - camera.matrixAutoUpdate && camera.update( undefined, true ); - - scene.update( undefined, false, camera ); - - _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); - computeFrustum( _projScreenMatrix ); - - objects = this.projectObjects( scene, camera, true ); - - for ( o = 0, ol = objects.length; o < ol; o++ ) { - - object = objects[ o ].object; - - if ( !object.visible ) continue; - - objectMatrix = object.matrixWorld; - objectMatrixRotation = object.matrixRotationWorld; - - objectMaterials = object.materials; - objectOverdraw = object.overdraw; - - _vertexCount = 0; - - if ( object instanceof THREE.Mesh ) { - - geometry = object.geometry; - vertices = geometry.vertices; - faces = geometry.faces; - faceVertexUvs = geometry.faceVertexUvs; - - for ( v = 0, vl = vertices.length; v < vl; v ++ ) { - - _vertex = getNextVertexInPool(); - _vertex.positionWorld.copy( vertices[ v ].position ); - - objectMatrix.multiplyVector3( _vertex.positionWorld ); - - _vertex.positionScreen.copy( _vertex.positionWorld ); - _projScreenMatrix.multiplyVector4( _vertex.positionScreen ); - - _vertex.positionScreen.x /= _vertex.positionScreen.w; - _vertex.positionScreen.y /= _vertex.positionScreen.w; - - _vertex.visible = _vertex.positionScreen.z > near && _vertex.positionScreen.z < far; - - } - - for ( f = 0, fl = faces.length; f < fl; f ++ ) { - - face = faces[ f ]; - - if ( face instanceof THREE.Face3 ) { - - v1 = _vertexPool[ face.a ]; - v2 = _vertexPool[ face.b ]; - v3 = _vertexPool[ face.c ]; - - if ( v1.visible && v2.visible && v3.visible && - ( object.doubleSided || ( object.flipSided != - ( v3.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) - - ( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ) ) ) { - - _face = getNextFace3InPool(); - - _face.v1.copy( v1 ); - _face.v2.copy( v2 ); - _face.v3.copy( v3 ); - - } else { - - continue; - - } - - } else if ( face instanceof THREE.Face4 ) { - - v1 = _vertexPool[ face.a ]; - v2 = _vertexPool[ face.b ]; - v3 = _vertexPool[ face.c ]; - v4 = _vertexPool[ face.d ]; - - if ( v1.visible && v2.visible && v3.visible && v4.visible && - ( object.doubleSided || ( object.flipSided != - ( ( v4.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) - - ( v4.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 || - ( v2.positionScreen.x - v3.positionScreen.x ) * ( v4.positionScreen.y - v3.positionScreen.y ) - - ( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0 ) ) ) ) { - - _face = getNextFace4InPool(); - - _face.v1.copy( v1 ); - _face.v2.copy( v2 ); - _face.v3.copy( v3 ); - _face.v4.copy( v4 ); - - } else { - - continue; - - } - - } - - _face.normalWorld.copy( face.normal ); - objectMatrixRotation.multiplyVector3( _face.normalWorld ); - - _face.centroidWorld.copy( face.centroid ); - objectMatrix.multiplyVector3( _face.centroidWorld ); - - _face.centroidScreen.copy( _face.centroidWorld ); - _projScreenMatrix.multiplyVector3( _face.centroidScreen ); - - faceVertexNormals = face.vertexNormals; - - for ( n = 0, nl = faceVertexNormals.length; n < nl; n ++ ) { - - normal = _face.vertexNormalsWorld[ n ]; - normal.copy( faceVertexNormals[ n ] ); - objectMatrixRotation.multiplyVector3( normal ); - - } - - for ( c = 0, cl = faceVertexUvs.length; c < cl; c ++ ) { - - uvs = faceVertexUvs[ c ][ f ]; - - if ( !uvs ) continue; - - for ( u = 0, ul = uvs.length; u < ul; u ++ ) { - - _face.uvs[ c ][ u ] = uvs[ u ]; - - } - - } - - _face.meshMaterials = objectMaterials; - _face.faceMaterials = face.materials; - _face.overdraw = objectOverdraw; - - _face.z = _face.centroidScreen.z; - - _renderList.push( _face ); - - } - - } else if ( object instanceof THREE.Line ) { - - _projScreenObjectMatrix.multiply( _projScreenMatrix, objectMatrix ); - - vertices = object.geometry.vertices; - - v1 = getNextVertexInPool(); - v1.positionScreen.copy( vertices[ 0 ].position ); - _projScreenObjectMatrix.multiplyVector4( v1.positionScreen ); - - for ( v = 1, vl = vertices.length; v < vl; v++ ) { - - v1 = getNextVertexInPool(); - v1.positionScreen.copy( vertices[ v ].position ); - _projScreenObjectMatrix.multiplyVector4( v1.positionScreen ); - - v2 = _vertexPool[ _vertexCount - 2 ]; - - _clippedVertex1PositionScreen.copy( v1.positionScreen ); - _clippedVertex2PositionScreen.copy( v2.positionScreen ); - - if ( clipLine( _clippedVertex1PositionScreen, _clippedVertex2PositionScreen ) ) { - - // Perform the perspective divide - _clippedVertex1PositionScreen.multiplyScalar( 1 / _clippedVertex1PositionScreen.w ); - _clippedVertex2PositionScreen.multiplyScalar( 1 / _clippedVertex2PositionScreen.w ); - - _line = getNextLineInPool(); - _line.v1.positionScreen.copy( _clippedVertex1PositionScreen ); - _line.v2.positionScreen.copy( _clippedVertex2PositionScreen ); - - _line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z ); - - _line.materials = object.materials; - - _renderList.push( _line ); - - } - } - - } else if ( object instanceof THREE.Particle ) { - - _vector4.set( object.matrixWorld.n14, object.matrixWorld.n24, object.matrixWorld.n34, 1 ); - _projScreenMatrix.multiplyVector4( _vector4 ); - - _vector4.z /= _vector4.w; - - if ( _vector4.z > 0 && _vector4.z < 1 ) { - - _particle = getNextParticleInPool(); - _particle.x = _vector4.x / _vector4.w; - _particle.y = _vector4.y / _vector4.w; - _particle.z = _vector4.z; - - _particle.rotation = object.rotation.z; - - _particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) ); - _particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) ); - - _particle.materials = object.materials; - - _renderList.push( _particle ); - - } - - } - - } - - sort && _renderList.sort( painterSort ); - - return _renderList; - - }; - - // Pools - - function getNextObjectInPool() { - - var object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject(); - - _objectCount ++; - - return object; - - } - - function getNextVertexInPool() { - - var vertex = _vertexPool[ _vertexCount ] = _vertexPool[ _vertexCount ] || new THREE.RenderableVertex(); - - _vertexCount ++; - - return vertex; - - } - - function getNextFace3InPool() { - - var face = _face3Pool[ _face3Count ] = _face3Pool[ _face3Count ] || new THREE.RenderableFace3(); - - _face3Count ++; - - return face; - - } - - function getNextFace4InPool() { - - var face = _face4Pool[ _face4Count ] = _face4Pool[ _face4Count ] || new THREE.RenderableFace4(); - - _face4Count ++; - - return face; - - } - - function getNextLineInPool() { - - var line = _linePool[ _lineCount ] = _linePool[ _lineCount ] || new THREE.RenderableLine(); - - _lineCount ++; - - return line; - - } - - function getNextParticleInPool() { - - var particle = _particlePool[ _particleCount ] = _particlePool[ _particleCount ] || new THREE.RenderableParticle(); - _particleCount ++; - return particle; - - } - - // - - function painterSort( a, b ) { - - return b.z - a.z; - - } - - function computeFrustum( m ) { - - _frustum[ 0 ].set( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 ); - _frustum[ 1 ].set( m.n41 + m.n11, m.n42 + m.n12, m.n43 + m.n13, m.n44 + m.n14 ); - _frustum[ 2 ].set( m.n41 + m.n21, m.n42 + m.n22, m.n43 + m.n23, m.n44 + m.n24 ); - _frustum[ 3 ].set( m.n41 - m.n21, m.n42 - m.n22, m.n43 - m.n23, m.n44 - m.n24 ); - _frustum[ 4 ].set( m.n41 - m.n31, m.n42 - m.n32, m.n43 - m.n33, m.n44 - m.n34 ); - _frustum[ 5 ].set( m.n41 + m.n31, m.n42 + m.n32, m.n43 + m.n33, m.n44 + m.n34 ); - - for ( var i = 0; i < 6; i ++ ) { - - var plane = _frustum[ i ]; - plane.divideScalar( Math.sqrt( plane.x * plane.x + plane.y * plane.y + plane.z * plane.z ) ); - - } - - } - - function isInFrustum( object ) { - - var distance, matrix = object.matrixWorld, - radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) ); - - for ( var i = 0; i < 6; i ++ ) { - - distance = _frustum[ i ].x * matrix.n14 + _frustum[ i ].y * matrix.n24 + _frustum[ i ].z * matrix.n34 + _frustum[ i ].w; - if ( distance <= radius ) return false; - - } - - return true; - - }; - - function clipLine( s1, s2 ) { - - var alpha1 = 0, alpha2 = 1, - - // Calculate the boundary coordinate of each vertex for the near and far clip planes, - // Z = -1 and Z = +1, respectively. - bc1near = s1.z + s1.w, - bc2near = s2.z + s2.w, - bc1far = - s1.z + s1.w, - bc2far = - s2.z + s2.w; - - if ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) { - - // Both vertices lie entirely within all clip planes. - return true; - - } else if ( ( bc1near < 0 && bc2near < 0) || (bc1far < 0 && bc2far < 0 ) ) { - - // Both vertices lie entirely outside one of the clip planes. - return false; - - } else { - - // The line segment spans at least one clip plane. - - if ( bc1near < 0 ) { - - // v1 lies outside the near plane, v2 inside - alpha1 = Math.max( alpha1, bc1near / ( bc1near - bc2near ) ); - - } else if ( bc2near < 0 ) { - - // v2 lies outside the near plane, v1 inside - alpha2 = Math.min( alpha2, bc1near / ( bc1near - bc2near ) ); - - } - - if ( bc1far < 0 ) { - - // v1 lies outside the far plane, v2 inside - alpha1 = Math.max( alpha1, bc1far / ( bc1far - bc2far ) ); - - } else if ( bc2far < 0 ) { - - // v2 lies outside the far plane, v2 inside - alpha2 = Math.min( alpha2, bc1far / ( bc1far - bc2far ) ); - - } - - if ( alpha2 < alpha1 ) { - - // The line segment spans two boundaries, but is outside both of them. - // (This can't happen when we're only clipping against just near/far but good - // to leave the check here for future usage if other clip planes are added.) - return false; - - } else { - - // Update the s1 and s2 vertices to match the clipped line segment. - s1.lerpSelf( s2, alpha1 ); - s2.lerpSelf( s1, 1 - alpha2 ); - - return true; - - } - - } - - } - -}; diff --git a/src/renderers/SVGRenderer.js b/src/renderers/SVGRenderer.js index 5b6975db..3e1422fa 100644 --- a/src/renderers/SVGRenderer.js +++ b/src/renderers/SVGRenderer.js @@ -5,7 +5,7 @@ THREE.SVGRenderer = function () { var _this = this, - _renderList = null, + _renderData, _elements, _lights, _projector = new THREE.Projector(), _svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'), _svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf, @@ -16,11 +16,10 @@ THREE.SVGRenderer = function () { _bboxRect = new THREE.Rectangle(), _enableLighting = false, - _color = new THREE.Color( 0xffffff ), - _light = new THREE.Color( 0xffffff ), - _ambientLight = new THREE.Color( 0x000000 ), - _directionalLights = new THREE.Color( 0x000000 ), - _pointLights = new THREE.Color( 0x000000 ), + _color = new THREE.Color(), + _ambientLight = new THREE.Color(), + _directionalLights = new THREE.Color(), + _pointLights = new THREE.Color(), _w, // z-buffer to w-buffer _vector3 = new THREE.Vector3(), // Needed for PointLight @@ -80,7 +79,7 @@ THREE.SVGRenderer = function () { }; - this.render = function( scene, camera ) { + this.render = function ( scene, camera ) { var e, el, m, ml, fm, fml, element, material; @@ -89,21 +88,23 @@ THREE.SVGRenderer = function () { _this.info.render.vertices = 0; _this.info.render.faces = 0; - _renderList = _projector.projectScene( scene, camera, this.sortElements ); + _renderData = _projector.projectScene( scene, camera, this.sortElements ); + _elements = _renderData.elements; + _lights = _renderData.lights; _pathCount = 0; _circleCount = 0; _lineCount = 0; - _enableLighting = scene.lights.length > 0; + _enableLighting = _lights.length > 0; if ( _enableLighting ) { - calculateLights( scene ); + calculateLights( _lights ); } - for ( e = 0, el = _renderList.length; e < el; e ++ ) { + for ( e = 0, el = _elements.length; e < el; e ++ ) { - element = _renderList[ e ]; + element = _elements[ e ]; _bboxRect.empty(); @@ -240,10 +241,9 @@ THREE.SVGRenderer = function () { }; - function calculateLights( scene ) { + function calculateLights( lights ) { - var l, ll, light, lightColor, - lights = scene.lights; + var l, ll, light, lightColor; _ambientLight.setRGB( 0, 0, 0 ); _directionalLights.setRGB( 0, 0, 0 ); @@ -278,40 +278,46 @@ THREE.SVGRenderer = function () { } - function calculateFaceLight( scene, element, color ) { + function calculateLight( lights, position, normal, color ) { - var l, ll, light, amount; + var l, ll, light, lightColor, lightPosition, amount; - for ( l = 0, ll = scene.lights.length; l < ll; l++ ) { + for ( l = 0, ll = lights.length; l < ll; l ++ ) { - light = scene.lights[ l ]; + light = lights[ l ]; + lightColor = light.color; if ( light instanceof THREE.DirectionalLight ) { - amount = element.normalWorld.dot( light.position ) * light.intensity; + lightPosition = light.matrixWorld.getPosition(); - if ( amount > 0 ) { + amount = normal.dot( lightPosition ); - color.r += light.color.r * amount; - color.g += light.color.g * amount; - color.b += light.color.b * amount; + if ( amount <= 0 ) continue; - } + amount *= light.intensity; + + color.r += lightColor.r * amount; + color.g += lightColor.g * amount; + color.b += lightColor.b * amount; } else if ( light instanceof THREE.PointLight ) { - _vector3.sub( light.position, element.centroidWorld ); - _vector3.normalize(); + lightPosition = light.matrixWorld.getPosition(); - amount = element.normalWorld.dot( _vector3 ) * light.intensity; + amount = normal.dot( _vector3.sub( lightPosition, position ).normalize() ); - if ( amount > 0 ) { + if ( amount <= 0 ) continue; - color.r += light.color.r * amount; - color.g += light.color.g * amount; - color.b += light.color.b * amount; + amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 ); - } + if ( amount == 0 ) continue; + + amount *= light.intensity; + + color.r += lightColor.r * amount; + color.g += lightColor.g * amount; + color.b += lightColor.b * amount; } @@ -331,13 +337,13 @@ THREE.SVGRenderer = function () { if ( _enableLighting ) { - _light.r = _ambientLight.r + _directionalLights.r + _pointLights.r; - _light.g = _ambientLight.g + _directionalLights.g + _pointLights.g; - _light.b = _ambientLight.b + _directionalLights.b + _pointLights.b; + _color.r = _ambientLight.r + _directionalLights.r + _pointLights.r; + _color.g = _ambientLight.g + _directionalLights.g + _pointLights.g; + _color.b = _ambientLight.b + _directionalLights.b + _pointLights.b; - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; + _color.r = material.color.r * _color.r; + _color.g = material.color.g * _color.g; + _color.b = material.color.b * _color.b; _color.updateStyleString(); @@ -391,15 +397,15 @@ THREE.SVGRenderer = function () { if ( _enableLighting ) { - _light.r = _ambientLight.r; - _light.g = _ambientLight.g; - _light.b = _ambientLight.b; + _color.r = _ambientLight.r; + _color.g = _ambientLight.g; + _color.b = _ambientLight.b; - calculateFaceLight( scene, element, _light ); + calculateLight( _lights, element.centroidWorld, element.normalWorld, _color ); - _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); - _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); - _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); + _color.r = Math.max( 0, Math.min( material.color.r * _color.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) ); } else { @@ -448,15 +454,15 @@ THREE.SVGRenderer = function () { if ( _enableLighting ) { - _light.r = _ambientLight.r; - _light.g = _ambientLight.g; - _light.b = _ambientLight.b; + _color.r = _ambientLight.r; + _color.g = _ambientLight.g; + _color.b = _ambientLight.b; - calculateFaceLight( scene, element, _light ); + calculateLight( _lights, element.centroidWorld, element.normalWorld, _color ); - _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); - _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); - _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); + _color.r = Math.max( 0, Math.min( material.color.r * _color.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _color.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _color.b, 1 ) ); } else { diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 9177a64a..ea322255 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -3524,12 +3524,16 @@ THREE.WebGLRenderer = function ( parameters ) { scene.update( undefined, false, _cameraLight ); + THREE.Matrix4.makeInvert( _cameraLight.matrixWorld, _cameraLight.matrixWorldInverse ); + // compute shadow matrix - shadowMatrix.set( 0.5, 0.0, 0.0, 0.5, - 0.0, 0.5, 0.0, 0.5, - 0.0, 0.0, 0.5, 0.5, - 0.0, 0.0, 0.0, 1.0 ); + shadowMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); shadowMatrix.multiplySelf( _cameraLight.projectionMatrix ); shadowMatrix.multiplySelf( _cameraLight.matrixWorldInverse ); @@ -3540,6 +3544,7 @@ THREE.WebGLRenderer = function ( parameters ) { _cameraLight.projectionMatrix.flattenToArray( _projectionMatrixArray ); _projScreenMatrix.multiply( _cameraLight.projectionMatrix, _cameraLight.matrixWorldInverse ); + computeFrustum( _projScreenMatrix ); _this.initWebGLObjects( scene ); @@ -3713,6 +3718,8 @@ THREE.WebGLRenderer = function ( parameters ) { scene.update( undefined, false, camera ); + THREE.Matrix4.makeInvert( camera.matrixWorld, camera.matrixWorldInverse ); + camera.matrixWorldInverse.flattenToArray( _viewMatrixArray ); camera.projectionMatrix.flattenToArray( _projectionMatrixArray ); diff --git a/src/renderers/renderables/RenderableObject.js b/src/renderers/renderables/RenderableObject.js deleted file mode 100644 index 4903aa2e..00000000 --- a/src/renderers/renderables/RenderableObject.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @author mr.doob / http://mrdoob.com/ - */ - -THREE.RenderableObject = function () { - - this.object = null; - this.z = null; - -}; diff --git a/src/scenes/Scene.js b/src/scenes/Scene.js index ab4be4ed..6909eafb 100644 --- a/src/scenes/Scene.js +++ b/src/scenes/Scene.js @@ -1,6 +1,5 @@ /** * @author mr.doob / http://mrdoob.com/ - * @author mikael emtinger / http://gomo.se/ */ THREE.Scene = function () { @@ -8,160 +7,11 @@ THREE.Scene = function () { THREE.Object3D.call( this ); this.fog = null; - - this.matrixAutoUpdate = false; - this.overrideMaterial = null; - this.collisions = null; - - this.objects = []; - this.lights = []; - - this.__objectsAdded = []; - this.__objectsRemoved = []; + this.matrixAutoUpdate = false; }; THREE.Scene.prototype = new THREE.Object3D(); THREE.Scene.prototype.constructor = THREE.Scene; -THREE.Scene.prototype.supr = THREE.Object3D.prototype; - -THREE.Scene.prototype.add = function ( object ) { - - this.supr.add.call( this, object ); - this.addChildRecurse( object ); - -} - -THREE.Scene.prototype.addChildRecurse = function ( child ) { - - if ( child instanceof THREE.Light ) { - - if ( this.lights.indexOf( child ) === - 1 ) { - - this.lights.push( child ); - - } - - } else if ( !( child instanceof THREE.Camera || child instanceof THREE.Bone ) ) { - - if ( this.objects.indexOf( child ) === - 1 ) { - - this.objects.push( child ); - this.__objectsAdded.push( child ); - - // check if previously removed - - var i = this.__objectsRemoved.indexOf( child ); - - if ( i !== -1 ) { - - this.__objectsRemoved.splice( i, 1 ); - - } - - } - - } - - for ( var c = 0; c < child.children.length; c ++ ) { - - this.addChildRecurse( child.children[ c ] ); - - } - -} - -THREE.Scene.prototype.remove = function ( object ) { - - this.supr.remove.call( this, object ); - this.removeChildRecurse( object ); - -} - -THREE.Scene.prototype.removeChildRecurse = function ( child ) { - - if ( child instanceof THREE.Light ) { - - var i = this.lights.indexOf( child ); - - if ( i !== -1 ) { - - this.lights.splice( i, 1 ); - - } - - } else if ( !( child instanceof THREE.Camera ) ) { - - var i = this.objects.indexOf( child ); - - if( i !== -1 ) { - - this.objects.splice( i, 1 ); - this.__objectsRemoved.push( child ); - - // check if previously added - - var ai = this.__objectsAdded.indexOf( child ); - - if ( ai !== -1 ) { - - this.__objectsAdded.splice( ai, 1 ); - - } - } - - } - - for ( var c = 0; c < child.children.length; c ++ ) { - - this.removeChildRecurse( child.children[ c ] ); - - } - -} - -// DEPRECATED - -THREE.Scene.prototype.addChild = function ( child ) { - - console.warn( 'DEPRECATED: Scene.addChild() is now Scene.add().' ); - this.add( child ); - -} - -THREE.Scene.prototype.addObject = function ( child ) { - - console.warn( 'DEPRECATED: Scene.addObject() is now Scene.add().' ); - this.add( child ); - -} - -THREE.Scene.prototype.addLight = function ( child ) { - - console.warn( 'DEPRECATED: Scene.addLight() is now Scene.add().' ); - this.add( child ); - -} - -THREE.Scene.prototype.removeChild = function ( child ) { - - console.warn( 'DEPRECATED: Scene.removeChild() is now Scene.remove().' ); - this.remove( child ); - -} - -THREE.Scene.prototype.removeObject = function ( child ) { - - console.warn( 'DEPRECATED: Scene.removeObject() is now Scene.remove().' ); - this.remove( child ); - -} - -THREE.Scene.prototype.removeLight = function ( child ) { - - console.warn( 'DEPRECATED: Scene.removeLight() is now Scene.remove().' ); - this.remove( child ); - -} diff --git a/utils/build.py b/utils/build.py index f0398d34..432906a7 100644 --- a/utils/build.py +++ b/utils/build.py @@ -76,7 +76,6 @@ COMMON_FILES = [ 'renderers/renderables/RenderableVertex.js', 'renderers/renderables/RenderableFace3.js', 'renderers/renderables/RenderableFace4.js', -'renderers/renderables/RenderableObject.js', 'renderers/renderables/RenderableParticle.js', 'renderers/renderables/RenderableLine.js' ] @@ -177,7 +176,6 @@ CANVAS_FILES = [ 'renderers/renderables/RenderableVertex.js', 'renderers/renderables/RenderableFace3.js', 'renderers/renderables/RenderableFace4.js', -'renderers/renderables/RenderableObject.js', 'renderers/renderables/RenderableParticle.js', 'renderers/renderables/RenderableLine.js' ] @@ -253,7 +251,6 @@ SVG_FILES = [ 'renderers/renderables/RenderableVertex.js', 'renderers/renderables/RenderableFace3.js', 'renderers/renderables/RenderableFace4.js', -'renderers/renderables/RenderableObject.js', 'renderers/renderables/RenderableParticle.js', 'renderers/renderables/RenderableLine.js' ] diff --git a/utils/exporters/utf8/objcompress b/utils/exporters/utf8/objcompress new file mode 100755 index 00000000..55cd93e2 Binary files /dev/null and b/utils/exporters/utf8/objcompress differ