From 207df16bf690ceed955cf53eb3b53bcb85e5b46a Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 26 Jul 2011 12:22:30 +0200 Subject: [PATCH] Meging with alteredq's dev branch. --- build/Three.js | 478 ++++++++++++------------ build/custom/ThreeCanvas.js | 4 +- build/custom/ThreeExtras.js | 12 +- build/custom/ThreeWebGL.js | 185 ++++----- examples/webgl_flycamera_earth.html | 2 +- src/extras/cameras/FirstPersonCamera.js | 12 +- src/materials/Texture.js | 7 +- src/renderers/WebGLRenderer.js | 23 +- src/renderers/WebGLShaders.js | 7 + 9 files changed, 385 insertions(+), 345 deletions(-) diff --git a/build/Three.js b/build/Three.js index f09dd9fd..e8bb32b3 100755 --- a/build/Three.js +++ b/build/Three.js @@ -15,8 +15,8 @@ b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){ setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,j,h,m,n,p,o,t,u,v,x=b.geometry, -w=x.vertices,B=[],f=0;for(g=x.faces.length;f0:t<0))if(o=o.dot((new THREE.Vector3).sub(h,u))/t,u=u.addSelf(v.multiplyScalar(o)), -j instanceof THREE.Face3)e(u,h,m,n)&&(j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},B.push(j));else if(j instanceof THREE.Face4&&(e(u,h,m,p)||e(u,m,n,p)))j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},B.push(j);return B}else return[]}}; +w=x.vertices,y=[],f=0;for(g=x.faces.length;f0:t<0))if(o=o.dot((new THREE.Vector3).sub(h,u))/t,u=u.addSelf(v.multiplyScalar(o)), +j instanceof THREE.Face3)e(u,h,m,n)&&(j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},y.push(j));else if(j instanceof THREE.Face4&&(e(u,h,m,p)||e(u,m,n,p)))j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},y.push(j);return y}else return[]}}; THREE.Rectangle=function(){function b(){j=f-c;h=g-e}var c,e,f,g,j,h,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,j,o,t){m=!1;c=h;e=j;f=o;g=t;b()};this.addPoint=function(h,j){m?(m=!1,c=h,e=j,f=h,g=j):(c=ch?f:h,g=g>j?g:j);b()};this.add3Points= function(h,j,o,t,u,v){m?(m=!1,c=ho?h>u?h:u:o>u?o:u,g=j>t?j>v?j:v:t>v?t:v):(c=ho?h>u?h>f?h:f:u>f?u:f:o>u?o>f?o:f:u>f?u:f,g=j>t?j>v?j>g?j:g:v>g?v:g:t>v?t>g?t:g:v>g?v:g);b()};this.addRectangle=function(h){m?(m=!1,c=h.getLeft(),e=h.getTop(),f=h.getRight(),g=h.getBottom()):(c=ch.getRight()?f:h.getRight(),g=g> h.getBottom()?g:h.getBottom());b()};this.inflate=function(h){c-=h;e-=h;f+=h;g+=h;b()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();e=e>h.getTop()?e:h.getTop();f=f=0&&Math.min(g,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){m=!0;g=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]}; @@ -24,8 +24,8 @@ THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[ THREE.Matrix4.prototype={set:function(b,c,e,f,g,j,h,m,n,p,o,t,u,v,x,w){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=h;this.n24=m;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=u;this.n42=v;this.n43=x;this.n44=w;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;f.cross(e,j).normalize();f.length()===0&&(j.x+=1.0E-4,f.cross(e,j).normalize());g.cross(j,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=j.x;this.n21=f.y;this.n22=g.y;this.n23=j.y;this.n31=f.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g;b.y=(this.n21*c+this.n22*e+this.n23* f+this.n24)*g;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+e*this.n32+f*this.n33;b.normalize(); -return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,x=b.n41,w=b.n42,B=b.n43,y=b.n44,F=c.n11,C=c.n12,E=c.n13,G=c.n14,A=c.n21,P=c.n22, -I=c.n23,H=c.n24,T=c.n31,U=c.n32,J=c.n33,Y=c.n34,K=c.n41,S=c.n42,k=c.n43,V=c.n44;this.n11=e*F+f*A+g*T+j*K;this.n12=e*C+f*P+g*U+j*S;this.n13=e*E+f*I+g*J+j*k;this.n14=e*G+f*H+g*Y+j*V;this.n21=h*F+m*A+n*T+p*K;this.n22=h*C+m*P+n*U+p*S;this.n23=h*E+m*I+n*J+p*k;this.n24=h*G+m*H+n*Y+p*V;this.n31=o*F+t*A+u*T+v*K;this.n32=o*C+t*P+u*U+v*S;this.n33=o*E+t*I+u*J+v*k;this.n34=o*G+t*H+u*Y+v*V;this.n41=x*F+w*A+B*T+y*K;this.n42=x*C+w*P+B*U+y*S;this.n43=x*E+w*I+B*J+y*k;this.n44=x*G+w*H+B*Y+y*V;return this},multiplyToArray:function(b, +return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,x=b.n41,w=b.n42,y=b.n43,C=b.n44,E=c.n11,B=c.n12,I=c.n13,F=c.n14,A=c.n21,P=c.n22, +H=c.n23,G=c.n24,U=c.n31,V=c.n32,J=c.n33,Z=c.n34,K=c.n41,S=c.n42,k=c.n43,W=c.n44;this.n11=e*E+f*A+g*U+j*K;this.n12=e*B+f*P+g*V+j*S;this.n13=e*I+f*H+g*J+j*k;this.n14=e*F+f*G+g*Z+j*W;this.n21=h*E+m*A+n*U+p*K;this.n22=h*B+m*P+n*V+p*S;this.n23=h*I+m*H+n*J+p*k;this.n24=h*F+m*G+n*Z+p*W;this.n31=o*E+t*A+u*U+v*K;this.n32=o*B+t*P+u*V+v*S;this.n33=o*I+t*H+u*J+v*k;this.n34=o*F+t*G+u*Z+v*W;this.n41=x*E+w*A+y*U+C*K;this.n42=x*B+w*P+y*V+C*S;this.n43=x*I+w*H+y*J+C*k;this.n44=x*F+w*G+y*Z+C*W;return this},multiplyToArray:function(b, c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*= b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,j=this.n22,h=this.n23,m=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,u=this.n41,v=this.n42,x=this.n43,w=this.n44;return f*h*p*u-e*m*p*u-f*j*o*u+c*m*o*u+e*j*t*u-c*h*t*u-f*h*n*v+e*m*n*v+f*g*o*v-b*m*o*v-e*g*t*v+b*h*t*v+f*j*n*x-c*m*n*x-f*g*p*x+b*m*p*x+c*g*t*x-b*j*t*x-e*j*n*w+c*h*n*w+e*g*p*w-b*h*p*w-c*g*o*w+b*j*o*w},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= @@ -38,8 +38,8 @@ o*e-p;this.n13=j*f;this.n21=j*g;this.n22=j*m;this.n23=-e;this.n31=p*e-o;this.n32 o*g+p;this.n21=g;this.n22=j*m;this.n23=-e*m;this.n31=-f*m;this.n32=p*g+o;this.n33=n-t*g;break;case "XZY":n=j*h;p=j*f;o=e*h;t=e*f;this.n11=h*m;this.n12=-g;this.n13=f*m;this.n21=n*g+t;this.n22=j*m;this.n23=p*g-o;this.n31=o*g-p;this.n32=e*m;this.n33=t*g+n;break;default:n=j*m,p=j*g,o=e*m,t=e*g,this.n11=h*m,this.n12=-h*g,this.n13=f,this.n21=p+o*f,this.n22=n-t*f,this.n23=-e*h,this.n31=t-n*f,this.n32=o+p*f,this.n33=j*h}return this},setRotationFromQuaternion:function(b){var c=b.x,e=b.y,f=b.z,g=b.w,j=c+c, h=e+e,m=f+f,b=c*j,n=c*h;c*=m;var p=e*h;e*=m;f*=m;j*=g;h*=g;g*=m;this.n11=1-(p+f);this.n12=n-g;this.n13=c+h;this.n21=n+g;this.n22=1-(b+f);this.n23=e-j;this.n31=c-h;this.n32=e+j;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b, c){var e=1/c.x,f=1/c.y,g=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,x=b.n41,w=b.n42,B=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*w-p*u*w+p*t*B-m*v*B-n*t*y+m*u*y;c.n12=j*u*w-g*v*w-j*t*B+f*v*B+g*t*y-f*u*y;c.n13=g*p*w-j*n*w+j*m*B-f*p*B-g*m*y+f*n*y;c.n14=j*n*t-g*p*t-j*m*u+f*p*u+g*m*v-f*n*v;c.n21=p*u*x-n*v*x-p*o*B+h*v*B+n*o*y-h*u*y;c.n22=g*v*x-j*u*x+j*o*B-e*v*B-g*o*y+e*u*y;c.n23=j*n*x-g*p*x-j*h*B+e*p*B+g*h*y-e*n*y;c.n24= -g*p*o-j*n*o+j*h*u-e*p*u-g*h*v+e*n*v;c.n31=m*v*x-p*t*x+p*o*w-h*v*w-m*o*y+h*t*y;c.n32=j*t*x-f*v*x-j*o*w+e*v*w+f*o*y-e*t*y;c.n33=g*p*x-j*m*x+j*h*w-e*p*w-f*h*y+e*m*y;c.n34=j*m*o-f*p*o-j*h*t+e*p*t+f*h*v-e*m*v;c.n41=n*t*x-m*u*x-n*o*w+h*u*w+m*o*B-h*t*B;c.n42=f*u*x-g*t*x+g*o*w-e*u*w-f*o*B+e*t*B;c.n43=g*m*x-f*n*x-g*h*w+e*n*w+f*h*B-e*m*B;c.n44=f*n*o-g*m*o+g*h*t-e*n*t-f*h*u+e*m*u;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,x=b.n41,w=b.n42,y=b.n43,C=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*w-p*u*w+p*t*y-m*v*y-n*t*C+m*u*C;c.n12=j*u*w-g*v*w-j*t*y+f*v*y+g*t*C-f*u*C;c.n13=g*p*w-j*n*w+j*m*y-f*p*y-g*m*C+f*n*C;c.n14=j*n*t-g*p*t-j*m*u+f*p*u+g*m*v-f*n*v;c.n21=p*u*x-n*v*x-p*o*y+h*v*y+n*o*C-h*u*C;c.n22=g*v*x-j*u*x+j*o*y-e*v*y-g*o*C+e*u*C;c.n23=j*n*x-g*p*x-j*h*y+e*p*y+g*h*C-e*n*C;c.n24= +g*p*o-j*n*o+j*h*u-e*p*u-g*h*v+e*n*v;c.n31=m*v*x-p*t*x+p*o*w-h*v*w-m*o*C+h*t*C;c.n32=j*t*x-f*v*x-j*o*w+e*v*w+f*o*C-e*t*C;c.n33=g*p*x-j*m*x+j*h*w-e*p*w-f*h*C+e*m*C;c.n34=j*m*o-f*p*o-j*h*t+e*p*t+f*h*v-e*m*v;c.n41=n*t*x-m*u*x-n*o*w+h*u*w+m*o*y-h*t*y;c.n42=f*u*x-g*t*x+g*o*w-e*u*w-f*o*y+e*t*y;c.n43=g*m*x-f*n*x-g*h*w+e*n*w+f*h*y-e*m*y;c.n44=f*n*o-g*m*o+g*h*t-e*n*t-f*h*u+e*m*u;c.multiplyScalar(1/b.determinant());return c}; THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,h=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*h+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*j;e[3]=b*h;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*t;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,g,j){var h;h=new THREE.Matrix4;h.n11=2*g/(c-b);h.n12=0;h.n13=(c+b)/(c-b);h.n14=0;h.n21=0;h.n22=2*g/(f-e);h.n23=(f+e)/(f-e);h.n24=0;h.n31=0;h.n32=0;h.n33=-(j+g)/(j-g);h.n34=-2*j*g/(j-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(b,c,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,e,f)}; THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var h,m,n,p;h=new THREE.Matrix4;m=c-b;n=e-f;p=j-g;h.n11=2/m;h.n12=0;h.n13=0;h.n14=-((c+b)/m);h.n21=0;h.n22=2/n;h.n23=0;h.n24=-((e+f)/n);h.n31=0;h.n32=0;h.n33=-2/p;h.n34=-((j+g)/p);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; @@ -61,9 +61,9 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,c,e;b=0;for(c=this.f e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,g,j,h,m=new THREE.Vector3,n=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 c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, this.LODs[f].object3D.visible=!0;else break;for(;ft&&(e=o,o=t,t=e):ov&&(e=u,u=v,v=e):ut&&(e=o,o=t,t=e):ov&&(e=u,u=v,v=e):u=0&&g>=0&&j>=0&&m>=0?!0:h<0&&g<0||j<0&&m<0?!1:(h<0?c=Math.max(c,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),j<0?c=Math.max(c,j/(j-m)):m<0&&(f=Math.min(f,j/(j-m))),fS&&h.positionScreen.z0&&G.z<1))ha=C[F]=C[F]||new THREE.RenderableParticle,F++,y=ha,y.x=G.x/G.w,y.y=G.y/G.w,y.z=G.z,y.rotation=R.rotation.z,y.scale.x= -R.scale.x*Math.abs(y.x-(G.x+g.projectionMatrix.n11)/(G.w+g.projectionMatrix.n14)),y.scale.y=R.scale.y*Math.abs(y.y-(G.y+g.projectionMatrix.n22)/(G.w+g.projectionMatrix.n24)),y.materials=R.materials,E.push(y);j&&E.sort(c);return E}}; +THREE.Projector=function(){function b(){var b=n[m]=n[m]||new THREE.RenderableVertex;m++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,h=b.z+b.w,g=e.z+e.w,j=-b.z+b.w,m=-e.z+e.w;return h>=0&&g>=0&&j>=0&&m>=0?!0:h<0&&g<0||j<0&&m<0?!1:(h<0?c=Math.max(c,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),j<0?c=Math.max(c,j/(j-m)):m<0&&(f=Math.min(f,j/(j-m))),fS&&h.positionScreen.z0&&F.z<1))ia=B[E]=B[E]||new THREE.RenderableParticle,E++,C=ia,C.x=F.x/F.w,C.y=F.y/F.w,C.z=F.z,C.rotation=R.rotation.z,C.scale.x= +R.scale.x*Math.abs(C.x-(F.x+g.projectionMatrix.n11)/(F.w+g.projectionMatrix.n14)),C.scale.y=R.scale.y*Math.abs(C.y-(F.y+g.projectionMatrix.n22)/(F.w+g.projectionMatrix.n24)),C.materials=R.materials,I.push(C);j&&I.sort(c);return I}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var n,p,o,t,u,v,x,w;b=c.projectScene(e,f);n=0;for(p=b.length;n>1,Z=p.height>>1,j=h.scale.x*u,n=h.scale.y*v,k=j*o,m=n*Z,qa.set(b.x-k,b.y-m,b.x+k,b.y+m),sa.instersects(qa)&&(x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(j,-n),x.translate(-o,-Z),x.drawImage(p,0,0),x.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,m=h.scale.y*v,qa.set(b.x-k,b.y-m,b.x+k,b.y+m),sa.instersects(qa)&&(f(j.color),g(j.color),x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(k,m),j.program(x),x.restore()))}function w(b,h,g,j){c(j.opacity); -e(j.blending);x.beginPath();x.moveTo(b.positionScreen.x,b.positionScreen.y);x.lineTo(h.positionScreen.x,h.positionScreen.y);x.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(G!=b)x.lineWidth=G=b;b=j.linecap;if(A!=b)x.lineCap=A=b;b=j.linejoin;if(P!=b)x.lineJoin=P=b;f(j.color);x.stroke();qa.inflate(j.linewidth*2)}}function y(b,f,g,m,n,p,Z,t,u){h.data.vertices+=3;h.data.faces++;c(t.opacity);e(t.blending);K=b.positionScreen.x;S=b.positionScreen.y;k=f.positionScreen.x;V=f.positionScreen.y; -O=g.positionScreen.x;fa=g.positionScreen.y;C(K,S,k,V,O,fa);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(la=Z.uvs[0],Ca(K,S,k,V,O,fa,t.map.image,la[m].u,la[m].v,la[n].u,la[n].v,la[p].u,la[p].v));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=j.matrixWorldInverse,ja.copy(Z.vertexNormalsWorld[0]),oa=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,wa=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,ja.copy(Z.vertexNormalsWorld[1]), -Aa=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,va=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,ja.copy(Z.vertexNormalsWorld[2]),ya=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,Ma=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,Ca(K,S,k,V,O,fa,t.envMap.image,oa,wa,Aa,va,ya,Ma)}else t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof THREE.UVMapping&&(la=Z.uvs[0],Ca(K,S,k, -V,O,fa,t.map.image,la[m].u,la[m].v,la[n].u,la[n].v,la[p].u,la[p].v)),e(THREE.SubtractiveBlending)),Ba?!t.wireframe&&t.shading==THREE.SmoothShading&&Z.vertexNormalsWorld.length==3?(ha.r=$.r=ma.r=M.r,ha.g=$.g=ma.g=M.g,ha.b=$.b=ma.b=M.b,o(u,Z.v1.positionWorld,Z.vertexNormalsWorld[0],ha),o(u,Z.v2.positionWorld,Z.vertexNormalsWorld[1],$),o(u,Z.v3.positionWorld,Z.vertexNormalsWorld[2],ma),aa.r=($.r+ma.r)*0.5,aa.g=($.g+ma.g)*0.5,aa.b=($.b+ma.b)*0.5,na=Sa(ha,$,ma,aa),Ca(K,S,k,V,O,fa,na,0,0,1,0,0,1)):(ca.r= -M.r,ca.g=M.g,ca.b=M.b,o(u,Z.centroidWorld,Z.normalWorld,ca),R.r=Math.max(0,Math.min(t.color.r*ca.r,1)),R.g=Math.max(0,Math.min(t.color.g*ca.g,1)),R.b=Math.max(0,Math.min(t.color.b*ca.b,1)),R.updateHex(),t.wireframe?E(R,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(R)):t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(t.color);else if(t instanceof THREE.MeshDepthMaterial)ia=j.near,X=j.far,ha.r=ha.g=ha.b=1-Ia(b.positionScreen.z,ia,X),$.r=$.g=$.b= -1-Ia(f.positionScreen.z,ia,X),ma.r=ma.g=ma.b=1-Ia(g.positionScreen.z,ia,X),aa.r=($.r+ma.r)*0.5,aa.g=($.g+ma.g)*0.5,aa.b=($.b+ma.b)*0.5,na=Sa(ha,$,ma,aa),Ca(K,S,k,V,O,fa,na,0,0,1,0,0,1);else if(t instanceof THREE.MeshNormalMaterial)R.r=Na(Z.normalWorld.x),R.g=Na(Z.normalWorld.y),R.b=Na(Z.normalWorld.z),R.updateHex(),t.wireframe?E(R,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(R)}function B(b,f,g,m,n,p,t,Z,u){h.data.vertices+=4;h.data.faces++;c(Z.opacity);e(Z.blending);if(Z.map|| -Z.envMap)y(b,f,m,0,1,3,t,Z,u),y(n,g,p,1,2,3,t,Z,u);else if(K=b.positionScreen.x,S=b.positionScreen.y,k=f.positionScreen.x,V=f.positionScreen.y,O=g.positionScreen.x,fa=g.positionScreen.y,ea=m.positionScreen.x,W=m.positionScreen.y,da=n.positionScreen.x,ga=n.positionScreen.y,ka=p.positionScreen.x,pa=p.positionScreen.y,Z instanceof THREE.MeshBasicMaterial)F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(Z.color,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(Z.color);else if(Z instanceof THREE.MeshLambertMaterial)Ba? -!Z.wireframe&&Z.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(ha.r=$.r=ma.r=aa.r=M.r,ha.g=$.g=ma.g=aa.g=M.g,ha.b=$.b=ma.b=aa.b=M.b,o(u,t.v1.positionWorld,t.vertexNormalsWorld[0],ha),o(u,t.v2.positionWorld,t.vertexNormalsWorld[1],$),o(u,t.v4.positionWorld,t.vertexNormalsWorld[3],ma),o(u,t.v3.positionWorld,t.vertexNormalsWorld[2],aa),na=Sa(ha,$,ma,aa),C(K,S,k,V,ea,W),Ca(K,S,k,V,ea,W,na,0,0,1,0,0,1),C(da,ga,O,fa,ka,pa),Ca(da,ga,O,fa,ka,pa,na,1,0,1,1,0,1)):(ca.r=M.r,ca.g=M.g,ca.b=M.b, -o(u,t.centroidWorld,t.normalWorld,ca),R.r=Math.max(0,Math.min(Z.color.r*ca.r,1)),R.g=Math.max(0,Math.min(Z.color.g*ca.g,1)),R.b=Math.max(0,Math.min(Z.color.b*ca.b,1)),R.updateHex(),F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(R,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(R)):(F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(Z.color,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(Z.color));else if(Z instanceof THREE.MeshNormalMaterial)R.r=Na(t.normalWorld.x),R.g=Na(t.normalWorld.y),R.b= -Na(t.normalWorld.z),R.updateHex(),F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(R,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(R);else if(Z instanceof THREE.MeshDepthMaterial)ia=j.near,X=j.far,ha.r=ha.g=ha.b=1-Ia(b.positionScreen.z,ia,X),$.r=$.g=$.b=1-Ia(f.positionScreen.z,ia,X),ma.r=ma.g=ma.b=1-Ia(m.positionScreen.z,ia,X),aa.r=aa.g=aa.b=1-Ia(g.positionScreen.z,ia,X),na=Sa(ha,$,ma,aa),C(K,S,k,V,ea,W),Ca(K,S,k,V,ea,W,na,0,0,1,0,0,1),C(da,ga,O,fa,ka,pa),Ca(da,ga,O,fa,ka,pa,na,1,0,1,1,0,1)}function C(b, -e,c,f,h,g){x.beginPath();x.moveTo(b,e);x.lineTo(c,f);x.lineTo(h,g);x.lineTo(b,e);x.closePath()}function F(b,e,c,f,h,g,j,k){x.beginPath();x.moveTo(b,e);x.lineTo(c,f);x.lineTo(h,g);x.lineTo(j,k);x.lineTo(b,e);x.closePath()}function E(b,e,c,h){if(G!=e)x.lineWidth=G=e;if(A!=c)x.lineCap=A=c;if(P!=h)x.lineJoin=P=h;f(b);x.stroke();qa.inflate(e*2)}function Ea(b){g(b);x.fill()}function Ca(b,e,c,f,h,g,j,k,m,n,p,Z,t){var o,u;o=j.width-1;u=j.height-1;k*=o;m*=u;n*=o;p*=u;Z*=o;t*=u;c-=b;f-=e;h-=b;g-=e;n-=k;p-= -m;Z-=k;t-=m;o=n*t-Z*p;if(!((o<0?-o:o)<1))u=1/o,o=(t*c-p*h)*u,p=(t*f-p*g)*u,c=(n*h-Z*c)*u,f=(n*g-Z*f)*u,b=b-o*k-c*m,e=e-p*k-f*m,x.save(),x.transform(o,p,c,f,b,e),x.clip(),x.drawImage(j,0,0),x.restore()}function Sa(b,e,c,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);xa[0]=h<0?0:h>255?255:h;xa[1]=g<0?0:g>255?255:g;xa[2]=b<0?0:b>255?255:b;xa[4]=j<0?0:j>255?255:j;xa[5]=k<0?0: -k>255?255:k;xa[6]=e<0?0:e>255?255:e;xa[8]=m<0?0:m>255?255:m;xa[9]=n<0?0:n>255?255:n;xa[10]=c<0?0:c>255?255:c;xa[12]=p<0?0:p>255?255:p;xa[13]=t<0?0:t>255?255:t;xa[14]=f<0?0:f>255?255:f;Pa.putImageData(Va,0,0);Ra.drawImage(Z,0,0);return Qa}function Ia(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Na(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Fa(b,e){var c=e.x-b.x,f=e.y-b.y,h=c*c+f*f;h!=0&&(h=1/Math.sqrt(h),c*=h,f*=h,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ta,D,L,z,Ga,Oa,Ua,ta;this.autoClear?this.clear(): -x.setTransform(1,0,0,-1,u,v);h.data.vertices=0;h.data.faces=0;m=n.projectScene(b,j,this.sortElements);(Ba=b.lights.length>0)&&p(b);Ta=0;for(D=m.length;Ta0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j)):g instanceof THREE.PointLight&&(U.sub(g.position,e.centroidWorld),U.normalize(),j=e.normalWorld.dot(U)*g.intensity,j>0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j))}function c(e,c,k,m,n,t){h.data.vertices+=3;h.data.faces++;K=f(S++);K.setAttribute("d", -"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?E?(A.r=P.r,A.g=P.g,A.b=P.b,b(t,m,A),G.r=Math.max(0,Math.min(n.color.r*A.r,1)),G.g=Math.max(0,Math.min(n.color.g*A.g,1)),G.b=Math.max(0,Math.min(n.color.b*A.b,1)),G.updateHex()):G.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(T=1-n.__2near/(n.__farPlusNear- -m.z*n.__farMinusNear),G.setRGB(T,T,T)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));n.wireframe?K.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):K.setAttribute("style","fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+n.opacity);p.appendChild(K)}function e(e,c,k,m, -n,t,o){h.data.vertices+=4;h.data.faces++;K=f(S++);K.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.hex=t.color.hex:t instanceof THREE.MeshLambertMaterial?E?(A.r=P.r,A.g=P.g,A.b=P.b,b(o,n,A),G.r=Math.max(0,Math.min(t.color.r*A.r,1)),G.g=Math.max(0,Math.min(t.color.g*A.g,1)),G.b=Math.max(0,Math.min(t.color.b* -A.b,1)),G.updateHex()):G.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(T=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(T,T,T)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));t.wireframe?K.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):K.setAttribute("style", -"fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+t.opacity);p.appendChild(K)}function f(b){J[b]==null&&(J[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&J[b].setAttribute("shape-rendering","crispEdges"));return J[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function j(b){for(;b.length<6;)b="0"+b;return b}var h=this,m=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,u,v,x,w,B,y,F=new THREE.Rectangle,C=new THREE.Rectangle,E= -!1,G=new THREE.Color(16777215),A=new THREE.Color(16777215),P=new THREE.Color(0),I=new THREE.Color(0),H=new THREE.Color(0),T,U=new THREE.Vector3,J=[],Y=[],K,S,k,V=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":V=1;break;case "low":V=0}};this.setSize=function(b,e){o=b;t=e;u=o/2;v=t/2;p.setAttribute("viewBox",-u+" "+-v+" "+o+" "+t);p.setAttribute("width",o);p.setAttribute("height",t);F.set(-u,-v, -u,v)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(b,f){var g,t,o,A,G,T,R,J;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;m=n.projectScene(b,f,this.sortElements);k=S=0;if(E=b.lights.length>0){R=b.lights;P.setRGB(0,0,0);I.setRGB(0,0,0);H.setRGB(0,0,0);g=0;for(t=R.length;g>1,$=p.height>>1,j=h.scale.x*u,n=h.scale.y*v,k=j*o,m=n*$,qa.set(b.x-k,b.y-m,b.x+k,b.y+m),sa.instersects(qa)&&(x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(j,-n),x.translate(-o,-$),x.drawImage(p,0,0),x.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,m=h.scale.y*v,qa.set(b.x-k,b.y-m,b.x+k,b.y+m),sa.instersects(qa)&&(f(j.color),g(j.color),x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(k,m),j.program(x),x.restore()))}function C(b,h,g,j){c(j.opacity); +e(j.blending);x.beginPath();x.moveTo(b.positionScreen.x,b.positionScreen.y);x.lineTo(h.positionScreen.x,h.positionScreen.y);x.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(F!=b)x.lineWidth=F=b;b=j.linecap;if(A!=b)x.lineCap=A=b;b=j.linejoin;if(P!=b)x.lineJoin=P=b;f(j.color);x.stroke();qa.inflate(j.linewidth*2)}}function w(b,f,g,m,n,p,$,t,u){h.data.vertices+=3;h.data.faces++;c(t.opacity);e(t.blending);K=b.positionScreen.x;S=b.positionScreen.y;k=f.positionScreen.x;W=f.positionScreen.y; +O=g.positionScreen.x;ga=g.positionScreen.y;B(K,S,k,W,O,ga);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(la=$.uvs[0],Ca(K,S,k,W,O,ga,t.map.image,la[m].u,la[m].v,la[n].u,la[n].v,la[p].u,la[p].v));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=j.matrixWorldInverse,ja.copy($.vertexNormalsWorld[0]),oa=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,wa=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,ja.copy($.vertexNormalsWorld[1]), +Aa=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,va=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,ja.copy($.vertexNormalsWorld[2]),ya=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,Ma=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,Ca(K,S,k,W,O,ga,t.envMap.image,oa,wa,Aa,va,ya,Ma)}else t.wireframe?I(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof THREE.UVMapping&&(la=$.uvs[0],Ca(K,S,k, +W,O,ga,t.map.image,la[m].u,la[m].v,la[n].u,la[n].v,la[p].u,la[p].v)),e(THREE.SubtractiveBlending)),Ba?!t.wireframe&&t.shading==THREE.SmoothShading&&$.vertexNormalsWorld.length==3?(ia.r=aa.r=ma.r=M.r,ia.g=aa.g=ma.g=M.g,ia.b=aa.b=ma.b=M.b,o(u,$.v1.positionWorld,$.vertexNormalsWorld[0],ia),o(u,$.v2.positionWorld,$.vertexNormalsWorld[1],aa),o(u,$.v3.positionWorld,$.vertexNormalsWorld[2],ma),ca.r=(aa.r+ma.r)*0.5,ca.g=(aa.g+ma.g)*0.5,ca.b=(aa.b+ma.b)*0.5,na=Sa(ia,aa,ma,ca),Ca(K,S,k,W,O,ga,na,0,0,1,0,0, +1)):(da.r=M.r,da.g=M.g,da.b=M.b,o(u,$.centroidWorld,$.normalWorld,da),R.r=Math.max(0,Math.min(t.color.r*da.r,1)),R.g=Math.max(0,Math.min(t.color.g*da.g,1)),R.b=Math.max(0,Math.min(t.color.b*da.b,1)),R.updateHex(),t.wireframe?I(R,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(R)):t.wireframe?I(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(t.color);else if(t instanceof THREE.MeshDepthMaterial)T=j.near,Y=j.far,ia.r=ia.g=ia.b=1-Ia(b.positionScreen.z,T,Y),aa.r= +aa.g=aa.b=1-Ia(f.positionScreen.z,T,Y),ma.r=ma.g=ma.b=1-Ia(g.positionScreen.z,T,Y),ca.r=(aa.r+ma.r)*0.5,ca.g=(aa.g+ma.g)*0.5,ca.b=(aa.b+ma.b)*0.5,na=Sa(ia,aa,ma,ca),Ca(K,S,k,W,O,ga,na,0,0,1,0,0,1);else if(t instanceof THREE.MeshNormalMaterial)R.r=Na($.normalWorld.x),R.g=Na($.normalWorld.y),R.b=Na($.normalWorld.z),R.updateHex(),t.wireframe?I(R,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(R)}function y(b,f,g,m,n,p,t,$,u){h.data.vertices+=4;h.data.faces++;c($.opacity);e($.blending); +if($.map||$.envMap)w(b,f,m,0,1,3,t,$,u),w(n,g,p,1,2,3,t,$,u);else if(K=b.positionScreen.x,S=b.positionScreen.y,k=f.positionScreen.x,W=f.positionScreen.y,O=g.positionScreen.x,ga=g.positionScreen.y,fa=m.positionScreen.x,X=m.positionScreen.y,ea=n.positionScreen.x,ha=n.positionScreen.y,ka=p.positionScreen.x,pa=p.positionScreen.y,$ instanceof THREE.MeshBasicMaterial)E(K,S,k,W,O,ga,fa,X),$.wireframe?I($.color,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ea($.color);else if($ instanceof THREE.MeshLambertMaterial)Ba? +!$.wireframe&&$.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(ia.r=aa.r=ma.r=ca.r=M.r,ia.g=aa.g=ma.g=ca.g=M.g,ia.b=aa.b=ma.b=ca.b=M.b,o(u,t.v1.positionWorld,t.vertexNormalsWorld[0],ia),o(u,t.v2.positionWorld,t.vertexNormalsWorld[1],aa),o(u,t.v4.positionWorld,t.vertexNormalsWorld[3],ma),o(u,t.v3.positionWorld,t.vertexNormalsWorld[2],ca),na=Sa(ia,aa,ma,ca),B(K,S,k,W,fa,X),Ca(K,S,k,W,fa,X,na,0,0,1,0,0,1),B(ea,ha,O,ga,ka,pa),Ca(ea,ha,O,ga,ka,pa,na,1,0,1,1,0,1)):(da.r=M.r,da.g=M.g,da.b= +M.b,o(u,t.centroidWorld,t.normalWorld,da),R.r=Math.max(0,Math.min($.color.r*da.r,1)),R.g=Math.max(0,Math.min($.color.g*da.g,1)),R.b=Math.max(0,Math.min($.color.b*da.b,1)),R.updateHex(),E(K,S,k,W,O,ga,fa,X),$.wireframe?I(R,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ea(R)):(E(K,S,k,W,O,ga,fa,X),$.wireframe?I($.color,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ea($.color));else if($ instanceof THREE.MeshNormalMaterial)R.r=Na(t.normalWorld.x),R.g=Na(t.normalWorld.y), +R.b=Na(t.normalWorld.z),R.updateHex(),E(K,S,k,W,O,ga,fa,X),$.wireframe?I(R,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ea(R);else if($ instanceof THREE.MeshDepthMaterial)T=j.near,Y=j.far,ia.r=ia.g=ia.b=1-Ia(b.positionScreen.z,T,Y),aa.r=aa.g=aa.b=1-Ia(f.positionScreen.z,T,Y),ma.r=ma.g=ma.b=1-Ia(m.positionScreen.z,T,Y),ca.r=ca.g=ca.b=1-Ia(g.positionScreen.z,T,Y),na=Sa(ia,aa,ma,ca),B(K,S,k,W,fa,X),Ca(K,S,k,W,fa,X,na,0,0,1,0,0,1),B(ea,ha,O,ga,ka,pa),Ca(ea,ha,O,ga,ka,pa,na,1,0,1,1,0,1)} +function B(b,e,c,f,h,g){x.beginPath();x.moveTo(b,e);x.lineTo(c,f);x.lineTo(h,g);x.lineTo(b,e);x.closePath()}function E(b,e,c,f,h,g,j,k){x.beginPath();x.moveTo(b,e);x.lineTo(c,f);x.lineTo(h,g);x.lineTo(j,k);x.lineTo(b,e);x.closePath()}function I(b,e,c,h){if(F!=e)x.lineWidth=F=e;if(A!=c)x.lineCap=A=c;if(P!=h)x.lineJoin=P=h;f(b);x.stroke();qa.inflate(e*2)}function Ea(b){g(b);x.fill()}function Ca(b,e,c,f,h,g,j,k,m,n,p,$,t){var o,u;o=j.width-1;u=j.height-1;k*=o;m*=u;n*=o;p*=u;$*=o;t*=u;c-=b;f-=e;h-=b; +g-=e;n-=k;p-=m;$-=k;t-=m;o=n*t-$*p;if(!((o<0?-o:o)<1))u=1/o,o=(t*c-p*h)*u,p=(t*f-p*g)*u,c=(n*h-$*c)*u,f=(n*g-$*f)*u,b=b-o*k-c*m,e=e-p*k-f*m,x.save(),x.transform(o,p,c,f,b,e),x.clip(),x.drawImage(j,0,0),x.restore()}function Sa(b,e,c,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);xa[0]=h<0?0:h>255?255:h;xa[1]=g<0?0:g>255?255:g;xa[2]=b<0?0:b>255?255:b;xa[4]=j<0?0:j>255?255: +j;xa[5]=k<0?0:k>255?255:k;xa[6]=e<0?0:e>255?255:e;xa[8]=m<0?0:m>255?255:m;xa[9]=n<0?0:n>255?255:n;xa[10]=c<0?0:c>255?255:c;xa[12]=p<0?0:p>255?255:p;xa[13]=t<0?0:t>255?255:t;xa[14]=f<0?0:f>255?255:f;Pa.putImageData(Va,0,0);Ra.drawImage($,0,0);return Qa}function Ia(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Na(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Fa(b,e){var c=e.x-b.x,f=e.y-b.y,h=c*c+f*f;h!=0&&(h=1/Math.sqrt(h),c*=h,f*=h,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ta,D,L,z,Ga,Oa,Ua,ta;this.autoClear? +this.clear():x.setTransform(1,0,0,-1,u,v);h.data.vertices=0;h.data.faces=0;m=n.projectScene(b,j,this.sortElements);(Ba=b.lights.length>0)&&p(b);Ta=0;for(D=m.length;Ta0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j)):g instanceof THREE.PointLight&&(V.sub(g.position,e.centroidWorld),V.normalize(),j=e.normalWorld.dot(V)*g.intensity,j>0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j))}function c(e,c,k,m,n,t){h.data.vertices+=3;h.data.faces++;K=f(S++);K.setAttribute("d", +"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?F.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?I?(A.r=P.r,A.g=P.g,A.b=P.b,b(t,m,A),F.r=Math.max(0,Math.min(n.color.r*A.r,1)),F.g=Math.max(0,Math.min(n.color.g*A.g,1)),F.b=Math.max(0,Math.min(n.color.b*A.b,1)),F.updateHex()):F.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(U=1-n.__2near/(n.__farPlusNear- +m.z*n.__farMinusNear),F.setRGB(U,U,U)):n instanceof THREE.MeshNormalMaterial&&F.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));n.wireframe?K.setAttribute("style","fill: none; stroke: #"+j(F.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):K.setAttribute("style","fill: #"+j(F.hex.toString(16))+"; fill-opacity: "+n.opacity);p.appendChild(K)}function e(e,c,k,m, +n,t,o){h.data.vertices+=4;h.data.faces++;K=f(S++);K.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?F.hex=t.color.hex:t instanceof THREE.MeshLambertMaterial?I?(A.r=P.r,A.g=P.g,A.b=P.b,b(o,n,A),F.r=Math.max(0,Math.min(t.color.r*A.r,1)),F.g=Math.max(0,Math.min(t.color.g*A.g,1)),F.b=Math.max(0,Math.min(t.color.b* +A.b,1)),F.updateHex()):F.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(U=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),F.setRGB(U,U,U)):t instanceof THREE.MeshNormalMaterial&&F.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));t.wireframe?K.setAttribute("style","fill: none; stroke: #"+j(F.hex.toString(16))+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):K.setAttribute("style", +"fill: #"+j(F.hex.toString(16))+"; fill-opacity: "+t.opacity);p.appendChild(K)}function f(b){J[b]==null&&(J[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),W==0&&J[b].setAttribute("shape-rendering","crispEdges"));return J[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function j(b){for(;b.length<6;)b="0"+b;return b}var h=this,m=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,u,v,x,w,y,C,E=new THREE.Rectangle,B=new THREE.Rectangle,I= +!1,F=new THREE.Color(16777215),A=new THREE.Color(16777215),P=new THREE.Color(0),H=new THREE.Color(0),G=new THREE.Color(0),U,V=new THREE.Vector3,J=[],Z=[],K,S,k,W=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":W=1;break;case "low":W=0}};this.setSize=function(b,e){o=b;t=e;u=o/2;v=t/2;p.setAttribute("viewBox",-u+" "+-v+" "+o+" "+t);p.setAttribute("width",o);p.setAttribute("height",t);E.set(-u,-v, +u,v)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(b,f){var g,t,o,A,F,U,R,J;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;m=n.projectScene(b,f,this.sortElements);k=S=0;if(I=b.lights.length>0){R=b.lights;P.setRGB(0,0,0);H.setRGB(0,0,0);G.setRGB(0,0,0);g=0;for(t=R.length;g 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", -default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var c,e,f,g={};for(c=0;c=0)k.bindBuffer(k.ARRAY_BUFFER, -h.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0);else{c=g.program.attributes;j.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,t=j.morphTargetForcedOrder,n=j.morphTargetInfluences;fp&&(o=u,p=n[o]);k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[o]);k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]= -p;t[o]=1;p=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(g.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[m],c.size,k.FLOAT,!1,0,0));b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglColorBuffer),k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER, -h.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0, -0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER, -h.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0));j instanceof THREE.Mesh?(g.wireframe?(k.lineWidth(g.wireframeLinewidth),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),k.drawElements(k.LINES,h.__webglLineCount,k.UNSIGNED_SHORT,0)):(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),k.drawElements(k.TRIANGLES,h.__webglFaceCount,k.UNSIGNED_SHORT,0)),S.data.vertices+=h.__webglFaceCount,S.data.faces+=h.__webglFaceCount/3,S.data.drawCalls++):j instanceof -THREE.Line?(j=j.type==THREE.LineStrip?k.LINE_STRIP:k.LINES,k.lineWidth(g.linewidth),k.drawArrays(j,0,h.__webglLineCount),S.data.drawCalls++):j instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,h.__webglParticleCount),S.data.drawCalls++):j instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,h.__webglVertexCount),S.data.drawCalls++)}}function g(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=k.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=k.createBuffer();b.hasPos&& -(k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,b.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(e.attributes.position),k.vertexAttribPointer(e.attributes.position,3,k.FLOAT,!1,0,0));if(b.hasNormal){k.bindBuffer(k.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,g,j,m,t,n,p,o,u,v=b.count*3;for(u=0;u0&&y[0]0&&y[1]0.0010&&m.scale>0.0010)x[0]=m.x,x[1]=m.y, -x[2]=m.z,u=m.size*m.scale/ia,v[0]=u*n,v[1]=u,k.uniform3fv(w.screenPosition,x),k.uniform2fv(w.scale,v),k.uniform1f(w.rotation,m.rotation),k.uniform1f(w.opacity,m.opacity),I(m.blending),T(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(ea)}function y(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} -function F(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,Y,m));sa&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglNormalBuffer),k.bufferData(k.ARRAY_BUFFER,ea, -m));Aa&&ja.hasTangents&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglTangentBuffer),k.bufferData(k.ARRAY_BUFFER,V,m));qa&&T>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,fa,m));qa&&R>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,ca,m));ra&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ga,m),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ka,m));N> -0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,da,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,oa,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,$,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,aa,m));j.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array, -delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;C(h)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;w=b.vertices;g=b.colors;B=w.length;j=g.length;A=b.__vertexArray;m=b.__colorArray; -G=b.__dirtyColors;if(b.__dirtyVertices){for(t=0;t=0;c--)b[c].object==e&&b.splice(c,1)}function A(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(o[m].counter+=1,t=o[m].hash+"_"+o[m].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]={faces:[],materials:k,vertices:0,numMorphTargets:n})),b.geometryGroups[t].faces.push(h),b.geometryGroups[t].vertices+=j}function P(b,e,c){b.push({buffer:e,object:c, -opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=ga){switch(b){case THREE.AdditiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR);break;default:k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}ga= -b}}function H(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(k.texParameteri(b,k.TEXTURE_WRAP_S,K(e.wrapS)),k.texParameteri(b,k.TEXTURE_WRAP_T,K(e.wrapT)),k.texParameteri(b,k.TEXTURE_MAG_FILTER,K(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,K(e.minFilter)),k.generateMipmap(b)):(k.texParameteri(b,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_MAG_FILTER,Y(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,Y(e.minFilter)))} -function T(b,e){if(b.needsUpdate)b.__webglInit?(k.bindTexture(k.TEXTURE_2D,b.__webglTexture),k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image)):(b.__webglTexture=k.createTexture(),k.bindTexture(k.TEXTURE_2D,b.__webglTexture),k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image),b.__webglInit=!0),H(k.TEXTURE_2D,b,b.image),k.bindTexture(k.TEXTURE_2D,null),b.needsUpdate=!1;k.activeTexture(k.TEXTURE0+e);k.bindTexture(k.TEXTURE_2D,b.__webglTexture)}function U(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer=== -void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=k.createFramebuffer();b.__webglRenderbuffer=k.createRenderbuffer();b.__webglTexture=k.createTexture();k.bindTexture(k.TEXTURE_2D,b.__webglTexture);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,K(b.wrapS));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,K(b.wrapT));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,K(b.magFilter));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,K(b.minFilter));k.texImage2D(k.TEXTURE_2D, -0,K(b.format),b.width,b.height,0,K(b.format),K(b.type),null);k.bindRenderbuffer(k.RENDERBUFFER,b.__webglRenderbuffer);k.bindFramebuffer(k.FRAMEBUFFER,b.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER, -k.DEPTH_STENCIL,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height);k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=aa,b=ia);e!=fa&&(k.bindFramebuffer(k.FRAMEBUFFER,e),k.viewport($,ma,c,b),fa=e)}function J(b,e){var c;b=="fragment"?c=k.createShader(k.FRAGMENT_SHADER): -b=="vertex"&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,e);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS))return console.error(k.getShaderInfoLog(c)),console.error(e),null;return c}function Y(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST;default:return k.LINEAR}}function K(b){switch(b){case THREE.RepeatWrapping:return k.REPEAT;case THREE.ClampToEdgeWrapping:return k.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return k.MIRRORED_REPEAT; -case THREE.NearestFilter:return k.NEAREST;case THREE.NearestMipMapNearestFilter:return k.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return k.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return k.LINEAR;case THREE.LinearMipMapNearestFilter:return k.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return k.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return k.BYTE;case THREE.UnsignedByteType:return k.UNSIGNED_BYTE;case THREE.ShortType:return k.SHORT;case THREE.UnsignedShortType:return k.UNSIGNED_SHORT; -case THREE.IntType:return k.INT;case THREE.UnsignedShortType:return k.UNSIGNED_INT;case THREE.FloatType:return k.FLOAT;case THREE.AlphaFormat:return k.ALPHA;case THREE.RGBFormat:return k.RGB;case THREE.RGBAFormat:return k.RGBA;case THREE.LuminanceFormat:return k.LUMINANCE;case THREE.LuminanceAlphaFormat:return k.LUMINANCE_ALPHA}return 0}var S=this,k,V=[],O=null,fa=null,ea=!0,W=null,da=null,ga=null,ka=null,pa=null,R=null,ha=null,$=0,ma=0,aa=0,ia=0,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],na=new THREE.Matrix4,la=new Float32Array(16),oa=new Float32Array(16),wa=new THREE.Vector4,Aa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},va=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ya=b.stencil!==void 0?b.stencil:!0,Ma=b.antialias!==void 0?b.antialias:!1,sa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ra=b.clearAlpha!== -void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=va;this.sortObjects=this.autoClear=!0;try{if(!(k=va.getContext("experimental-webgl",{antialias:Ma,stencil:ya})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+k.getParameter(k.VERSION)+" | "+k.getParameter(k.VENDOR)+" | "+k.getParameter(k.RENDERER)+" | "+k.getParameter(k.SHADING_LANGUAGE_VERSION))}catch(qa){console.error(qa)}k.clearColor(0,0,0,1);k.clearDepth(1);k.enable(k.DEPTH_TEST); -k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(sa.r,sa.g,sa.b,ra);this.context=k;var Ba=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ya){var ca={};ca.vertices=new Float32Array(12);ca.faces=new Uint16Array(6);ca.darkness=0.5;ca.vertices[0]=-20;ca.vertices[1]=-20;ca.vertices[2]=-1;ca.vertices[3]=20;ca.vertices[4]=-20;ca.vertices[5]=-1;ca.vertices[6]=20; -ca.vertices[7]=20;ca.vertices[8]=-1;ca.vertices[9]=-20;ca.vertices[10]=20;ca.vertices[11]=-1;ca.faces[0]=0;ca.faces[1]=1;ca.faces[2]=2;ca.faces[3]=0;ca.faces[4]=2;ca.faces[5]=3;ca.vertexBuffer=k.createBuffer();ca.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,ca.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,ca.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,ca.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,ca.faces,k.STATIC_DRAW);ca.program=k.createProgram();k.attachShader(ca.program, -J("fragment",THREE.ShaderLib.shadowPost.fragmentShader));k.attachShader(ca.program,J("vertex",THREE.ShaderLib.shadowPost.vertexShader));k.linkProgram(ca.program);ca.vertexLocation=k.getAttribLocation(ca.program,"position");ca.projectionLocation=k.getUniformLocation(ca.program,"projectionMatrix");ca.darknessLocation=k.getUniformLocation(ca.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=k.createBuffer();M.elementBuffer=k.createBuffer();M.tempTexture=k.createTexture();M.occlusionTexture=k.createTexture();k.bindBuffer(k.ARRAY_BUFFER,M.vertexBuffer);k.bufferData(k.ARRAY_BUFFER, -M.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,M.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,M.faces,k.STATIC_DRAW);k.bindTexture(k.TEXTURE_2D,M.tempTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGB,16,16,0,k.RGB,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.bindTexture(k.TEXTURE_2D, -M.occlusionTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGBA,16,16,0,k.RGBA,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(M.hasVertexTexture=!1,M.program=k.createProgram(),k.attachShader(M.program,J("fragment",THREE.ShaderLib.lensFlare.fragmentShader)), -k.attachShader(M.program,J("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(M.hasVertexTexture=!0,M.program=k.createProgram(),k.attachShader(M.program,J("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),k.attachShader(M.program,J("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));k.linkProgram(M.program);M.attributes={};M.uniforms={};M.attributes.vertex=k.getAttribLocation(M.program,"position");M.attributes.uv=k.getAttribLocation(M.program,"UV");M.uniforms.renderType= -k.getUniformLocation(M.program,"renderType");M.uniforms.map=k.getUniformLocation(M.program,"map");M.uniforms.occlusionMap=k.getUniformLocation(M.program,"occlusionMap");M.uniforms.opacity=k.getUniformLocation(M.program,"opacity");M.uniforms.scale=k.getUniformLocation(M.program,"scale");M.uniforms.rotation=k.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition=k.getUniformLocation(M.program,"screenPosition");var ua=!1,Q={};Q.vertices=new Float32Array(16);Q.faces=new Uint16Array(6);b= -0;Q.vertices[b++]=-1;Q.vertices[b++]=-1;Q.vertices[b++]=0;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=-1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=0;Q.vertices[b++]=-1;Q.vertices[b++]=1;Q.vertices[b++]=0;b=Q.vertices[b++]=0;Q.faces[b++]=0;Q.faces[b++]=1;Q.faces[b++]=2;Q.faces[b++]=0;Q.faces[b++]=2;Q.faces[b++]=3;Q.vertexBuffer=k.createBuffer();Q.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.bufferData(k.ARRAY_BUFFER, -Q.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Q.faces,k.STATIC_DRAW);Q.program=k.createProgram();k.attachShader(Q.program,J("fragment",THREE.ShaderLib.sprite.fragmentShader));k.attachShader(Q.program,J("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(Q.program);Q.attributes={};Q.uniforms={};Q.attributes.position=k.getAttribLocation(Q.program,"position");Q.attributes.uv=k.getAttribLocation(Q.program,"uv");Q.uniforms.uvOffset= -k.getUniformLocation(Q.program,"uvOffset");Q.uniforms.uvScale=k.getUniformLocation(Q.program,"uvScale");Q.uniforms.rotation=k.getUniformLocation(Q.program,"rotation");Q.uniforms.scale=k.getUniformLocation(Q.program,"scale");Q.uniforms.alignment=k.getUniformLocation(Q.program,"alignment");Q.uniforms.map=k.getUniformLocation(Q.program,"map");Q.uniforms.opacity=k.getUniformLocation(Q.program,"opacity");Q.uniforms.useScreenCoordinates=k.getUniformLocation(Q.program,"useScreenCoordinates");Q.uniforms.affectedByDistance= -k.getUniformLocation(Q.program,"affectedByDistance");Q.uniforms.screenPosition=k.getUniformLocation(Q.program,"screenPosition");Q.uniforms.modelViewMatrix=k.getUniformLocation(Q.program,"modelViewMatrix");Q.uniforms.projectionMatrix=k.getUniformLocation(Q.program,"projectionMatrix");var ja=!1;this.setSize=function(b,e){va.width=b;va.height=e;this.setViewport(0,0,va.width,va.height)};this.setViewport=function(b,e,c,f){$=b;ma=e;aa=c;ia=f;k.viewport($,ma,aa,ia)};this.setScissor=function(b,e,c,f){k.scissor(b, -e,c,f)};this.enableScissorTest=function(b){b?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){ea=b;k.depthMask(b)};this.setClearColorHex=function(b,e){sa.setHex(b);ra=e;k.clearColor(sa.r,sa.g,sa.b,ra)};this.setClearColor=function(b,e){sa.copy(b);ra=e;k.clearColor(sa.r,sa.g,sa.b,ra)};this.clear=function(){k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT|k.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){ca.darkness=b};this.getContext=function(){return k}; -this.initMaterial=function(b,e,c,f){var h,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var m=THREE.ShaderLib[j];b.uniforms= -THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var t,o,n;t=n=m=0;for(o=e.length;t=0)k.bindBuffer(k.ARRAY_BUFFER,h.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0);else if(j.morphTargetBase){c=g.program.attributes;j.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglVertexBuffer),k.vertexAttribPointer(c.position, +3,k.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,t=j.morphTargetForcedOrder,n=j.morphTargetInfluences;fp&&(o=u,p=n[o]);k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[o]);k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]=p;t[o]=1;p=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(g.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[m],c.size, +k.FLOAT,!1,0,0));b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglColorBuffer),k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)): +k.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB, +4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0));j instanceof THREE.Mesh?(g.wireframe?(k.lineWidth(g.wireframeLinewidth),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),k.drawElements(k.LINES,h.__webglLineCount,k.UNSIGNED_SHORT,0)):(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),k.drawElements(k.TRIANGLES, +h.__webglFaceCount,k.UNSIGNED_SHORT,0)),S.data.vertices+=h.__webglFaceCount,S.data.faces+=h.__webglFaceCount/3,S.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?k.LINE_STRIP:k.LINES,k.lineWidth(g.linewidth),k.drawArrays(j,0,h.__webglLineCount),S.data.drawCalls++):j instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,h.__webglParticleCount),S.data.drawCalls++):j instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,h.__webglVertexCount),S.data.drawCalls++)}}function g(b, +e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=k.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=k.createBuffer();b.hasPos&&(k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,b.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(e.attributes.position),k.vertexAttribPointer(e.attributes.position,3,k.FLOAT,!1,0,0));if(b.hasNormal){k.bindBuffer(k.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,g,j,m,t,n,p,o,u,v=b.count*3;for(u= +0;u0&&w[0]0&&w[1]0.0010&&m.scale>0.0010)x[0]=m.x,x[1]=m.y,x[2]=m.z,u=m.size*m.scale/T,v[0]=u*n,v[1]=u,k.uniform3fv(y.screenPosition,x),k.uniform2fv(y.scale,v),k.uniform1f(y.rotation,m.rotation),k.uniform1f(y.opacity,m.opacity),H(m.blending),U(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(fa)}function C(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse, +b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function E(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b0&&(k.bindBuffer(k.ARRAY_BUFFER, +g.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,Z,m));sa&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglNormalBuffer),k.bufferData(k.ARRAY_BUFFER,fa,m));Aa&&ja.hasTangents&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglTangentBuffer),k.bufferData(k.ARRAY_BUFFER,W,m));qa&&U>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,ga,m));qa&&R>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,da,m));ra&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer), +k.bufferData(k.ELEMENT_ARRAY_BUFFER,ha,m),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ka,m));N>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,ea,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,oa,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,aa,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER, +ca,m));j.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;B(h)}else if(b instanceof THREE.Ribbon){f= +b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;y=b.vertices;g=b.colors;C=y.length;j=g.length;A=b.__vertexArray;m=b.__colorArray;F=b.__dirtyColors;if(b.__dirtyVertices){for(t=0;t=0;c--)b[c].object==e&&b.splice(c,1)}function A(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(o[m].counter+=1,t=o[m].hash+"_"+o[m].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]= +{faces:[],materials:k,vertices:0,numMorphTargets:n})),b.geometryGroups[t].faces.push(h),b.geometryGroups[t].vertices+=j}function P(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=ha){switch(b){case THREE.AdditiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.blendEquation(k.FUNC_ADD); +k.blendFunc(k.ZERO,k.SRC_COLOR);break;default:k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}ha=b}}function G(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(k.texParameteri(b,k.TEXTURE_WRAP_S,K(e.wrapS)),k.texParameteri(b,k.TEXTURE_WRAP_T,K(e.wrapT)),k.texParameteri(b,k.TEXTURE_MAG_FILTER,K(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,K(e.minFilter)),k.generateMipmap(b)):(k.texParameteri(b,k.TEXTURE_WRAP_S, +k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_MAG_FILTER,Z(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,Z(e.minFilter)))}function U(b,e){if(b.needsUpdate)b.__webglInit?(k.bindTexture(k.TEXTURE_2D,b.__webglTexture),k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image)):(b.__webglTexture=k.createTexture(),k.bindTexture(k.TEXTURE_2D,b.__webglTexture),k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image),b.__webglInit= +!0),G(k.TEXTURE_2D,b,b.image),k.bindTexture(k.TEXTURE_2D,null),b.needsUpdate=!1;k.activeTexture(k.TEXTURE0+e);k.bindTexture(k.TEXTURE_2D,b.__webglTexture)}function V(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=k.createFramebuffer();b.__webglRenderbuffer=k.createRenderbuffer();b.__webglTexture=k.createTexture();k.bindTexture(k.TEXTURE_2D,b.__webglTexture);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S, +K(b.wrapS));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,K(b.wrapT));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,K(b.magFilter));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,K(b.minFilter));k.texImage2D(k.TEXTURE_2D,0,K(b.format),b.width,b.height,0,K(b.format),K(b.type),null);k.bindRenderbuffer(k.RENDERBUFFER,b.__webglRenderbuffer);k.bindFramebuffer(k.FRAMEBUFFER,b.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&& +!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_STENCIL,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height);k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER, +null);k.bindFramebuffer(k.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=ca,b=T);e!=ga&&(k.bindFramebuffer(k.FRAMEBUFFER,e),k.viewport(aa,ma,c,b),ga=e)}function J(b,e){var c;b=="fragment"?c=k.createShader(k.FRAGMENT_SHADER):b=="vertex"&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,e);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS))return console.error(k.getShaderInfoLog(c)),console.error(e),null;return c}function Z(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST; +default:return k.LINEAR}}function K(b){switch(b){case THREE.RepeatWrapping:return k.REPEAT;case THREE.ClampToEdgeWrapping:return k.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return k.MIRRORED_REPEAT;case THREE.NearestFilter:return k.NEAREST;case THREE.NearestMipMapNearestFilter:return k.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return k.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return k.LINEAR;case THREE.LinearMipMapNearestFilter:return k.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return k.LINEAR_MIPMAP_LINEAR; +case THREE.ByteType:return k.BYTE;case THREE.UnsignedByteType:return k.UNSIGNED_BYTE;case THREE.ShortType:return k.SHORT;case THREE.UnsignedShortType:return k.UNSIGNED_SHORT;case THREE.IntType:return k.INT;case THREE.UnsignedShortType:return k.UNSIGNED_INT;case THREE.FloatType:return k.FLOAT;case THREE.AlphaFormat:return k.ALPHA;case THREE.RGBFormat:return k.RGB;case THREE.RGBAFormat:return k.RGBA;case THREE.LuminanceFormat:return k.LUMINANCE;case THREE.LuminanceAlphaFormat:return k.LUMINANCE_ALPHA}return 0} +var S=this,k,W=[],O=null,ga=null,fa=!0,X=null,ea=null,ha=null,ka=null,pa=null,R=null,ia=null,aa=0,ma=0,ca=0,T=0,Y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],na=new THREE.Matrix4,la=new Float32Array(16),oa=new Float32Array(16),wa=new THREE.Vector4,Aa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},va=b.canvas!==void 0?b.canvas:document.createElement("canvas"), +ya=b.stencil!==void 0?b.stencil:!0,Ma=b.antialias!==void 0?b.antialias:!1,sa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ra=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=va;this.sortObjects=this.autoClear=!0;try{if(!(k=va.getContext("experimental-webgl",{antialias:Ma,stencil:ya})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+k.getParameter(k.VERSION)+" | "+k.getParameter(k.VENDOR)+ +" | "+k.getParameter(k.RENDERER)+" | "+k.getParameter(k.SHADING_LANGUAGE_VERSION))}catch(qa){console.error(qa)}k.clearColor(0,0,0,1);k.clearDepth(1);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(sa.r,sa.g,sa.b,ra);this.context=k;var Ba=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ya){var da={};da.vertices=new Float32Array(12); +da.faces=new Uint16Array(6);da.darkness=0.5;da.vertices[0]=-20;da.vertices[1]=-20;da.vertices[2]=-1;da.vertices[3]=20;da.vertices[4]=-20;da.vertices[5]=-1;da.vertices[6]=20;da.vertices[7]=20;da.vertices[8]=-1;da.vertices[9]=-20;da.vertices[10]=20;da.vertices[11]=-1;da.faces[0]=0;da.faces[1]=1;da.faces[2]=2;da.faces[3]=0;da.faces[4]=2;da.faces[5]=3;da.vertexBuffer=k.createBuffer();da.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,da.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,da.vertices, +k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,da.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,da.faces,k.STATIC_DRAW);da.program=k.createProgram();k.attachShader(da.program,J("fragment",THREE.ShaderLib.shadowPost.fragmentShader));k.attachShader(da.program,J("vertex",THREE.ShaderLib.shadowPost.vertexShader));k.linkProgram(da.program);da.vertexLocation=k.getAttribLocation(da.program,"position");da.projectionLocation=k.getUniformLocation(da.program,"projectionMatrix");da.darknessLocation= +k.getUniformLocation(da.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=k.createBuffer();M.elementBuffer=k.createBuffer();M.tempTexture=k.createTexture();M.occlusionTexture=k.createTexture();k.bindBuffer(k.ARRAY_BUFFER,M.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,M.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,M.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,M.faces,k.STATIC_DRAW);k.bindTexture(k.TEXTURE_2D,M.tempTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGB,16,16,0,k.RGB,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S, +k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.bindTexture(k.TEXTURE_2D,M.occlusionTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGBA,16,16,0,k.RGBA,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST); +k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(M.hasVertexTexture=!1,M.program=k.createProgram(),k.attachShader(M.program,J("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),k.attachShader(M.program,J("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(M.hasVertexTexture=!0,M.program=k.createProgram(),k.attachShader(M.program,J("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),k.attachShader(M.program,J("vertex", +THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));k.linkProgram(M.program);M.attributes={};M.uniforms={};M.attributes.vertex=k.getAttribLocation(M.program,"position");M.attributes.uv=k.getAttribLocation(M.program,"UV");M.uniforms.renderType=k.getUniformLocation(M.program,"renderType");M.uniforms.map=k.getUniformLocation(M.program,"map");M.uniforms.occlusionMap=k.getUniformLocation(M.program,"occlusionMap");M.uniforms.opacity=k.getUniformLocation(M.program,"opacity");M.uniforms.scale=k.getUniformLocation(M.program, +"scale");M.uniforms.rotation=k.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition=k.getUniformLocation(M.program,"screenPosition");var ua=!1,Q={};Q.vertices=new Float32Array(16);Q.faces=new Uint16Array(6);b=0;Q.vertices[b++]=-1;Q.vertices[b++]=-1;Q.vertices[b++]=0;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=-1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=0;Q.vertices[b++]=-1;Q.vertices[b++]=1;Q.vertices[b++]=0;b= +Q.vertices[b++]=0;Q.faces[b++]=0;Q.faces[b++]=1;Q.faces[b++]=2;Q.faces[b++]=0;Q.faces[b++]=2;Q.faces[b++]=3;Q.vertexBuffer=k.createBuffer();Q.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,Q.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Q.faces,k.STATIC_DRAW);Q.program=k.createProgram();k.attachShader(Q.program,J("fragment",THREE.ShaderLib.sprite.fragmentShader));k.attachShader(Q.program, +J("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(Q.program);Q.attributes={};Q.uniforms={};Q.attributes.position=k.getAttribLocation(Q.program,"position");Q.attributes.uv=k.getAttribLocation(Q.program,"uv");Q.uniforms.uvOffset=k.getUniformLocation(Q.program,"uvOffset");Q.uniforms.uvScale=k.getUniformLocation(Q.program,"uvScale");Q.uniforms.rotation=k.getUniformLocation(Q.program,"rotation");Q.uniforms.scale=k.getUniformLocation(Q.program,"scale");Q.uniforms.alignment=k.getUniformLocation(Q.program, +"alignment");Q.uniforms.map=k.getUniformLocation(Q.program,"map");Q.uniforms.opacity=k.getUniformLocation(Q.program,"opacity");Q.uniforms.useScreenCoordinates=k.getUniformLocation(Q.program,"useScreenCoordinates");Q.uniforms.affectedByDistance=k.getUniformLocation(Q.program,"affectedByDistance");Q.uniforms.screenPosition=k.getUniformLocation(Q.program,"screenPosition");Q.uniforms.modelViewMatrix=k.getUniformLocation(Q.program,"modelViewMatrix");Q.uniforms.projectionMatrix=k.getUniformLocation(Q.program, +"projectionMatrix");var ja=!1;this.setSize=function(b,e){va.width=b;va.height=e;this.setViewport(0,0,va.width,va.height)};this.setViewport=function(b,e,c,f){aa=b;ma=e;ca=c;T=f;k.viewport(aa,ma,ca,T)};this.setScissor=function(b,e,c,f){k.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){fa=b;k.depthMask(b)};this.setClearColorHex=function(b,e){sa.setHex(b);ra=e;k.clearColor(sa.r,sa.g,sa.b,ra)};this.setClearColor= +function(b,e){sa.copy(b);ra=e;k.clearColor(sa.r,sa.g,sa.b,ra)};this.clear=function(){k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT|k.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){da.darkness=b};this.getContext=function(){return k};this.initMaterial=function(b,e,c,f){var h,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic": +b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var m=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var t,o,n;t=n=m=0;for(o=e.length;t=0&&k.enableVertexAttribArray(p.position);p.color>=0&&k.enableVertexAttribArray(p.color);p.normal>=0&&k.enableVertexAttribArray(p.normal);p.tangent>=0&&k.enableVertexAttribArray(p.tangent); +"uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(v=0;v=0&&k.enableVertexAttribArray(p.position);p.color>=0&&k.enableVertexAttribArray(p.color);p.normal>=0&&k.enableVertexAttribArray(p.normal);p.tangent>=0&&k.enableVertexAttribArray(p.tangent); b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(k.enableVertexAttribArray(p.skinVertexA),k.enableVertexAttribArray(p.skinVertexB),k.enableVertexAttribArray(p.skinIndex),k.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(h in b.attributes)p[h]!==void 0&&p[h]>=0&&k.enableVertexAttribArray(p[h]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=0&&(k.enableVertexAttribArray(p.morphTarget0),b.numSupportedMorphTargets++);p.morphTarget1>=0&&(k.enableVertexAttribArray(p.morphTarget1), b.numSupportedMorphTargets++);p.morphTarget2>=0&&(k.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(k.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(k.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(k.enableVertexAttribArray(p.morphTarget5),b.numSupportedMorphTargets++);p.morphTarget6>=0&&(k.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>= -0&&(k.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(h=this.maxMorphTargets;b0||u.faceVertexUvs.length>0)j.__uvArray=new Float32Array(t*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(t*2)}if(m.geometry.skinWeights.length&&m.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(x*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(y*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];u=0;for(v=j.numMorphTargets;u0||u.faceVertexUvs.length>0)j.__uvArray=new Float32Array(t*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(t*2)}if(m.geometry.skinWeights.length&&m.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(x*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(w*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];u=0;for(v=j.numMorphTargets;u=0;h--)e[h]==c&&e.splice(h,1)}else c instanceof THREE.LensFlare?G(e.__webglLensFlares,c):c instanceof THREE.MarchingCubes&&G(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;e=0;h--)e[h]==c&&e.splice(h,1)}else c instanceof THREE.LensFlare?F(e.__webglLensFlares,c):c instanceof THREE.MarchingCubes&&F(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;ethis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&& -(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi= -(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.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",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown), -!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype; -THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))}; -THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},g,j=e.getControlPointsArray(),m=e.getLength(),n=j.length,F=0;g=n-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[g]={time:f,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;gthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c); +this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown&&this.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+= +this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.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",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera; +THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))}; +THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},g,j=e.getControlPointsArray(),m=e.getLength(),n=j.length,E=0;g=n-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[g]={time:f,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);this.translateY(b*u);n&&(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.y0?(h=e[e.length-1],v=h.x,x=h.y):(h=this.actions[f-1].args,v=h[h.length-2],x=h[h.length-1]);for(h=1;h<=b;h++)w=h/b,j=THREE.FontUtils.b2(w,v,t,m),w=THREE.FontUtils.b2(w,x,u,n), e.push(new THREE.Vector2(j,w));break;case THREE.PathActions.BEZIER_CURVE_TO:m=j[4];n=j[5];t=j[0];u=j[1];p=j[2];o=j[3];e.length>0?(h=e[e.length-1],v=h.x,x=h.y):(h=this.actions[f-1].args,v=h[h.length-2],x=h[h.length-1]);for(h=1;h<=b;h++)w=h/b,j=THREE.FontUtils.b3(w,v,t,p,m),w=THREE.FontUtils.b3(w,x,u,o,n),e.push(new THREE.Vector2(j,w));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[f-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];w=b*j[0].length;h=h.concat(j[0]);j=new THREE.SplineCurve(h); -for(h=1;h<=w;h++)e.push(j.getPointAt(h/w));break;case THREE.PathActions.ARC:h=this.actions[f-1].args;m=j[0];n=j[1];p=j[2];t=j[3];w=j[4];u=!!j[5];o=h[h.length-2];v=h[h.length-1];h.length==0&&(o=v=0);x=w-t;var B=b*2;for(h=1;h<=B;h++)w=h/B,u||(w=1-w),w=t+w*x,j=o+m+p*Math.cos(w),w=v+n+p*Math.sin(w),e.push(new THREE.Vector2(j,w))}c&&e.push(e[0]);return e}; +for(h=1;h<=w;h++)e.push(j.getPointAt(h/w));break;case THREE.PathActions.ARC:h=this.actions[f-1].args;m=j[0];n=j[1];p=j[2];t=j[3];w=j[4];u=!!j[5];o=h[h.length-2];v=h[h.length-1];h.length==0&&(o=v=0);x=w-t;var y=b*2;for(h=1;h<=y;h++)w=h/y,u||(w=1-w),w=t+w*x,j=o+m+p*Math.cos(w),w=v+n+p*Math.sin(w),e.push(new THREE.Vector2(j,w))}c&&e.push(e[0]);return e}; THREE.Path.prototype.getMinAndMax=function(){var b=this.getPoints(),c,e,f,g;c=e=Number.NEGATIVE_INFINITY;f=g=Number.POSITIVE_INFINITY;var j,h,m;h=0;for(m=b.length;hc)c=j.x;else if(j.xe)e=j.y;else if(j.y=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null}; THREE.Path.prototype.getLength=function(){var b=[],c=0,e,f=this.curves.length;for(e=0;e=0?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;var w=[p[h],e[m],e[g]];t=THREE.FontUtils.Triangulate.area(w);var B=[p[h],p[j],e[m]];u=THREE.FontUtils.Triangulate.area(B);v=m;o=h;m+=1;h+=-1;m<0&&(m+=e.length);m%=e.length; -h<0&&(h+=p.length);h%=p.length;g=m-1>=0?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;w=[p[h],e[m],e[g]];w=THREE.FontUtils.Triangulate.area(w);B=[p[h],p[j],e[m]];B=THREE.FontUtils.Triangulate.area(B);t+u>w+B&&(m=v,h=o,m<0&&(m+=e.length),m%=e.length,h<0&&(h+=p.length),h%=p.length,g=m-1>=0?m-1:e.length-1,j=h-1>=0?h-1:p.length-1);t=e.slice(0,m);u=e.slice(m);v=p.slice(h);o=p.slice(0,h);j=[p[h],p[j],e[m]];x.push([p[h],e[m],e[g]]);x.push(j);e=t.concat(v).concat(o).concat(u)}return{shape:e,isolatedPts:x,allpoints:f}}, +THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),g,j,h,m,n,p,o,t,u,v,x=[];for(n=0;n=0?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;var w=[p[h],e[m],e[g]];t=THREE.FontUtils.Triangulate.area(w);var y=[p[h],p[j],e[m]];u=THREE.FontUtils.Triangulate.area(y);v=m;o=h;m+=1;h+=-1;m<0&&(m+=e.length);m%=e.length; +h<0&&(h+=p.length);h%=p.length;g=m-1>=0?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;w=[p[h],e[m],e[g]];w=THREE.FontUtils.Triangulate.area(w);y=[p[h],p[j],e[m]];y=THREE.FontUtils.Triangulate.area(y);t+u>w+y&&(m=v,h=o,m<0&&(m+=e.length),m%=e.length,h<0&&(h+=p.length),h%=p.length,g=m-1>=0?m-1:e.length-1,j=h-1>=0?h-1:p.length-1);t=e.slice(0,m);u=e.slice(m);v=p.slice(h);o=p.slice(0,h);j=[p[h],p[j],e[m]];x.push([p[h],e[m],e[g]]);x.push(j);e=t.concat(v).concat(o).concat(u)}return{shape:e,isolatedPts:x,allpoints:f}}, triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,g=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),j,h,m,n;for(j=0;j0){h(0,0,-o-(j||0));for(n=b;n0){h(0,0,o+ (g||0));for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n=0;){k=A;V=A-1;V<0&&(V=b.length-1);for(var e=0,e=0;e0;U--){w=U/o;Y=m*w;J=n*(1-Math.sin((1-w)*Math.PI/2));A=0;for(P=G.length;A=0;){k=A;W=A-1;W<0&&(W=b.length-1);for(var e=0,e=0;e0;V--){w=V/o;Z=m*w;J=n*(1-Math.sin((1-w)*Math.PI/2));A=0;for(P=F.length;A0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);p.push(o)}c.push(p)}for(var v,x,w,g=c.length,e=0;e0)for(f=0;f1&&(v= -this.vertices[h].position.clone(),x=this.vertices[n].position.clone(),w=this.vertices[p].position.clone(),v.normalize(),x.normalize(),w.normalize(),this.faces.push(new THREE.Face3(h,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)])),this.faceVertexUvs[0].push([o,t,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +j-1:f];p=c[e-1][p?0:f+1];u=e/(g-1);v=(e-1)/(g-1);x=(f+1)/j;var t=f/j,o=new THREE.UV(1-x,u),u=new THREE.UV(1-t,u),t=new THREE.UV(1-t,v),y=new THREE.UV(1-x,v);e1&&(v= +this.vertices[h].position.clone(),x=this.vertices[n].position.clone(),w=this.vertices[p].position.clone(),v.normalize(),x.normalize(),w.normalize(),this.faces.push(new THREE.Face3(h,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)])),this.faceVertexUvs[0].push([o,t,y]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(b,c){THREE.Geometry.call(this);this.parameters=c||{};this.set(b)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.TextGeometry.prototype.set=function(b,c){function e(b,e,c){x.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,c)))}function f(b,e,c,f){x.faces.push(new THREE.Face4(b,e,c,f))}this.text=b;var c=c||this.parameters,g=c.height!==void 0?c.height:50,j=c.curveSegments!==void 0?c.curveSegments:4,h=c.font!==void 0?c.font:"helvetiker",m=c.weight!==void 0?c.weight:"normal",n=c.style!==void 0?c.style:"normal",p=c.bevelThickness!==void 0?c.bevelThickness:10,o=c.bevelSize!==void 0?c.bevelSize:8,t=c.bevelEnabled!== -void 0?c.bevelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=j;THREE.FontUtils.face=h;THREE.FontUtils.weight=m;THREE.FontUtils.style=n;THREE.FontUtils.bevelSize=o;var m=THREE.FontUtils.drawText(b),j=m.points,u=m.faces,h=m.contour,v=m.bevel,x=this;x.vertices=[];x.faces=[];for(var w,n=j.length,B=u.length,o=v.length,m=0;m0;){if(y){if(y.equals(h[m])){y=null;continue}}else y=h[m];p=n*2+m;u=p-1;f(p,u,u+o,p+o);for(t=0;t0;){if(y){if(y.equals(h[m])){y=null;continue}}else y=h[m];for(t=0;t0;){if(C){if(C.equals(h[m])){C=null;continue}}else C=h[m];p=n*2+m;u=p-1;f(p,u,u+o,p+o);for(t=0;t0;){if(C){if(C.equals(h[m])){C=null;continue}}else C=h[m];for(t=0;t0&&m.push({shape:g,holes:f}),g=t,f=[]):f.push(t):this.Triangulate.area(t)<0?(m.push({shape:t,holes:f}),f=[]):f.push(t);e++}o&&m.push({shape:g,holes:f})}var u,v,x, -w,B,y;j=[];for(h=0;h=0?v-1:g.length-1;var t=u-1>=0?u-1:o.length-1,F=[];F.push(o[u]);F.push(g[v]);F.push(g[e]);x=this.Triangulate.area(F);var C=[];C.push(o[u]);C.push(o[t]);C.push(g[v]);B=this.Triangulate.area(C);w=v;y=u;v+=1;u+=-1;v<0&&(v+=g.length);v%=g.length;u<0&&(u+=o.length);u%=g.length;e=v- -1>=0?v-1:g.length-1;t=u-1>=0?u-1:o.length-1;F=[];F.push(o[u]);F.push(g[v]);F.push(g[e]);F=this.Triangulate.area(F);C=[];C.push(o[u]);C.push(o[t]);C.push(g[v]);C=this.Triangulate.area(C);x+B>F+C&&(v=w,u=y,v<0&&(v+=g.length),v%=g.length,u<0&&(u+=o.length),u%=g.length,e=v-1>=0?v-1:g.length-1,t=u-1>=0?u-1:o.length-1);x=g.slice(0,v);B=g.slice(v);w=o.slice(u);y=o.slice(0,u);j.push(o[u]);j.push(g[v]);j.push(g[e]);j.push(o[u]);j.push(o[t]);j.push(g[v]);g=x.concat(w).concat(y).concat(B)}n.shape=g}u=[];v=[]; -for(h=p=0;h=0?v-1:g.length-1;var t=u-1>=0?u-1:o.length-1,E=[];E.push(o[u]);E.push(g[v]);E.push(g[e]);x=this.Triangulate.area(E);var B=[];B.push(o[u]);B.push(o[t]);B.push(g[v]);y=this.Triangulate.area(B);w=v;C=u;v+=1;u+=-1;v<0&&(v+=g.length);v%=g.length;u<0&&(u+=o.length);u%=g.length;e=v- +1>=0?v-1:g.length-1;t=u-1>=0?u-1:o.length-1;E=[];E.push(o[u]);E.push(g[v]);E.push(g[e]);E=this.Triangulate.area(E);B=[];B.push(o[u]);B.push(o[t]);B.push(g[v]);B=this.Triangulate.area(B);x+y>E+B&&(v=w,u=C,v<0&&(v+=g.length),v%=g.length,u<0&&(u+=o.length),u%=g.length,e=v-1>=0?v-1:g.length-1,t=u-1>=0?u-1:o.length-1);x=g.slice(0,v);y=g.slice(v);w=o.slice(u);C=o.slice(0,u);j.push(o[u]);j.push(g[v]);j.push(g[e]);j.push(o[u]);j.push(o[t]);j.push(g[v]);g=x.concat(w).concat(C).concat(y)}n.shape=g}u=[];v=[]; +for(h=p=0;h=0;){if(o){if(o.equals(e[b])){o=null;n=this.Triangulate.area(f)>0;h.push(n);j.push(m.divideScalar(f.length));f=[];m=new THREE.Vector2;continue}}else o=e[b];m.addSelf(e[b]);f.push(e[b])}b=e.length;for(f= 0;--b>=0;)n=e[b],m=j[f],n=n.clone().subSelf(m),p=this.bevelSize/n.length(),h[f]?p+=1:p=1-p,p=n.multiplyScalar(p).addSelf(m),g.unshift(p),o?o.equals(e[b])&&(o=null,f++):o=e[b];c.bevel=g;return c},b2p0:function(b,c){var e=1-b;return e*e*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,e,f){return this.b2p0(b,c)+this.b2p1(b,e)+this.b2p2(b,f)},b3p0:function(b,c){var e=1-b;return e*e*e*c},b3p1:function(b,c){var e=1-b;return 3*e*e*b*c},b3p2:function(b,c){return 3* -(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,g){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,g)},extractGlyphPoints:function(b,c,e,f,g){var j=[],h,m,n,p,o,t,u,v,x,w,B=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(B){if(B.o){c=B._cachedOutline||(B._cachedOutline=B.o.split(" "));n=c.length;for(b=0;b0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return j}n=p;g<=n&&(n=0);p=n+1;g<=p&&(p=0);o=p+1;g<=o&&(o=0);var u;a:{u=b;var v=n,x=p,w=o,B=g,y=h,F=void 0,C=void 0,E=void 0, -G=void 0,A=void 0,P=void 0,I=void 0,H=void 0,T=void 0,C=u[y[v]].x,E=u[y[v]].y,G=u[y[x]].x,A=u[y[x]].y,P=u[y[w]].x,I=u[y[w]].y;if(1.0E-10>(G-C)*(I-E)-(A-E)*(P-C))u=!1;else{for(F=0;F=0&&Y>=0&&S>=0){u=!1;break a}}u= +(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,g){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,g)},extractGlyphPoints:function(b,c,e,f,g){var j=[],h,m,n,p,o,t,u,v,x,w,y=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(y){if(y.o){c=y._cachedOutline||(y._cachedOutline=y.o.split(" "));n=c.length;for(b=0;b0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return j}n=p;g<=n&&(n=0);p=n+1;g<=p&&(p=0);o=p+1;g<=o&&(o=0);var u;a:{u=b;var v=n,x=p,w=o,y=g,C=h,E=void 0,B=void 0,I=void 0, +F=void 0,A=void 0,P=void 0,H=void 0,G=void 0,U=void 0,B=u[C[v]].x,I=u[C[v]].y,F=u[C[x]].x,A=u[C[x]].y,P=u[C[w]].x,H=u[C[w]].y;if(1.0E-10>(F-B)*(H-I)-(A-I)*(P-B))u=!1;else{for(E=0;E=0&&Z>=0&&S>=0){u=!1;break a}}u= !0}}if(u){j.push([b[h[n]],b[h[p]],b[h[o]]]);m.push([h[n],h[p],h[o]]);n=p;for(o=p+1;o>7)-127;f|=(h&127)<<16|g<<8;if(f==0&&k==-127)return 0;return(1-2*(j>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,k)}function g(b,e){var c=o(b,e),f=o(b,e+1),h=o(b,e+2);return(o(b,e+3)<<24)+(h<<16)+(f<<8)+c}function n(b,e){var c=o(b,e);return(o(b,e+1)<<8)+c}function p(b,e){var c=o(b,e);return c>127?c-256:c}function o(b, -e){return b.charCodeAt(e)&255}function t(e){var c,f,h;c=g(b,e);f=g(b,e+A);h=g(b,e+P);e=n(b,e+I);THREE.BinaryLoader.prototype.f3(y,c,f,h,e)}function u(e){var c,f,h,j,k,p;c=g(b,e);f=g(b,e+A);h=g(b,e+P);j=n(b,e+I);k=g(b,e+H);p=g(b,e+T);e=g(b,e+U);THREE.BinaryLoader.prototype.f3n(y,E,c,f,h,j,k,p,e)}function v(e){var c,f,h,j;c=g(b,e);f=g(b,e+J);h=g(b,e+Y);j=g(b,e+K);e=n(b,e+S);THREE.BinaryLoader.prototype.f4(y,c,f,h,j,e)}function x(e){var c,f,h,j,p,o,t,u;c=g(b,e);f=g(b,e+J);h=g(b,e+Y);j=g(b,e+K);p=n(b, -e+S);o=g(b,e+k);t=g(b,e+V);u=g(b,e+O);e=g(b,e+fa);THREE.BinaryLoader.prototype.f4n(y,E,c,f,h,j,p,o,t,u,e)}function w(e){var c,f;c=g(b,e);f=g(b,e+ea);e=g(b,e+W);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],G[c*2],G[c*2+1],G[f*2],G[f*2+1],G[e*2],G[e*2+1])}function B(e){var c,f,h;c=g(b,e);f=g(b,e+da);h=g(b,e+ga);e=g(b,e+ka);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],G[c*2],G[c*2+1],G[f*2],G[f*2+1],G[h*2],G[h*2+1],G[e*2],G[e*2+1])}var y=this,F=0,C,E=[],G=[],A,P,I,H,T,U,J,Y,K,S,k,V,O,fa, -ea,W,da,ga,ka,pa,R,ha,$,ma,aa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,f,e);C={signature:b.substr(F,8),header_bytes:o(b,F+8),vertex_coordinate_bytes:o(b,F+9),normal_coordinate_bytes:o(b,F+10),uv_coordinate_bytes:o(b,F+11),vertex_index_bytes:o(b,F+12),normal_index_bytes:o(b,F+13),uv_index_bytes:o(b,F+14),material_index_bytes:o(b,F+15),nvertices:g(b,F+16),nnormals:g(b,F+16+4),nuvs:g(b,F+16+8),ntri_flat:g(b,F+16+12),ntri_smooth:g(b,F+16+16),ntri_flat_uv:g(b,F+16+20),ntri_smooth_uv:g(b, -F+16+24),nquad_flat:g(b,F+16+28),nquad_smooth:g(b,F+16+32),nquad_flat_uv:g(b,F+16+36),nquad_smooth_uv:g(b,F+16+40)};F+=C.header_bytes;A=C.vertex_index_bytes;P=C.vertex_index_bytes*2;I=C.vertex_index_bytes*3;H=C.vertex_index_bytes*3+C.material_index_bytes;T=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;U=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;J=C.vertex_index_bytes;Y=C.vertex_index_bytes*2;K=C.vertex_index_bytes*3;S=C.vertex_index_bytes*4;k=C.vertex_index_bytes* -4+C.material_index_bytes;V=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;O=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;fa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;ea=C.uv_index_bytes;W=C.uv_index_bytes*2;da=C.uv_index_bytes;ga=C.uv_index_bytes*2;ka=C.uv_index_bytes*3;e=C.vertex_index_bytes*3+C.material_index_bytes;aa=C.vertex_index_bytes*4+C.material_index_bytes;pa=C.ntri_flat*e;R=C.ntri_smooth*(e+C.normal_index_bytes*3);ha= -C.ntri_flat_uv*(e+C.uv_index_bytes*3);$=C.ntri_smooth_uv*(e+C.normal_index_bytes*3+C.uv_index_bytes*3);ma=C.nquad_flat*aa;e=C.nquad_smooth*(aa+C.normal_index_bytes*4);aa=C.nquad_flat_uv*(aa+C.uv_index_bytes*4);F+=function(e){for(var f,g,j,k=C.vertex_coordinate_bytes*3,m=e+C.nvertices*k;e1&&(T=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(A,T);object.name=v;object.position.set(C[0],C[1],C[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=F.visible;O.scene.addObject(object);O.objects[v]=object;F.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),O.scene.collisions.colliders.push(b)); -if(F.castsShadow)b=new THREE.ShadowVolume(A),O.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},O.triggers[object.name]=b)}}else C=F.position,r=F.rotation,q=F.quaternion,s=F.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(C[0],C[1],C[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=F.visible!==void 0?F.visible:!1,O.scene.addObject(object),O.objects[v]=object,O.empties[v]=object,F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},O.triggers[object.name]=b)}function n(b){return function(c){O.geometries[b]=c;m();K-=1;e.onLoadComplete();o()}}function p(b){return function(e){O.geometries[b]=e}}function o(){e.callbackProgress({totalModels:k,totalTextures:V,loadedModels:k-K,loadedTextures:V-S},O);e.onLoadProgress();K==0&&S==0&&c(O)}var t, -u,v,x,w,B,y,F,C,E,G,A,P,I,H,T,U,J,Y,K,S,k,V,O;J=b.data;H=new THREE.BinaryLoader;Y=new THREE.JSONLoader;S=K=0;O={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in J.objects)if(F=J.objects[v],F.meshCollider){b=!0;break}if(b)O.scene.collisions=new THREE.CollisionSystem;if(J.transform){b=J.transform.position;E=J.transform.rotation;var fa=J.transform.scale;b&&O.scene.position.set(b[0],b[1],b[2]);E&&O.scene.rotation.set(E[0], -E[1],E[2]);fa&&O.scene.scale.set(fa[0],fa[1],fa[2]);(b||E||fa)&&O.scene.updateMatrix()}b=function(){S-=1;o();e.onLoadComplete()};for(w in J.cameras){E=J.cameras[w];if(E.type=="perspective")P=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho")P=new THREE.Camera,P.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far);C=E.position;E=E.target;P.position.set(C[0],C[1],C[2]);P.target.position.set(E[0],E[1],E[2]);O.cameras[w]=P}for(x in J.lights)w=J.lights[x], -P=w.color!==void 0?w.color:16777215,E=w.intensity!==void 0?w.intensity:1,w.type=="directional"?(C=w.direction,U=new THREE.DirectionalLight(P,E),U.position.set(C[0],C[1],C[2]),U.position.normalize()):w.type=="point"?(C=w.position,d=w.distance,U=new THREE.PointLight(P,E,d),U.position.set(C[0],C[1],C[2])):w.type=="ambient"&&(U=new THREE.AmbientLight(P)),O.scene.addLight(U),O.lights[x]=U;for(B in J.fogs)x=J.fogs[B],x.type=="linear"?I=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(I=new THREE.FogExp2(0, -x.density)),E=x.color,I.color.setRGB(E[0],E[1],E[2]),O.fogs[B]=I;if(O.cameras&&J.defaults.camera)O.currentCamera=O.cameras[J.defaults.camera];if(O.fogs&&J.defaults.fog)O.scene.fog=O.fogs[J.defaults.fog];E=J.defaults.bgcolor;O.bgColor=new THREE.Color;O.bgColor.setRGB(E[0],E[1],E[2]);O.bgColorAlpha=J.defaults.bgalpha;for(t in J.geometries)if(B=J.geometries[t],B.type=="bin_mesh"||B.type=="ascii_mesh")K+=1,e.onLoadStart();k=K;for(t in J.geometries)B=J.geometries[t],B.type=="cube"?(A=new THREE.CubeGeometry(B.width, -B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),O.geometries[t]=A):B.type=="plane"?(A=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),O.geometries[t]=A):B.type=="sphere"?(A=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),O.geometries[t]=A):B.type=="cylinder"?(A=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),O.geometries[t]=A):B.type=="torus"?(A=new THREE.TorusGeometry(B.radius, -B.tube,B.segmentsR,B.segmentsT),O.geometries[t]=A):B.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(B.subdivisions),O.geometries[t]=A):B.type=="bin_mesh"?H.load({model:f(B.url,J.urlBaseType),callback:n(t)}):B.type=="ascii_mesh"?Y.load({model:f(B.url,J.urlBaseType),callback:n(t)}):B.type=="embedded_mesh"&&(B=J.embeds[B.id])&&Y.createModel(B,p(t),"");for(y in J.textures)if(t=J.textures[y],t.url instanceof Array){S+=t.url.length;for(H=0;H1&&(U=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(A,U);object.name=v;object.position.set(B[0],B[1],B[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;O.scene.addObject(object);O.objects[v]=object;E.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),O.scene.collisions.colliders.push(b)); +if(E.castsShadow)b=new THREE.ShadowVolume(A),O.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},O.triggers[object.name]=b)}}else B=E.position,r=E.rotation,q=E.quaternion,s=E.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(B[0],B[1],B[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], +s[1],s[2]),object.visible=E.visible!==void 0?E.visible:!1,O.scene.addObject(object),O.objects[v]=object,O.empties[v]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},O.triggers[object.name]=b)}function n(b){return function(c){O.geometries[b]=c;m();K-=1;e.onLoadComplete();o()}}function p(b){return function(e){O.geometries[b]=e}}function o(){e.callbackProgress({totalModels:k,totalTextures:W,loadedModels:k-K,loadedTextures:W-S},O);e.onLoadProgress();K==0&&S==0&&c(O)}var t, +u,v,x,w,y,C,E,B,I,F,A,P,H,G,U,V,J,Z,K,S,k,W,O;J=b.data;G=new THREE.BinaryLoader;Z=new THREE.JSONLoader;S=K=0;O={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in J.objects)if(E=J.objects[v],E.meshCollider){b=!0;break}if(b)O.scene.collisions=new THREE.CollisionSystem;if(J.transform){b=J.transform.position;I=J.transform.rotation;var ga=J.transform.scale;b&&O.scene.position.set(b[0],b[1],b[2]);I&&O.scene.rotation.set(I[0], +I[1],I[2]);ga&&O.scene.scale.set(ga[0],ga[1],ga[2]);(b||I||ga)&&O.scene.updateMatrix()}b=function(){S-=1;o();e.onLoadComplete()};for(w in J.cameras){I=J.cameras[w];if(I.type=="perspective")P=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")P=new THREE.Camera,P.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);B=I.position;I=I.target;P.position.set(B[0],B[1],B[2]);P.target.position.set(I[0],I[1],I[2]);O.cameras[w]=P}for(x in J.lights)w=J.lights[x], +P=w.color!==void 0?w.color:16777215,I=w.intensity!==void 0?w.intensity:1,w.type=="directional"?(B=w.direction,V=new THREE.DirectionalLight(P,I),V.position.set(B[0],B[1],B[2]),V.position.normalize()):w.type=="point"?(B=w.position,d=w.distance,V=new THREE.PointLight(P,I,d),V.position.set(B[0],B[1],B[2])):w.type=="ambient"&&(V=new THREE.AmbientLight(P)),O.scene.addLight(V),O.lights[x]=V;for(y in J.fogs)x=J.fogs[y],x.type=="linear"?H=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(H=new THREE.FogExp2(0, +x.density)),I=x.color,H.color.setRGB(I[0],I[1],I[2]),O.fogs[y]=H;if(O.cameras&&J.defaults.camera)O.currentCamera=O.cameras[J.defaults.camera];if(O.fogs&&J.defaults.fog)O.scene.fog=O.fogs[J.defaults.fog];I=J.defaults.bgcolor;O.bgColor=new THREE.Color;O.bgColor.setRGB(I[0],I[1],I[2]);O.bgColorAlpha=J.defaults.bgalpha;for(t in J.geometries)if(y=J.geometries[t],y.type=="bin_mesh"||y.type=="ascii_mesh")K+=1,e.onLoadStart();k=K;for(t in J.geometries)y=J.geometries[t],y.type=="cube"?(A=new THREE.CubeGeometry(y.width, +y.height,y.depth,y.segmentsWidth,y.segmentsHeight,y.segmentsDepth,null,y.flipped,y.sides),O.geometries[t]=A):y.type=="plane"?(A=new THREE.PlaneGeometry(y.width,y.height,y.segmentsWidth,y.segmentsHeight),O.geometries[t]=A):y.type=="sphere"?(A=new THREE.SphereGeometry(y.radius,y.segmentsWidth,y.segmentsHeight),O.geometries[t]=A):y.type=="cylinder"?(A=new THREE.CylinderGeometry(y.numSegs,y.topRad,y.botRad,y.height,y.topOffset,y.botOffset),O.geometries[t]=A):y.type=="torus"?(A=new THREE.TorusGeometry(y.radius, +y.tube,y.segmentsR,y.segmentsT),O.geometries[t]=A):y.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(y.subdivisions),O.geometries[t]=A):y.type=="bin_mesh"?G.load({model:f(y.url,J.urlBaseType),callback:n(t)}):y.type=="ascii_mesh"?Z.load({model:f(y.url,J.urlBaseType),callback:n(t)}):y.type=="embedded_mesh"&&(y=J.embeds[y.id])&&Z.createModel(y,p(t),"");for(C in J.textures)if(t=J.textures[C],t.url instanceof Array){S+=t.url.length;for(G=0;G=this.maxCount-3&&m(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(n=this.size-1);var u=Math.floor(p-m);u<1&&(u=1);p=Math.floor(p+m);p>this.size-1&&(p=this.size-1);var v=Math.floor(o-m);v<1&&(v=1);m=Math.floor(o+m);m>this.size-1&&(m=this.size- -1);for(var x,w,B,y,F,C;t0&&(this.field[B+x]+=y)}}};this.addPlaneX=function(b,c){var g,j,h,m,n,p=this.size,o=this.yd,t=this.zd,u=this.field,v=p*Math.sqrt(b/c);v>p&&(v=p);for(g=0;g0)for(j=0;j0&&(this.field[y+x]+=C)}}};this.addPlaneX=function(b,c){var g,j,h,m,n,p=this.size,o=this.yd,t=this.zd,u=this.field,v=p*Math.sqrt(b/c);v>p&&(v=p);for(g=0;g0)for(j=0;jo&&(x=o);for(j=0;j0){n=j*t;for(g=0;gsize&&(dist=size);for(h=0;h0){n=zd*h;for(j=0;jthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&& -(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi= -(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown), -!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype; -THREE.FirstPersonCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))}; +!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update= +function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c); +this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown&&this.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+= +this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu", +function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera; +THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))}; THREE.PathCamera=function(a){function c(a,b,c,e){var g={name:c,fps:0.6,length:e,hierarchy:[]},h,f=b.getControlPointsArray(),j=b.getLength(),k=f.length,y=0;h=k-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h0){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,e=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=0,d=0,e=this.vertices.length;d=0&&c>=0&&h>=0&&i>=0?!0:g<0&&c<0||h<0&&i<0?!1:(g<0?e=Math.max(e,g/(g-c)):c<0&&(f=Math.min(f,g/(g-c))),h<0?e=Math.max(e,h/(h-i)):i<0&&(f=Math.min(f,h/(h-i))),fM&&h.positionScreen.zM&&h.positionScreen.z0&&I.z<1))ra=pa[oa]=pa[oa]||new THREE.RenderableParticle,oa++,C=ra,C.x=I.x/I.w,C.y=I.y/I.w,C.z=I.z,C.rotation=R.rotation.z,C.scale.x=R.scale.x*Math.abs(C.x- -(I.x+g.projectionMatrix.n11)/(I.w+g.projectionMatrix.n14)),C.scale.y=R.scale.y*Math.abs(C.y-(I.y+g.projectionMatrix.n22)/(I.w+g.projectionMatrix.n24)),C.materials=R.materials,H.push(C);i&&H.sort(d);return H}}; +P.length;B0&&I.z<1))ra=pa[oa]=pa[oa]||new THREE.RenderableParticle,oa++,C=ra,C.x=I.x/I.w,C.y=I.y/I.w,C.z=I.z,C.rotation=S.rotation.z,C.scale.x=S.scale.x*Math.abs(C.x- +(I.x+g.projectionMatrix.n11)/(I.w+g.projectionMatrix.n14)),C.scale.y=S.scale.y*Math.abs(C.y-(I.y+g.projectionMatrix.n22)/(I.w+g.projectionMatrix.n24)),C.materials=S.materials,H.push(C);i&&H.sort(d);return H}}; THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif", @@ -156,7 +156,8 @@ lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", -default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var d,e,f,g={};for(d=0;d=0)c.bindBuffer(c.ARRAY_BUFFER, -h.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else{d=g.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[i.morphTargetBase]),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length)for(var f=0,k=i.morphTargetForcedOrder,o=i.morphTargetInfluences;fp&&(q=S,p=o[q]);c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[q]);c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]= -p;k[q]=1;p=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&c.uniform1fv(g.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(j in h.__webglCustomAttributes)b[j]>=0&&(d=h.__webglCustomAttributes[j],c.bindBuffer(c.ARRAY_BUFFER,d.buffer),c.vertexAttribPointer(b[j],d.size,c.FLOAT,!1,0,0));b.color>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglColorBuffer),c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER, -h.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,!1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)):c.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0, -0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER, -h.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(g.wireframe?(c.lineWidth(g.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.drawElements(c.LINES,h.__webglLineCount,c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.drawElements(c.TRIANGLES,h.__webglFaceCount,c.UNSIGNED_SHORT,0)),M.data.vertices+=h.__webglFaceCount,M.data.faces+=h.__webglFaceCount/3,M.data.drawCalls++):i instanceof -THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(g.linewidth),c.drawArrays(i,0,h.__webglLineCount),M.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,h.__webglParticleCount),M.data.drawCalls++):i instanceof THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,h.__webglVertexCount),M.data.drawCalls++)}}function g(b,d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=c.createBuffer();b.hasPos&& -(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,b.positionArray,c.DYNAMIC_DRAW),c.enableVertexAttribArray(d.attributes.position),c.vertexAttribPointer(d.attributes.position,3,c.FLOAT,!1,0,0));if(b.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,h,g,i,j,k,o,q,p,n,v=b.count*3;for(n=0;n0&&u[0]0&&u[1]0.0010&&j.scale>0.0010)t[0]=j.x,t[1]=j.y, -t[2]=j.z,p=j.size*j.scale/P,v[0]=p*o,v[1]=p,c.uniform3fv(y.screenPosition,t),c.uniform2fv(y.scale,v),c.uniform1f(y.rotation,j.rotation),c.uniform1f(y.opacity,j.opacity),G(j.blending),$(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ia)}function C(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} -function oa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ga,j));na&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,O,j));qa&&ka.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,V, -j));ja&&R>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));ja&&T>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,aa,j));la&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,N,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,P,j));x>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER, -g.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j));i.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray, -delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;pa(h)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;u=b.vertices;g=b.colors;y=u.length;i=g.length;z=b.__vertexArray;j=b.__colorArray;C=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k=0;e--)b[e].object==c&&b.splice(e,1)}function y(b){function c(b){var f=[];e=0;for(d=b.length;e65535&&(q[j].counter+=1,k=q[j].hash+"_"+q[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:o})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=h}function K(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(b){if(b!=F){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); -c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}F=b}}function ca(b,e,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,H(e.wrapS)),c.texParameteri(b, -c.TEXTURE_WRAP_T,H(e.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,H(e.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,H(e.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,na(e.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,na(e.minFilter)))}function $(b,e){if(b.needsUpdate)b.__webglInit?(c.bindTexture(c.TEXTURE_2D,b.__webglTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA, -c.RGBA,c.UNSIGNED_BYTE,b.image)):(b.__webglTexture=c.createTexture(),c.bindTexture(c.TEXTURE_2D,b.__webglTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image),b.__webglInit=!0),ca(c.TEXTURE_2D,b,b.image),c.bindTexture(c.TEXTURE_2D,null),b.needsUpdate=!1;c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function qa(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer= -c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,H(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,H(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,H(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,H(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,H(b.format),b.width,b.height,0,H(b.format),H(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER, -b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER, -c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var e,d;b?(e=b.__webglFramebuffer,d=b.width,b=b.height):(e=null,d=sa,b=P);e!=aa&&(c.bindFramebuffer(c.FRAMEBUFFER,e),c.viewport(va,Ea,d,b),aa=e)}function Q(b,e){var d;b=="fragment"?d=c.createShader(c.FRAGMENT_SHADER):b=="vertex"&&(d=c.createShader(c.VERTEX_SHADER)); -c.shaderSource(d,e);c.compileShader(d);if(!c.getShaderParameter(d,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(d)),console.error(e),null;return d}function na(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function H(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT; +f.ambient,j.specular.value=f.specular,j.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)j.mNear.value=b.near,j.mFar.value=b.far,j.opacity.value=f.opacity;else if(f instanceof THREE.MeshNormalMaterial)j.opacity.value=f.opacity;for(var A in j)if(Q=h.uniforms[A])if(k=j[A],q=k.type,e=k.value,q=="i")c.uniform1i(Q,e);else if(q=="f")c.uniform1f(Q,e);else if(q=="fv1")c.uniform1fv(Q,e);else if(q=="fv")c.uniform3fv(Q,e);else if(q=="v2")c.uniform2f(Q,e.x,e.y);else if(q=="v3")c.uniform3f(Q, +e.x,e.y,e.z);else if(q=="v4")c.uniform4f(Q,e.x,e.y,e.z,e.w);else if(q=="m4"){if(!k._array)k._array=new Float32Array(16);e.flattenToArray(k._array);c.uniformMatrix4fv(Q,!1,k._array)}else if(q=="c")c.uniform3f(Q,e.r,e.g,e.b);else if(q=="t"&&(c.uniform1i(Q,e),k=k.texture))if(k.image instanceof Array&&k.image.length==6){if(k.image.length==6){if(k.needsUpdate){if(k.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(q=0;q<6;++q)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+q, +0,0,0,c.RGBA,c.UNSIGNED_BYTE,k.image[q])}else{k.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(q=0;q<6;++q)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,k.image[q]);k.__webglInit=!0}ca(c.TEXTURE_CUBE_MAP,k,k.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);k.needsUpdate=!1}c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube)}}else $(k,e);c.uniformMatrix4fv(i.modelViewMatrix, +!1,g._modelViewMatrixArray);c.uniformMatrix3fv(i.normalMatrix,!1,g._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&i.cameraPosition!==null&&c.uniform3f(i.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning)&&i.objectMatrix!==null&&c.uniformMatrix4fv(i.objectMatrix,!1,g._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof +THREE.MeshShaderMaterial||f.skinning)&&i.viewMatrix!==null&&c.uniformMatrix4fv(i.viewMatrix,!1,Ha);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=j.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,c.uniform3fv(i.directionalLightDirection,b),c.uniformMatrix4fv(i.objectMatrix,!1,g._objectMatrixArray),c.uniformMatrix4fv(i.viewMatrix,!1,Ha);f.skinning&&(c.uniformMatrix4fv(i.cameraInverseMatrix,!1,Ha),c.uniformMatrix4fv(i.boneGlobalMatrices,!1,g.boneMatrices)); +return h}function f(b,d,f,g,h,i){if(g.opacity!=0){var j,b=e(b,d,f,g,i).attributes;if(!g.morphTargets&&b.position>=0)c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else if(i.morphTargetBase){d=g.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[i.morphTargetBase]),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.vertexAttribPointer(d.position, +3,c.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length)for(var f=0,k=i.morphTargetForcedOrder,o=i.morphTargetInfluences;fp&&(q=Q,p=o[q]);c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[q]);c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]=p;k[q]=1;p=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&c.uniform1fv(g.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(j in h.__webglCustomAttributes)b[j]>=0&&(d=h.__webglCustomAttributes[j],c.bindBuffer(c.ARRAY_BUFFER,d.buffer),c.vertexAttribPointer(b[j],d.size, +c.FLOAT,!1,0,0));b.color>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglColorBuffer),c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,!1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)): +c.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB, +4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(g.wireframe?(c.lineWidth(g.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.drawElements(c.LINES,h.__webglLineCount,c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.drawElements(c.TRIANGLES, +h.__webglFaceCount,c.UNSIGNED_SHORT,0)),M.data.vertices+=h.__webglFaceCount,M.data.faces+=h.__webglFaceCount/3,M.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(g.linewidth),c.drawArrays(i,0,h.__webglLineCount),M.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,h.__webglParticleCount),M.data.drawCalls++):i instanceof THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,h.__webglVertexCount),M.data.drawCalls++)}}function g(b, +d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=c.createBuffer();b.hasPos&&(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,b.positionArray,c.DYNAMIC_DRAW),c.enableVertexAttribArray(d.attributes.position),c.vertexAttribPointer(d.attributes.position,3,c.FLOAT,!1,0,0));if(b.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,h,g,i,j,k,o,q,p,n,v=b.count*3;for(n= +0;n0&&u[0]0&&u[1]0.0010&&j.scale>0.0010)t[0]=j.x,t[1]=j.y,t[2]=j.z,p=j.size*j.scale/P,v[0]=p*o,v[1]=p,c.uniform3fv(y.screenPosition,t),c.uniform2fv(y.scale,v),c.uniform1f(y.rotation,j.rotation),c.uniform1f(y.opacity,j.opacity),G(j.blending),$(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ia)}function C(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse, +b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function oa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ga,j));na&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER, +O,j));qa&&ka.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,V,j));ja&&S>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));ja&&T>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,aa,j));la&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,N,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,P,j));x> +0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j));i.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array, +delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;pa(h)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;u=b.vertices;g=b.colors;y=u.length;i=g.length;z=b.__vertexArray;j=b.__colorArray; +C=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k=0;e--)b[e].object==c&&b.splice(e,1)}function y(b){function c(b){var f=[];e=0;for(d=b.length;e65535&&(q[j].counter+=1,k=q[j].hash+"_"+q[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:o})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=h}function K(b,c,e){b.push({buffer:c,object:e, +opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(b){if(b!=F){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}F= +b}}function ca(b,e,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,H(e.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,H(e.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,H(e.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,H(e.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,na(e.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,na(e.minFilter)))} +function $(b,e){if(b.needsUpdate)b.__webglInit?(c.bindTexture(c.TEXTURE_2D,b.__webglTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image)):(b.__webglTexture=c.createTexture(),c.bindTexture(c.TEXTURE_2D,b.__webglTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image),b.__webglInit=!0),ca(c.TEXTURE_2D,b,b.image),c.bindTexture(c.TEXTURE_2D,null),b.needsUpdate=!1;c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function qa(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer=== +void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,H(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,H(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,H(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,H(b.minFilter));c.texImage2D(c.TEXTURE_2D, +0,H(b.format),b.width,b.height,0,H(b.format),H(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER, +c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var e,d;b?(e=b.__webglFramebuffer,d=b.width,b=b.height):(e=null,d=sa,b=P);e!=aa&&(c.bindFramebuffer(c.FRAMEBUFFER,e),c.viewport(va,Ea,d,b),aa=e)}function R(b,e){var d;b=="fragment"?d=c.createShader(c.FRAGMENT_SHADER): +b=="vertex"&&(d=c.createShader(c.VERTEX_SHADER));c.shaderSource(d,e);c.compileShader(d);if(!c.getShaderParameter(d,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(d)),console.error(e),null;return d}function na(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function H(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT; case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT; -case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var M=this,c,ua=[],ha=null,aa=null,ia=!0,B=null,O=null,F=null,N=null,ja=null,R=null,ra=null,va=0,Ea=0,sa=0,P=0,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var M=this,c,ua=[],ha=null,aa=null,ia=!0,B=null,O=null,F=null,N=null,ja=null,S=null,ra=null,va=0,Ea=0,sa=0,P=0,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ma=new THREE.Matrix4,Ga=new Float32Array(16),Ha=new Float32Array(16),Fa=new THREE.Vector4,Ka={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},wa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Ja=b.stencil!==void 0?b.stencil:!0,Oa=b.antialias!==void 0?b.antialias:!1,ta=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ia=b.clearAlpha!== void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=wa;this.sortObjects=this.autoClear=!0;try{if(!(c=wa.getContext("experimental-webgl",{antialias:Oa,stencil:Ja})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION))}catch(Pa){console.error(Pa)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST); c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(ta.r,ta.g,ta.b,Ia);this.context=c;var Na=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Ja){var w={};w.vertices=new Float32Array(12);w.faces=new Uint16Array(6);w.darkness=0.5;w.vertices[0]=-20;w.vertices[1]=-20;w.vertices[2]=-1;w.vertices[3]=20;w.vertices[4]=-20;w.vertices[5]=-1;w.vertices[6]=20;w.vertices[7]= -20;w.vertices[8]=-1;w.vertices[9]=-20;w.vertices[10]=20;w.vertices[11]=-1;w.faces[0]=0;w.faces[1]=1;w.faces[2]=2;w.faces[3]=0;w.faces[4]=2;w.faces[5]=3;w.vertexBuffer=c.createBuffer();w.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,w.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,w.faces,c.STATIC_DRAW);w.program=c.createProgram();c.attachShader(w.program,Q("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); -c.attachShader(w.program,Q("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(w.program);w.vertexLocation=c.getAttribLocation(w.program,"position");w.projectionLocation=c.getUniformLocation(w.program,"projectionMatrix");w.darknessLocation=c.getUniformLocation(w.program,"darkness")}var r={};r.vertices=new Float32Array(16);r.faces=new Uint16Array(6);b=0;r.vertices[b++]=-1;r.vertices[b++]=-1;r.vertices[b++]=0;r.vertices[b++]=0;r.vertices[b++]=1;r.vertices[b++]=-1;r.vertices[b++]=1;r.vertices[b++]= +20;w.vertices[8]=-1;w.vertices[9]=-20;w.vertices[10]=20;w.vertices[11]=-1;w.faces[0]=0;w.faces[1]=1;w.faces[2]=2;w.faces[3]=0;w.faces[4]=2;w.faces[5]=3;w.vertexBuffer=c.createBuffer();w.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,w.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,w.faces,c.STATIC_DRAW);w.program=c.createProgram();c.attachShader(w.program,R("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); +c.attachShader(w.program,R("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(w.program);w.vertexLocation=c.getAttribLocation(w.program,"position");w.projectionLocation=c.getUniformLocation(w.program,"projectionMatrix");w.darknessLocation=c.getUniformLocation(w.program,"darkness")}var r={};r.vertices=new Float32Array(16);r.faces=new Uint16Array(6);b=0;r.vertices[b++]=-1;r.vertices[b++]=-1;r.vertices[b++]=0;r.vertices[b++]=0;r.vertices[b++]=1;r.vertices[b++]=-1;r.vertices[b++]=1;r.vertices[b++]= 0;r.vertices[b++]=1;r.vertices[b++]=1;r.vertices[b++]=1;r.vertices[b++]=1;r.vertices[b++]=-1;r.vertices[b++]=1;r.vertices[b++]=0;r.vertices[b++]=1;b=0;r.faces[b++]=0;r.faces[b++]=1;r.faces[b++]=2;r.faces[b++]=0;r.faces[b++]=2;r.faces[b++]=3;r.vertexBuffer=c.createBuffer();r.elementBuffer=c.createBuffer();r.tempTexture=c.createTexture();r.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,r.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,r.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, r.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,r.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,r.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,r.occlusionTexture);c.texImage2D(c.TEXTURE_2D, -0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(r.hasVertexTexture=!1,r.program=c.createProgram(),c.attachShader(r.program,Q("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(r.program, -Q("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(r.hasVertexTexture=!0,r.program=c.createProgram(),c.attachShader(r.program,Q("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(r.program,Q("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(r.program);r.attributes={};r.uniforms={};r.attributes.vertex=c.getAttribLocation(r.program,"position");r.attributes.uv=c.getAttribLocation(r.program,"UV");r.uniforms.renderType=c.getUniformLocation(r.program, +0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(r.hasVertexTexture=!1,r.program=c.createProgram(),c.attachShader(r.program,R("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(r.program, +R("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(r.hasVertexTexture=!0,r.program=c.createProgram(),c.attachShader(r.program,R("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(r.program,R("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(r.program);r.attributes={};r.uniforms={};r.attributes.vertex=c.getAttribLocation(r.program,"position");r.attributes.uv=c.getAttribLocation(r.program,"UV");r.uniforms.renderType=c.getUniformLocation(r.program, "renderType");r.uniforms.map=c.getUniformLocation(r.program,"map");r.uniforms.occlusionMap=c.getUniformLocation(r.program,"occlusionMap");r.uniforms.opacity=c.getUniformLocation(r.program,"opacity");r.uniforms.scale=c.getUniformLocation(r.program,"scale");r.uniforms.rotation=c.getUniformLocation(r.program,"rotation");r.uniforms.screenPosition=c.getUniformLocation(r.program,"screenPosition");var Ma=!1,u={};u.vertices=new Float32Array(16);u.faces=new Uint16Array(6);b=0;u.vertices[b++]=-1;u.vertices[b++]= -1;u.vertices[b++]=0;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=-1;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=0;u.vertices[b++]=-1;u.vertices[b++]=1;u.vertices[b++]=0;b=u.vertices[b++]=0;u.faces[b++]=0;u.faces[b++]=1;u.faces[b++]=2;u.faces[b++]=0;u.faces[b++]=2;u.faces[b++]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,u.vertices,c.STATIC_DRAW); -c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);u.program=c.createProgram();c.attachShader(u.program,Q("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(u.program,Q("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(u.program);u.attributes={};u.uniforms={};u.attributes.position=c.getAttribLocation(u.program,"position");u.attributes.uv=c.getAttribLocation(u.program,"uv");u.uniforms.uvOffset=c.getUniformLocation(u.program, +c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);u.program=c.createProgram();c.attachShader(u.program,R("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(u.program,R("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(u.program);u.attributes={};u.uniforms={};u.attributes.position=c.getAttribLocation(u.program,"position");u.attributes.uv=c.getAttribLocation(u.program,"uv");u.uniforms.uvOffset=c.getUniformLocation(u.program, "uvOffset");u.uniforms.uvScale=c.getUniformLocation(u.program,"uvScale");u.uniforms.rotation=c.getUniformLocation(u.program,"rotation");u.uniforms.scale=c.getUniformLocation(u.program,"scale");u.uniforms.alignment=c.getUniformLocation(u.program,"alignment");u.uniforms.map=c.getUniformLocation(u.program,"map");u.uniforms.opacity=c.getUniformLocation(u.program,"opacity");u.uniforms.useScreenCoordinates=c.getUniformLocation(u.program,"useScreenCoordinates");u.uniforms.affectedByDistance=c.getUniformLocation(u.program, "affectedByDistance");u.uniforms.screenPosition=c.getUniformLocation(u.program,"screenPosition");u.uniforms.modelViewMatrix=c.getUniformLocation(u.program,"modelViewMatrix");u.uniforms.projectionMatrix=c.getUniformLocation(u.program,"projectionMatrix");var La=!1;this.setSize=function(b,c){wa.width=b;wa.height=c;this.setViewport(0,0,wa.width,wa.height)};this.setViewport=function(b,e,d,f){va=b;Ea=e;sa=d;P=f;c.viewport(va,Ea,sa,P)};this.setScissor=function(b,e,d,f){c.scissor(b,e,d,f)};this.enableScissorTest= function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){ia=b;c.depthMask(b)};this.setClearColorHex=function(b,e){ta.setHex(b);Ia=e;c.clearColor(ta.r,ta.g,ta.b,Ia)};this.setClearColor=function(b,e){ta.copy(b);Ia=e;c.clearColor(ta.r,ta.g,ta.b,Ia)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){w.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b, @@ -270,16 +271,16 @@ e,d,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THR b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,o,q;k=q=j=0;for(o=e.length;k=0&&c.enableVertexAttribArray(n.position);n.color>=0&&c.enableVertexAttribArray(n.color);n.normal>=0&&c.enableVertexAttribArray(n.normal);n.tangent>=0&&c.enableVertexAttribArray(n.tangent); b.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0&&(c.enableVertexAttribArray(n.skinVertexA),c.enableVertexAttribArray(n.skinVertexB),c.enableVertexAttribArray(n.skinIndex),c.enableVertexAttribArray(n.skinWeight));if(b.attributes)for(h in b.attributes)n[h]!==void 0&&n[h]>=0&&c.enableVertexAttribArray(n[h]);if(b.morphTargets){b.numSupportedMorphTargets=0;n.morphTarget0>=0&&(c.enableVertexAttribArray(n.morphTarget0),b.numSupportedMorphTargets++);n.morphTarget1>=0&&(c.enableVertexAttribArray(n.morphTarget1), b.numSupportedMorphTargets++);n.morphTarget2>=0&&(c.enableVertexAttribArray(n.morphTarget2),b.numSupportedMorphTargets++);n.morphTarget3>=0&&(c.enableVertexAttribArray(n.morphTarget3),b.numSupportedMorphTargets++);n.morphTarget4>=0&&(c.enableVertexAttribArray(n.morphTarget4),b.numSupportedMorphTargets++);n.morphTarget5>=0&&(c.enableVertexAttribArray(n.morphTarget5),b.numSupportedMorphTargets++);n.morphTarget6>=0&&(c.enableVertexAttribArray(n.morphTarget6),b.numSupportedMorphTargets++);n.morphTarget7>= -0&&(c.enableVertexAttribArray(n.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(h=this.maxMorphTargets;b