From aac5b6117b890f104417fedb868e54bb37e593b5 Mon Sep 17 00:00:00 2001 From: alteredq Date: Sat, 16 Apr 2011 00:40:07 +0200 Subject: [PATCH] Refactored SceneLoader. Just a single callback is now passed to loader.load( "scene.js", callbackFinal ) - callback which is called when everything from the scene was already loaded. If you want to use also callbacks for initialization of procedural synchronously created elements, you can set property of loader: loader.callbackSync = function( result ) { ... } If you want to get callback for load progress, set: loader.callbackProgress = function( progress, result ) { ... } Also added per scene creation of collision systems (it used to be singleton). --- build/Three.js | 572 ++++++++++++------------- build/custom/ThreeCanvas.js | 2 +- build/custom/ThreeDOM.js | 2 +- build/custom/ThreeExtras.js | 264 ++++++------ build/custom/ThreeSVG.js | 2 +- build/custom/ThreeWebGL.js | 2 +- examples/webgl_scene_test.html | 16 +- examples/webgl_scene_test_blender.html | 28 +- src/extras/io/SceneLoader.js | 50 ++- src/scenes/Scene.js | 2 + 10 files changed, 477 insertions(+), 463 deletions(-) diff --git a/build/Three.js b/build/Three.js index 42538161d74b66..82fef216b47087 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,34 +12,34 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,c,f){this.set(b||0,d||0,c||0,f||1)}; THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b0&&V>0&&J+V<1}var c,f,g,h,j,k,m,o,p,t, -v,u=b.geometry,B=u.vertices,F=[];c=0;for(f=u.faces.length;c0:p<0)){o=o.dot((new THREE.Vector3).sub(h,t))/ -p;t=t.addSelf(v.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(t,h,j,k)){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};F.push(g)}}else if(g instanceof THREE.Face4&&(d(t,h,j,m)||d(t,j,k,m))){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};F.push(g)}}}return F}}; -THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,o,p,t){k=!1;d=m;c=o;f=p;g=t;b()};this.addPoint=function(m,o){if(k){k=!1;d=m;c=o;f=m;g=o}else{d=dm?f:m;g=g>o?g:o}b()}; -this.add3Points=function(m,o,p,t,v,u){if(k){k=!1;d=mp?m>v?m:v:p>v?p:v;g=o>t?o>u?o:u:t>u?t:u}else{d=mp?m>v?m>f?m:f:v>f?v:f:p>v?p>f?p:f:v>f?v:f;g=o>t?o>u?o>g?o:g:u>g?u:g:t>u?t>g?t:g:u>g?u:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=dm.getRight()? +THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b0&&Q>0&&R+Q<1}var c,f,g,h,j,k,m,p,o,t, +y,u=b.geometry,B=u.vertices,A=[];c=0;for(f=u.faces.length;c0:o<0)){p=p.dot((new THREE.Vector3).sub(h,t))/ +o;t=t.addSelf(y.multiplyScalar(p));if(g instanceof THREE.Face3){if(d(t,h,j,k)){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};A.push(g)}}else if(g instanceof THREE.Face4&&(d(t,h,j,m)||d(t,j,k,m))){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};A.push(g)}}}return A}}; +THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,p,o,t){k=!1;d=m;c=p;f=o;g=t;b()};this.addPoint=function(m,p){if(k){k=!1;d=m;c=p;f=m;g=p}else{d=dm?f:m;g=g>p?g:p}b()}; +this.add3Points=function(m,p,o,t,y,u){if(k){k=!1;d=mo?m>y?m:y:o>y?o:y;g=p>t?p>u?p:u:t>u?t:u}else{d=mo?m>y?m>f?m:f:y>f?y:f:o>y?o>f?o:f:y>f?y:f;g=p>t?p>u?p>g?p:g:u>g?u:g:t>u?t>g?t:g:u>g?u:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=dm.getRight()? f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}b()};this.inflate=function(m){d-=m;c-=m;f+=m;g+=m;b()};this.minSelf=function(m){d=d>m.getLeft()?d:m.getLeft();c=c>m.getTop()?c:m.getTop();f=f=0&&Math.min(g,m.getBottom())-Math.max(c,m.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}}; -THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,o,p,t,v,u,B,F){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,o||0,p||1,t||0,v||0,u||0,B||0,F||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,o,p,t,v,u,B,F){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=o;this.n33=p;this.n34=t;this.n41=v;this.n42=u;this.n43=B;this.n44=F;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,d,c){var f=THREE.Matrix4.__v1, +THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,p,o,t,y,u,B,A){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,p||0,o||1,t||0,y||0,u||0,B||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,p,o,t,y,u,B,A){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=p;this.n33=o;this.n34=t;this.n41=y;this.n42=u;this.n43=B;this.n44=A;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,d,c){var f=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23* f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize(); -return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,t=b.n32,v=b.n33,u=b.n34,B=b.n41,F=b.n42,V=b.n43,A=b.n44,S=d.n11,D=d.n12,Y=d.n13,J=d.n14,L=d.n21,oa=d.n22, -ja=d.n23,ra=d.n24,va=d.n31,X=d.n32,e=d.n33,na=d.n34;this.n11=c*S+f*L+g*va;this.n12=c*D+f*oa+g*X;this.n13=c*Y+f*ja+g*e;this.n14=c*J+f*ra+g*na+h;this.n21=j*S+k*L+m*va;this.n22=j*D+k*oa+m*X;this.n23=j*Y+k*ja+m*e;this.n24=j*J+k*ra+m*na+o;this.n31=p*S+t*L+v*va;this.n32=p*D+t*oa+v*X;this.n33=p*Y+t*ja+v*e;this.n34=p*J+t*ra+v*na+u;this.n41=B*S+F*L+V*va;this.n42=B*D+F*oa+V*X;this.n43=B*Y+F*ja+V*e;this.n44=B*J+F*ra+V*na+A;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);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(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,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,o=this.n32,p=this.n33,t=this.n34,v=this.n41,u=this.n42,B=this.n43,F=this.n44;return f*j*o*v-c*k*o*v-f*h*p*v+d*k*p*v+c*h*t*v-d*j*t*v-f*j*m*u+c*k*m*u+f*g*p*u-b*k*p*u-c*g*t*u+b*j*t*u+f*h*m*B-d*k*m*B-f*g*o*B+b*k*o*B+d*g*t*B-b*h*t*B-c*h*m*F+d*j*m*F+c*g*o*F-b*j*o*F-d*g*p*F+b*h*p*F},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,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,0,1);return this}, -setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g=1-c,h=b.x,j=b.y,k= -b.z,m=g*h,o=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,o*j+c,o*k-f*h,0,m*k-f*j,o*k+f*h,g*k*k+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(){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= +return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,t=b.n32,y=b.n33,u=b.n34,B=b.n41,A=b.n42,Q=b.n43,E=b.n44,V=d.n11,C=d.n12,X=d.n13,R=d.n14,P=d.n21,ya=d.n22, +la=d.n23,ca=d.n24,Ba=d.n31,ea=d.n32,e=d.n33,oa=d.n34;this.n11=c*V+f*P+g*Ba;this.n12=c*C+f*ya+g*ea;this.n13=c*X+f*la+g*e;this.n14=c*R+f*ca+g*oa+h;this.n21=j*V+k*P+m*Ba;this.n22=j*C+k*ya+m*ea;this.n23=j*X+k*la+m*e;this.n24=j*R+k*ca+m*oa+p;this.n31=o*V+t*P+y*Ba;this.n32=o*C+t*ya+y*ea;this.n33=o*X+t*la+y*e;this.n34=o*R+t*ca+y*oa+u;this.n41=B*V+A*P+Q*Ba;this.n42=B*C+A*ya+Q*ea;this.n43=B*X+A*la+Q*e;this.n44=B*R+A*ca+Q*oa+E;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);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(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,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,p=this.n32,o=this.n33,t=this.n34,y=this.n41,u=this.n42,B=this.n43,A=this.n44;return f*j*p*y-c*k*p*y-f*h*o*y+d*k*o*y+c*h*t*y-d*j*t*y-f*j*m*u+c*k*m*u+f*g*o*u-b*k*o*u-c*g*t*u+b*j*t*u+f*h*m*B-d*k*m*B-f*g*p*B+b*k*p*B+d*g*t*B-b*h*t*B-c*h*m*A+d*j*m*A+c*g*p*A-b*j*p*A-d*g*o*A+b*h*o*A},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,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0, +0,1);return this},setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g= +1-c,h=b.x,j=b.y,k=b.z,m=g*h,p=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,p*j+c,p*k-f*h,0,m*k-f*j,p*k+f*h,g*k*k+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(){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){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+ -d*h;this.n33=b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var o=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(o+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+o);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this}, +d*h;this.n33=b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var p=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(p+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+p);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this}, extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;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*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,t=b.n32,v=b.n33,u=b.n34,B=b.n41,F=b.n42,V=b.n43,A=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*u*F-o*v*F+o*t*V-k*u*V-m*t*A+k*v*A;d.n12=h*v*F-g*u*F-h*t*V+f*u*V+g*t*A-f*v*A;d.n13=g*o*F-h*m*F+h*k*V-f*o*V-g*k*A+f*m*A;d.n14=h*m*t-g*o*t-h*k*v+f*o*v+g*k*u-f*m*u;d.n21=o*v*B-m*u*B-o*p*V+j*u*V+m*p*A-j*v*A;d.n22=g*u*B-h*v*B+h*p*V-c*u*V-g*p*A+c*v*A;d.n23=h*m*B-g*o*B-h*j*V+c*o*V+g*j*A-c*m*A; -d.n24=g*o*p-h*m*p+h*j*v-c*o*v-g*j*u+c*m*u;d.n31=k*u*B-o*t*B+o*p*F-j*u*F-k*p*A+j*t*A;d.n32=h*t*B-f*u*B-h*p*F+c*u*F+f*p*A-c*t*A;d.n33=g*o*B-h*k*B+h*j*F-c*o*F-f*j*A+c*k*A;d.n34=h*k*p-f*o*p-h*j*t+c*o*t+f*j*u-c*k*u;d.n41=m*t*B-k*v*B-m*p*F+j*v*F+k*p*V-j*t*V;d.n42=f*v*B-g*t*B+g*p*F-c*v*F-f*p*V+c*t*V;d.n43=g*k*B-f*m*B-g*j*F+c*m*F+f*j*V-c*k*V;d.n44=f*m*p-g*k*p+g*j*t-c*m*t-f*j*v+c*k*v;d.multiplyScalar(1/b.determinant());return d}; -THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=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,m=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*o;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*o;c[7]=b*p;c[8]=b*t;return d}; +THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,t=b.n32,y=b.n33,u=b.n34,B=b.n41,A=b.n42,Q=b.n43,E=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*u*A-p*y*A+p*t*Q-k*u*Q-m*t*E+k*y*E;d.n12=h*y*A-g*u*A-h*t*Q+f*u*Q+g*t*E-f*y*E;d.n13=g*p*A-h*m*A+h*k*Q-f*p*Q-g*k*E+f*m*E;d.n14=h*m*t-g*p*t-h*k*y+f*p*y+g*k*u-f*m*u;d.n21=p*y*B-m*u*B-p*o*Q+j*u*Q+m*o*E-j*y*E;d.n22=g*u*B-h*y*B+h*o*Q-c*u*Q-g*o*E+c*y*E;d.n23=h*m*B-g*p*B-h*j*Q+c*p*Q+g*j*E-c*m*E; +d.n24=g*p*o-h*m*o+h*j*y-c*p*y-g*j*u+c*m*u;d.n31=k*u*B-p*t*B+p*o*A-j*u*A-k*o*E+j*t*E;d.n32=h*t*B-f*u*B-h*o*A+c*u*A+f*o*E-c*t*E;d.n33=g*p*B-h*k*B+h*j*A-c*p*A-f*j*E+c*k*E;d.n34=h*k*o-f*p*o-h*j*t+c*p*t+f*j*u-c*k*u;d.n41=m*t*B-k*y*B-m*o*A+j*y*A+k*o*Q-j*t*Q;d.n42=f*y*B-g*t*B+g*o*A-c*y*A-f*o*Q+c*t*Q;d.n43=g*k*B-f*m*B-g*j*A+c*m*A+f*j*Q-c*k*Q;d.n44=f*m*o-g*k*o+g*j*t-c*m*t-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d}; +THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=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,m=-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,t=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*p;c[7]=b*o;c[8]=b*t;return d}; THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)}; -THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,o;j=new THREE.Matrix4;k=d-b;m=c-f;o=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+g)/o);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.makeOrtho=function(b,d,c,f,g,h){var j,k,m,p;j=new THREE.Matrix4;k=d-b;m=c-f;p=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((h+g)/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.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.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)},addChild:function(b){if(this.children.indexOf(b)=== @@ -48,8 +48,8 @@ this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.m this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var f=this.children.length;b=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010){c.w=0.5*(b.w+d.w);c.x=0.5*(b.x+d.x);c.y=0.5*(b.y+d.y);c.z=0.5*(b.z+d.z);return c}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=b.w*g+d.w*f;c.x=b.x*g+d.x*f;c.y=b.y*g+d.y*f;c.z=b.z*g+d.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,d,c,f,g,h){this.a=b;this.b=d;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,d,c,f,g,h,j){this.a=b;this.b=d;this.c=c;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; @@ -58,17 +58,17 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.f c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,c,f,g,h,j,k=new THREE.Vector3,m=new THREE.Vector3;f=0;for(g=this.faces.length;f0){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 d=1,c=this.vertices.length;dthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; +c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(ja,qa,pa,wa,fa,ka,ma){k=ja.vertices[qa].position;m=ja.vertices[pa].position;p=ja.vertices[wa].position;o=j[fa];t=j[ka];y=j[ma];u=m.x-k.x;B=p.x-k.x;A=m.y-k.y;Q=p.y-k.y;E=m.z-k.z;V=p.z-k.z;C=t.u-o.u;X=y.u-o.u;R=t.v-o.v;P=y.v-o.v;ya=1/(C* +P-X*R);ea.set((P*u-R*B)*ya,(P*A-R*Q)*ya,(P*E-R*V)*ya);e.set((C*B-X*u)*ya,(C*Q-X*A)*ya,(C*V-X*E)*ya);ca[qa].addSelf(ea);ca[pa].addSelf(ea);ca[wa].addSelf(ea);Ba[qa].addSelf(e);Ba[pa].addSelf(e);Ba[wa].addSelf(e)}var d,c,f,g,h,j,k,m,p,o,t,y,u,B,A,Q,E,V,C,X,R,P,ya,la,ca=[],Ba=[],ea=new THREE.Vector3,e=new THREE.Vector3,oa=new THREE.Vector3,Da=new THREE.Vector3,da=new THREE.Vector3;d=0;for(c=this.vertices.length;d0){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 d=1,c=this.vertices.length;dthis.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=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;dthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;o=this.points[c[0]];p=this.points[c[1]]; -t=this.points[c[2]];v=this.points[c[3]];k=j*j;m=j*k;f.x=d(o.x,p.x,t.x,v.x,j,k,m);f.y=d(o.y,p.y,t.y,v.y,j,k,m);f.z=d(o.z,p.z,t.z,v.z,j,k,m);return f};this.getControlPointsArray=function(){var u,B,F=this.points.length,V=[];for(u=0;uthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]]; +t=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(p.x,o.x,t.x,y.x,j,k,m);f.y=d(p.y,o.y,t.y,y.y,j,k,m);f.z=d(p.z,o.z,t.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var u,B,A=this.points.length,Q=[];for(u=0;u1){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(;ft){c=p;p=t;t=c}}else if(pu){c=v;v=u;u=c}}else if(vt){c=o;o=t;t=c}}else if(ou){c=y;y=u;u=c}}else if(y=0&&Da>=0&&ka>=0&&ea>=0)return!0;else if(wa<0&&Da<0||ka<0&&ea<0)return!1;else{if(wa<0)na=Math.max(na,wa/(wa-Da));else Da<0&&(za=Math.min(za,wa/(wa-Da)));if(ka<0)na=Math.max(na,ka/(ka-ea));else ea<0&&(za=Math.min(za,ka/(ka-ea)));if(zawa&&j.positionScreen.z0&&J.z<1){Ja=D[S]=D[S]||new THREE.RenderableParticle;S++;A=Ja;A.x=J.x/J.w;A.y=J.y/J.w;A.z=J.z;A.rotation=ga.rotation.z;A.scale.x=ga.scale.x*Math.abs(A.x-(J.x+e.projectionMatrix.n11)/(J.w+e.projectionMatrix.n14));A.scale.y=ga.scale.y*Math.abs(A.y-(J.y+e.projectionMatrix.n22)/(J.w+e.projectionMatrix.n24));A.materials=ga.materials;za.push(A)}}}}na&&za.sort(d);return za}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,o,p,t,v,u,B,F;b=d.projectScene(j,k);m=0;for(o=b.length;m>1;Ia=ya.height>>1;ha=ma.scale.x*o;qa=ma.scale.y*p;ca=ha*W;ta=qa*Ia;z.set(U.x- -ca,U.y-ta,U.x+ca,U.y+ta);if(y.instersects(z)){t.save();t.translate(U.x,U.y);t.rotate(-ma.rotation);t.scale(ha,-qa);t.translate(-W,-Ia);t.drawImage(ya,0,0);t.restore()}}}else if(ha instanceof THREE.ParticleCanvasMaterial){ca=ma.scale.x*o;ta=ma.scale.y*p;z.set(U.x-ca,U.y-ta,U.x+ca,U.y+ta);if(y.instersects(z)){c(ha.color.__styleString);qa=ha.color.__styleString;if(A!=qa)t.fillStyle=A=qa;t.save();t.translate(U.x,U.y);t.rotate(-ma.rotation);t.scale(ca,ta);ha.program(t);t.restore()}}}function E(U,ma,ha, -ca){b(ca.opacity);d(ca.blending);t.beginPath();t.moveTo(U.positionScreen.x,U.positionScreen.y);t.lineTo(ma.positionScreen.x,ma.positionScreen.y);t.closePath();if(ca instanceof THREE.LineBasicMaterial){la.__styleString=ca.color.__styleString;U=ca.linewidth;if(S!=U)t.lineWidth=S=U;U=ca.linecap;if(D!=U)t.lineCap=D=U;U=ca.linejoin;if(Y!=U)t.lineJoin=Y=U;c(la.__styleString);t.stroke();z.inflate(ca.linewidth*2)}}function da(U,ma,ha,ca,ta,qa,ya,W,Ia){f.data.vertices+=3;f.data.faces++;b(W.opacity);d(W.blending); -X=U.positionScreen.x;e=U.positionScreen.y;na=ma.positionScreen.x;za=ma.positionScreen.y;wa=ha.positionScreen.x;Da=ha.positionScreen.y;ab(X,e,na,za,wa,Da);if(W instanceof THREE.MeshBasicMaterial)if(W.map){if(W.map.mapping instanceof THREE.UVMapping){Q=ya.uvs[0];cb(X,e,na,za,wa,Da,W.map.image,Q[ca].u,Q[ca].v,Q[ta].u,Q[ta].v,Q[qa].u,Q[qa].v)}}else if(W.envMap){if(W.envMap.mapping instanceof THREE.SphericalReflectionMapping){U=xa.matrixWorldInverse;I.copy(ya.vertexNormalsWorld[0]);R=(I.x*U.n11+I.y*U.n12+ -I.z*U.n13)*0.5+0.5;O=-(I.x*U.n21+I.y*U.n22+I.z*U.n23)*0.5+0.5;I.copy(ya.vertexNormalsWorld[1]);Ba=(I.x*U.n11+I.y*U.n12+I.z*U.n13)*0.5+0.5;La=-(I.x*U.n21+I.y*U.n22+I.z*U.n23)*0.5+0.5;I.copy(ya.vertexNormalsWorld[2]);n=(I.x*U.n11+I.y*U.n12+I.z*U.n13)*0.5+0.5;C=-(I.x*U.n21+I.y*U.n22+I.z*U.n23)*0.5+0.5;cb(X,e,na,za,wa,Da,W.envMap.image,R,O,Ba,La,n,C)}}else W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&& -!W.wireframe){if(W.map.mapping instanceof THREE.UVMapping){Q=ya.uvs[0];cb(X,e,na,za,wa,Da,W.map.image,Q[ca].u,Q[ca].v,Q[ta].u,Q[ta].v,Q[qa].u,Q[qa].v)}d(THREE.SubtractiveBlending)}if(P)if(!W.wireframe&&W.shading==THREE.SmoothShading&&ya.vertexNormalsWorld.length==3){Fa.r=ia.r=ga.r=G.r;Fa.g=ia.g=ga.g=G.g;Fa.b=ia.b=ga.b=G.b;Aa(Ia,ya.v1.positionWorld,ya.vertexNormalsWorld[0],Fa);Aa(Ia,ya.v2.positionWorld,ya.vertexNormalsWorld[1],ia);Aa(Ia,ya.v3.positionWorld,ya.vertexNormalsWorld[2],ga);Ja.r=(ia.r+ga.r)* -0.5;Ja.g=(ia.g+ga.g)*0.5;Ja.b=(ia.b+ga.b)*0.5;Ta=hb(Fa,ia,ga,Ja);cb(X,e,na,za,wa,Da,Ta,0,0,1,0,0,1)}else{K.r=G.r;K.g=G.g;K.b=G.b;Aa(Ia,ya.centroidWorld,ya.normalWorld,K);la.r=W.color.r*K.r;la.g=W.color.g*K.g;la.b=W.color.b*K.b;la.updateStyleString();W.wireframe?Oa(la.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(la.__styleString)}else W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString)}else if(W instanceof -THREE.MeshDepthMaterial){Xa=xa.near;Za=xa.far;Fa.r=Fa.g=Fa.b=1-Wa(U.positionScreen.z,Xa,Za);ia.r=ia.g=ia.b=1-Wa(ma.positionScreen.z,Xa,Za);ga.r=ga.g=ga.b=1-Wa(ha.positionScreen.z,Xa,Za);Ja.r=(ia.r+ga.r)*0.5;Ja.g=(ia.g+ga.g)*0.5;Ja.b=(ia.b+ga.b)*0.5;Ta=hb(Fa,ia,ga,Ja);cb(X,e,na,za,wa,Da,Ta,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){la.r=$a(ya.normalWorld.x);la.g=$a(ya.normalWorld.y);la.b=$a(ya.normalWorld.z);la.updateStyleString();W.wireframe?Oa(la.__styleString,W.wireframeLinewidth, -W.wireframeLinecap,W.wireframeLinejoin):Qa(la.__styleString)}}function w(U,ma,ha,ca,ta,qa,ya,W,Ia){f.data.vertices+=4;f.data.faces++;b(W.opacity);d(W.blending);if(W.map||W.envMap){da(U,ma,ca,0,1,3,ya,W,Ia);da(ta,ha,qa,1,2,3,ya,W,Ia)}else{X=U.positionScreen.x;e=U.positionScreen.y;na=ma.positionScreen.x;za=ma.positionScreen.y;wa=ha.positionScreen.x;Da=ha.positionScreen.y;ka=ca.positionScreen.x;ea=ca.positionScreen.y;ua=ta.positionScreen.x;sa=ta.positionScreen.y;aa=qa.positionScreen.x;fa=qa.positionScreen.y; -if(W instanceof THREE.MeshBasicMaterial){fb(X,e,na,za,wa,Da,ka,ea);W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString)}else if(W instanceof THREE.MeshLambertMaterial)if(P)if(!W.wireframe&&W.shading==THREE.SmoothShading&&ya.vertexNormalsWorld.length==4){Fa.r=ia.r=ga.r=Ja.r=G.r;Fa.g=ia.g=ga.g=Ja.g=G.g;Fa.b=ia.b=ga.b=Ja.b=G.b;Aa(Ia,ya.v1.positionWorld,ya.vertexNormalsWorld[0],Fa);Aa(Ia,ya.v2.positionWorld,ya.vertexNormalsWorld[1], -ia);Aa(Ia,ya.v4.positionWorld,ya.vertexNormalsWorld[3],ga);Aa(Ia,ya.v3.positionWorld,ya.vertexNormalsWorld[2],Ja);Ta=hb(Fa,ia,ga,Ja);ab(X,e,na,za,ka,ea);cb(X,e,na,za,ka,ea,Ta,0,0,1,0,0,1);ab(ua,sa,wa,Da,aa,fa);cb(ua,sa,wa,Da,aa,fa,Ta,1,0,1,1,0,1)}else{K.r=G.r;K.g=G.g;K.b=G.b;Aa(Ia,ya.centroidWorld,ya.normalWorld,K);la.r=W.color.r*K.r;la.g=W.color.g*K.g;la.b=W.color.b*K.b;la.updateStyleString();fb(X,e,na,za,wa,Da,ka,ea);W.wireframe?Oa(la.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin): -Qa(la.__styleString)}else{fb(X,e,na,za,wa,Da,ka,ea);W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString)}else if(W instanceof THREE.MeshNormalMaterial){la.r=$a(ya.normalWorld.x);la.g=$a(ya.normalWorld.y);la.b=$a(ya.normalWorld.z);la.updateStyleString();fb(X,e,na,za,wa,Da,ka,ea);W.wireframe?Oa(la.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(la.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){Xa= -xa.near;Za=xa.far;Fa.r=Fa.g=Fa.b=1-Wa(U.positionScreen.z,Xa,Za);ia.r=ia.g=ia.b=1-Wa(ma.positionScreen.z,Xa,Za);ga.r=ga.g=ga.b=1-Wa(ca.positionScreen.z,Xa,Za);Ja.r=Ja.g=Ja.b=1-Wa(ha.positionScreen.z,Xa,Za);Ta=hb(Fa,ia,ga,Ja);ab(X,e,na,za,ka,ea);cb(X,e,na,za,ka,ea,Ta,0,0,1,0,0,1);ab(ua,sa,wa,Da,aa,fa);cb(ua,sa,wa,Da,aa,fa,Ta,1,0,1,1,0,1)}}}function ab(U,ma,ha,ca,ta,qa){t.beginPath();t.moveTo(U,ma);t.lineTo(ha,ca);t.lineTo(ta,qa);t.lineTo(U,ma);t.closePath()}function fb(U,ma,ha,ca,ta,qa,ya,W){t.beginPath(); -t.moveTo(U,ma);t.lineTo(ha,ca);t.lineTo(ta,qa);t.lineTo(ya,W);t.lineTo(U,ma);t.closePath()}function Oa(U,ma,ha,ca){if(S!=ma)t.lineWidth=S=ma;if(D!=ha)t.lineCap=D=ha;if(Y!=ca)t.lineJoin=Y=ca;c(U);t.stroke();z.inflate(ma*2)}function Qa(U){if(A!=U)t.fillStyle=A=U;t.fill()}function cb(U,ma,ha,ca,ta,qa,ya,W,Ia,Ya,eb,Sa,kb){var gb,db;gb=ya.width-1;db=ya.height-1;W*=gb;Ia*=db;Ya*=gb;eb*=db;Sa*=gb;kb*=db;ha-=U;ca-=ma;ta-=U;qa-=ma;Ya-=W;eb-=Ia;Sa-=W;kb-=Ia;gb=Ya*kb-Sa*eb;if(gb!=0){db=1/gb;gb=(kb*ha-eb*ta)* -db;eb=(kb*ca-eb*qa)*db;ha=(Ya*ta-Sa*ha)*db;ca=(Ya*qa-Sa*ca)*db;U=U-gb*W-ha*Ia;ma=ma-eb*W-ca*Ia;t.save();t.transform(gb,eb,ha,ca,U,ma);t.clip();t.drawImage(ya,0,0);t.restore()}}function hb(U,ma,ha,ca){var ta=~~(U.r*255),qa=~~(U.g*255);U=~~(U.b*255);var ya=~~(ma.r*255),W=~~(ma.g*255);ma=~~(ma.b*255);var Ia=~~(ha.r*255),Ya=~~(ha.g*255);ha=~~(ha.b*255);var eb=~~(ca.r*255),Sa=~~(ca.g*255);ca=~~(ca.b*255);pa[0]=ta<0?0:ta>255?255:ta;pa[1]=qa<0?0:qa>255?255:qa;pa[2]=U<0?0:U>255?255:U;pa[4]=ya<0?0:ya>255? -255:ya;pa[5]=W<0?0:W>255?255:W;pa[6]=ma<0?0:ma>255?255:ma;pa[8]=Ia<0?0:Ia>255?255:Ia;pa[9]=Ya<0?0:Ya>255?255:Ya;pa[10]=ha<0?0:ha>255?255:ha;pa[12]=eb<0?0:eb>255?255:eb;pa[13]=Sa<0?0:Sa>255?255:Sa;pa[14]=ca<0?0:ca>255?255:ca;$.putImageData(Z,0,0);Ca.drawImage(M,0,0);return Ka}function Wa(U,ma,ha){U=(U-ma)/(ha-ma);return U*U*(3-2*U)}function $a(U){U=(U+1)*0.5;return U<0?0:U>1?1:U}function Ma(U,ma){var ha=ma.x-U.x,ca=ma.y-U.y,ta=1/Math.sqrt(ha*ha+ca*ca);ha*=ta;ca*=ta;ma.x+=ha;ma.y+=ca;U.x-=ha;U.y-=ca} -var bb,Va,N,Na,Ra,ib,jb,Pa;this.autoClear?this.clear():t.setTransform(1,0,0,-1,o,p);f.data.vertices=0;f.data.faces=0;g=h.projectScene(Ga,xa,this.sortElements);(P=Ga.lights.length>0)&&Ea(Ga);bb=0;for(Va=g.length;bb0){ua.r+=fa.color.r*la;ua.g+=fa.color.g*la;ua.b+=fa.color.b*la}}else if(fa instanceof THREE.PointLight){va.sub(fa.position,ea.centroidWorld);va.normalize();la=ea.normalWorld.dot(va)*fa.intensity;if(la>0){ua.r+=fa.color.r*la;ua.g+=fa.color.g*la;ua.b+=fa.color.b*la}}}}function d(ka,ea, -ua,sa,aa,fa){h.data.vertices+=3;h.data.faces++;na=f(za++);na.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+ea.positionScreen.x+" "+ea.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)Y.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(D){J.r=L.r;J.g=L.g;J.b=L.b;b(fa,sa,J);Y.r=aa.color.r*J.r;Y.g=aa.color.g*J.g;Y.b=aa.color.b*J.b;Y.updateStyleString()}else Y.__styleString= -aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){ra=1-aa.__2near/(aa.__farPlusNear-sa.z*aa.__farMinusNear);Y.setRGB(ra,ra,ra)}else aa instanceof THREE.MeshNormalMaterial&&Y.setRGB(g(sa.normalWorld.x),g(sa.normalWorld.y),g(sa.normalWorld.z));aa.wireframe?na.setAttribute("style","fill: none; stroke: "+Y.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+"; stroke-linejoin: "+aa.wireframeLinejoin):na.setAttribute("style", -"fill: "+Y.__styleString+"; fill-opacity: "+aa.opacity);m.appendChild(na)}function c(ka,ea,ua,sa,aa,fa,la){h.data.vertices+=4;h.data.faces++;na=f(za++);na.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+ea.positionScreen.x+" "+ea.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(fa instanceof THREE.MeshBasicMaterial)Y.__styleString=fa.color.__styleString;else if(fa instanceof THREE.MeshLambertMaterial)if(D){J.r= -L.r;J.g=L.g;J.b=L.b;b(la,aa,J);Y.r=fa.color.r*J.r;Y.g=fa.color.g*J.g;Y.b=fa.color.b*J.b;Y.updateStyleString()}else Y.__styleString=fa.color.__styleString;else if(fa instanceof THREE.MeshDepthMaterial){ra=1-fa.__2near/(fa.__farPlusNear-aa.z*fa.__farMinusNear);Y.setRGB(ra,ra,ra)}else fa instanceof THREE.MeshNormalMaterial&&Y.setRGB(g(aa.normalWorld.x),g(aa.normalWorld.y),g(aa.normalWorld.z));fa.wireframe?na.setAttribute("style","fill: none; stroke: "+Y.__styleString+"; stroke-width: "+fa.wireframeLinewidth+ -"; stroke-opacity: "+fa.opacity+"; stroke-linecap: "+fa.wireframeLinecap+"; stroke-linejoin: "+fa.wireframeLinejoin):na.setAttribute("style","fill: "+Y.__styleString+"; fill-opacity: "+fa.opacity);m.appendChild(na)}function f(ka){if(X[ka]==null){X[ka]=document.createElementNS("http://www.w3.org/2000/svg","path");Da==0&&X[ka].setAttribute("shape-rendering","crispEdges")}return X[ka]}function g(ka){return ka<0?Math.min((1+ka)*0.5,0.5):0.5+Math.min(ka*0.5,0.5)}var h=this,j=null,k=new THREE.Projector, -m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,p,t,v,u,B,F,V,A=new THREE.Rectangle,S=new THREE.Rectangle,D=!1,Y=new THREE.Color(16777215),J=new THREE.Color(16777215),L=new THREE.Color(0),oa=new THREE.Color(0),ja=new THREE.Color(0),ra,va=new THREE.Vector3,X=[],e=[],na,za,wa,Da=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(ka){switch(ka){case "high":Da=1;break;case "low":Da=0}};this.setSize=function(ka, -ea){o=ka;p=ea;t=o/2;v=p/2;m.setAttribute("viewBox",-t+" "+-v+" "+o+" "+p);m.setAttribute("width",o);m.setAttribute("height",p);A.set(-t,-v,t,v)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(ka,ea){var ua,sa,aa,fa,la,Fa,ia,ga;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;j=k.projectScene(ka,ea,this.sortElements);wa=za=0;if(D=ka.lights.length>0){ia=ka.lights;L.setRGB(0,0,0);oa.setRGB(0,0,0);ja.setRGB(0,0,0);ua=0;for(sa=ia.length;ua< -sa;ua++){aa=ia[ua];fa=aa.color;if(aa instanceof THREE.AmbientLight){L.r+=fa.r;L.g+=fa.g;L.b+=fa.b}else if(aa instanceof THREE.DirectionalLight){oa.r+=fa.r;oa.g+=fa.g;oa.b+=fa.b}else if(aa instanceof THREE.PointLight){ja.r+=fa.r;ja.g+=fa.g;ja.b+=fa.b}}}ua=0;for(sa=j.length;ua=0&&va>=0&&ja>=0&&qa>=0)return!0;else if(da<0&&va<0||ja<0&&qa<0)return!1;else{if(da<0)oa=Math.max(oa,da/(da-va));else va<0&&(Da=Math.min(Da,da/(da-va)));if(ja<0)oa=Math.max(oa,ja/(ja-qa));else qa<0&&(Da=Math.min(Da,ja/(ja-qa)));if(Dada&&j.positionScreen.z0&&R.z<1){Ja=C[V]=C[V]||new THREE.RenderableParticle;V++;E=Ja;E.x=R.x/R.w;E.y=R.y/R.w;E.z=R.z;E.rotation=ga.rotation.z;E.scale.x=ga.scale.x*Math.abs(E.x-(R.x+e.projectionMatrix.n11)/(R.w+e.projectionMatrix.n14));E.scale.y=ga.scale.y*Math.abs(E.y-(R.y+e.projectionMatrix.n22)/(R.w+e.projectionMatrix.n24));E.materials=ga.materials;Da.push(E)}}}}oa&&Da.sort(d);return Da}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,p,o,t,y,u,B,A;b=d.projectScene(j,k);m=0;for(p=b.length;m>1;Ia=xa.height>>1;ha=na.scale.x*p;sa=na.scale.y*o;$=ha*W;ta=sa*Ia;z.set(U.x-$,U.y-ta,U.x+$,U.y+ +ta);if(x.instersects(z)){t.save();t.translate(U.x,U.y);t.rotate(-na.rotation);t.scale(ha,-sa);t.translate(-W,-Ia);t.drawImage(xa,0,0);t.restore()}}}else if(ha instanceof THREE.ParticleCanvasMaterial){$=na.scale.x*p;ta=na.scale.y*o;z.set(U.x-$,U.y-ta,U.x+$,U.y+ta);if(x.instersects(z)){c(ha.color.__styleString);sa=ha.color.__styleString;if(E!=sa)t.fillStyle=E=sa;t.save();t.translate(U.x,U.y);t.rotate(-na.rotation);t.scale($,ta);ha.program(t);t.restore()}}}function F(U,na,ha,$){b($.opacity);d($.blending); +t.beginPath();t.moveTo(U.positionScreen.x,U.positionScreen.y);t.lineTo(na.positionScreen.x,na.positionScreen.y);t.closePath();if($ instanceof THREE.LineBasicMaterial){ma.__styleString=$.color.__styleString;U=$.linewidth;if(V!=U)t.lineWidth=V=U;U=$.linecap;if(C!=U)t.lineCap=C=U;U=$.linejoin;if(X!=U)t.lineJoin=X=U;c(ma.__styleString);t.stroke();z.inflate($.linewidth*2)}}function aa(U,na,ha,$,ta,sa,xa,W,Ia){f.data.vertices+=3;f.data.faces++;b(W.opacity);d(W.blending);ea=U.positionScreen.x;e=U.positionScreen.y; +oa=na.positionScreen.x;Da=na.positionScreen.y;da=ha.positionScreen.x;va=ha.positionScreen.y;ab(ea,e,oa,Da,da,va);if(W instanceof THREE.MeshBasicMaterial)if(W.map){if(W.map.mapping instanceof THREE.UVMapping){O=xa.uvs[0];cb(ea,e,oa,Da,da,va,W.map.image,O[$].u,O[$].v,O[ta].u,O[ta].v,O[sa].u,O[sa].v)}}else if(W.envMap){if(W.envMap.mapping instanceof THREE.SphericalReflectionMapping){U=ua.matrixWorldInverse;I.copy(xa.vertexNormalsWorld[0]);S=(I.x*U.n11+I.y*U.n12+I.z*U.n13)*0.5+0.5;M=-(I.x*U.n21+I.y*U.n22+ +I.z*U.n23)*0.5+0.5;I.copy(xa.vertexNormalsWorld[1]);Aa=(I.x*U.n11+I.y*U.n12+I.z*U.n13)*0.5+0.5;La=-(I.x*U.n21+I.y*U.n22+I.z*U.n23)*0.5+0.5;I.copy(xa.vertexNormalsWorld[2]);n=(I.x*U.n11+I.y*U.n12+I.z*U.n13)*0.5+0.5;D=-(I.x*U.n21+I.y*U.n22+I.z*U.n23)*0.5+0.5;cb(ea,e,oa,Da,da,va,W.envMap.image,S,M,Aa,La,n,D)}}else W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){if(W.map.mapping instanceof +THREE.UVMapping){O=xa.uvs[0];cb(ea,e,oa,Da,da,va,W.map.image,O[$].u,O[$].v,O[ta].u,O[ta].v,O[sa].u,O[sa].v)}d(THREE.SubtractiveBlending)}if(N)if(!W.wireframe&&W.shading==THREE.SmoothShading&&xa.vertexNormalsWorld.length==3){Fa.r=ia.r=ga.r=G.r;Fa.g=ia.g=ga.g=G.g;Fa.b=ia.b=ga.b=G.b;za(Ia,xa.v1.positionWorld,xa.vertexNormalsWorld[0],Fa);za(Ia,xa.v2.positionWorld,xa.vertexNormalsWorld[1],ia);za(Ia,xa.v3.positionWorld,xa.vertexNormalsWorld[2],ga);Ja.r=(ia.r+ga.r)*0.5;Ja.g=(ia.g+ga.g)*0.5;Ja.b=(ia.b+ga.b)* +0.5;Ta=hb(Fa,ia,ga,Ja);cb(ea,e,oa,Da,da,va,Ta,0,0,1,0,0,1)}else{J.r=G.r;J.g=G.g;J.b=G.b;za(Ia,xa.centroidWorld,xa.normalWorld,J);ma.r=W.color.r*J.r;ma.g=W.color.g*J.g;ma.b=W.color.b*J.b;ma.updateStyleString();W.wireframe?Oa(ma.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(ma.__styleString)}else W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){Xa= +ua.near;Za=ua.far;Fa.r=Fa.g=Fa.b=1-Wa(U.positionScreen.z,Xa,Za);ia.r=ia.g=ia.b=1-Wa(na.positionScreen.z,Xa,Za);ga.r=ga.g=ga.b=1-Wa(ha.positionScreen.z,Xa,Za);Ja.r=(ia.r+ga.r)*0.5;Ja.g=(ia.g+ga.g)*0.5;Ja.b=(ia.b+ga.b)*0.5;Ta=hb(Fa,ia,ga,Ja);cb(ea,e,oa,Da,da,va,Ta,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){ma.r=$a(xa.normalWorld.x);ma.g=$a(xa.normalWorld.y);ma.b=$a(xa.normalWorld.z);ma.updateStyleString();W.wireframe?Oa(ma.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin): +Qa(ma.__styleString)}}function v(U,na,ha,$,ta,sa,xa,W,Ia){f.data.vertices+=4;f.data.faces++;b(W.opacity);d(W.blending);if(W.map||W.envMap){aa(U,na,$,0,1,3,xa,W,Ia);aa(ta,ha,sa,1,2,3,xa,W,Ia)}else{ea=U.positionScreen.x;e=U.positionScreen.y;oa=na.positionScreen.x;Da=na.positionScreen.y;da=ha.positionScreen.x;va=ha.positionScreen.y;ja=$.positionScreen.x;qa=$.positionScreen.y;pa=ta.positionScreen.x;wa=ta.positionScreen.y;fa=sa.positionScreen.x;ka=sa.positionScreen.y;if(W instanceof THREE.MeshBasicMaterial){fb(ea, +e,oa,Da,da,va,ja,qa);W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString)}else if(W instanceof THREE.MeshLambertMaterial)if(N)if(!W.wireframe&&W.shading==THREE.SmoothShading&&xa.vertexNormalsWorld.length==4){Fa.r=ia.r=ga.r=Ja.r=G.r;Fa.g=ia.g=ga.g=Ja.g=G.g;Fa.b=ia.b=ga.b=Ja.b=G.b;za(Ia,xa.v1.positionWorld,xa.vertexNormalsWorld[0],Fa);za(Ia,xa.v2.positionWorld,xa.vertexNormalsWorld[1],ia);za(Ia,xa.v4.positionWorld,xa.vertexNormalsWorld[3], +ga);za(Ia,xa.v3.positionWorld,xa.vertexNormalsWorld[2],Ja);Ta=hb(Fa,ia,ga,Ja);ab(ea,e,oa,Da,ja,qa);cb(ea,e,oa,Da,ja,qa,Ta,0,0,1,0,0,1);ab(pa,wa,da,va,fa,ka);cb(pa,wa,da,va,fa,ka,Ta,1,0,1,1,0,1)}else{J.r=G.r;J.g=G.g;J.b=G.b;za(Ia,xa.centroidWorld,xa.normalWorld,J);ma.r=W.color.r*J.r;ma.g=W.color.g*J.g;ma.b=W.color.b*J.b;ma.updateStyleString();fb(ea,e,oa,Da,da,va,ja,qa);W.wireframe?Oa(ma.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(ma.__styleString)}else{fb(ea,e,oa, +Da,da,va,ja,qa);W.wireframe?Oa(W.color.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(W.color.__styleString)}else if(W instanceof THREE.MeshNormalMaterial){ma.r=$a(xa.normalWorld.x);ma.g=$a(xa.normalWorld.y);ma.b=$a(xa.normalWorld.z);ma.updateStyleString();fb(ea,e,oa,Da,da,va,ja,qa);W.wireframe?Oa(ma.__styleString,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):Qa(ma.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){Xa=ua.near;Za=ua.far;Fa.r= +Fa.g=Fa.b=1-Wa(U.positionScreen.z,Xa,Za);ia.r=ia.g=ia.b=1-Wa(na.positionScreen.z,Xa,Za);ga.r=ga.g=ga.b=1-Wa($.positionScreen.z,Xa,Za);Ja.r=Ja.g=Ja.b=1-Wa(ha.positionScreen.z,Xa,Za);Ta=hb(Fa,ia,ga,Ja);ab(ea,e,oa,Da,ja,qa);cb(ea,e,oa,Da,ja,qa,Ta,0,0,1,0,0,1);ab(pa,wa,da,va,fa,ka);cb(pa,wa,da,va,fa,ka,Ta,1,0,1,1,0,1)}}}function ab(U,na,ha,$,ta,sa){t.beginPath();t.moveTo(U,na);t.lineTo(ha,$);t.lineTo(ta,sa);t.lineTo(U,na);t.closePath()}function fb(U,na,ha,$,ta,sa,xa,W){t.beginPath();t.moveTo(U,na);t.lineTo(ha, +$);t.lineTo(ta,sa);t.lineTo(xa,W);t.lineTo(U,na);t.closePath()}function Oa(U,na,ha,$){if(V!=na)t.lineWidth=V=na;if(C!=ha)t.lineCap=C=ha;if(X!=$)t.lineJoin=X=$;c(U);t.stroke();z.inflate(na*2)}function Qa(U){if(E!=U)t.fillStyle=E=U;t.fill()}function cb(U,na,ha,$,ta,sa,xa,W,Ia,Ya,eb,Sa,kb){var gb,db;gb=xa.width-1;db=xa.height-1;W*=gb;Ia*=db;Ya*=gb;eb*=db;Sa*=gb;kb*=db;ha-=U;$-=na;ta-=U;sa-=na;Ya-=W;eb-=Ia;Sa-=W;kb-=Ia;gb=Ya*kb-Sa*eb;if(gb!=0){db=1/gb;gb=(kb*ha-eb*ta)*db;eb=(kb*$-eb*sa)*db;ha=(Ya*ta- +Sa*ha)*db;$=(Ya*sa-Sa*$)*db;U=U-gb*W-ha*Ia;na=na-eb*W-$*Ia;t.save();t.transform(gb,eb,ha,$,U,na);t.clip();t.drawImage(xa,0,0);t.restore()}}function hb(U,na,ha,$){var ta=~~(U.r*255),sa=~~(U.g*255);U=~~(U.b*255);var xa=~~(na.r*255),W=~~(na.g*255);na=~~(na.b*255);var Ia=~~(ha.r*255),Ya=~~(ha.g*255);ha=~~(ha.b*255);var eb=~~($.r*255),Sa=~~($.g*255);$=~~($.b*255);ra[0]=ta<0?0:ta>255?255:ta;ra[1]=sa<0?0:sa>255?255:sa;ra[2]=U<0?0:U>255?255:U;ra[4]=xa<0?0:xa>255?255:xa;ra[5]=W<0?0:W>255?255:W;ra[6]=na<0? +0:na>255?255:na;ra[8]=Ia<0?0:Ia>255?255:Ia;ra[9]=Ya<0?0:Ya>255?255:Ya;ra[10]=ha<0?0:ha>255?255:ha;ra[12]=eb<0?0:eb>255?255:eb;ra[13]=Sa<0?0:Sa>255?255:Sa;ra[14]=$<0?0:$>255?255:$;Z.putImageData(Y,0,0);Ca.drawImage(K,0,0);return Ka}function Wa(U,na,ha){U=(U-na)/(ha-na);return U*U*(3-2*U)}function $a(U){U=(U+1)*0.5;return U<0?0:U>1?1:U}function Ma(U,na){var ha=na.x-U.x,$=na.y-U.y,ta=1/Math.sqrt(ha*ha+$*$);ha*=ta;$*=ta;na.x+=ha;na.y+=$;U.x-=ha;U.y-=$}var bb,Va,L,Na,Ra,ib,jb,Pa;this.autoClear?this.clear(): +t.setTransform(1,0,0,-1,p,o);f.data.vertices=0;f.data.faces=0;g=h.projectScene(Ga,ua,this.sortElements);(N=Ga.lights.length>0)&&Ea(Ga);bb=0;for(Va=g.length;bb0){pa.r+=ka.color.r*ma;pa.g+=ka.color.g*ma;pa.b+=ka.color.b*ma}}else if(ka instanceof THREE.PointLight){Ba.sub(ka.position,qa.centroidWorld);Ba.normalize();ma=qa.normalWorld.dot(Ba)*ka.intensity;if(ma>0){pa.r+=ka.color.r*ma;pa.g+=ka.color.g*ma;pa.b+=ka.color.b*ma}}}}function d(ja,qa, +pa,wa,fa,ka){h.data.vertices+=3;h.data.faces++;oa=f(Da++);oa.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+qa.positionScreen.x+" "+qa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(fa instanceof THREE.MeshBasicMaterial)X.__styleString=fa.color.__styleString;else if(fa instanceof THREE.MeshLambertMaterial)if(C){R.r=P.r;R.g=P.g;R.b=P.b;b(ka,wa,R);X.r=fa.color.r*R.r;X.g=fa.color.g*R.g;X.b=fa.color.b*R.b;X.updateStyleString()}else X.__styleString= +fa.color.__styleString;else if(fa instanceof THREE.MeshDepthMaterial){ca=1-fa.__2near/(fa.__farPlusNear-wa.z*fa.__farMinusNear);X.setRGB(ca,ca,ca)}else fa instanceof THREE.MeshNormalMaterial&&X.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));fa.wireframe?oa.setAttribute("style","fill: none; stroke: "+X.__styleString+"; stroke-width: "+fa.wireframeLinewidth+"; stroke-opacity: "+fa.opacity+"; stroke-linecap: "+fa.wireframeLinecap+"; stroke-linejoin: "+fa.wireframeLinejoin):oa.setAttribute("style", +"fill: "+X.__styleString+"; fill-opacity: "+fa.opacity);m.appendChild(oa)}function c(ja,qa,pa,wa,fa,ka,ma){h.data.vertices+=4;h.data.faces++;oa=f(Da++);oa.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+qa.positionScreen.x+" "+qa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(ka instanceof THREE.MeshBasicMaterial)X.__styleString=ka.color.__styleString;else if(ka instanceof THREE.MeshLambertMaterial)if(C){R.r= +P.r;R.g=P.g;R.b=P.b;b(ma,fa,R);X.r=ka.color.r*R.r;X.g=ka.color.g*R.g;X.b=ka.color.b*R.b;X.updateStyleString()}else X.__styleString=ka.color.__styleString;else if(ka instanceof THREE.MeshDepthMaterial){ca=1-ka.__2near/(ka.__farPlusNear-fa.z*ka.__farMinusNear);X.setRGB(ca,ca,ca)}else ka instanceof THREE.MeshNormalMaterial&&X.setRGB(g(fa.normalWorld.x),g(fa.normalWorld.y),g(fa.normalWorld.z));ka.wireframe?oa.setAttribute("style","fill: none; stroke: "+X.__styleString+"; stroke-width: "+ka.wireframeLinewidth+ +"; stroke-opacity: "+ka.opacity+"; stroke-linecap: "+ka.wireframeLinecap+"; stroke-linejoin: "+ka.wireframeLinejoin):oa.setAttribute("style","fill: "+X.__styleString+"; fill-opacity: "+ka.opacity);m.appendChild(oa)}function f(ja){if(ea[ja]==null){ea[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");va==0&&ea[ja].setAttribute("shape-rendering","crispEdges")}return ea[ja]}function g(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var h=this,j=null,k=new THREE.Projector, +m=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,o,t,y,u,B,A,Q,E=new THREE.Rectangle,V=new THREE.Rectangle,C=!1,X=new THREE.Color(16777215),R=new THREE.Color(16777215),P=new THREE.Color(0),ya=new THREE.Color(0),la=new THREE.Color(0),ca,Ba=new THREE.Vector3,ea=[],e=[],oa,Da,da,va=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(ja){switch(ja){case "high":va=1;break;case "low":va=0}};this.setSize=function(ja, +qa){p=ja;o=qa;t=p/2;y=o/2;m.setAttribute("viewBox",-t+" "+-y+" "+p+" "+o);m.setAttribute("width",p);m.setAttribute("height",o);E.set(-t,-y,t,y)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(ja,qa){var pa,wa,fa,ka,ma,Fa,ia,ga;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;j=k.projectScene(ja,qa,this.sortElements);da=Da=0;if(C=ja.lights.length>0){ia=ja.lights;P.setRGB(0,0,0);ya.setRGB(0,0,0);la.setRGB(0,0,0);pa=0;for(wa=ia.length;pa< +wa;pa++){fa=ia[pa];ka=fa.color;if(fa instanceof THREE.AmbientLight){P.r+=ka.r;P.g+=ka.g;P.b+=ka.b}else if(fa instanceof THREE.DirectionalLight){ya.r+=ka.r;ya.g+=ka.g;ya.b+=ka.b}else if(fa instanceof THREE.PointLight){la.r+=ka.r;la.g+=ka.g;la.b+=ka.b}}}pa=0;for(wa=j.length;paH){I=M;H=T[I]}e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[I]);e.vertexAttribPointer(C["morphTarget"+y],3,e.FLOAT,!1,0,0); -P.__webglMorphTargetInfluences[y]=H;G[I]=1;H=-1;y++}}e.uniform1fv(x.program.uniforms.morphTargetInfluences,P.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}if(z.__webglCustomAttributes)for(K in z.__webglCustomAttributes)if(n[K]>=0){C=z.__webglCustomAttributes[K];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(n[K],C.size,e.FLOAT,!1,0,0)}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglColorBuffer); +THREE.WebGLRenderer=function(b){function d(n,D,x){var w,z,N,J=n.vertices,G=J.length,T=n.colors,H=T.length,I=n.__vertexArray,K=n.__colorArray,Z=n.__sortArray,Y=n.__dirtyVertices,ra=n.__dirtyColors;if(x.sortParticles){Ja.multiplySelf(x.matrixWorld);for(w=0;wH){I=K;H=T[I]}e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[I]);e.vertexAttribPointer(D["morphTarget"+x],3,e.FLOAT,!1,0,0); +N.__webglMorphTargetInfluences[x]=H;G[I]=1;H=-1;x++}}e.uniform1fv(w.program.uniforms.morphTargetInfluences,N.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}if(z.__webglCustomAttributes)for(J in z.__webglCustomAttributes)if(n[J]>=0){D=z.__webglCustomAttributes[J];e.bindBuffer(e.ARRAY_BUFFER,D.buffer);e.vertexAttribPointer(n[J],D.size,e.FLOAT,!1,0,0)}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglColorBuffer); e.vertexAttribPointer(n.color,3,e.FLOAT,!1,0,0)}if(n.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,!1,0,0)}if(n.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglTangentBuffer);e.vertexAttribPointer(n.tangent,4,e.FLOAT,!1,0,0)}if(n.uv>=0)if(z.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,z.__webglUVBuffer);e.vertexAttribPointer(n.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv)}else e.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(z.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER, -z.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(x.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex, -4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(P instanceof THREE.Mesh){if(x.wireframe){e.lineWidth(x.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglLineBuffer);e.drawElements(e.LINES,z.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglFaceBuffer);e.drawElements(e.TRIANGLES,z.__webglFaceCount,e.UNSIGNED_SHORT,0)}X.data.vertices+=z.__webglFaceCount;X.data.faces+= -z.__webglFaceCount/3}else if(P instanceof THREE.Line){P=P.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(x.linewidth);e.drawArrays(P,0,z.__webglLineCount)}else if(P instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,z.__webglParticleCount);else P instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,z.__webglVertexCount)}}function g(n,C,y){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER, -n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(C.attributes.position);e.vertexAttribPointer(C.attributes.position,3,e.FLOAT,!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(y==THREE.FlatShading){var x,z,P,K,G,T,H,I,M,$,Z=n.count*3;for($=0;$0&&Ka[0]0&&Ka[1]0.0010&&G.scale>0.0010){pa[0]=G.x;pa[1]=G.y;pa[2]=G.z;$=G.size* -G.scale/ia;Z[0]=$*H;Z[1]=$;e.uniform3fv(Ca.screenPosition,pa);e.uniform2fv(Ca.scale,Z);e.uniform1f(Ca.rotation,G.rotation);e.uniform1f(Ca.opacity,G.opacity);Y(G.blending);L(G.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ka)}function V(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function A(n){var C, -y,x,z,P;if(n instanceof THREE.Mesh){y=n.geometry;for(C in y.geometryGroups){x=y.geometryGroups[C];P=!1;for(z in x.__webglCustomAttributes)if(x.__webglCustomAttributes[z].needsUpdate){P=!0;break}if(y.__dirtyVertices||y.__dirtyMorphTargets||y.__dirtyElements||y.__dirtyUvs||y.__dirtyNormals||y.__dirtyColors||y.__dirtyTangents||P){P=e.DYNAMIC_DRAW;var K=void 0,G=void 0,T=void 0,H=void 0;T=void 0;var I=void 0,M=void 0,$=void 0,Z=void 0,pa=void 0,Ka=void 0,Ca=void 0,Ha=void 0,Ga=void 0,xa=void 0,Ea=void 0, -Aa=void 0,Ua=void 0;M=void 0;$=void 0;H=void 0;Z=void 0;H=void 0;var E=void 0,da=void 0;M=void 0;E=void 0;da=void 0;var w=void 0,ab=void 0;E=void 0;da=void 0;w=void 0;ab=void 0;E=void 0;da=void 0;w=void 0;ab=void 0;E=void 0;da=void 0;w=void 0;H=void 0;Z=void 0;I=void 0;T=void 0;T=void 0;E=void 0;da=void 0;w=void 0;var fb=void 0,Oa=0,Qa=0,cb=0,hb=0,Wa=0,$a=0,Ma=0,bb=0,Va=0,N=0,Na=0;da=E=0;var Ra=x.__vertexArray,ib=x.__uvArray,jb=x.__uv2Array,Pa=x.__normalArray,U=x.__tangentArray,ma=x.__colorArray, -ha=x.__skinVertexAArray,ca=x.__skinVertexBArray,ta=x.__skinIndexArray,qa=x.__skinWeightArray,ya=x.__morphTargetsArrays,W=x.__webglCustomAttributes;w=void 0;var Ia=x.__faceArray,Ya=x.__lineArray,eb=x.__needsSmoothNormals;Ka=x.__vertexColorType;pa=x.__uvType;Ca=x.__normalType;var Sa=n.geometry,kb=Sa.__dirtyVertices,gb=Sa.__dirtyElements,db=Sa.__dirtyUvs,rb=Sa.__dirtyNormals,sb=Sa.__dirtyTangents,tb=Sa.__dirtyColors,ub=Sa.__dirtyMorphTargets,nb=Sa.vertices,vb=x.faces,yb=Sa.faces,wb=Sa.faceVertexUvs[0], -xb=Sa.faceVertexUvs[1],ob=Sa.skinVerticesA,pb=Sa.skinVerticesB,qb=Sa.skinIndices,lb=Sa.skinWeights,mb=n instanceof THREE.ShadowVolume?Sa.edgeFaces:undefined;morphTargets=Sa.morphTargets;if(W)for(fb in W){W[fb].offset=0;W[fb].offsetSrc=0}K=0;for(G=vb.length;K0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ma,P)}if(rb){e.bindBuffer(e.ARRAY_BUFFER,x.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,P)}if(sb&&Sa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,x.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,U,P)}if(db&&cb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,P)}if(db&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER, -jb,P)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ia,P);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ya,P)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,ha,P);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ca,P);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ta,P);e.bindBuffer(e.ARRAY_BUFFER, -x.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,qa,P)}}}y.__dirtyVertices=!1;y.__dirtyMorphTargets=!1;y.__dirtyElements=!1;y.__dirtyUvs=!1;y.__dirtyNormals=!1;y.__dirtyTangents=!1;y.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){y=n.geometry;if(y.__dirtyVertices||y.__dirtyColors){n=y;C=e.DYNAMIC_DRAW;Ka=n.vertices;x=n.colors;Ca=Ka.length;P=x.length;Ha=n.__vertexArray;K=n.__colorArray;Ga=n.__dirtyColors;if(n.__dirtyVertices){for(G=0;G65535){I[T].counter+=1;H=I[T].hash+"_"+I[T].counter;n.geometryGroups[H]==undefined&&(n.geometryGroups[H]={faces:[],materials:G,vertices:0,numMorphTargets:M})}n.geometryGroups[H].faces.push(z);n.geometryGroups[H].vertices+=K}}function D(n,C,y){n.push({buffer:C,object:y,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function Y(n){if(n!=sa){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD); -e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}sa=n}}function J(n,C,y){if((y.width&y.width-1)==0&&(y.height&y.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,va(C.wrapS)); -e.texParameteri(n,e.TEXTURE_WRAP_T,va(C.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,va(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,va(C.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,ra(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ra(C.minFilter))}}function L(n,C){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D, -0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image);n.__webglInit=!0}J(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+C);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function oa(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer= -e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer();n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,va(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,va(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,va(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,va(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,va(n.format),n.width,n.height,0,va(n.format),va(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER, -n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER, -e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,y;if(n){C=n.__webglFramebuffer;y=n.width;n=n.height}else{C=null;y=Fa;n=ia}if(C!=Da){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(fa,la,y,n);Da=C}}function ja(n,C){var y;if(n=="fragment")y=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(y=e.createShader(e.VERTEX_SHADER)); -e.shaderSource(y,C);e.compileShader(y);if(!e.getShaderParameter(y,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(y));console.error(C);return null}return y}function ra(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function va(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT; -case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT; -case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var X=this,e,na=document.createElement("canvas"),za=[],wa=null,Da=null,ka=!0,ea=null,ua=null,sa=null,aa=null,fa=0,la=0,Fa=0,ia=0,ga=[new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ja=new THREE.Matrix4,Xa=new Float32Array(16),Za=new Float32Array(16),Ta=new THREE.Vector4,Q={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined? -b.clearAlpha:0;this.data={vertices:0,faces:0};this.maxMorphTargets=8;this.domElement=na;this.autoClear=!0;this.sortObjects=!0;(function(n,C,y,x){try{if(!(e=na.getContext("experimental-webgl",{antialias:n,stencil:x})))throw"Error creating WebGL context.";}catch(z){console.error(z)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST); -e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r,C.g,C.b,y)})(antialias,clearColor,clearAlpha,stencil);this.context=e;if(stencil){var R={};R.vertices=new Float32Array(12);R.faces=new Uint16Array(6);R.darkness=0.5;R.vertices[0]=-20;R.vertices[1]=-20;R.vertices[2]=-1;R.vertices[3]=20;R.vertices[4]=-20;R.vertices[5]=-1;R.vertices[6]=20;R.vertices[7]=20;R.vertices[8]= --1;R.vertices[9]=-20;R.vertices[10]=20;R.vertices[11]=-1;R.faces[0]=0;R.faces[1]=1;R.faces[2]=2;R.faces[3]=0;R.faces[4]=2;R.faces[5]=3;R.vertexBuffer=e.createBuffer();R.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,R.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,R.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,R.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,R.faces,e.STATIC_DRAW);R.program=e.createProgram();e.attachShader(R.program,ja("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); -e.attachShader(R.program,ja("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(R.program);R.vertexLocation=e.getAttribLocation(R.program,"position");R.projectionLocation=e.getUniformLocation(R.program,"projectionMatrix");R.darknessLocation=e.getUniformLocation(R.program,"darkness")}var O={};O.vertices=new Float32Array(16);O.faces=new Uint16Array(6);b=0;O.vertices[b++]=-1;O.vertices[b++]=-1;O.vertices[b++]=0;O.vertices[b++]=0;O.vertices[b++]=1;O.vertices[b++]=-1;O.vertices[b++]=1;O.vertices[b++]= -0;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=-1;O.vertices[b++]=1;O.vertices[b++]=0;O.vertices[b++]=1;b=0;O.faces[b++]=0;O.faces[b++]=1;O.faces[b++]=2;O.faces[b++]=0;O.faces[b++]=2;O.faces[b++]=3;O.vertexBuffer=e.createBuffer();O.elementBuffer=e.createBuffer();O.tempTexture=e.createTexture();O.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,O.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,O.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, -O.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,O.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,O.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,O.occlusionTexture);e.texImage2D(e.TEXTURE_2D, -0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){O.hasVertexTexture=!1;O.program=e.createProgram();e.attachShader(O.program,ja("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(O.program, -ja("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{O.hasVertexTexture=!0;O.program=e.createProgram();e.attachShader(O.program,ja("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(O.program,ja("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(O.program);O.attributes={};O.uniforms={};O.attributes.vertex=e.getAttribLocation(O.program,"position");O.attributes.uv=e.getAttribLocation(O.program,"UV");O.uniforms.renderType=e.getUniformLocation(O.program, -"renderType");O.uniforms.map=e.getUniformLocation(O.program,"map");O.uniforms.occlusionMap=e.getUniformLocation(O.program,"occlusionMap");O.uniforms.opacity=e.getUniformLocation(O.program,"opacity");O.uniforms.scale=e.getUniformLocation(O.program,"scale");O.uniforms.rotation=e.getUniformLocation(O.program,"rotation");O.uniforms.screenPosition=e.getUniformLocation(O.program,"screenPosition");var Ba=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]= +z.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(w.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex, +4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(N instanceof THREE.Mesh){if(w.wireframe){e.lineWidth(w.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglLineBuffer);e.drawElements(e.LINES,z.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglFaceBuffer);e.drawElements(e.TRIANGLES,z.__webglFaceCount,e.UNSIGNED_SHORT,0)}ea.data.vertices+=z.__webglFaceCount;ea.data.faces+= +z.__webglFaceCount/3}else if(N instanceof THREE.Line){N=N.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(w.linewidth);e.drawArrays(N,0,z.__webglLineCount)}else if(N instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,z.__webglParticleCount);else N instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,z.__webglVertexCount)}}function g(n,D,x){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER, +n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(D.attributes.position);e.vertexAttribPointer(D.attributes.position,3,e.FLOAT,!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(x==THREE.FlatShading){var w,z,N,J,G,T,H,I,K,Z,Y=n.count*3;for(Z=0;Z0&&Ka[0]0&&Ka[1]0.0010&&G.scale>0.0010){ra[0]=G.x;ra[1]=G.y;ra[2]=G.z;Z=G.size* +G.scale/ia;Y[0]=Z*H;Y[1]=Z;e.uniform3fv(Ca.screenPosition,ra);e.uniform2fv(Ca.scale,Y);e.uniform1f(Ca.rotation,G.rotation);e.uniform1f(Ca.opacity,G.opacity);X(G.blending);P(G.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ja)}function Q(n,D){n._modelViewMatrix.multiplyToArray(D.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function E(n){var D, +x,w,z,N;if(n instanceof THREE.Mesh){x=n.geometry;for(D in x.geometryGroups){w=x.geometryGroups[D];N=!1;for(z in w.__webglCustomAttributes)if(w.__webglCustomAttributes[z].needsUpdate){N=!0;break}if(x.__dirtyVertices||x.__dirtyMorphTargets||x.__dirtyElements||x.__dirtyUvs||x.__dirtyNormals||x.__dirtyColors||x.__dirtyTangents||N){N=e.DYNAMIC_DRAW;var J=void 0,G=void 0,T=void 0,H=void 0;T=void 0;var I=void 0,K=void 0,Z=void 0,Y=void 0,ra=void 0,Ka=void 0,Ca=void 0,Ha=void 0,Ga=void 0,ua=void 0,Ea=void 0, +za=void 0,Ua=void 0;K=void 0;Z=void 0;H=void 0;Y=void 0;H=void 0;var F=void 0,aa=void 0;K=void 0;F=void 0;aa=void 0;var v=void 0,ab=void 0;F=void 0;aa=void 0;v=void 0;ab=void 0;F=void 0;aa=void 0;v=void 0;ab=void 0;F=void 0;aa=void 0;v=void 0;H=void 0;Y=void 0;I=void 0;T=void 0;T=void 0;F=void 0;aa=void 0;v=void 0;var fb=void 0,Oa=0,Qa=0,cb=0,hb=0,Wa=0,$a=0,Ma=0,bb=0,Va=0,L=0,Na=0;aa=F=0;var Ra=w.__vertexArray,ib=w.__uvArray,jb=w.__uv2Array,Pa=w.__normalArray,U=w.__tangentArray,na=w.__colorArray, +ha=w.__skinVertexAArray,$=w.__skinVertexBArray,ta=w.__skinIndexArray,sa=w.__skinWeightArray,xa=w.__morphTargetsArrays,W=w.__webglCustomAttributes;v=void 0;var Ia=w.__faceArray,Ya=w.__lineArray,eb=w.__needsSmoothNormals;Ka=w.__vertexColorType;ra=w.__uvType;Ca=w.__normalType;var Sa=n.geometry,kb=Sa.__dirtyVertices,gb=Sa.__dirtyElements,db=Sa.__dirtyUvs,rb=Sa.__dirtyNormals,sb=Sa.__dirtyTangents,tb=Sa.__dirtyColors,ub=Sa.__dirtyMorphTargets,nb=Sa.vertices,vb=w.faces,yb=Sa.faces,wb=Sa.faceVertexUvs[0], +xb=Sa.faceVertexUvs[1],ob=Sa.skinVerticesA,pb=Sa.skinVerticesB,qb=Sa.skinIndices,lb=Sa.skinWeights,mb=n instanceof THREE.ShadowVolume?Sa.edgeFaces:undefined;morphTargets=Sa.morphTargets;if(W)for(fb in W){W[fb].offset=0;W[fb].offsetSrc=0}J=0;for(G=vb.length;J0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,na,N)}if(rb){e.bindBuffer(e.ARRAY_BUFFER,w.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,N)}if(sb&&Sa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,w.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,U,N)}if(db&&cb>0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,N)}if(db&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,jb,N)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, +w.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ia,N);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,w.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ya,N)}if(L>0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,ha,N);e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,$,N);e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ta,N);e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER, +sa,N)}}}x.__dirtyVertices=!1;x.__dirtyMorphTargets=!1;x.__dirtyElements=!1;x.__dirtyUvs=!1;x.__dirtyNormals=!1;x.__dirtyTangents=!1;x.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){x=n.geometry;if(x.__dirtyVertices||x.__dirtyColors){n=x;D=e.DYNAMIC_DRAW;Ka=n.vertices;w=n.colors;Ca=Ka.length;N=w.length;Ha=n.__vertexArray;J=n.__colorArray;Ga=n.__dirtyColors;if(n.__dirtyVertices){for(G=0;G65535){I[T].counter+=1;H=I[T].hash+"_"+I[T].counter;n.geometryGroups[H]==undefined&&(n.geometryGroups[H]={faces:[],materials:G,vertices:0,numMorphTargets:K})}n.geometryGroups[H].faces.push(z);n.geometryGroups[H].vertices+=J}}function C(n,D,x){n.push({buffer:D,object:x,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function X(n){if(n!=wa){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD); +e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}wa=n}}function R(n,D,x){if((x.width&x.width-1)==0&&(x.height&x.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,Ba(D.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,Ba(D.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,Ba(D.magFilter)); +e.texParameteri(n,e.TEXTURE_MIN_FILTER,Ba(D.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,ca(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ca(D.minFilter))}}function P(n,D){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{n.__webglTexture=e.createTexture(); +e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image);n.__webglInit=!0}R(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+D);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function ya(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer(); +n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,Ba(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,Ba(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,Ba(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,Ba(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,Ba(n.format),n.width,n.height,0,Ba(n.format),Ba(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER, +n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER, +n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var D,x;if(n){D=n.__webglFramebuffer;x=n.width;n=n.height}else{D=null;x=Fa;n=ia}if(D!=va){e.bindFramebuffer(e.FRAMEBUFFER,D);e.viewport(ka,ma,x,n);va=D}}function la(n,D){var x;if(n=="fragment")x=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(x=e.createShader(e.VERTEX_SHADER));e.shaderSource(x, +D);e.compileShader(x);if(!e.getShaderParameter(x,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(x));console.error(D);return null}return x}function ca(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function Ba(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST; +case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT; +case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var ea=this,e,oa=document.createElement("canvas"),Da=[],da=null,va=null,ja=!0,qa=null,pa=null,wa=null,fa=null,ka=0,ma=0,Fa=0,ia=0,ga=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4],Ja=new THREE.Matrix4,Xa=new Float32Array(16),Za=new Float32Array(16),Ta=new THREE.Vector4,O={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0, +faces:0};this.maxMorphTargets=8;this.domElement=oa;this.autoClear=!0;this.sortObjects=!0;(function(n,D,x,w){try{if(!(e=oa.getContext("experimental-webgl",{antialias:n,stencil:w})))throw"Error creating WebGL context.";}catch(z){console.error(z)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL); +e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(D.r,D.g,D.b,x)})(antialias,clearColor,clearAlpha,stencil);this.context=e;if(stencil){var S={};S.vertices=new Float32Array(12);S.faces=new Uint16Array(6);S.darkness=0.5;S.vertices[0]=-20;S.vertices[1]=-20;S.vertices[2]=-1;S.vertices[3]=20;S.vertices[4]=-20;S.vertices[5]=-1;S.vertices[6]=20;S.vertices[7]=20;S.vertices[8]=-1;S.vertices[9]= +-20;S.vertices[10]=20;S.vertices[11]=-1;S.faces[0]=0;S.faces[1]=1;S.faces[2]=2;S.faces[3]=0;S.faces[4]=2;S.faces[5]=3;S.vertexBuffer=e.createBuffer();S.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,S.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,S.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,S.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,S.faces,e.STATIC_DRAW);S.program=e.createProgram();e.attachShader(S.program,la("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); +e.attachShader(S.program,la("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(S.program);S.vertexLocation=e.getAttribLocation(S.program,"position");S.projectionLocation=e.getUniformLocation(S.program,"projectionMatrix");S.darknessLocation=e.getUniformLocation(S.program,"darkness")}var M={};M.vertices=new Float32Array(16);M.faces=new Uint16Array(6);b=0;M.vertices[b++]=-1;M.vertices[b++]=-1;M.vertices[b++]=0;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]= +0;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;b=0;M.faces[b++]=0;M.faces[b++]=1;M.faces[b++]=2;M.faces[b++]=0;M.faces[b++]=2;M.faces[b++]=3;M.vertexBuffer=e.createBuffer();M.elementBuffer=e.createBuffer();M.tempTexture=e.createTexture();M.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,M.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,M.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, +M.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,M.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,M.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,M.occlusionTexture);e.texImage2D(e.TEXTURE_2D, +0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){M.hasVertexTexture=!1;M.program=e.createProgram();e.attachShader(M.program,la("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(M.program, +la("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{M.hasVertexTexture=!0;M.program=e.createProgram();e.attachShader(M.program,la("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(M.program,la("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(M.program);M.attributes={};M.uniforms={};M.attributes.vertex=e.getAttribLocation(M.program,"position");M.attributes.uv=e.getAttribLocation(M.program,"UV");M.uniforms.renderType=e.getUniformLocation(M.program, +"renderType");M.uniforms.map=e.getUniformLocation(M.program,"map");M.uniforms.occlusionMap=e.getUniformLocation(M.program,"occlusionMap");M.uniforms.opacity=e.getUniformLocation(M.program,"opacity");M.uniforms.scale=e.getUniformLocation(M.program,"scale");M.uniforms.rotation=e.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition=e.getUniformLocation(M.program,"screenPosition");var Aa=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]= -1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer= -e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,ja("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,ja("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program); +e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,la("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,la("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program); _sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment= e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix= -e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var La=!1;this.setSize=function(n,C){na.width=n;na.height=C;this.setViewport(0,0,na.width,na.height)};this.setViewport=function(n,C,y,x){fa=n;la=C;Fa=y;ia=x;e.viewport(fa,la,Fa,ia)};this.setScissor=function(n,C,y,x){e.scissor(n,C,y,x)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){ka= -n;e.depthMask(n)};this.setClearColorHex=function(n,C){var y=new THREE.Color(n);e.clearColor(y.r,y.g,y.b,C)};this.setClearColor=function(n,C){e.clearColor(n.r,n.g,n.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){R.darkness=n};this.getContext=function(){return e};this.initMaterial=function(n,C,y,x){var z,P,K;if(n instanceof THREE.MeshDepthMaterial)K="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)K= -"shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)K="normal";else if(n instanceof THREE.MeshBasicMaterial)K="basic";else if(n instanceof THREE.MeshLambertMaterial)K="lambert";else if(n instanceof THREE.MeshPhongMaterial)K="phong";else if(n instanceof THREE.LineBasicMaterial)K="basic";else n instanceof THREE.ParticleBasicMaterial&&(K="particle_basic");if(K){var G=THREE.ShaderLib[K];n.uniforms=THREE.UniformsUtils.clone(G.uniforms);n.vertexShader=G.vertexShader;n.fragmentShader=G.fragmentShader}var T, -H,I;T=I=G=0;for(H=C.length;T0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,"#define MAX_BONES "+y.maxBones,y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?"#define USE_LIGHTMAP": -"",y.vertexColors?"#define USE_COLOR":"",y.skinning?"#define USE_SKINNING":"",y.morphTargets?"#define USE_MORPHTARGETS":"",y.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); -e.attachShader($,ja("fragment",prefix_fragment+T));e.attachShader($,ja("vertex",prefix_vertex+H));e.linkProgram($);e.getProgramParameter($,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter($,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");$.uniforms={};$.attributes={};var Z;T=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(Z in G)T.push(Z); -Z=T;G=0;for(T=Z.length;G=0&&e.enableVertexAttribArray(M.color);M.normal>= -0&&e.enableVertexAttribArray(M.normal);M.tangent>=0&&e.enableVertexAttribArray(M.tangent);if(n.skinning&&M.skinVertexA>=0&&M.skinVertexB>=0&&M.skinIndex>=0&&M.skinWeight>=0){e.enableVertexAttribArray(M.skinVertexA);e.enableVertexAttribArray(M.skinVertexB);e.enableVertexAttribArray(M.skinIndex);e.enableVertexAttribArray(M.skinWeight)}for(z in n.attributes)M[z]>=0&&e.enableVertexAttribArray(M[z]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(M.morphTarget0>=0){e.enableVertexAttribArray(M.morphTarget0); -n.numSupportedMorphTargets++}if(M.morphTarget1>=0){e.enableVertexAttribArray(M.morphTarget1);n.numSupportedMorphTargets++}if(M.morphTarget2>=0){e.enableVertexAttribArray(M.morphTarget2);n.numSupportedMorphTargets++}if(M.morphTarget3>=0){e.enableVertexAttribArray(M.morphTarget3);n.numSupportedMorphTargets++}if(M.morphTarget4>=0){e.enableVertexAttribArray(M.morphTarget4);n.numSupportedMorphTargets++}if(M.morphTarget5>=0){e.enableVertexAttribArray(M.morphTarget5);n.numSupportedMorphTargets++}if(M.morphTarget6>= -0){e.enableVertexAttribArray(M.morphTarget6);n.numSupportedMorphTargets++}if(M.morphTarget7>=0){e.enableVertexAttribArray(M.morphTarget7);n.numSupportedMorphTargets++}x.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(z=this.maxMorphTargets;n0||$.faceVertexUvs.length>0)K.__uvArray=new Float32Array(T*2);if($.faceUvs.length>1||$.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(T*2)}if(G.geometry.skinWeights.length&&G.geometry.skinIndices.length){K.__skinVertexAArray= -new Float32Array(T*4);K.__skinVertexBArray=new Float32Array(T*4);K.__skinIndexArray=new Float32Array(T*4);K.__skinWeightArray=new Float32Array(T*4)}K.__faceArray=new Uint16Array(pa*3+(G.geometry.edgeFaces?G.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(Ka*2);if(K.numMorphTargets){K.__morphTargetsArrays=[];$=0;for(Z=K.numMorphTargets;$=0;z--){x=y.__webglObjects[z].object;if(C==x){y.__webglObjects.splice(z,1);break}}else if(C instanceof THREE.Sprite)for(z=y.__webglSprites.length-1;z>=0;z--){x=y.__webglSprites[z];if(C==x){y.__webglSprites.splice(z,1);break}}n.__objectsRemoved.splice(0,1)}C=0;for(y=n.__webglObjects.length;C0}}; +e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var La=!1;this.setSize=function(n,D){oa.width=n;oa.height=D;this.setViewport(0,0,oa.width,oa.height)};this.setViewport=function(n,D,x,w){ka=n;ma=D;Fa=x;ia=w;e.viewport(ka,ma,Fa,ia)};this.setScissor=function(n,D,x,w){e.scissor(n,D,x,w)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){ja= +n;e.depthMask(n)};this.setClearColorHex=function(n,D){var x=new THREE.Color(n);e.clearColor(x.r,x.g,x.b,D)};this.setClearColor=function(n,D){e.clearColor(n.r,n.g,n.b,D)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){S.darkness=n};this.getContext=function(){return e};this.initMaterial=function(n,D,x,w){var z,N,J;if(n instanceof THREE.MeshDepthMaterial)J="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)J= +"shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)J="normal";else if(n instanceof THREE.MeshBasicMaterial)J="basic";else if(n instanceof THREE.MeshLambertMaterial)J="lambert";else if(n instanceof THREE.MeshPhongMaterial)J="phong";else if(n instanceof THREE.LineBasicMaterial)J="basic";else n instanceof THREE.ParticleBasicMaterial&&(J="particle_basic");if(J){var G=THREE.ShaderLib[J];n.uniforms=THREE.UniformsUtils.clone(G.uniforms);n.vertexShader=G.vertexShader;n.fragmentShader=G.fragmentShader}var T, +H,I;T=I=G=0;for(H=D.length;T0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,"#define MAX_BONES "+x.maxBones,x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP": +"",x.vertexColors?"#define USE_COLOR":"",x.skinning?"#define USE_SKINNING":"",x.morphTargets?"#define USE_MORPHTARGETS":"",x.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); +e.attachShader(Z,la("fragment",prefix_fragment+T));e.attachShader(Z,la("vertex",prefix_vertex+H));e.linkProgram(Z);e.getProgramParameter(Z,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(Z,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");Z.uniforms={};Z.attributes={};var Y;T=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(Y in G)T.push(Y); +Y=T;G=0;for(T=Y.length;G=0&&e.enableVertexAttribArray(K.color);K.normal>= +0&&e.enableVertexAttribArray(K.normal);K.tangent>=0&&e.enableVertexAttribArray(K.tangent);if(n.skinning&&K.skinVertexA>=0&&K.skinVertexB>=0&&K.skinIndex>=0&&K.skinWeight>=0){e.enableVertexAttribArray(K.skinVertexA);e.enableVertexAttribArray(K.skinVertexB);e.enableVertexAttribArray(K.skinIndex);e.enableVertexAttribArray(K.skinWeight)}for(z in n.attributes)K[z]>=0&&e.enableVertexAttribArray(K[z]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(K.morphTarget0>=0){e.enableVertexAttribArray(K.morphTarget0); +n.numSupportedMorphTargets++}if(K.morphTarget1>=0){e.enableVertexAttribArray(K.morphTarget1);n.numSupportedMorphTargets++}if(K.morphTarget2>=0){e.enableVertexAttribArray(K.morphTarget2);n.numSupportedMorphTargets++}if(K.morphTarget3>=0){e.enableVertexAttribArray(K.morphTarget3);n.numSupportedMorphTargets++}if(K.morphTarget4>=0){e.enableVertexAttribArray(K.morphTarget4);n.numSupportedMorphTargets++}if(K.morphTarget5>=0){e.enableVertexAttribArray(K.morphTarget5);n.numSupportedMorphTargets++}if(K.morphTarget6>= +0){e.enableVertexAttribArray(K.morphTarget6);n.numSupportedMorphTargets++}if(K.morphTarget7>=0){e.enableVertexAttribArray(K.morphTarget7);n.numSupportedMorphTargets++}w.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(z=this.maxMorphTargets;n0||Z.faceVertexUvs.length>0)J.__uvArray=new Float32Array(T*2);if(Z.faceUvs.length>1||Z.faceVertexUvs.length>1)J.__uv2Array=new Float32Array(T*2)}if(G.geometry.skinWeights.length&&G.geometry.skinIndices.length){J.__skinVertexAArray= +new Float32Array(T*4);J.__skinVertexBArray=new Float32Array(T*4);J.__skinIndexArray=new Float32Array(T*4);J.__skinWeightArray=new Float32Array(T*4)}J.__faceArray=new Uint16Array(ra*3+(G.geometry.edgeFaces?G.geometry.edgeFaces.length*6:0));J.__lineArray=new Uint16Array(Ka*2);if(J.numMorphTargets){J.__morphTargetsArrays=[];Z=0;for(Y=J.numMorphTargets;Z=0;z--){w=x.__webglObjects[z].object;if(D==w){x.__webglObjects.splice(z,1);break}}else if(D instanceof THREE.Sprite)for(z=x.__webglSprites.length-1;z>=0;z--){w=x.__webglSprites[z];if(D==w){x.__webglSprites.splice(z,1);break}}n.__objectsRemoved.splice(0,1)}D=0;for(x=n.__webglObjects.length;D0}}; THREE.WebGLRenderTarget=function(b,d,c){this.width=b;this.height=d;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBAFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!== undefined?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==undefined?c.stencilBuffer:!0}; THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,c){c&&b.update(undefined,!1,d);c=b.sounds;var f,g=c.length;for(f=0;f1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= this.getPrevKeyWith("pos",u,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(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(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&p[0][o]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;ub.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];o=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],o[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],o[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],o[2],g,c,j);return f}; +"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;ub.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];p=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],p[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],p[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],p[2],g,c,j);return f}; THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(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]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]}; -var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,o=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var p=0,t=j.length;p=0?v:v+g;v=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange; -this.phi=(this.phi-v[0])*(u[1]-u[0])/(v[1]-v[0])+u[0];v=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-v[0])*(u[1]-u[0])/(v[1]-v[0])+u[0];v=this.target.position;v.x=100*Math.sin(this.phi)*Math.cos(this.theta);v.y=100*Math.cos(this.phi);v.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,p,t)};this.onMouseMove=function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); +this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,t){var y,u;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;y=this.phi%g;this.phi=y>=0?y:y+g;y=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange; +this.phi=(this.phi-y[0])*(u[1]-u[0])/(y[1]-y[0])+u[0];y=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(u[1]-u[0])/(y[1]-y[0])+u[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,t)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation= -d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(o,p){return function(){p.apply(o,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; +d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(p,o){return function(){o.apply(p,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==undefined)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.autoForward!==undefined)this.autoForward= b.autoForward;if(b.domElement!==undefined)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(c){if(typeof this[c.type]=="function")this[c.type](c)};this.keydown=function(c){if(!c.altKey){switch(c.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; @@ -404,89 +403,90 @@ this.rollSpeed;this.translateX(this.moveVector.x*c);this.translateY(this.moveVec 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=-c+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",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1);window.addEventListener("keyup",d(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(b,d,c,f){THREE.Camera.call(this,b,d,c,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,o=1,p=0,t=0,v=0,u=0,B=0,F=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;if(this.mouseLook){A=this.delta*this.lookSpeed;this.rotateHorizontally(A*u);this.rotateVertically(A*B)}A=this.delta*this.movementSpeed;this.translateZ(A*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(A*t);this.translateY(A*v);m&&(this.roll+=this.rollSpeed*this.delta*o);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y< +THREE.RollCamera=function(b,d,c,f){THREE.Camera.call(this,b,d,c,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,p=1,o=0,t=0,y=0,u=0,B=0,A=window.innerWidth/2,Q=window.innerHeight/2;this.update= +function(){var E=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=E;this.delta=(E-this.lastUpdate)/1E3;this.lastUpdate=E;if(this.mouseLook){E=this.delta*this.lookSpeed;this.rotateHorizontally(E*u);this.rotateVertically(E*B)}E=this.delta*this.movementSpeed;this.translateZ(E*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(E*t);this.translateY(E*y);m&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y< this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}j.copy(this.forward);h.set(0,1,0);g.cross(h,j).normalize();h.cross(j,g).normalize();this.matrix.n11=g.x;this.matrix.n12=h.x;this.matrix.n13=j.x;this.matrix.n21=g.y;this.matrix.n22=h.y;this.matrix.n23=j.y;this.matrix.n31=g.z;this.matrix.n32=h.z;this.matrix.n33=j.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k); -this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(A){this.position.x+=this.matrix.n11*A;this.position.y+=this.matrix.n21*A;this.position.z+=this.matrix.n31*A};this.translateY=function(A){this.position.x+=this.matrix.n12*A;this.position.y+=this.matrix.n22*A;this.position.z+=this.matrix.n32*A};this.translateZ=function(A){this.position.x-=this.matrix.n13*A;this.position.y-= -this.matrix.n23*A;this.position.z-=this.matrix.n33*A};this.rotateHorizontally=function(A){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(A);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(A){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(A);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(A){A.preventDefault()},!1);this.domElement.addEventListener("mousemove", -function(A){u=(A.clientX-F)/window.innerWidth;B=(A.clientY-V)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(A){A.preventDefault();A.stopPropagation();switch(A.button){case 0:p=1;break;case 2:p=-1}},!1);this.domElement.addEventListener("mouseup",function(A){A.preventDefault();A.stopPropagation();switch(A.button){case 0:p=0;break;case 2:p=0}},!1);this.domElement.addEventListener("keydown",function(A){switch(A.keyCode){case 38:case 87:p=1;break;case 37:case 65:t=-1;break; -case 40:case 83:p=-1;break;case 39:case 68:t=1;break;case 81:m=!0;o=1;break;case 69:m=!0;o=-1;break;case 82:v=1;break;case 70:v=-1}},!1);this.domElement.addEventListener("keyup",function(A){switch(A.keyCode){case 38:case 87:p=0;break;case 37:case 65:t=0;break;case 40:case 83:p=0;break;case 39:case 68:t=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:v=0;break;case 70:v=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; +this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(E){this.position.x+=this.matrix.n11*E;this.position.y+=this.matrix.n21*E;this.position.z+=this.matrix.n31*E};this.translateY=function(E){this.position.x+=this.matrix.n12*E;this.position.y+=this.matrix.n22*E;this.position.z+=this.matrix.n32*E};this.translateZ=function(E){this.position.x-=this.matrix.n13*E;this.position.y-= +this.matrix.n23*E;this.position.z-=this.matrix.n33*E};this.rotateHorizontally=function(E){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(E);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(E){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(E);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(E){E.preventDefault()},!1);this.domElement.addEventListener("mousemove", +function(E){u=(E.clientX-A)/window.innerWidth;B=(E.clientY-Q)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(E){E.preventDefault();E.stopPropagation();switch(E.button){case 0:o=1;break;case 2:o=-1}},!1);this.domElement.addEventListener("mouseup",function(E){E.preventDefault();E.stopPropagation();switch(E.button){case 0:o=0;break;case 2:o=0}},!1);this.domElement.addEventListener("keydown",function(E){switch(E.keyCode){case 38:case 87:o=1;break;case 37:case 65:t=-1;break; +case 40:case 83:o=-1;break;case 39:case 68:t=1;break;case 81:m=!0;p=1;break;case 69:m=!0;p=-1;break;case 82:y=1;break;case 70:y=-1}},!1);this.domElement.addEventListener("keyup",function(E){switch(E.keyCode){case 38:case 87:o=0;break;case 37:case 65:t=0;break;case 40:case 83:o=0;break;case 39:case 68:t=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:y=0;break;case 70:y=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; THREE.RollCamera.prototype.supr=THREE.Camera.prototype; -THREE.Cube=function(b,d,c,f,g,h,j,k,m){function o(V,A,S,D,Y,J,L,oa){var ja,ra,va=f||1,X=g||1,e=Y/2,na=J/2,za=p.vertices.length;if(V=="x"&&A=="y"||V=="y"&&A=="x")ja="z";else if(V=="x"&&A=="z"||V=="z"&&A=="x"){ja="y";X=h||1}else if(V=="z"&&A=="y"||V=="y"&&A=="z"){ja="x";va=h||1}var wa=va+1,Da=X+1;Y/=va;var ka=J/X;for(ra=0;ra0){j(0,0,-p-(h||0));for(m=b;m0){j(0,0,p+(g||0)); -for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0){j(0,0,-o-(h||0));for(m=b;m0){j(0,0,o+(g||0)); +for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,v)))-1);o.push(p)}d.push(o)}var u,B,F;g=d.length;for(c=0;c0)for(f=0;f1){u=this.vertices[j].position.clone(); -B=this.vertices[m].position.clone();F=this.vertices[o].position.clone();u.normalize();B.normalize();F.normalize();this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(F.x,F.y,F.z)]));this.faceVertexUvs[0].push([p,t,V])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; +THREE.Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,y)))-1);p.push(o)}d.push(p)}var u,B,A;g=d.length;for(c=0;c0)for(f=0;f1){u=this.vertices[j].position.clone(); +B=this.vertices[m].position.clone();A=this.vertices[p].position.clone();u.normalize();B.normalize();A.normalize();this.faces.push(new THREE.Face3(j,m,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(A.x,A.y,A.z)]));this.faceVertexUvs[0].push([o,t,Q])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; THREE.Torus=function(b,d,c,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c= 1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; -THREE.TorusKnot=function(b,d,c,f,g,h,j){function k(t,v,u,B,F,V){v=u/B*t;u=Math.cos(v);return new THREE.Vector3(F*(2+u)*0.5*Math.cos(t),F*(2+u)*Math.sin(t)*0.5,V*F*Math.sin(v)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b>7)-127;O|=(La&127)<<16|Ba<<8;if(O==0&&C==-127)return 0;return(1-2*(n>>7))*(1+O*Math.pow(2,-23))*Math.pow(2,C)}function k(Q,R){var O=p(Q,R),Ba=p(Q,R+1),La=p(Q,R+2);return(p(Q,R+3)<<24)+(La<<16)+(Ba<<8)+O}function m(Q,R){var O=p(Q,R);return(p(Q,R+1)<<8)+O}function o(Q,R){var O=p(Q,R);return O>127?O-256:O}function p(Q, -R){return Q.charCodeAt(R)&255}function t(Q){var R,O,Ba;R=k(b,Q);O=k(b,Q+L);Ba=k(b,Q+oa);Q=m(b,Q+ja);THREE.BinaryLoader.prototype.f3(A,R,O,Ba,Q)}function v(Q){var R,O,Ba,La,n,C;R=k(b,Q);O=k(b,Q+L);Ba=k(b,Q+oa);La=m(b,Q+ja);n=k(b,Q+ra);C=k(b,Q+va);Q=k(b,Q+X);THREE.BinaryLoader.prototype.f3n(A,Y,R,O,Ba,La,n,C,Q)}function u(Q){var R,O,Ba,La;R=k(b,Q);O=k(b,Q+e);Ba=k(b,Q+na);La=k(b,Q+za);Q=m(b,Q+wa);THREE.BinaryLoader.prototype.f4(A,R,O,Ba,La,Q)}function B(Q){var R,O,Ba,La,n,C,y,x;R=k(b,Q);O=k(b,Q+e);Ba= -k(b,Q+na);La=k(b,Q+za);n=m(b,Q+wa);C=k(b,Q+Da);y=k(b,Q+ka);x=k(b,Q+ea);Q=k(b,Q+ua);THREE.BinaryLoader.prototype.f4n(A,Y,R,O,Ba,La,n,C,y,x,Q)}function F(Q){var R,O;R=k(b,Q);O=k(b,Q+sa);Q=k(b,Q+aa);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],J[R*2],J[R*2+1],J[O*2],J[O*2+1],J[Q*2],J[Q*2+1])}function V(Q){var R,O,Ba;R=k(b,Q);O=k(b,Q+fa);Ba=k(b,Q+la);Q=k(b,Q+Fa);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],J[R*2],J[R*2+1],J[O*2],J[O*2+1],J[Ba*2],J[Ba*2+1],J[Q*2],J[Q*2+1])}var A=this,S=0, -D,Y=[],J=[],L,oa,ja,ra,va,X,e,na,za,wa,Da,ka,ea,ua,sa,aa,fa,la,Fa,ia,ga,Ja,Xa,Za,Ta;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,f,h);D={signature:b.substr(S,8),header_bytes:p(b,S+8),vertex_coordinate_bytes:p(b,S+9),normal_coordinate_bytes:p(b,S+10),uv_coordinate_bytes:p(b,S+11),vertex_index_bytes:p(b,S+12),normal_index_bytes:p(b,S+13),uv_index_bytes:p(b,S+14),material_index_bytes:p(b,S+15),nvertices:k(b,S+16),nnormals:k(b,S+16+4),nuvs:k(b,S+16+8),ntri_flat:k(b,S+16+12),ntri_smooth:k(b, -S+16+16),ntri_flat_uv:k(b,S+16+20),ntri_smooth_uv:k(b,S+16+24),nquad_flat:k(b,S+16+28),nquad_smooth:k(b,S+16+32),nquad_flat_uv:k(b,S+16+36),nquad_smooth_uv:k(b,S+16+40)};S+=D.header_bytes;L=D.vertex_index_bytes;oa=D.vertex_index_bytes*2;ja=D.vertex_index_bytes*3;ra=D.vertex_index_bytes*3+D.material_index_bytes;va=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;X=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;e=D.vertex_index_bytes;na=D.vertex_index_bytes*2; -za=D.vertex_index_bytes*3;wa=D.vertex_index_bytes*4;Da=D.vertex_index_bytes*4+D.material_index_bytes;ka=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;ea=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;ua=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;sa=D.uv_index_bytes;aa=D.uv_index_bytes*2;fa=D.uv_index_bytes;la=D.uv_index_bytes*2;Fa=D.uv_index_bytes*3;h=D.vertex_index_bytes*3+D.material_index_bytes;Ta=D.vertex_index_bytes*4+D.material_index_bytes; -ia=D.ntri_flat*h;ga=D.ntri_smooth*(h+D.normal_index_bytes*3);Ja=D.ntri_flat_uv*(h+D.uv_index_bytes*3);Xa=D.ntri_smooth_uv*(h+D.normal_index_bytes*3+D.uv_index_bytes*3);Za=D.nquad_flat*Ta;h=D.nquad_smooth*(Ta+D.normal_index_bytes*4);Ta=D.nquad_flat_uv*(Ta+D.uv_index_bytes*4);S+=function(Q){for(var R,O,Ba,La=D.vertex_coordinate_bytes*3,n=Q+D.nvertices*La;Q1&&(va=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(oa,va);object.name=B;object.position.set(Y[0],Y[1],Y[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;ea.scene.addObject(object);ea.objects[B]=object;if(D.meshCollider){var aa=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(aa)}if(D.castsShadow){aa=new THREE.ShadowVolume(oa); -ea.scene.addChild(aa);aa.position=object.position;aa.rotation=object.rotation;aa.scale=object.scale}}}}function p(aa){return function(fa){ea.geometries[aa]=fa;o();za-=1;g.onLoadComplete();t()}}function t(){f({total_models:Da,total_textures:ka,loaded_models:Da-za,loaded_textures:ka-wa},ea);g.onLoadProgress();za==0&&wa==0&&c(ea)}var v,u,B,F,V,A,S,D,Y,J,L,oa,ja,ra,va,X,e,na,za,wa,Da,ka,ea;X=k.data;e=new THREE.BinaryLoader;na=new THREE.JSONLoader;wa=za=0;ea={scene:new THREE.Scene,geometries:{},materials:{}, -textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(X.transform){k=X.transform.position;J=X.transform.rotation;var ua=X.transform.scale;k&&ea.scene.position.set(k[0],k[1],k[2]);J&&ea.scene.rotation.set(J[0],J[1],J[2]);ua&&ea.scene.scale.set(ua[0],ua[1],ua[2]);(k||J||ua)&&ea.scene.updateMatrix()}k=function(){wa-=1;t();g.onLoadComplete()};for(V in X.cameras){J=X.cameras[V];if(J.type=="perspective")ja=new THREE.Camera(J.fov,J.aspect,J.near,J.far);else if(J.type=="ortho"){ja=new THREE.Camera;ja.projectionMatrix= -THREE.Matrix4.makeOrtho(J.left,J.right,J.top,J.bottom,J.near,J.far)}Y=J.position;J=J.target;ja.position.set(Y[0],Y[1],Y[2]);ja.target.position.set(J[0],J[1],J[2]);ea.cameras[V]=ja}for(F in X.lights){V=X.lights[F];ja=V.color!==undefined?V.color:16777215;J=V.intensity!==undefined?V.intensity:1;if(V.type=="directional"){Y=V.direction;light=new THREE.DirectionalLight(ja,J);light.position.set(Y[0],Y[1],Y[2]);light.position.normalize()}else if(V.type=="point"){Y=V.position;light=new THREE.PointLight(ja, -J);light.position.set(Y[0],Y[1],Y[2])}ea.scene.addLight(light);ea.lights[F]=light}for(A in X.fogs){F=X.fogs[A];if(F.type=="linear")ra=new THREE.Fog(0,F.near,F.far);else F.type=="exp2"&&(ra=new THREE.FogExp2(0,F.density));J=F.color;ra.color.setRGB(J[0],J[1],J[2]);ea.fogs[A]=ra}if(ea.cameras&&X.defaults.camera)ea.currentCamera=ea.cameras[X.defaults.camera];if(ea.fogs&&X.defaults.fog)ea.scene.fog=ea.fogs[X.defaults.fog];J=X.defaults.bgcolor;ea.bgColor=new THREE.Color;ea.bgColor.setRGB(J[0],J[1],J[2]); -ea.bgColorAlpha=X.defaults.bgalpha;for(v in X.geometries){A=X.geometries[v];if(A.type=="bin_mesh"||A.type=="ascii_mesh"){za+=1;g.onLoadStart()}}Da=za;for(v in X.geometries){A=X.geometries[v];if(A.type=="cube"){oa=new THREE.Cube(A.width,A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides);ea.geometries[v]=oa}else if(A.type=="plane"){oa=new THREE.Plane(A.width,A.height,A.segmentsWidth,A.segmentsHeight);ea.geometries[v]=oa}else if(A.type=="sphere"){oa=new THREE.Sphere(A.radius, -A.segmentsWidth,A.segmentsHeight);ea.geometries[v]=oa}else if(A.type=="cylinder"){oa=new THREE.Cylinder(A.numSegs,A.topRad,A.botRad,A.height,A.topOffset,A.botOffset);ea.geometries[v]=oa}else if(A.type=="torus"){oa=new THREE.Torus(A.radius,A.tube,A.segmentsR,A.segmentsT);ea.geometries[v]=oa}else if(A.type=="icosahedron"){oa=new THREE.Icosahedron(A.subdivisions);ea.geometries[v]=oa}else if(A.type=="bin_mesh")e.load({model:m(A.url,X.urlBaseType),callback:p(v)});else A.type=="ascii_mesh"&&na.load({model:m(A.url, -X.urlBaseType),callback:p(v)})}for(S in X.textures){v=X.textures[S];if(v.url instanceof Array){wa+=v.url.length;for(A=0;A>7)-127;M|=(La&127)<<16|Aa<<8;if(M==0&&D==-127)return 0;return(1-2*(n>>7))*(1+M*Math.pow(2,-23))*Math.pow(2,D)}function k(O,S){var M=o(O,S),Aa=o(O,S+1),La=o(O,S+2);return(o(O,S+3)<<24)+(La<<16)+(Aa<<8)+M}function m(O,S){var M=o(O,S);return(o(O,S+1)<<8)+M}function p(O,S){var M=o(O,S);return M>127?M-256:M}function o(O, +S){return O.charCodeAt(S)&255}function t(O){var S,M,Aa;S=k(b,O);M=k(b,O+P);Aa=k(b,O+ya);O=m(b,O+la);THREE.BinaryLoader.prototype.f3(E,S,M,Aa,O)}function y(O){var S,M,Aa,La,n,D;S=k(b,O);M=k(b,O+P);Aa=k(b,O+ya);La=m(b,O+la);n=k(b,O+ca);D=k(b,O+Ba);O=k(b,O+ea);THREE.BinaryLoader.prototype.f3n(E,X,S,M,Aa,La,n,D,O)}function u(O){var S,M,Aa,La;S=k(b,O);M=k(b,O+e);Aa=k(b,O+oa);La=k(b,O+Da);O=m(b,O+da);THREE.BinaryLoader.prototype.f4(E,S,M,Aa,La,O)}function B(O){var S,M,Aa,La,n,D,x,w;S=k(b,O);M=k(b,O+e); +Aa=k(b,O+oa);La=k(b,O+Da);n=m(b,O+da);D=k(b,O+va);x=k(b,O+ja);w=k(b,O+qa);O=k(b,O+pa);THREE.BinaryLoader.prototype.f4n(E,X,S,M,Aa,La,n,D,x,w,O)}function A(O){var S,M;S=k(b,O);M=k(b,O+wa);O=k(b,O+fa);THREE.BinaryLoader.prototype.uv3(E.faceVertexUvs[0],R[S*2],R[S*2+1],R[M*2],R[M*2+1],R[O*2],R[O*2+1])}function Q(O){var S,M,Aa;S=k(b,O);M=k(b,O+ka);Aa=k(b,O+ma);O=k(b,O+Fa);THREE.BinaryLoader.prototype.uv4(E.faceVertexUvs[0],R[S*2],R[S*2+1],R[M*2],R[M*2+1],R[Aa*2],R[Aa*2+1],R[O*2],R[O*2+1])}var E=this, +V=0,C,X=[],R=[],P,ya,la,ca,Ba,ea,e,oa,Da,da,va,ja,qa,pa,wa,fa,ka,ma,Fa,ia,ga,Ja,Xa,Za,Ta;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,f,h);C={signature:b.substr(V,8),header_bytes:o(b,V+8),vertex_coordinate_bytes:o(b,V+9),normal_coordinate_bytes:o(b,V+10),uv_coordinate_bytes:o(b,V+11),vertex_index_bytes:o(b,V+12),normal_index_bytes:o(b,V+13),uv_index_bytes:o(b,V+14),material_index_bytes:o(b,V+15),nvertices:k(b,V+16),nnormals:k(b,V+16+4),nuvs:k(b,V+16+8),ntri_flat:k(b,V+16+12), +ntri_smooth:k(b,V+16+16),ntri_flat_uv:k(b,V+16+20),ntri_smooth_uv:k(b,V+16+24),nquad_flat:k(b,V+16+28),nquad_smooth:k(b,V+16+32),nquad_flat_uv:k(b,V+16+36),nquad_smooth_uv:k(b,V+16+40)};V+=C.header_bytes;P=C.vertex_index_bytes;ya=C.vertex_index_bytes*2;la=C.vertex_index_bytes*3;ca=C.vertex_index_bytes*3+C.material_index_bytes;Ba=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;ea=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;e=C.vertex_index_bytes;oa=C.vertex_index_bytes* +2;Da=C.vertex_index_bytes*3;da=C.vertex_index_bytes*4;va=C.vertex_index_bytes*4+C.material_index_bytes;ja=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;qa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;pa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;wa=C.uv_index_bytes;fa=C.uv_index_bytes*2;ka=C.uv_index_bytes;ma=C.uv_index_bytes*2;Fa=C.uv_index_bytes*3;h=C.vertex_index_bytes*3+C.material_index_bytes;Ta=C.vertex_index_bytes*4+C.material_index_bytes; +ia=C.ntri_flat*h;ga=C.ntri_smooth*(h+C.normal_index_bytes*3);Ja=C.ntri_flat_uv*(h+C.uv_index_bytes*3);Xa=C.ntri_smooth_uv*(h+C.normal_index_bytes*3+C.uv_index_bytes*3);Za=C.nquad_flat*Ta;h=C.nquad_smooth*(Ta+C.normal_index_bytes*4);Ta=C.nquad_flat_uv*(Ta+C.uv_index_bytes*4);V+=function(O){for(var S,M,Aa,La=C.vertex_coordinate_bytes*3,n=O+C.nvertices*La;O1&&(la=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(R,la);object.name=y;object.position.set(V[0],V[1],V[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;da.scene.addObject(object);da.objects[y]=object;if(E.meshCollider){var pa=THREE.CollisionUtils.MeshColliderWBox(object);da.scene.collisions.colliders.push(pa)}if(E.castsShadow){pa=new THREE.ShadowVolume(R); +da.scene.addChild(pa);pa.position=object.position;pa.rotation=object.rotation;pa.scale=object.scale}}}}function m(pa){return function(wa){da.geometries[pa]=wa;k();ea-=1;c.onLoadComplete();p()}}function p(){c.callbackProgress({totalModels:oa,totalTextures:Da,loadedModels:oa-ea,loadedTextures:Da-e},da);c.onLoadProgress();ea==0&&e==0&&d(da)}var o,t,y,u,B,A,Q,E,V,C,X,R,P,ya,la,ca,Ba,ea,e,oa,Da,da;ca=h.data;h=new THREE.BinaryLoader;Ba=new THREE.JSONLoader;e=ea=0;da={scene:new THREE.Scene,geometries:{}, +materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};var va=!1;for(y in ca.objects){E=ca.objects[y];if(E.meshCollider){va=!0;break}}if(va)da.scene.collisions=new THREE.CollisionSystem;if(ca.transform){va=ca.transform.position;C=ca.transform.rotation;var ja=ca.transform.scale;va&&da.scene.position.set(va[0],va[1],va[2]);C&&da.scene.rotation.set(C[0],C[1],C[2]);ja&&da.scene.scale.set(ja[0],ja[1],ja[2]);(va||C||ja)&&da.scene.updateMatrix()}va=function(){e-=1;p();c.onLoadComplete()};for(B in ca.cameras){C= +ca.cameras[B];if(C.type=="perspective")P=new THREE.Camera(C.fov,C.aspect,C.near,C.far);else if(C.type=="ortho"){P=new THREE.Camera;P.projectionMatrix=THREE.Matrix4.makeOrtho(C.left,C.right,C.top,C.bottom,C.near,C.far)}V=C.position;C=C.target;P.position.set(V[0],V[1],V[2]);P.target.position.set(C[0],C[1],C[2]);da.cameras[B]=P}for(u in ca.lights){B=ca.lights[u];P=B.color!==undefined?B.color:16777215;C=B.intensity!==undefined?B.intensity:1;if(B.type=="directional"){V=B.direction;light=new THREE.DirectionalLight(P, +C);light.position.set(V[0],V[1],V[2]);light.position.normalize()}else if(B.type=="point"){V=B.position;light=new THREE.PointLight(P,C);light.position.set(V[0],V[1],V[2])}da.scene.addLight(light);da.lights[u]=light}for(A in ca.fogs){u=ca.fogs[A];if(u.type=="linear")ya=new THREE.Fog(0,u.near,u.far);else u.type=="exp2"&&(ya=new THREE.FogExp2(0,u.density));C=u.color;ya.color.setRGB(C[0],C[1],C[2]);da.fogs[A]=ya}if(da.cameras&&ca.defaults.camera)da.currentCamera=da.cameras[ca.defaults.camera];if(da.fogs&& +ca.defaults.fog)da.scene.fog=da.fogs[ca.defaults.fog];C=ca.defaults.bgcolor;da.bgColor=new THREE.Color;da.bgColor.setRGB(C[0],C[1],C[2]);da.bgColorAlpha=ca.defaults.bgalpha;for(o in ca.geometries){A=ca.geometries[o];if(A.type=="bin_mesh"||A.type=="ascii_mesh"){ea+=1;c.onLoadStart()}}oa=ea;for(o in ca.geometries){A=ca.geometries[o];if(A.type=="cube"){R=new THREE.Cube(A.width,A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides);da.geometries[o]=R}else if(A.type== +"plane"){R=new THREE.Plane(A.width,A.height,A.segmentsWidth,A.segmentsHeight);da.geometries[o]=R}else if(A.type=="sphere"){R=new THREE.Sphere(A.radius,A.segmentsWidth,A.segmentsHeight);da.geometries[o]=R}else if(A.type=="cylinder"){R=new THREE.Cylinder(A.numSegs,A.topRad,A.botRad,A.height,A.topOffset,A.botOffset);da.geometries[o]=R}else if(A.type=="torus"){R=new THREE.Torus(A.radius,A.tube,A.segmentsR,A.segmentsT);da.geometries[o]=R}else if(A.type=="icosahedron"){R=new THREE.Icosahedron(A.subdivisions); +da.geometries[o]=R}else if(A.type=="bin_mesh")h.load({model:j(A.url,ca.urlBaseType),callback:m(o)});else A.type=="ascii_mesh"&&Ba.load({model:j(A.url,ca.urlBaseType),callback:m(o)})}for(Q in ca.textures){o=ca.textures[Q];if(o.url instanceof Array){e+=o.url.length;for(A=0;A=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;fthis.size-1&&(m=this.size-1);var v=Math.floor(o-k);v<1&&(v=1);o=Math.floor(o+k);o>this.size-1&&(o= -this.size-1);var u=Math.floor(p-k);u<1&&(u=1);k=Math.floor(p+k);k>this.size-1&&(k=this.size-1);for(var B,F,V,A,S,D;t0&&(this.field[V+B]+=A)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,o=this.size,p=this.yd,t=this.zd,v=this.field,u=o*Math.sqrt(c/f);u>o&&(u=o);for(g=0;g0)for(h=0;hp&&(B=p);for(h=0;h0){m=h*t;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;h=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;fthis.size-1&&(m=this.size-1);var y=Math.floor(p-k);y<1&&(y=1);p=Math.floor(p+k);p>this.size-1&& +(p=this.size-1);var u=Math.floor(o-k);u<1&&(u=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var B,A,Q,E,V,C;t0&&(this.field[Q+B]+=E)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,p=this.size,o=this.yd,t=this.zd,y=this.field,u=p*Math.sqrt(c/f);u>p&&(u=p);for(g=0;g0)for(h=0;ho&&(B=o);for(h=0;h0){m=h*t;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;h=j*g))return Number.MAX_VALUE;h/=j;var m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(h);m.addSelf(b.origin);if(Math.abs(k.x)>Math.abs(k.y))if(Math.abs(k.x)> Math.abs(k.z)){b=m.y-d.y;g=c.y-d.y;j=f.y-d.y;m=m.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=m.x-d.x;g=c.x-d.x;j=f.x-d.x;m=m.y-d.y;c=c.y-d.y;f=f.y-d.y}else if(Math.abs(k.y)>Math.abs(k.z)){b=m.x-d.x;g=c.x-d.x;j=f.x-d.x;m=m.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=m.x-d.x;g=c.x-d.x;j=f.x-d.x;m=m.y-d.y;c=c.y-d.y;f=f.y-d.y}d=g*f-c*j;if(d==0)return Number.MAX_VALUE;d=1/d;f=(b*f-m*j)*d;if(!(f>=0))return Number.MAX_VALUE;d*=g*m-c*b;if(!(d>=0))return Number.MAX_VALUE;if(!(1-f-d>=0))return Number.MAX_VALUE;this.collisionNormal= k;return h};THREE.CollisionSystem.prototype.makeRayLocal=function(b,d){var c=new THREE.Ray(b.origin.clone(),b.direction.clone()),f=THREE.Matrix4.makeInvert(d.matrixWorld);f.multiplyVector3(c.origin);f.rotateAxis(c.direction);c.direction.normalize();return c}; -THREE.CollisionSystem.prototype.rayBox=function(b,d){var c;c=d.dynamic&&d.mesh&&d.mesh.matrixWorld?this.makeRayLocal(b,d.mesh):new THREE.Ray(b.origin.clone(),b.direction.clone());var f=0,g=0,h=0,j=0,k=0,m=0,o=!0;if(c.origin.xd.max.x){f=d.max.x-c.origin.x;f/=c.direction.x;o=!1;j=1}if(c.origin.yd.max.y){g=d.max.y-c.origin.y;g/=c.direction.y;o=!1;k= -1}if(c.origin.zd.max.z){h=d.max.z-c.origin.z;h/=c.direction.z;o=!1;m=1}if(o)return-1;o=0;if(g>f){o=1;f=g}if(h>f){o=2;f=h}switch(o){case 0:k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(j,0,0);break;case 1:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE;c=c.origin.z+ +THREE.CollisionSystem.prototype.rayBox=function(b,d){var c;c=d.dynamic&&d.mesh&&d.mesh.matrixWorld?this.makeRayLocal(b,d.mesh):new THREE.Ray(b.origin.clone(),b.direction.clone());var f=0,g=0,h=0,j=0,k=0,m=0,p=!0;if(c.origin.xd.max.x){f=d.max.x-c.origin.x;f/=c.direction.x;p=!1;j=1}if(c.origin.yd.max.y){g=d.max.y-c.origin.y;g/=c.direction.y;p=!1;k= +1}if(c.origin.zd.max.z){h=d.max.z-c.origin.z;h/=c.direction.z;p=!1;m=1}if(p)return-1;p=0;if(g>f){p=1;f=g}if(h>f){p=2;f=h}switch(p){case 0:k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(j,0,0);break;case 1:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE;c=c.origin.z+ c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,k,0);break;case 2:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,0,m)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,d){var c=b.direction.dot(d.normal),f=d.point.dot(d.normal);if(c<0)c=(f-b.origin.dot(d.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,d){var c=d.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.CollisionUtils={}; THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var d=b.geometry.boundingBox,c=new THREE.Vector3(d.x[0],d.y[0],d.z[0]);d=new THREE.Vector3(d.x[1],d.y[1],d.z[1]);c=new THREE.BoxCollider(c,d);c.mesh=b;return c};THREE.CollisionUtils.MeshAABB=function(b){var d=THREE.CollisionUtils.MeshOBB(b);d.min.addSelf(b.position);d.max.addSelf(b.position);d.dynamic=!1;return d}; diff --git a/build/custom/ThreeCanvas.js b/build/custom/ThreeCanvas.js index c0531f68150b04..254f947b8abb78 100644 --- a/build/custom/ThreeCanvas.js +++ b/build/custom/ThreeCanvas.js @@ -99,7 +99,7 @@ THREE.Sound=function(a,b,c,d){THREE.Object3D.call(this);this.isLoaded=!1;this.is THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()}; THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0}; THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+p);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=c[0]+(f[0]-c[0])*e;b.y=c[1]+(f[1]-c[1])*e;b.z=c[2]+(f[2]-c[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",p,g.index-1).pos;this.points[1]=c;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",p,h.index+1).pos;e=e*0.33+0.33;c=this.interpolateCatmullRom(this.points,e);b.x=c[0];b.y=c[1];b.z=c[2];if(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(c,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=c[0]+(f[0]-c[0])*e;b.y=c[1]+(f[1]-c[1])*e;b.z=c[2]+(f[2]-c[2])*e}}}}if(this.JITCompile&&k[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;pa.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];h=a[b[1]];j=a[b[2]];l=a[b[3]];b=c*c;g=c*b;e[0]=this.interpolate(f[0],h[0],j[0],l[0],c,b,g);e[1]=this.interpolate(f[1],h[1],j[1],l[1],c,b,g);e[2]=this.interpolate(f[2],h[2],j[2],l[2],c,b,g);return e}; -THREE.Animation.prototype.interpolate=function(a,d,b,e,c,f,g){a=(b-a)*0.5;e=(e-d)*0.5;return(2*(d-b)+a+e)*g+(-3*(d-b)-2*a-e)*f+a*c+d};THREE.Animation.prototype.getNextKeyWith=function(a,d,b){var e=this.data.hierarchy[d].keys;if(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]!==undefined)return e[b];return this.data.hierarchy[d].keys[e.length-1]}; -var GeometryUtils={merge:function(a,d){var b=d instanceof THREE.Mesh,e=a.vertices.length,c=b?d.geometry:d,f=a.vertices,g=c.vertices,h=a.faces,j=c.faces,l=a.faceVertexUvs[0];c=c.faceVertexUvs[0];b&&d.matrixAutoUpdate&&d.updateMatrix();for(var k=0,t=g.length;k1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+n);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=d[0]+(f[0]-d[0])*e;b.y=d[1]+(f[1]-d[1])*e;b.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=d;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);b.x=d[0];b.y=d[1];b.z=d[2];if(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(d,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=d[0]+(f[0]-d[0])*e;b.y=d[1]+(f[1]-d[1])*e;b.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&k[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;na.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];h=a[b[1]];j=a[b[2]];l=a[b[3]];b=d*d;g=d*b;e[0]=this.interpolate(f[0],h[0],j[0],l[0],d,b,g);e[1]=this.interpolate(f[1],h[1],j[1],l[1],d,b,g);e[2]=this.interpolate(f[2],h[2],j[2],l[2],d,b,g);return e}; +THREE.Animation.prototype.interpolate=function(a,c,b,e,d,f,g){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*g+(-3*(c-b)-2*a-e)*f+a*d+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;if(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]!==undefined)return e[b];return this.data.hierarchy[c].keys[e.length-1]}; +var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,d=b?c.geometry:c,f=a.vertices,g=d.vertices,h=a.faces,j=d.faces,l=a.faceVertexUvs[0];d=d.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var k=0,t=g.length;k25&&(f=25);c=(f-1)*0.5;b=Array(f);for(d=e=0;d25&&(f=25);d=(f-1)*0.5;b=Array(f);for(c=e=0;cthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(e+this.autoSpeedFactor));this.moveBackward&&this.translateZ(e);this.moveLeft&&this.translateX(-e);this.moveRight&&this.translateX(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;b=this.target.position;var c=this.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.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;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;c=this.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.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this, -this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; -THREE.QuakeCamera.prototype.translate=function(a,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(a));this.target.position.addSelf(d.multiplyScalar(a))}; -THREE.PathCamera=function(a){function d(l,k,t,m){var p={name:t,fps:0.6,length:m,hierarchy:[]},y,w=k.getControlPointsArray(),B=k.getLength(),n=w.length,x=0;y=n-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:w[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[y]={time:m,pos:w[y],rot:[0,0,0,1],scl:[1,1,1]};for(y=1;y=0?m:m+c;m=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange; -this.phi=(this.phi-m[0])*(p[1]-p[0])/(m[1]-m[0])+p[0];m=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-m[0])*(p[1]-p[0])/(m[1]-m[0])+p[0];m=this.target.position;m.x=100*Math.sin(this.phi)*Math.cos(this.theta);m.y=100*Math.cos(this.phi);m.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,t)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); -this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= -d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -THREE.FlyCamera=function(a){function d(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward= +this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,f=Math.PI/180;this.update=function(l,k,t){var o,n;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;o=this.phi%d;this.phi=o>=0?o:o+d;o=this.verticalAngleMap.srcRange;n=this.verticalAngleMap.dstRange; +this.phi=(this.phi-o[0])*(n[1]-n[0])/(o[1]-o[0])+n[0];o=this.horizontalAngleMap.srcRange;n=this.horizontalAngleMap.dstRange;this.theta=(this.theta-o[0])*(n[1]-n[0])/(o[1]-o[0])+n[0];o=this.target.position;o.x=100*Math.sin(this.phi)*Math.cos(this.theta);o.y=100*Math.cos(this.phi);o.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,t)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); +this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= +c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; +THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward= a.autoForward;if(a.domElement!==undefined)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break; -case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),c=e.size[0]/2,f=e.size[1]/2;this.moveState.yawLeft=-(b.clientX-e.offset[0]-c)/c;this.moveState.pitchDown=(b.clientY- +case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),d=e.size[0]/2,f=e.size[1]/2;this.moveState.yawLeft=-(b.clientX-e.offset[0]-d)/d;this.moveState.pitchDown=(b.clientY- e.offset[1]-f)/f;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;b=this.tdiff*this.movementSpeed;var e=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*e,this.rotationVector.y*e,this.rotationVector.z*e,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};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",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1);window.addEventListener("keyup",d(this, +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);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(a,d,b,e){THREE.Camera.call(this,a,d,b,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var c=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Matrix4,j=!1,l=1,k=0,t=0,m=0,p=0,y=0,w=window.innerWidth/2,B=window.innerHeight/2;this.update= -function(){var n=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=n;this.delta=(n-this.lastUpdate)/1E3;this.lastUpdate=n;if(this.mouseLook){n=this.delta*this.lookSpeed;this.rotateHorizontally(n*p);this.rotateVertically(n*y)}n=this.delta*this.movementSpeed;this.translateZ(n*(k>0||this.autoForward&&!(k<0)?1:k));this.translateX(n*t);this.translateY(n*m);j&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y< -this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}g.copy(this.forward);f.set(0,1,0);c.cross(f,g).normalize();f.cross(g,c).normalize();this.matrix.n11=c.x;this.matrix.n12=f.x;this.matrix.n13=g.x;this.matrix.n21=c.y;this.matrix.n22=f.y;this.matrix.n23=g.y;this.matrix.n31=c.z;this.matrix.n32=f.z;this.matrix.n33=g.z;h.identity();h.n11=Math.cos(this.roll);h.n12=-Math.sin(this.roll);h.n21=Math.sin(this.roll);h.n22=Math.cos(this.roll);this.matrix.multiplySelf(h); -this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(n){this.position.x+=this.matrix.n11*n;this.position.y+=this.matrix.n21*n;this.position.z+=this.matrix.n31*n};this.translateY=function(n){this.position.x+=this.matrix.n12*n;this.position.y+=this.matrix.n22*n;this.position.z+=this.matrix.n32*n};this.translateZ=function(n){this.position.x-=this.matrix.n13*n;this.position.y-= -this.matrix.n23*n;this.position.z-=this.matrix.n33*n};this.rotateHorizontally=function(n){c.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);c.multiplyScalar(n);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(n){f.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);f.multiplyScalar(n);this.forward.addSelf(f);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(n){n.preventDefault()},!1);this.domElement.addEventListener("mousemove", -function(n){p=(n.clientX-w)/window.innerWidth;y=(n.clientY-B)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(n){n.preventDefault();n.stopPropagation();switch(n.button){case 0:k=1;break;case 2:k=-1}},!1);this.domElement.addEventListener("mouseup",function(n){n.preventDefault();n.stopPropagation();switch(n.button){case 0:k=0;break;case 2:k=0}},!1);this.domElement.addEventListener("keydown",function(n){switch(n.keyCode){case 38:case 87:k=1;break;case 37:case 65:t=-1;break; -case 40:case 83:k=-1;break;case 39:case 68:t=1;break;case 81:j=!0;l=1;break;case 69:j=!0;l=-1;break;case 82:m=1;break;case 70:m=-1}},!1);this.domElement.addEventListener("keyup",function(n){switch(n.keyCode){case 38:case 87:k=0;break;case 37:case 65:t=0;break;case 40:case 83:k=0;break;case 39:case 68:t=0;break;case 81:j=!1;break;case 69:j=!1;break;case 82:m=0;break;case 70:m=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; +THREE.RollCamera=function(a,c,b,e){THREE.Camera.call(this,a,c,b,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var d=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Matrix4,j=!1,l=1,k=0,t=0,o=0,n=0,w=0,p=window.innerWidth/2,z=window.innerHeight/2;this.update= +function(){var v=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=v;this.delta=(v-this.lastUpdate)/1E3;this.lastUpdate=v;if(this.mouseLook){v=this.delta*this.lookSpeed;this.rotateHorizontally(v*n);this.rotateVertically(v*w)}v=this.delta*this.movementSpeed;this.translateZ(v*(k>0||this.autoForward&&!(k<0)?1:k));this.translateX(v*t);this.translateY(v*o);j&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y< +this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}g.copy(this.forward);f.set(0,1,0);d.cross(f,g).normalize();f.cross(g,d).normalize();this.matrix.n11=d.x;this.matrix.n12=f.x;this.matrix.n13=g.x;this.matrix.n21=d.y;this.matrix.n22=f.y;this.matrix.n23=g.y;this.matrix.n31=d.z;this.matrix.n32=f.z;this.matrix.n33=g.z;h.identity();h.n11=Math.cos(this.roll);h.n12=-Math.sin(this.roll);h.n21=Math.sin(this.roll);h.n22=Math.cos(this.roll);this.matrix.multiplySelf(h); +this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(v){this.position.x+=this.matrix.n11*v;this.position.y+=this.matrix.n21*v;this.position.z+=this.matrix.n31*v};this.translateY=function(v){this.position.x+=this.matrix.n12*v;this.position.y+=this.matrix.n22*v;this.position.z+=this.matrix.n32*v};this.translateZ=function(v){this.position.x-=this.matrix.n13*v;this.position.y-= +this.matrix.n23*v;this.position.z-=this.matrix.n33*v};this.rotateHorizontally=function(v){d.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);d.multiplyScalar(v);this.forward.subSelf(d);this.forward.normalize()};this.rotateVertically=function(v){f.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);f.multiplyScalar(v);this.forward.addSelf(f);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(v){v.preventDefault()},!1);this.domElement.addEventListener("mousemove", +function(v){n=(v.clientX-p)/window.innerWidth;w=(v.clientY-z)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:k=1;break;case 2:k=-1}},!1);this.domElement.addEventListener("mouseup",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:k=0;break;case 2:k=0}},!1);this.domElement.addEventListener("keydown",function(v){switch(v.keyCode){case 38:case 87:k=1;break;case 37:case 65:t=-1;break; +case 40:case 83:k=-1;break;case 39:case 68:t=1;break;case 81:j=!0;l=1;break;case 69:j=!0;l=-1;break;case 82:o=1;break;case 70:o=-1}},!1);this.domElement.addEventListener("keyup",function(v){switch(v.keyCode){case 38:case 87:k=0;break;case 37:case 65:t=0;break;case 40:case 83:k=0;break;case 39:case 68:t=0;break;case 81:j=!1;break;case 69:j=!1;break;case 82:o=0;break;case 70:o=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; THREE.RollCamera.prototype.supr=THREE.Camera.prototype; -THREE.Cube=function(a,d,b,e,c,f,g,h,j){function l(B,n,x,o,D,z,G,K){var H,J,L=e||1,E=c||1,R=D/2,S=z/2,N=k.vertices.length;if(B=="x"&&n=="y"||B=="y"&&n=="x")H="z";else if(B=="x"&&n=="z"||B=="z"&&n=="x"){H="y";E=f||1}else if(B=="z"&&n=="y"||B=="y"&&n=="z"){H="x";L=f||1}var M=L+1,T=E+1;D/=L;var U=z/E;for(J=0;J0){g(0,0,-k-(f||0));for(j=a;j0){g(0,0,k+(c||0)); -for(j=a+a/2;j<2*a;j++)h.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0){g(0,0,-k-(f||0));for(j=a;j0){g(0,0,k+(d||0)); +for(j=a+a/2;j<2*a;j++)h.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,h,m)))-1);l.push(k)}d.push(l)}var p,y,w;c=d.length;for(b=0;b0)for(e=0;e1){p=this.vertices[g].position.clone(); -y=this.vertices[j].position.clone();w=this.vertices[l].position.clone();p.normalize();y.normalize();w.normalize();this.faces.push(new THREE.Face3(g,j,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(w.x,w.y,w.z)]));this.faceVertexUvs[0].push([k,t,B])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; -THREE.Torus=function(a,d,b,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=d||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];for(d=0;d<=this.segmentsR;++d)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var c=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(c))*Math.cos(e),(this.radius+this.tube*Math.cos(c))*Math.sin(e),this.tube*Math.sin(c))));a.push([b/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(b= -1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*d+b;c=(this.segmentsT+1)*d+b-1;var f=(this.segmentsT+1)*(d-1)+b-1,g=(this.segmentsT+1)*(d-1)+b;this.faces.push(new THREE.Face4(e,c,f,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; -THREE.TorusKnot=function(a,d,b,e,c,f,g){function h(t,m,p,y,w,B){m=p/y*t;p=Math.cos(m);return new THREE.Vector3(w*(2+p)*0.5*Math.cos(t),w*(2+p)*Math.sin(t)*0.5,B*w*Math.sin(m)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=d||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=c||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,h,o)))-1);l.push(k)}c.push(l)}var n,w,p;d=c.length;for(b=0;b0)for(e=0;e1){n=this.vertices[g].position.clone(); +w=this.vertices[j].position.clone();p=this.vertices[l].position.clone();n.normalize();w.normalize();p.normalize();this.faces.push(new THREE.Face3(g,j,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(p.x,p.y,p.z)]));this.faceVertexUvs[0].push([k,t,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; +THREE.Torus=function(a,c,b,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var d=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(d))*Math.cos(e),(this.radius+this.tube*Math.cos(d))*Math.sin(e),this.tube*Math.sin(d))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= +1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*c+b;d=(this.segmentsT+1)*c+b-1;var f=(this.segmentsT+1)*(c-1)+b-1,g=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(e,d,f,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; +THREE.TorusKnot=function(a,c,b,e,d,f,g){function h(t,o,n,w,p,z){o=n/w*t;n=Math.cos(o);return new THREE.Vector3(p*(2+n)*0.5*Math.cos(t),p*(2+n)*Math.sin(t)*0.5,z*p*Math.sin(o)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=d||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a>7)-127;A|=(I&127)<<16|C<<8;if(A==0&&V==-127)return 0;return(1-2*(P>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,V)}function h(u,v){var A=k(u,v),C=k(u,v+1),I=k(u,v+2);return(k(u,v+3)<<24)+(I<<16)+(C<<8)+A}function j(u,v){var A=k(u,v);return(k(u,v+1)<<8)+A}function l(u,v){var A=k(u,v);return A>127?A-256:A}function k(u, -v){return u.charCodeAt(v)&255}function t(u){var v,A,C;v=h(a,u);A=h(a,u+G);C=h(a,u+K);u=j(a,u+H);THREE.BinaryLoader.prototype.f3(n,v,A,C,u)}function m(u){var v,A,C,I,P,V;v=h(a,u);A=h(a,u+G);C=h(a,u+K);I=j(a,u+H);P=h(a,u+J);V=h(a,u+L);u=h(a,u+E);THREE.BinaryLoader.prototype.f3n(n,D,v,A,C,I,P,V,u)}function p(u){var v,A,C,I;v=h(a,u);A=h(a,u+R);C=h(a,u+S);I=h(a,u+N);u=j(a,u+M);THREE.BinaryLoader.prototype.f4(n,v,A,C,I,u)}function y(u){var v,A,C,I,P,V,da,ea;v=h(a,u);A=h(a,u+R);C=h(a,u+S);I=h(a,u+N);P=j(a, -u+M);V=h(a,u+T);da=h(a,u+U);ea=h(a,u+F);u=h(a,u+W);THREE.BinaryLoader.prototype.f4n(n,D,v,A,C,I,P,V,da,ea,u)}function w(u){var v,A;v=h(a,u);A=h(a,u+Q);u=h(a,u+O);THREE.BinaryLoader.prototype.uv3(n.faceVertexUvs[0],z[v*2],z[v*2+1],z[A*2],z[A*2+1],z[u*2],z[u*2+1])}function B(u){var v,A,C;v=h(a,u);A=h(a,u+Y);C=h(a,u+fa);u=h(a,u+ga);THREE.BinaryLoader.prototype.uv4(n.faceVertexUvs[0],z[v*2],z[v*2+1],z[A*2],z[A*2+1],z[C*2],z[C*2+1],z[u*2],z[u*2+1])}var n=this,x=0,o,D=[],z=[],G,K,H,J,L,E,R,S,N,M,T,U,F, -W,Q,O,Y,fa,ga,Z,$,aa,ba,ca,X;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(n,e,f);o={signature:a.substr(x,8),header_bytes:k(a,x+8),vertex_coordinate_bytes:k(a,x+9),normal_coordinate_bytes:k(a,x+10),uv_coordinate_bytes:k(a,x+11),vertex_index_bytes:k(a,x+12),normal_index_bytes:k(a,x+13),uv_index_bytes:k(a,x+14),material_index_bytes:k(a,x+15),nvertices:h(a,x+16),nnormals:h(a,x+16+4),nuvs:h(a,x+16+8),ntri_flat:h(a,x+16+12),ntri_smooth:h(a,x+16+16),ntri_flat_uv:h(a,x+16+20),ntri_smooth_uv:h(a, -x+16+24),nquad_flat:h(a,x+16+28),nquad_smooth:h(a,x+16+32),nquad_flat_uv:h(a,x+16+36),nquad_smooth_uv:h(a,x+16+40)};x+=o.header_bytes;G=o.vertex_index_bytes;K=o.vertex_index_bytes*2;H=o.vertex_index_bytes*3;J=o.vertex_index_bytes*3+o.material_index_bytes;L=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;E=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;R=o.vertex_index_bytes;S=o.vertex_index_bytes*2;N=o.vertex_index_bytes*3;M=o.vertex_index_bytes*4;T=o.vertex_index_bytes* -4+o.material_index_bytes;U=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;F=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;W=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;Q=o.uv_index_bytes;O=o.uv_index_bytes*2;Y=o.uv_index_bytes;fa=o.uv_index_bytes*2;ga=o.uv_index_bytes*3;f=o.vertex_index_bytes*3+o.material_index_bytes;X=o.vertex_index_bytes*4+o.material_index_bytes;Z=o.ntri_flat*f;$=o.ntri_smooth*(f+o.normal_index_bytes*3);aa=o.ntri_flat_uv* -(f+o.uv_index_bytes*3);ba=o.ntri_smooth_uv*(f+o.normal_index_bytes*3+o.uv_index_bytes*3);ca=o.nquad_flat*X;f=o.nquad_smooth*(X+o.normal_index_bytes*4);X=o.nquad_flat_uv*(X+o.uv_index_bytes*4);x+=function(u){for(var v,A,C,I=o.vertex_coordinate_bytes*3,P=u+o.nvertices*I;u1&& -(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(K,L);object.name=y;object.position.set(D[0],D[1],D[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=o.visible;F.scene.addObject(object);F.objects[y]=object;if(o.meshCollider){var O=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(O)}if(o.castsShadow){O=new THREE.ShadowVolume(K);F.scene.addChild(O);O.position= -object.position;O.rotation=object.rotation;O.scale=object.scale}}}}function k(O){return function(Y){F.geometries[O]=Y;l();N-=1;c.onLoadComplete();t()}}function t(){e({total_models:T,total_textures:U,loaded_models:T-N,loaded_textures:U-M},F);c.onLoadProgress();N==0&&M==0&&b(F)}var m,p,y,w,B,n,x,o,D,z,G,K,H,J,L,E,R,S,N,M,T,U,F;E=h.data;R=new THREE.BinaryLoader;S=new THREE.JSONLoader;M=N=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(E.transform){h= -E.transform.position;z=E.transform.rotation;var W=E.transform.scale;h&&F.scene.position.set(h[0],h[1],h[2]);z&&F.scene.rotation.set(z[0],z[1],z[2]);W&&F.scene.scale.set(W[0],W[1],W[2]);(h||z||W)&&F.scene.updateMatrix()}h=function(){M-=1;t();c.onLoadComplete()};for(B in E.cameras){z=E.cameras[B];if(z.type=="perspective")H=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho"){H=new THREE.Camera;H.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far)}D= -z.position;z=z.target;H.position.set(D[0],D[1],D[2]);H.target.position.set(z[0],z[1],z[2]);F.cameras[B]=H}for(w in E.lights){B=E.lights[w];H=B.color!==undefined?B.color:16777215;z=B.intensity!==undefined?B.intensity:1;if(B.type=="directional"){D=B.direction;light=new THREE.DirectionalLight(H,z);light.position.set(D[0],D[1],D[2]);light.position.normalize()}else if(B.type=="point"){D=B.position;light=new THREE.PointLight(H,z);light.position.set(D[0],D[1],D[2])}F.scene.addLight(light);F.lights[w]=light}for(n in E.fogs){w= -E.fogs[n];if(w.type=="linear")J=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(J=new THREE.FogExp2(0,w.density));z=w.color;J.color.setRGB(z[0],z[1],z[2]);F.fogs[n]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];if(F.fogs&&E.defaults.fog)F.scene.fog=F.fogs[E.defaults.fog];z=E.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(z[0],z[1],z[2]);F.bgColorAlpha=E.defaults.bgalpha;for(m in E.geometries){n=E.geometries[m];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){N+= -1;c.onLoadStart()}}T=N;for(m in E.geometries){n=E.geometries[m];if(n.type=="cube"){K=new THREE.Cube(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);F.geometries[m]=K}else if(n.type=="plane"){K=new THREE.Plane(n.width,n.height,n.segmentsWidth,n.segmentsHeight);F.geometries[m]=K}else if(n.type=="sphere"){K=new THREE.Sphere(n.radius,n.segmentsWidth,n.segmentsHeight);F.geometries[m]=K}else if(n.type=="cylinder"){K=new THREE.Cylinder(n.numSegs,n.topRad, -n.botRad,n.height,n.topOffset,n.botOffset);F.geometries[m]=K}else if(n.type=="torus"){K=new THREE.Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);F.geometries[m]=K}else if(n.type=="icosahedron"){K=new THREE.Icosahedron(n.subdivisions);F.geometries[m]=K}else if(n.type=="bin_mesh")R.load({model:j(n.url,E.urlBaseType),callback:k(m)});else n.type=="ascii_mesh"&&S.load({model:j(n.url,E.urlBaseType),callback:k(m)})}for(x in E.textures){m=E.textures[x];if(m.url instanceof Array){M+=m.url.length;for(n=0;n< -m.url.length;n++)c.onLoadStart()}else{M+=1;c.onLoadStart()}}U=M;for(x in E.textures){m=E.textures[x];if(m.mapping!=undefined&&THREE[m.mapping]!=undefined)m.mapping=new THREE[m.mapping];if(m.url instanceof Array){n=[];for(var Q=0;Q=this.maxCount-3&&h(this)};this.begin= -function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;ethis.size-1&&(j=this.size-1);var m=Math.floor(l-h);m<1&&(m=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);h=Math.floor(k+h); -h>this.size-1&&(h=this.size-1);for(var y,w,B,n,x,o;t0&&(this.field[B+y]+=n)}}}};this.addPlaneX=function(b,e){var c,f,g,h,j,l=this.size,k=this.yd,t=this.zd,m=this.field,p=l*Math.sqrt(b/e);p>l&&(p=l);for(c=0;c0)for(f=0;fk&&(y=k);for(f=0;f0){j=f*t;for(c=0;csize&&(dist=size);for(g=0;g0){j=zd*g;for(f=0;f>7)-127;A|=(G&127)<<16|E<<8;if(A==0&&U==-127)return 0;return(1-2*(R>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,U)}function h(u,x){var A=k(u,x),E=k(u,x+1),G=k(u,x+2);return(k(u,x+3)<<24)+(G<<16)+(E<<8)+A}function j(u,x){var A=k(u,x);return(k(u,x+1)<<8)+A}function l(u,x){var A=k(u,x);return A>127?A-256:A}function k(u, +x){return u.charCodeAt(x)&255}function t(u){var x,A,E;x=h(a,u);A=h(a,u+I);E=h(a,u+L);u=j(a,u+H);THREE.BinaryLoader.prototype.f3(v,x,A,E,u)}function o(u){var x,A,E,G,R,U;x=h(a,u);A=h(a,u+I);E=h(a,u+L);G=j(a,u+H);R=h(a,u+B);U=h(a,u+K);u=h(a,u+J);THREE.BinaryLoader.prototype.f3n(v,D,x,A,E,G,R,U,u)}function n(u){var x,A,E,G;x=h(a,u);A=h(a,u+P);E=h(a,u+T);G=h(a,u+Q);u=j(a,u+F);THREE.BinaryLoader.prototype.f4(v,x,A,E,G,u)}function w(u){var x,A,E,G,R,U,ba,ca;x=h(a,u);A=h(a,u+P);E=h(a,u+T);G=h(a,u+Q);R=j(a, +u+F);U=h(a,u+N);ba=h(a,u+S);ca=h(a,u+M);u=h(a,u+O);THREE.BinaryLoader.prototype.f4n(v,D,x,A,E,G,R,U,ba,ca,u)}function p(u){var x,A;x=h(a,u);A=h(a,u+W);u=h(a,u+da);THREE.BinaryLoader.prototype.uv3(v.faceVertexUvs[0],C[x*2],C[x*2+1],C[A*2],C[A*2+1],C[u*2],C[u*2+1])}function z(u){var x,A,E;x=h(a,u);A=h(a,u+ea);E=h(a,u+fa);u=h(a,u+ga);THREE.BinaryLoader.prototype.uv4(v.faceVertexUvs[0],C[x*2],C[x*2+1],C[A*2],C[A*2+1],C[E*2],C[E*2+1],C[u*2],C[u*2+1])}var v=this,y=0,m,D=[],C=[],I,L,H,B,K,J,P,T,Q,F,N,S, +M,O,W,da,ea,fa,ga,X,Y,Z,$,aa,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);m={signature:a.substr(y,8),header_bytes:k(a,y+8),vertex_coordinate_bytes:k(a,y+9),normal_coordinate_bytes:k(a,y+10),uv_coordinate_bytes:k(a,y+11),vertex_index_bytes:k(a,y+12),normal_index_bytes:k(a,y+13),uv_index_bytes:k(a,y+14),material_index_bytes:k(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a, +y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=m.header_bytes;I=m.vertex_index_bytes;L=m.vertex_index_bytes*2;H=m.vertex_index_bytes*3;B=m.vertex_index_bytes*3+m.material_index_bytes;K=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes;T=m.vertex_index_bytes*2;Q=m.vertex_index_bytes*3;F=m.vertex_index_bytes*4;N=m.vertex_index_bytes* +4+m.material_index_bytes;S=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;M=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;O=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;W=m.uv_index_bytes;da=m.uv_index_bytes*2;ea=m.uv_index_bytes;fa=m.uv_index_bytes*2;ga=m.uv_index_bytes*3;f=m.vertex_index_bytes*3+m.material_index_bytes;V=m.vertex_index_bytes*4+m.material_index_bytes;X=m.ntri_flat*f;Y=m.ntri_smooth*(f+m.normal_index_bytes*3);Z=m.ntri_flat_uv* +(f+m.uv_index_bytes*3);$=m.ntri_smooth_uv*(f+m.normal_index_bytes*3+m.uv_index_bytes*3);aa=m.nquad_flat*V;f=m.nquad_smooth*(V+m.normal_index_bytes*4);V=m.nquad_flat_uv*(V+m.uv_index_bytes*4);y+=function(u){for(var x,A,E,G=m.vertex_coordinate_bytes*3,R=u+m.nvertices*G;u1&&(H=[new THREE.MeshFaceMaterial]); +object=new THREE.Mesh(C,H);object.name=o;object.position.set(y[0],y[1],y[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=v.visible;F.scene.addObject(object);F.objects[o]=object;if(v.meshCollider){var O=THREE.CollisionUtils.MeshColliderWBox(object);F.scene.collisions.colliders.push(O)}if(v.castsShadow){O=new THREE.ShadowVolume(C);F.scene.addChild(O);O.position=object.position;O.rotation= +object.rotation;O.scale=object.scale}}}}function j(O){return function(W){F.geometries[O]=W;h();J-=1;b.onLoadComplete();l()}}function l(){b.callbackProgress({totalModels:T,totalTextures:Q,loadedModels:T-J,loadedTextures:Q-P},F);b.onLoadProgress();J==0&&P==0&&c(F)}var k,t,o,n,w,p,z,v,y,m,D,C,I,L,H,B,K,J,P,T,Q,F;B=f.data;f=new THREE.BinaryLoader;K=new THREE.JSONLoader;P=J=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};var N=!1;for(o in B.objects){v= +B.objects[o];if(v.meshCollider){N=!0;break}}if(N)F.scene.collisions=new THREE.CollisionSystem;if(B.transform){N=B.transform.position;m=B.transform.rotation;var S=B.transform.scale;N&&F.scene.position.set(N[0],N[1],N[2]);m&&F.scene.rotation.set(m[0],m[1],m[2]);S&&F.scene.scale.set(S[0],S[1],S[2]);(N||m||S)&&F.scene.updateMatrix()}N=function(){P-=1;l();b.onLoadComplete()};for(w in B.cameras){m=B.cameras[w];if(m.type=="perspective")I=new THREE.Camera(m.fov,m.aspect,m.near,m.far);else if(m.type=="ortho"){I= +new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(m.left,m.right,m.top,m.bottom,m.near,m.far)}y=m.position;m=m.target;I.position.set(y[0],y[1],y[2]);I.target.position.set(m[0],m[1],m[2]);F.cameras[w]=I}for(n in B.lights){w=B.lights[n];I=w.color!==undefined?w.color:16777215;m=w.intensity!==undefined?w.intensity:1;if(w.type=="directional"){y=w.direction;light=new THREE.DirectionalLight(I,m);light.position.set(y[0],y[1],y[2]);light.position.normalize()}else if(w.type=="point"){y=w.position; +light=new THREE.PointLight(I,m);light.position.set(y[0],y[1],y[2])}F.scene.addLight(light);F.lights[n]=light}for(p in B.fogs){n=B.fogs[p];if(n.type=="linear")L=new THREE.Fog(0,n.near,n.far);else n.type=="exp2"&&(L=new THREE.FogExp2(0,n.density));m=n.color;L.color.setRGB(m[0],m[1],m[2]);F.fogs[p]=L}if(F.cameras&&B.defaults.camera)F.currentCamera=F.cameras[B.defaults.camera];if(F.fogs&&B.defaults.fog)F.scene.fog=F.fogs[B.defaults.fog];m=B.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(m[0], +m[1],m[2]);F.bgColorAlpha=B.defaults.bgalpha;for(k in B.geometries){p=B.geometries[k];if(p.type=="bin_mesh"||p.type=="ascii_mesh"){J+=1;b.onLoadStart()}}T=J;for(k in B.geometries){p=B.geometries[k];if(p.type=="cube"){C=new THREE.Cube(p.width,p.height,p.depth,p.segmentsWidth,p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides);F.geometries[k]=C}else if(p.type=="plane"){C=new THREE.Plane(p.width,p.height,p.segmentsWidth,p.segmentsHeight);F.geometries[k]=C}else if(p.type=="sphere"){C=new THREE.Sphere(p.radius, +p.segmentsWidth,p.segmentsHeight);F.geometries[k]=C}else if(p.type=="cylinder"){C=new THREE.Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);F.geometries[k]=C}else if(p.type=="torus"){C=new THREE.Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);F.geometries[k]=C}else if(p.type=="icosahedron"){C=new THREE.Icosahedron(p.subdivisions);F.geometries[k]=C}else if(p.type=="bin_mesh")f.load({model:g(p.url,B.urlBaseType),callback:j(k)});else p.type=="ascii_mesh"&&K.load({model:g(p.url, +B.urlBaseType),callback:j(k)})}for(z in B.textures){k=B.textures[z];if(k.url instanceof Array){P+=k.url.length;for(p=0;p=this.maxCount-3&&h(this)};this.begin= +function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;ethis.size-1&&(j=this.size-1);var o=Math.floor(l-h);o<1&&(o=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);h=Math.floor(k+h); +h>this.size-1&&(h=this.size-1);for(var w,p,z,v,y,m;t0&&(this.field[z+w]+=v)}}}};this.addPlaneX=function(b,e){var d,f,g,h,j,l=this.size,k=this.yd,t=this.zd,o=this.field,n=l*Math.sqrt(b/e);n>l&&(n=l);for(d=0;d0)for(f=0;fk&&(w=k);for(f=0;f0){j=f*t;for(d=0;dsize&&(dist=size);for(g=0;g0){j=zd*g;for(f=0;ff?this.hits.push(c):this.hits.unshift(c);f=e}}return this.hits}; -THREE.CollisionSystem.prototype.rayCastNearest=function(a){var d=this.rayCastAll(a);if(d.length==0)return null;for(var b=0;d[b]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,d[b]);if(ed.length)return null;return d[b]}; -THREE.CollisionSystem.prototype.rayCast=function(a,d){if(d instanceof THREE.PlaneCollider)return this.rayPlane(a,d);else if(d instanceof THREE.SphereCollider)return this.raySphere(a,d);else if(d instanceof THREE.BoxCollider)return this.rayBox(a,d);else if(d instanceof THREE.MeshCollider&&d.box)return this.rayBox(a,d.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(a,d){for(var b=this.makeRayLocal(a,d.mesh),e=Number.MAX_VALUE,c=0;c=g*c))return Number.MAX_VALUE;f/=g;var j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(f);j.addSelf(a.origin);if(Math.abs(h.x)>Math.abs(h.y))if(Math.abs(h.x)> -Math.abs(h.z)){a=j.y-d.y;c=b.y-d.y;g=e.y-d.y;j=j.z-d.z;b=b.z-d.z;e=e.z-d.z}else{a=j.x-d.x;c=b.x-d.x;g=e.x-d.x;j=j.y-d.y;b=b.y-d.y;e=e.y-d.y}else if(Math.abs(h.y)>Math.abs(h.z)){a=j.x-d.x;c=b.x-d.x;g=e.x-d.x;j=j.z-d.z;b=b.z-d.z;e=e.z-d.z}else{a=j.x-d.x;c=b.x-d.x;g=e.x-d.x;j=j.y-d.y;b=b.y-d.y;e=e.y-d.y}d=c*e-b*g;if(d==0)return Number.MAX_VALUE;d=1/d;e=(a*e-j*g)*d;if(!(e>=0))return Number.MAX_VALUE;d*=c*j-b*a;if(!(d>=0))return Number.MAX_VALUE;if(!(1-e-d>=0))return Number.MAX_VALUE;this.collisionNormal= -h;return f};THREE.CollisionSystem.prototype.makeRayLocal=function(a,d){var b=new THREE.Ray(a.origin.clone(),a.direction.clone()),e=THREE.Matrix4.makeInvert(d.matrixWorld);e.multiplyVector3(b.origin);e.rotateAxis(b.direction);b.direction.normalize();return b}; -THREE.CollisionSystem.prototype.rayBox=function(a,d){var b;b=d.dynamic&&d.mesh&&d.mesh.matrixWorld?this.makeRayLocal(a,d.mesh):new THREE.Ray(a.origin.clone(),a.direction.clone());var e=0,c=0,f=0,g=0,h=0,j=0,l=!0;if(b.origin.xd.max.x){e=d.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.yd.max.y){c=d.max.y-b.origin.y;c/=b.direction.y;l=!1;h= -1}if(b.origin.zd.max.z){f=d.max.z-b.origin.z;f/=b.direction.z;l=!1;j=1}if(l)return-1;l=0;if(c>e){l=1;e=c}if(f>e){l=2;e=f}switch(l){case 0:h=b.origin.y+b.direction.y*e;if(hd.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(gd.max.x)return Number.MAX_VALUE;b=b.origin.z+ -b.direction.z*e;if(bd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(gd.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(hd.max.y)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,0,j)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,d){var b=a.direction.dot(d.normal),e=d.point.dot(d.normal);if(b<0)b=(e-a.origin.dot(d.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE}; -THREE.CollisionSystem.prototype.raySphere=function(a,d){var b=d.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.CollisionUtils={}; -THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var d=a.geometry.boundingBox,b=new THREE.Vector3(d.x[0],d.y[0],d.z[0]);d=new THREE.Vector3(d.x[1],d.y[1],d.z[1]);b=new THREE.BoxCollider(b,d);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var d=THREE.CollisionUtils.MeshOBB(a);d.min.addSelf(a.position);d.max.addSelf(a.position);d.dynamic=!1;return d}; -THREE.CollisionUtils.MeshColliderWBox=function(a){for(var d=a.geometry.vertices,b=d.length,e=a.geometry.faces,c=e.length,f=[],g=[],h=[],j=0;jf?this.hits.push(d):this.hits.unshift(d);f=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(ec.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,d=0;d=g*d))return Number.MAX_VALUE;f/=g;var j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(f);j.addSelf(a.origin);if(Math.abs(h.x)>Math.abs(h.y))if(Math.abs(h.x)> +Math.abs(h.z)){a=j.y-c.y;d=b.y-c.y;g=e.y-c.y;j=j.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=j.x-c.x;d=b.x-c.x;g=e.x-c.x;j=j.y-c.y;b=b.y-c.y;e=e.y-c.y}else if(Math.abs(h.y)>Math.abs(h.z)){a=j.x-c.x;d=b.x-c.x;g=e.x-c.x;j=j.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=j.x-c.x;d=b.x-c.x;g=e.x-c.x;j=j.y-c.y;b=b.y-c.y;e=e.y-c.y}c=d*e-b*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-j*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=d*j-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;this.collisionNormal= +h;return f};THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=new THREE.Ray(a.origin.clone(),a.direction.clone()),e=THREE.Matrix4.makeInvert(c.matrixWorld);e.multiplyVector3(b.origin);e.rotateAxis(b.direction);b.direction.normalize();return b}; +THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;b=c.dynamic&&c.mesh&&c.mesh.matrixWorld?this.makeRayLocal(a,c.mesh):new THREE.Ray(a.origin.clone(),a.direction.clone());var e=0,d=0,f=0,g=0,h=0,j=0,l=!0;if(b.origin.xc.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.yc.max.y){d=c.max.y-b.origin.y;d/=b.direction.y;l=!1;h= +1}if(b.origin.zc.max.z){f=c.max.z-b.origin.z;f/=b.direction.z;l=!1;j=1}if(l)return-1;l=0;if(d>e){l=1;e=d}if(f>e){l=2;e=f}switch(l){case 0:h=b.origin.y+b.direction.y*e;if(hc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal=new THREE.Vector3(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(gc.max.x)return Number.MAX_VALUE;b=b.origin.z+ +b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal=new THREE.Vector3(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(gc.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(hc.max.y)return Number.MAX_VALUE;c.normal=new THREE.Vector3(0,0,j)}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.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){for(var c=a.geometry.vertices,b=c.length,e=a.geometry.faces,d=e.length,f=[],g=[],h=[],j=0;j