From 77341c86b1808967276281114249a59847648d50 Mon Sep 17 00:00:00 2001 From: alteredq Date: Wed, 27 Jul 2011 01:35:44 +0200 Subject: [PATCH] First attempt at shadow mapping (work-in-progress). --- build/Three.js | 695 +++++++++++++------------- build/custom/ThreeCanvas.js | 2 +- build/custom/ThreeDOM.js | 2 +- build/custom/ThreeExtras.js | 10 +- build/custom/ThreeSVG.js | 2 +- build/custom/ThreeWebGL.js | 417 ++++++++-------- src/core/Object3D.js | 5 +- src/extras/geometries/TextGeometry.js | 2 +- src/renderers/WebGLRenderer.js | 305 ++++++++++- src/renderers/WebGLShaders.js | 179 ++++++- utils/build.py | 2 + 11 files changed, 1035 insertions(+), 586 deletions(-) diff --git a/build/Three.js b/build/Three.js index e8bb32b3..32c2b206 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,6 +1,6 @@ // Three.js r42 - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){this.setHex(b)}; -THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;this.updateHex()},setHSV:function(b,c,e){var f,g,j,h,m,n;if(e==0)f=g=j=0;else switch(h=Math.floor(b*6),m=b*6-h,b=e*(1-c),n=e*(1-c*m),c=e*(1-c*(1-m)),h){case 1:f=n;g=e;j=b;break;case 2:f=b;g=e;j=c;break;case 3:f=b;g=n;j=e;break;case 4:f=c;g=b;j=e;break;case 5:f=e;g=b;j=n;break;case 6:case 0:f=e,g=c,j=b}this.setRGB(f, +THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;this.updateHex()},setHSV:function(b,c,e){var f,g,j,h,m,o;if(e==0)f=g=j=0;else switch(h=Math.floor(b*6),m=b*6-h,b=e*(1-c),o=e*(1-c*m),c=e*(1-c*(1-m)),h){case 1:f=o;g=e;j=b;break;case 2:f=b;g=e;j=c;break;case 3:f=b;g=o;j=e;break;case 4:f=c;g=b;j=e;break;case 5:f=e;g=b;j=o;break;case 6:case 0:f=e,g=c,j=b}this.setRGB(f, g,j)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,c){this.set(b||0,c||0)}; THREE.Vector2.prototype={set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this},divideScalar:function(b){b? (this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, @@ -14,71 +14,72 @@ THREE.Vector4.prototype={set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())}, setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={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,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> +g=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(g),h=c.dot(c),c=c.dot(g),g=1/(b*h-e*e),h=(h*f-e*c)*g,b=(b*c-e*f)*g;return h>0&&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,o,p,n,t,u,v,x=b.geometry, +y=x.vertices,w=[],f=0;for(g=x.faces.length;f0:t<0))if(n=n.dot((new THREE.Vector3).sub(h,u))/t,u=u.addSelf(v.multiplyScalar(n)), +j instanceof THREE.Face3)e(u,h,m,o)&&(j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},w.push(j));else if(j instanceof THREE.Face4&&(e(u,h,m,p)||e(u,m,o,p)))j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},w.push(j);return w}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,n,t){m=!1;c=h;e=j;f=n;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,n,t,u,v){m?(m=!1,c=hn?h>u?h:u:n>u?n:u,g=j>t?j>v?j:v:t>v?t:v):(c=hn?h>u?h>f?h:f:u>f?u:f:n>u?n>f?n: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=[]}; -THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,e,f,g,j,h,m,n,p,o,t,u,v,x,w){this.set(b||1,c||0,e||0,f||0,g||0,j||1,h||0,m||0,n||0,p||0,o||1,t||0,u||0,v||0,x||0,w||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -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, +THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,e,f,g,j,h,m,o,p,n,t,u,v,x,y){this.set(b||1,c||0,e||0,f||0,g||0,j||1,h||0,m||0,o||0,p||0,n||1,t||0,u||0,v||0,x||0,y||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,c,e,f,g,j,h,m,o,p,n,t,u,v,x,y){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=o;this.n32=p;this.n33=n;this.n34=t;this.n41=u;this.n42=v;this.n43=x;this.n44=y;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1, 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,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, +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,o=b.n23,p=b.n24,n=b.n31,t=b.n32,u=b.n33,v=b.n34,x=b.n41,y=b.n42,w=b.n43,z=b.n44,H=c.n11,A=c.n12,J=c.n13,G=c.n14,C=c.n21,P=c.n22, +F=c.n23,K=c.n24,I=c.n31,V=c.n32,E=c.n33,$=c.n34,Q=c.n41,S=c.n42,T=c.n43,k=c.n44;this.n11=e*H+f*C+g*I+j*Q;this.n12=e*A+f*P+g*V+j*S;this.n13=e*J+f*F+g*E+j*T;this.n14=e*G+f*K+g*$+j*k;this.n21=h*H+m*C+o*I+p*Q;this.n22=h*A+m*P+o*V+p*S;this.n23=h*J+m*F+o*E+p*T;this.n24=h*G+m*K+o*$+p*k;this.n31=n*H+t*C+u*I+v*Q;this.n32=n*A+t*P+u*V+v*S;this.n33=n*J+t*F+u*E+v*T;this.n34=n*G+t*K+u*$+v*k;this.n41=x*H+y*C+w*I+z*Q;this.n42=x*A+y*P+w*V+z*S;this.n43=x*J+y*F+w*E+z*T;this.n44=x*G+y*K+w*$+z*k;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= +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,o=this.n31,p=this.n32,n=this.n33,t=this.n34,u=this.n41,v=this.n42,x=this.n43,y=this.n44;return f*h*p*u-e*m*p*u-f*j*n*u+c*m*n*u+e*j*t*u-c*h*t*u-f*h*o*v+e*m*o*v+f*g*n*v-b*m*n*v-e*g*t*v+b*h*t*v+f*j*o*x-c*m*o*x-f*g*p*x+b*m*p*x+c*g*t*x-b*j*t*x-e*j*o*y+c*h*o*y+e*g*p*y-b*h*p*y-c*g*n*y+b*j*n*y},transpose:function(){var b;b=this.n21;this.n21= this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44= this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]= this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b, c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b, -c){var e=Math.cos(c),f=Math.sin(c),g=1-e,j=b.x,h=b.y,m=b.z,n=g*j,p=g*h;this.set(n*j+e,n*h-f*m,n*m+f*h,0,n*h+f*m,p*h+e,p*m-f*j,0,n*m-f*h,p*m+f*j,g*m*m+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31); -return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var e=b.x,f=b.y,g=b.z,j=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),m=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var n=h*m,p=h*g,o=f*m,t=f*g;this.n11=n+t*e;this.n12= -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=t+n*e;this.n33=j*h;break;case "ZXY":n=h*m;p=h*g;o=f*m;t=f*g;this.n11=n-t*e;this.n12=-j*g;this.n13=o+p*e;this.n21=p+o*e;this.n22=j*m;this.n23=t-n*e;this.n31=-j*f;this.n32=e;this.n33=j*h;break;case "ZYX":n=j*m;p=j*g;o=e*m;t=e*g;this.n11=h*m;this.n12=o*f-p;this.n13=n*f+t;this.n21=h*g;this.n22=t*f+n;this.n23=p*f-o;this.n31=-f;this.n32=e*h;this.n33=j*h;break;case "YZX":n=j*h;p=j*f;o=e*h;t=e*f;this.n11=h*m;this.n12=t-n*g;this.n13= -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=Math.cos(c),f=Math.sin(c),g=1-e,j=b.x,h=b.y,m=b.z,o=g*j,p=g*h;this.set(o*j+e,o*h-f*m,o*m+f*h,0,o*h+f*m,p*h+e,p*m-f*j,0,o*m-f*h,p*m+f*j,g*m*m+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31); +return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var e=b.x,f=b.y,g=b.z,j=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),m=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var o=h*m,p=h*g,n=f*m,t=f*g;this.n11=o+t*e;this.n12= +n*e-p;this.n13=j*f;this.n21=j*g;this.n22=j*m;this.n23=-e;this.n31=p*e-n;this.n32=t+o*e;this.n33=j*h;break;case "ZXY":o=h*m;p=h*g;n=f*m;t=f*g;this.n11=o-t*e;this.n12=-j*g;this.n13=n+p*e;this.n21=p+n*e;this.n22=j*m;this.n23=t-o*e;this.n31=-j*f;this.n32=e;this.n33=j*h;break;case "ZYX":o=j*m;p=j*g;n=e*m;t=e*g;this.n11=h*m;this.n12=n*f-p;this.n13=o*f+t;this.n21=h*g;this.n22=t*f+o;this.n23=p*f-n;this.n31=-f;this.n32=e*h;this.n33=j*h;break;case "YZX":o=j*h;p=j*f;n=e*h;t=e*f;this.n11=h*m;this.n12=t-o*g;this.n13= +n*g+p;this.n21=g;this.n22=j*m;this.n23=-e*m;this.n31=-f*m;this.n32=p*g+n;this.n33=o-t*g;break;case "XZY":o=j*h;p=j*f;n=e*h;t=e*f;this.n11=h*m;this.n12=-g;this.n13=f*m;this.n21=o*g+t;this.n22=j*m;this.n23=p*g-n;this.n31=n*g-p;this.n32=e*m;this.n33=t*g+o;break;default:o=j*m,p=j*g,n=e*m,t=e*g,this.n11=h*m,this.n12=-h*g,this.n13=f,this.n21=p+n*f,this.n22=o-t*f,this.n23=-e*h,this.n31=t-o*f,this.n32=n+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,o=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=o-g;this.n13=c+h;this.n21=o+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,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.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,o=b.n23,p=b.n24,n=b.n31,t=b.n32,u=b.n33,v=b.n34,x=b.n41,y=b.n42,w=b.n43,z=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=o*v*y-p*u*y+p*t*w-m*v*w-o*t*z+m*u*z;c.n12=j*u*y-g*v*y-j*t*w+f*v*w+g*t*z-f*u*z;c.n13=g*p*y-j*o*y+j*m*w-f*p*w-g*m*z+f*o*z;c.n14=j*o*t-g*p*t-j*m*u+f*p*u+g*m*v-f*o*v;c.n21=p*u*x-o*v*x-p*n*w+h*v*w+o*n*z-h*u*z;c.n22=g*v*x-j*u*x+j*n*w-e*v*w-g*n*z+e*u*z;c.n23=j*o*x-g*p*x-j*h*w+e*p*w+g*h*z-e*o*z;c.n24= +g*p*n-j*o*n+j*h*u-e*p*u-g*h*v+e*o*v;c.n31=m*v*x-p*t*x+p*n*y-h*v*y-m*n*z+h*t*z;c.n32=j*t*x-f*v*x-j*n*y+e*v*y+f*n*z-e*t*z;c.n33=g*p*x-j*m*x+j*h*y-e*p*y-f*h*z+e*m*z;c.n34=j*m*n-f*p*n-j*h*t+e*p*t+f*h*v-e*m*v;c.n41=o*t*x-m*u*x-o*n*y+h*u*y+m*n*w-h*t*w;c.n42=f*u*x-g*t*x+g*n*y-e*u*y-f*n*w+e*t*w;c.n43=g*m*x-f*o*x-g*h*y+e*o*y+f*h*w-e*m*w;c.n44=f*o*n-g*m*n+g*h*t-e*o*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,o=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,n=-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*o;e[6]=b*p;e[7]=b*n;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; +THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var h,m,o,p;h=new THREE.Matrix4;m=c-b;o=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/o;h.n23=0;h.n24=-((e+f)/o);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; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion; -this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""}; +this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)=== -1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var e,f,g;e=0;for(f=this.children.length;e=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*j)/h;f=Math.sin(f*j)/h;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,c,e,f,g,j){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,e,f,g,j,h){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; THREE.UV.prototype={set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var b,c,e;b=0;for(c=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?j:j+1;e[3]=j>this.points.length-3?j:j+2;p=this.points[e[0]];o=this.points[e[1]]; -t=this.points[e[2]];u=this.points[e[3]];m=h*h;n=h*m;f.x=c(p.x,o.x,t.x,u.x,h,m,n);f.y=c(p.y,o.y,t.y,u.y,h,m,n);f.z=c(p.z,o.z,t.z,u.z,h,m,n);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;bthis.points.length-2?j:j+1;e[3]=j>this.points.length-3?j:j+2;p=this.points[e[0]];n=this.points[e[1]]; +t=this.points[e[2]];u=this.points[e[3]];m=h*h;o=h*m;f.x=c(p.x,n.x,t.x,u.x,h,m,o);f.y=c(p.y,n.y,t.y,u.y,h,m,o);f.z=c(p.z,n.z,t.z,u.z,h,m,o);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, this.LODs[f].object3D.visible=!0;else break;for(;ft&&(e=o,o=t,t=e):ov&&(e=u,u=v,v=e):ut&&(e=n,n=t,t=e):nv&&(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&&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,$=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&&g>=0&&k>=0&&j>=0?!0:h<0&&g<0||k<0&&j<0?!1:(h<0?c=Math.max(c,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),k<0?c=Math.max(c,k/(k-j)):j<0&&(f=Math.min(f,k/(k-j))),fS&&h.positionScreen.z0&&G.z<1))ma=A[H]=A[H]||new THREE.RenderableParticle,H++,z=ma,z.x=G.x/G.w,z.y=G.y/G.w,z.z= +G.z,z.rotation=M.rotation.z,z.scale.x=M.scale.x*Math.abs(z.x-(G.x+g.projectionMatrix.n11)/(G.w+g.projectionMatrix.n14)),z.scale.y=M.scale.y*Math.abs(z.y-(G.y+g.projectionMatrix.n22)/(G.w+g.projectionMatrix.n24)),z.materials=M.materials,J.push(z);j&&J.sort(c);return J}}; +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 o,p,n,t,u,v,x,y;b=c.projectScene(e,f);o=0;for(p=b.length;o>1,da=p.height>>1,j=h.scale.x*u,o=h.scale.y*v,k=j*n,m=o*da,ra.set(b.x-k,b.y-m,b.x+k,b.y+m),Z.instersects(ra)&&(x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(j,-o),x.translate(-n,-da),x.drawImage(p,0,0),x.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,m=h.scale.y*v,ra.set(b.x-k,b.y-m,b.x+k,b.y+m),Z.instersects(ra)&&(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 y(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(C!=b)x.lineCap=C=b;b=j.linejoin;if(P!=b)x.lineJoin=P=b;f(j.color);x.stroke();ra.inflate(j.linewidth*2)}}function z(b,f,g,m,o,p,da,t,u){h.data.vertices+=3;h.data.faces++;c(t.opacity);e(t.blending);Q=b.positionScreen.x;S=b.positionScreen.y;T=f.positionScreen.x;k=f.positionScreen.y; +L=g.positionScreen.x;fa=g.positionScreen.y;A(Q,S,T,k,L,fa);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(ka=da.uvs[0],J(Q,S,T,k,L,fa,t.map.image,ka[m].u,ka[m].v,ka[o].u,ka[o].v,ka[p].u,ka[p].v));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=j.matrixWorldInverse,sa.copy(da.vertexNormalsWorld[0]),na=(sa.x*b.n11+sa.y*b.n12+sa.z*b.n13)*0.5+0.5,xa=-(sa.x*b.n21+sa.y*b.n22+sa.z*b.n23)*0.5+0.5,sa.copy(da.vertexNormalsWorld[1]), +Aa=(sa.x*b.n11+sa.y*b.n12+sa.z*b.n13)*0.5+0.5,Ha=-(sa.x*b.n21+sa.y*b.n22+sa.z*b.n23)*0.5+0.5,sa.copy(da.vertexNormalsWorld[2]),Ba=(sa.x*b.n11+sa.y*b.n12+sa.z*b.n13)*0.5+0.5,Pa=-(sa.x*b.n21+sa.y*b.n22+sa.z*b.n23)*0.5+0.5,J(Q,S,T,k,L,fa,t.envMap.image,na,xa,Aa,Ha,Ba,Pa)}else t.wireframe?Ia(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ja(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof THREE.UVMapping&&(ka=da.uvs[0],J(Q,S, +T,k,L,fa,t.map.image,ka[m].u,ka[m].v,ka[o].u,ka[o].v,ka[p].u,ka[p].v)),e(THREE.SubtractiveBlending)),ta?!t.wireframe&&t.shading==THREE.SmoothShading&&da.vertexNormalsWorld.length==3?(ma.r=aa.r=ca.r=wa.r,ma.g=aa.g=ca.g=wa.g,ma.b=aa.b=ca.b=wa.b,n(u,da.v1.positionWorld,da.vertexNormalsWorld[0],ma),n(u,da.v2.positionWorld,da.vertexNormalsWorld[1],aa),n(u,da.v3.positionWorld,da.vertexNormalsWorld[2],ca),ja.r=(aa.r+ca.r)*0.5,ja.g=(aa.g+ca.g)*0.5,ja.b=(aa.b+ca.b)*0.5,oa=Sa(ma,aa,ca,ja),J(Q,S,T,k,L,fa,oa, +0,0,1,0,0,1)):(va.r=wa.r,va.g=wa.g,va.b=wa.b,n(u,da.centroidWorld,da.normalWorld,va),M.r=Math.max(0,Math.min(t.color.r*va.r,1)),M.g=Math.max(0,Math.min(t.color.g*va.g,1)),M.b=Math.max(0,Math.min(t.color.b*va.b,1)),M.updateHex(),t.wireframe?Ia(M,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ja(M)):t.wireframe?Ia(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ja(t.color);else if(t instanceof THREE.MeshDepthMaterial)U=j.near,W=j.far,ma.r=ma.g=ma.b=1-Na(b.positionScreen.z, +U,W),aa.r=aa.g=aa.b=1-Na(f.positionScreen.z,U,W),ca.r=ca.g=ca.b=1-Na(g.positionScreen.z,U,W),ja.r=(aa.r+ca.r)*0.5,ja.g=(aa.g+ca.g)*0.5,ja.b=(aa.b+ca.b)*0.5,oa=Sa(ma,aa,ca,ja),J(Q,S,T,k,L,fa,oa,0,0,1,0,0,1);else if(t instanceof THREE.MeshNormalMaterial)M.r=Qa(da.normalWorld.x),M.g=Qa(da.normalWorld.y),M.b=Qa(da.normalWorld.z),M.updateHex(),t.wireframe?Ia(M,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ja(M)}function w(b,f,g,m,o,p,t,da,u){h.data.vertices+=4;h.data.faces++;c(da.opacity); +e(da.blending);if(da.map||da.envMap)z(b,f,m,0,1,3,t,da,u),z(o,g,p,1,2,3,t,da,u);else if(Q=b.positionScreen.x,S=b.positionScreen.y,T=f.positionScreen.x,k=f.positionScreen.y,L=g.positionScreen.x,fa=g.positionScreen.y,Y=m.positionScreen.x,ga=m.positionScreen.y,ea=o.positionScreen.x,ia=o.positionScreen.y,qa=p.positionScreen.x,ha=p.positionScreen.y,da instanceof THREE.MeshBasicMaterial)H(Q,S,T,k,L,fa,Y,ga),da.wireframe?Ia(da.color,da.wireframeLinewidth,da.wireframeLinecap,da.wireframeLinejoin):Ja(da.color); +else if(da instanceof THREE.MeshLambertMaterial)ta?!da.wireframe&&da.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(ma.r=aa.r=ca.r=ja.r=wa.r,ma.g=aa.g=ca.g=ja.g=wa.g,ma.b=aa.b=ca.b=ja.b=wa.b,n(u,t.v1.positionWorld,t.vertexNormalsWorld[0],ma),n(u,t.v2.positionWorld,t.vertexNormalsWorld[1],aa),n(u,t.v4.positionWorld,t.vertexNormalsWorld[3],ca),n(u,t.v3.positionWorld,t.vertexNormalsWorld[2],ja),oa=Sa(ma,aa,ca,ja),A(Q,S,T,k,Y,ga),J(Q,S,T,k,Y,ga,oa,0,0,1,0,0,1),A(ea,ia,L,fa,qa,ha),J(ea, +ia,L,fa,qa,ha,oa,1,0,1,1,0,1)):(va.r=wa.r,va.g=wa.g,va.b=wa.b,n(u,t.centroidWorld,t.normalWorld,va),M.r=Math.max(0,Math.min(da.color.r*va.r,1)),M.g=Math.max(0,Math.min(da.color.g*va.g,1)),M.b=Math.max(0,Math.min(da.color.b*va.b,1)),M.updateHex(),H(Q,S,T,k,L,fa,Y,ga),da.wireframe?Ia(M,da.wireframeLinewidth,da.wireframeLinecap,da.wireframeLinejoin):Ja(M)):(H(Q,S,T,k,L,fa,Y,ga),da.wireframe?Ia(da.color,da.wireframeLinewidth,da.wireframeLinecap,da.wireframeLinejoin):Ja(da.color));else if(da instanceof +THREE.MeshNormalMaterial)M.r=Qa(t.normalWorld.x),M.g=Qa(t.normalWorld.y),M.b=Qa(t.normalWorld.z),M.updateHex(),H(Q,S,T,k,L,fa,Y,ga),da.wireframe?Ia(M,da.wireframeLinewidth,da.wireframeLinecap,da.wireframeLinejoin):Ja(M);else if(da instanceof THREE.MeshDepthMaterial)U=j.near,W=j.far,ma.r=ma.g=ma.b=1-Na(b.positionScreen.z,U,W),aa.r=aa.g=aa.b=1-Na(f.positionScreen.z,U,W),ca.r=ca.g=ca.b=1-Na(m.positionScreen.z,U,W),ja.r=ja.g=ja.b=1-Na(g.positionScreen.z,U,W),oa=Sa(ma,aa,ca,ja),A(Q,S,T,k,Y,ga),J(Q,S,T, +k,Y,ga,oa,0,0,1,0,0,1),A(ea,ia,L,fa,qa,ha),J(ea,ia,L,fa,qa,ha,oa,1,0,1,1,0,1)}function A(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 H(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 Ia(b,e,c,h){if(G!=e)x.lineWidth=G=e;if(C!=c)x.lineCap=C=c;if(P!=h)x.lineJoin=P=h;f(b);x.stroke();ra.inflate(e*2)}function Ja(b){g(b);x.fill()}function J(b,e,c,f,h,g,j,k,m,o,p,da,t){var n, +u;n=j.width-1;u=j.height-1;k*=n;m*=u;o*=n;p*=u;da*=n;t*=u;c-=b;f-=e;h-=b;g-=e;o-=k;p-=m;da-=k;t-=m;n=o*t-da*p;if(!((n<0?-n:n)<1))u=1/n,n=(t*c-p*h)*u,p=(t*f-p*g)*u,c=(o*h-da*c)*u,f=(o*g-da*f)*u,b=b-n*k-c*m,e=e-p*k-f*m,x.save(),x.transform(n,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),o=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),da=~~(f.g*255),f=~~(f.b*255);ua[0]=h<0?0:h>255? +255:h;ua[1]=g<0?0:g>255?255:g;ua[2]=b<0?0:b>255?255:b;ua[4]=j<0?0:j>255?255:j;ua[5]=k<0?0:k>255?255:k;ua[6]=e<0?0:e>255?255:e;ua[8]=m<0?0:m>255?255:m;ua[9]=o<0?0:o>255?255:o;ua[10]=c<0?0:c>255?255:c;ua[12]=p<0?0:p>255?255:p;ua[13]=da<0?0:da>255?255:da;ua[14]=f<0?0:f>255?255:f;X.putImageData(R,0,0);za.drawImage(Ea,0,0);return N}function Na(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Qa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ka(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,Va,pa,Ca,La,Ra,Ua,D;this.autoClear?this.clear():x.setTransform(1,0,0,-1,u,v);h.data.vertices=0;h.data.faces=0;m=o.projectScene(b,j,this.sortElements);(ta=b.lights.length>0)&&p(b);Ta=0;for(Va=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,o,t){h.data.vertices+=3;h.data.faces++;Q=f(S++);Q.setAttribute("d", +"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");o instanceof THREE.MeshBasicMaterial?G.hex=o.color.hex:o instanceof THREE.MeshLambertMaterial?J?(C.r=P.r,C.g=P.g,C.b=P.b,b(t,m,C),G.r=Math.max(0,Math.min(o.color.r*C.r,1)),G.g=Math.max(0,Math.min(o.color.g*C.g,1)),G.b=Math.max(0,Math.min(o.color.b*C.b,1)),G.updateHex()):G.hex=o.color.hex:o instanceof THREE.MeshDepthMaterial?(I=1-o.__2near/(o.__farPlusNear- +m.z*o.__farMinusNear),G.setRGB(I,I,I)):o instanceof THREE.MeshNormalMaterial&&G.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));o.wireframe?Q.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):Q.setAttribute("style","fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+o.opacity);p.appendChild(Q)}function e(e,c,k,m, +o,t,n){h.data.vertices+=4;h.data.faces++;Q=f(S++);Q.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?J?(C.r=P.r,C.g=P.g,C.b=P.b,b(n,o,C),G.r=Math.max(0,Math.min(t.color.r*C.r,1)),G.g=Math.max(0,Math.min(t.color.g*C.g,1)),G.b=Math.max(0,Math.min(t.color.b* +C.b,1)),G.updateHex()):G.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(I=1-t.__2near/(t.__farPlusNear-o.z*t.__farMinusNear),G.setRGB(I,I,I)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(g(o.normalWorld.x),g(o.normalWorld.y),g(o.normalWorld.z));t.wireframe?Q.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):Q.setAttribute("style", +"fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+t.opacity);p.appendChild(Q)}function f(b){E[b]==null&&(E[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),k==0&&E[b].setAttribute("shape-rendering","crispEdges"));return E[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,o=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,t,u,v,x,y,w,z,H=new THREE.Rectangle,A=new THREE.Rectangle,J= +!1,G=new THREE.Color(16777215),C=new THREE.Color(16777215),P=new THREE.Color(0),F=new THREE.Color(0),K=new THREE.Color(0),I,V=new THREE.Vector3,E=[],$=[],Q,S,T,k=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":k=1;break;case "low":k=0}};this.setSize=function(b,e){n=b;t=e;u=n/2;v=t/2;p.setAttribute("viewBox",-u+" "+-v+" "+n+" "+t);p.setAttribute("width",n);p.setAttribute("height",t);H.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,n,C,G,I,M,E;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;m=o.projectScene(b,f,this.sortElements);T=S=0;if(J=b.lights.length>0){M=b.lights;P.setRGB(0,0,0);F.setRGB(0,0,0);K.setRGB(0,0,0);g=0;for(t=M.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"}; +default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap;\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord;\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif", +shadowmap_fragment:"#ifdef USE_SHADOWMAP\nvec3 shadowCoord = vShadowCoord.xyz / vShadowCoord.w;\nvec4 rgbaDepth = texture2D( shadowMap, shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) && ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) )\ngl_FragColor = gl_FragColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord;\nuniform mat4 shadowMatrix;\n#endif", +shadowmap_vertex:"#ifdef USE_SHADOWMAP\nvShadowCoord = shadowMatrix * objectMatrix * vec4( position, 1.0 );\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 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)): +fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;", +THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"), +vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex, +THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment, +THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex, +THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex, +THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;", +THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment, +THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex, +"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex, +THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;", +THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},depthRGBA:{uniforms:{},fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}", +vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}}; +THREE.WebGLRenderer=function(b){function c(b,e,c){var f,h,g,j=b.vertices,m=j.length,o=b.colors,t=o.length,p=b.__vertexArray,n=b.__colorArray,u=b.__sortArray,v=b.__dirtyVertices,x=b.__dirtyColors,z=b.__webglCustomAttributes,y,w;if(z)for(y in z)z[y].offset=0;if(c.sortParticles){ka.multiplySelf(c.matrixWorld);for(f=0;f=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,o=j.morphTargetInfluences;fp&&(n=u,p=o[n]);k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[n]);k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]=p;t[n]=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&& +h.__webglFaceCount,k.UNSIGNED_SHORT,0)),T.data.vertices+=h.__webglFaceCount,T.data.faces+=h.__webglFaceCount/3,T.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),T.data.drawCalls++):j instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,h.__webglParticleCount),T.data.drawCalls++):j instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,h.__webglVertexCount),T.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,o,p,n,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/W,v[0]=u*o,v[1]=u,k.uniform3fv(z.screenPosition,x),k.uniform2fv(z.scale,v),k.uniform1f(z.rotation,m.rotation),k.uniform1f(z.opacity,m.opacity),K(m.blending),V(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST); +k.depthMask(ga)}function H(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function A(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,X,m));ta&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglNormalBuffer),k.bufferData(k.ARRAY_BUFFER,Z,m));va&&ha.hasTangents&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglTangentBuffer),k.bufferData(k.ARRAY_BUFFER,Y,m));xa&&Q>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,fa,m));xa&&ga>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,$,m));sa&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER, +g.__webglFaceBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ia,m),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,la,m));O>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,na,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,ea,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;J(h)}else if(b instanceof THREE.Ribbon){f= +b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;z=b.vertices;g=b.colors;y=z.length;j=g.length;C=b.__vertexArray;m=b.__colorArray;H=b.__dirtyColors;if(b.__dirtyVertices){for(t=0;t=0;c--)b[c].object==e&&b.splice(c,1)}function P(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(n[m].counter+=1,t=n[m].hash+"_"+n[m].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]= +{faces:[],materials:k,vertices:0,numMorphTargets:o})),b.geometryGroups[t].faces.push(h),b.geometryGroups[t].vertices+=j}function F(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function K(b){if(b!=qa){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)}qa=b}}function I(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(k.texParameteri(b,k.TEXTURE_WRAP_S,S(e.wrapS)),k.texParameteri(b,k.TEXTURE_WRAP_T,S(e.wrapT)),k.texParameteri(b,k.TEXTURE_MAG_FILTER,S(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,S(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,Q(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,Q(e.minFilter)))}function V(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),I(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 E(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, +S(b.wrapS));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,S(b.wrapT));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,S(b.magFilter));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,S(b.minFilter));k.texImage2D(k.TEXTURE_2D,0,S(b.format),b.width,b.height,0,S(b.format),S(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; +null);k.bindFramebuffer(k.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=U,b=W);e!=Y&&(k.bindFramebuffer(k.FRAMEBUFFER,e),k.viewport(ca,ja,c,b),Y=e)}function $(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 Q(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST; +default:return k.LINEAR}}function S(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); -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;b +0;if(Pa){var X={};X.vertices=new Float32Array(12);X.faces=new Uint16Array(6);X.darkness=0.5;X.vertices[0]=-20;X.vertices[1]=-20;X.vertices[2]=-1;X.vertices[3]=20;X.vertices[4]=-20;X.vertices[5]=-1;X.vertices[6]=20;X.vertices[7]=20;X.vertices[8]=-1;X.vertices[9]=-20;X.vertices[10]=20;X.vertices[11]=-1;X.faces[0]=0;X.faces[1]=1;X.faces[2]=2;X.faces[3]=0;X.faces[4]=2;X.faces[5]=3;X.vertexBuffer=k.createBuffer();X.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,X.vertexBuffer);k.bufferData(k.ARRAY_BUFFER, +X.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,X.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,X.faces,k.STATIC_DRAW);X.program=k.createProgram();k.attachShader(X.program,$("fragment",THREE.ShaderLib.shadowPost.fragmentShader));k.attachShader(X.program,$("vertex",THREE.ShaderLib.shadowPost.vertexShader));k.linkProgram(X.program);X.vertexLocation=k.getAttribLocation(X.program,"position");X.projectionLocation=k.getUniformLocation(X.program,"projectionMatrix");X.darknessLocation= +k.getUniformLocation(X.program,"darkness")}var R={};R.vertices=new Float32Array(16);R.faces=new Uint16Array(6);Z=0;R.vertices[Z++]=-1;R.vertices[Z++]=-1;R.vertices[Z++]=0;R.vertices[Z++]=0;R.vertices[Z++]=1;R.vertices[Z++]=-1;R.vertices[Z++]=1;R.vertices[Z++]=0;R.vertices[Z++]=1;R.vertices[Z++]=1;R.vertices[Z++]=1;R.vertices[Z++]=1;R.vertices[Z++]=-1;R.vertices[Z++]=1;R.vertices[Z++]=0;R.vertices[Z++]=1;Z=0;R.faces[Z++]=0;R.faces[Z++]=1;R.faces[Z++]=2;R.faces[Z++]=0;R.faces[Z++]=2;R.faces[Z++]=3; +R.vertexBuffer=k.createBuffer();R.elementBuffer=k.createBuffer();R.tempTexture=k.createTexture();R.occlusionTexture=k.createTexture();k.bindBuffer(k.ARRAY_BUFFER,R.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,R.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,R.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,R.faces,k.STATIC_DRAW);k.bindTexture(k.TEXTURE_2D,R.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,R.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?(R.hasVertexTexture=!1,R.program=k.createProgram(),k.attachShader(R.program,$("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),k.attachShader(R.program,$("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(R.hasVertexTexture=!0,R.program=k.createProgram(),k.attachShader(R.program,$("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),k.attachShader(R.program,$("vertex", +THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));k.linkProgram(R.program);R.attributes={};R.uniforms={};R.attributes.vertex=k.getAttribLocation(R.program,"position");R.attributes.uv=k.getAttribLocation(R.program,"UV");R.uniforms.renderType=k.getUniformLocation(R.program,"renderType");R.uniforms.map=k.getUniformLocation(R.program,"map");R.uniforms.occlusionMap=k.getUniformLocation(R.program,"occlusionMap");R.uniforms.opacity=k.getUniformLocation(R.program,"opacity");R.uniforms.scale=k.getUniformLocation(R.program, +"scale");R.uniforms.rotation=k.getUniformLocation(R.program,"rotation");R.uniforms.screenPosition=k.getUniformLocation(R.program,"screenPosition");var ua=!1,N={};N.vertices=new Float32Array(16);N.faces=new Uint16Array(6);Z=0;N.vertices[Z++]=-1;N.vertices[Z++]=-1;N.vertices[Z++]=0;N.vertices[Z++]=1;N.vertices[Z++]=1;N.vertices[Z++]=-1;N.vertices[Z++]=1;N.vertices[Z++]=1;N.vertices[Z++]=1;N.vertices[Z++]=1;N.vertices[Z++]=1;N.vertices[Z++]=0;N.vertices[Z++]=-1;N.vertices[Z++]=1;N.vertices[Z++]=0;Z= +N.vertices[Z++]=0;N.faces[Z++]=0;N.faces[Z++]=1;N.faces[Z++]=2;N.faces[Z++]=0;N.faces[Z++]=2;N.faces[Z++]=3;N.vertexBuffer=k.createBuffer();N.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,N.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,N.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,N.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,N.faces,k.STATIC_DRAW);N.program=k.createProgram();k.attachShader(N.program,$("fragment",THREE.ShaderLib.sprite.fragmentShader));k.attachShader(N.program, +$("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(N.program);N.attributes={};N.uniforms={};N.attributes.position=k.getAttribLocation(N.program,"position");N.attributes.uv=k.getAttribLocation(N.program,"uv");N.uniforms.uvOffset=k.getUniformLocation(N.program,"uvOffset");N.uniforms.uvScale=k.getUniformLocation(N.program,"uvScale");N.uniforms.rotation=k.getUniformLocation(N.program,"rotation");N.uniforms.scale=k.getUniformLocation(N.program,"scale");N.uniforms.alignment=k.getUniformLocation(N.program, +"alignment");N.uniforms.map=k.getUniformLocation(N.program,"map");N.uniforms.opacity=k.getUniformLocation(N.program,"opacity");N.uniforms.useScreenCoordinates=k.getUniformLocation(N.program,"useScreenCoordinates");N.uniforms.affectedByDistance=k.getUniformLocation(N.program,"affectedByDistance");N.uniforms.screenPosition=k.getUniformLocation(N.program,"screenPosition");N.uniforms.modelViewMatrix=k.getUniformLocation(N.program,"modelViewMatrix");N.uniforms.projectionMatrix=k.getUniformLocation(N.program, +"projectionMatrix");var za=!1;this.setSize=function(b,e){Ba.width=b;Ba.height=e;this.setViewport(0,0,Ba.width,Ba.height)};this.setViewport=function(b,e,c,f){ca=b;ja=e;U=c;W=f;k.viewport(ca,ja,U,W)};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){ga=b;k.depthMask(b)};this.setClearColorHex=function(b,e){la.setHex(b);ra=e;k.clearColor(la.r,la.g,la.b,ra)};this.setClearColor= +function(b,e){la.copy(b);ra=e;k.clearColor(la.r,la.g,la.b,ra)};this.clear=function(){k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT|k.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){X.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,n,o;t=o=m=0;for(n=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);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++)};this.render=function(b,c,n,C){var A,U,G,F,W,J,I,L,M=b.lights,N=b.fog;this.shadowMapEnabled&&x(b,c);T.data.vertices=0;T.data.faces=0;T.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(xa);c.projectionMatrix.flattenToArray(na);ka.multiply(c.projectionMatrix,c.matrixWorldInverse);o(ka);this.initWebGLObjects(b);E(n); +(this.autoClear||C)&&this.clear();W=b.__webglObjects.length;for(C=0;C0||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?F(e.__webglLensFlares,c):c instanceof THREE.MarchingCubes&&F(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;e0||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(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(x*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?C(e.__webglLensFlares,c):c instanceof THREE.MarchingCubes&&C(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;e1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=h;c.v=j;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,j=b.vertices,h=g.vertices,m=b.faces,n=g.faces,p=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,t=h.length;o25&&(j=25);g=(j-1)*0.5;e=Array(j);for(c=f=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,g,j,h,m,o,p,n=this.data.JIT.hierarchy,t,u;this.currentTime+=b*this.timeScale;u=this.currentTime;t=this.currentTime%=this.data.length;p=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var v=0,x=this.hierarchy.length;v1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",v,h.index-1).pos,this.points[1]=g,this.points[2]=j,this.points[3]=this.getNextKeyWith("pos",v,m.index+1).pos,f=f*0.33+0.33,g=this.interpolateCatmullRom(this.points,f),e.x=g[0],e.y=g[1],e.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== -"rot")THREE.Quaternion.slerp(g,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&o[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=g*g;h=g*e;f[0]=this.interpolate(j[0],m[0],n[0],p[0],g,e,h);f[1]=this.interpolate(j[1],m[1],n[1],p[1],g,e,h);f[2]=this.interpolate(j[2],m[2],n[2],p[2],g,e,h);return f}; +"rot")THREE.Quaternion.slerp(g,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&n[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];o=b[e[2]];p=b[e[3]];e=g*g;h=g*e;f[0]=this.interpolate(j[0],m[0],o[0],p[0],g,e,h);f[1]=this.interpolate(j[1],m[1],o[1],p[1],g,e,h);f[2]=this.interpolate(j[2],m[2],o[2],p[2],g,e,h);return f}; THREE.Animation.prototype.interpolate=function(b,c,e,f,g,j,h){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*h+(-3*(c-e)-2*b-f)*j+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]}; THREE.FirstPersonCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed= @@ -388,14 +399,14 @@ this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown 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;g=0?f:f+g;f=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var m=h[1]-h[0];this.phi= TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h[0])/m)*m+h[0];f=this.horizontalAngleMap.srcRange;h=this.horizontalAngleMap.dstRange;m=h[1]-h[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h[0])/m)*m+h[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,e,c)};this.onMouseMove=function(b){this.mouseX= -b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),h=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),n=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,h);b.position.set(0,10,0);this.animation= +b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),h=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),o=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(o,h);b.position.set(0,10,0);this.animation= c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.apply(b,arguments)}}(this,this.onMouseMove), !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward= @@ -408,22 +419,22 @@ this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVec this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,o=0,t=0,u=0,v=0,x=0,w=window.innerWidth/2,y=window.innerHeight/2;this.update= -function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*v),this.rotateVertically(b*x));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||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(); +THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,m=new THREE.Matrix4,o=!1,p=1,n=0,t=0,u=0,v=0,x=0,y=window.innerWidth/2,w=window.innerHeight/2;this.update= +function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*v),this.rotateVertically(b*x));b=this.delta*this.movementSpeed;this.translateZ(b*(n>0||this.autoForward&&!(n<0)?1:n));this.translateX(b*t);this.translateY(b*u);o&&(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.y1?c.normalize():c.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(c.y);f.addSelf(this.up.clone().crossSelf(g).setLength(c.x));f.addSelf(g.setLength(c.z));return f}; -this.rotateCamera=function(){var b=Math.acos(j.dot(h)/j.length()/h.length());if(b){var e=(new THREE.Vector3).cross(j,h).normalize(),c=new THREE.Quaternion;b*=this.rotateSpeed;c.setFromAxisAngle(e,-b);c.multiplyVector3(g);c.multiplyVector3(this.up);c.multiplyVector3(h);this.staticMoving?j=h:(c.setFromAxisAngle(e,b*(this.dynamicDampingFactor-1)),c.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(n.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var b=o.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var e=g.clone().crossSelf(this.up).setLength(b.x);e.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(e);this.target.position.addSelf(e);this.staticMoving?p=o:p.addSelf(b.sub(o,p).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +this.rotateCamera=function(){var b=Math.acos(j.dot(h)/j.length()/h.length());if(b){var e=(new THREE.Vector3).cross(j,h).normalize(),c=new THREE.Quaternion;b*=this.rotateSpeed;c.setFromAxisAngle(e,-b);c.multiplyVector3(g);c.multiplyVector3(this.up);c.multiplyVector3(h);this.staticMoving?j=h:(c.setFromAxisAngle(e,b*(this.dynamicDampingFactor-1)),c.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(o.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?m=o:m.y+=(o.y-m.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var b=n.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var e=g.clone().crossSelf(this.up).setLength(b.x);e.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(e);this.target.position.addSelf(e);this.staticMoving?p=n:p.addSelf(b.sub(n,p).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), g.lengthSq()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.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 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.getPoints=function(b,c){var b=b||12,e=[],f,g,j,h,m,o,p,n,t,u,v,x,y;f=0;for(g=this.actions.length;f0?(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++)y=h/b,j=THREE.FontUtils.b2(y,v,t,m),y=THREE.FontUtils.b2(y,x,u,o), +e.push(new THREE.Vector2(j,y));break;case THREE.PathActions.BEZIER_CURVE_TO:m=j[4];o=j[5];t=j[0];u=j[1];p=j[2];n=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++)y=h/b,j=THREE.FontUtils.b3(y,v,t,p,m),y=THREE.FontUtils.b3(y,x,u,n,o),e.push(new THREE.Vector2(j,y));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[f-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];y=b*j[0].length;h=h.concat(j[0]);j=new THREE.SplineCurve(h); +for(h=1;h<=y;h++)e.push(j.getPointAt(h/y));break;case THREE.PathActions.ARC:h=this.actions[f-1].args;m=j[0];o=j[1];p=j[2];t=j[3];y=j[4];u=!!j[5];n=h[h.length-2];v=h[h.length-1];h.length==0&&(n=v=0);x=y-t;var w=b*2;for(h=1;h<=w;h++)y=h/w,u||(y=1-y),y=t+y*x,j=n+m+p*Math.cos(y),y=v+o+p*Math.sin(y),e.push(new THREE.Vector2(j,y))}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 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?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;var y=[p[h],e[m],e[g]];t=THREE.FontUtils.Triangulate.area(y);var w=[p[h],p[j],e[m]];u=THREE.FontUtils.Triangulate.area(w);v=m;n=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;y=[p[h],e[m],e[g]];y=THREE.FontUtils.Triangulate.area(y);w=[p[h],p[j],e[m]];w=THREE.FontUtils.Triangulate.area(w);t+u>y+w&&(m=v,h=n,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);n=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(n).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,o;for(j=0;j0){h(0,0,-n-(j||0));for(o=b;o0){h(0,0,n+ +(g||0));for(o=b+b/2;o<2*b;o++)m.faces.push(new THREE.Face4(2*b+1,(2*o-2*b+2)%b+b,(2*o-2*b+1)%b+b,(2*o-2*b)%b+b))}o=0;for(b=this.faces.length;o=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;A=0;){T=C;k=C-1;k<0&&(k=b.length-1);for(var e=0,e=0;e0;V--){y=V/n;$=m*y;E=o*(1-Math.sin((1-y)*Math.PI/2));C=0;for(P=G.length;C0||(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,y]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,g=Math.PI,j=Math.max(3,c||8),h=Math.max(2,e||6),c=[],e=0;e0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);p.push(n)}c.push(p)}for(var v,x,y,g=c.length,e=0;e0)for(f=0;f1&&(v= +this.vertices[h].position.clone(),x=this.vertices[o].position.clone(),y=this.vertices[p].position.clone(),v.normalize(),x.normalize(),y.normalize(),this.faces.push(new THREE.Face3(h,o,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([n,t,w]))}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,y=u.length,o=v.length,m=0;m0;){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;){if(z){if(z.equals(h[m])){z=null;continue}}else z=h[m];p=o*2+m;u=p-1;f(p,u,u+n,p+n);for(t=0;t0;){if(z){if(z.equals(h[m])){z=null;continue}}else z=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,y,C;j=[];for(h=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,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;o0&&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++}n&&m.push({shape:g,holes:f})}var u,v,x, +y,w,z;j=[];for(h=0;h=0?v-1:g.length-1;var t=u-1>=0?u-1:n.length-1,H=[];H.push(n[u]);H.push(g[v]);H.push(g[e]);x=this.Triangulate.area(H);var A=[];A.push(n[u]);A.push(n[t]);A.push(g[v]);w=this.Triangulate.area(A);y=v;z=u;v+=1;u+=-1;v<0&&(v+=g.length);v%=g.length;u<0&&(u+=n.length);u%=g.length;e=v- +1>=0?v-1:g.length-1;t=u-1>=0?u-1:n.length-1;H=[];H.push(n[u]);H.push(g[v]);H.push(g[e]);H=this.Triangulate.area(H);A=[];A.push(n[u]);A.push(n[t]);A.push(g[v]);A=this.Triangulate.area(A);x+w>H+A&&(v=y,u=z,v<0&&(v+=g.length),v%=g.length,u<0&&(u+=n.length),u%=g.length,e=v-1>=0?v-1:g.length-1,t=u-1>=0?u-1:n.length-1);x=g.slice(0,v);w=g.slice(v);y=n.slice(u);z=n.slice(0,u);j.push(n[u]);j.push(g[v]);j.push(g[e]);j.push(n[u]);j.push(n[t]);j.push(g[v]);g=x.concat(y).concat(z).concat(w)}o.shape=g}u=[];v=[]; +for(h=p=0;h=0;){if(n){if(n.equals(e[b])){n=null;o=this.Triangulate.area(f)>0;h.push(o);j.push(m.divideScalar(f.length));f=[];m=new THREE.Vector2;continue}}else n=e[b];m.addSelf(e[b]);f.push(e[b])}b=e.length;for(f=0;--b>=0;)o=e[b], +m=j[f],o=o.clone().subSelf(m),p=this.bevelSize/o.length(),h[f]?p+=1:p=1-p,p=o.multiplyScalar(p).addSelf(m),g.unshift(p),n?n.equals(e[b])&&(n=null,f++):n=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,o,p,n,t,u,v,x,y,w=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(w){if(w.o){c=w._cachedOutline||(w._cachedOutline=w.o.split(" "));o=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}o=p;g<=o&&(o=0);p=o+1;g<=p&&(p=0);n=p+1;g<=n&&(n=0);var u;a:{u=b;var v=o,x=p,y=n,w=g,z=h,H=void 0,A=void 0,J=void 0, +G=void 0,C=void 0,P=void 0,F=void 0,K=void 0,I=void 0,A=u[z[v]].x,J=u[z[v]].y,G=u[z[x]].x,C=u[z[x]].y,P=u[z[y]].x,F=u[z[y]].y;if(1.0E-10>(G-A)*(F-J)-(C-J)*(P-A))u=!1;else{for(H=0;H=0&&$>=0&&S>=0){u=!1;break a}}u= +!0}}if(u){j.push([b[h[o]],b[h[p]],b[h[n]]]);m.push([h[o],h[p],h[n]]);o=p;for(n=p+1;n>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+H);THREE.BinaryLoader.prototype.f3(C,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+H);k=g(b,e+G);p=g(b,e+U);e=g(b,e+V);THREE.BinaryLoader.prototype.f3n(C,I,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+Z);j=g(b,e+K);e=n(b,e+S);THREE.BinaryLoader.prototype.f4(C,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+Z);j=g(b,e+K);p=n(b, -e+S);o=g(b,e+k);t=g(b,e+W);u=g(b,e+O);e=g(b,e+ga);THREE.BinaryLoader.prototype.f4n(C,I,c,f,h,j,p,o,t,u,e)}function w(e){var c,f;c=g(b,e);f=g(b,e+fa);e=g(b,e+X);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],F[c*2],F[c*2+1],F[f*2],F[f*2+1],F[e*2],F[e*2+1])}function y(e){var c,f,h;c=g(b,e);f=g(b,e+ea);h=g(b,e+ha);e=g(b,e+ka);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],F[c*2],F[c*2+1],F[f*2],F[f*2+1],F[h*2],F[h*2+1],F[e*2],F[e*2+1])}var C=this,E=0,B,I=[],F=[],A,P,H,G,U,V,J,Z,K,S,k,W,O,ga, -fa,X,ea,ha,ka,pa,R,ia,aa,ma,ca;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,f,e);B={signature:b.substr(E,8),header_bytes:o(b,E+8),vertex_coordinate_bytes:o(b,E+9),normal_coordinate_bytes:o(b,E+10),uv_coordinate_bytes:o(b,E+11),vertex_index_bytes:o(b,E+12),normal_index_bytes:o(b,E+13),uv_index_bytes:o(b,E+14),material_index_bytes:o(b,E+15),nvertices:g(b,E+16),nnormals:g(b,E+16+4),nuvs:g(b,E+16+8),ntri_flat:g(b,E+16+12),ntri_smooth:g(b,E+16+16),ntri_flat_uv:g(b,E+16+20),ntri_smooth_uv:g(b, -E+16+24),nquad_flat:g(b,E+16+28),nquad_smooth:g(b,E+16+32),nquad_flat_uv:g(b,E+16+36),nquad_smooth_uv:g(b,E+16+40)};E+=B.header_bytes;A=B.vertex_index_bytes;P=B.vertex_index_bytes*2;H=B.vertex_index_bytes*3;G=B.vertex_index_bytes*3+B.material_index_bytes;U=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;V=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;J=B.vertex_index_bytes;Z=B.vertex_index_bytes*2;K=B.vertex_index_bytes*3;S=B.vertex_index_bytes*4;k=B.vertex_index_bytes* -4+B.material_index_bytes;W=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;O=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;ga=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;fa=B.uv_index_bytes;X=B.uv_index_bytes*2;ea=B.uv_index_bytes;ha=B.uv_index_bytes*2;ka=B.uv_index_bytes*3;e=B.vertex_index_bytes*3+B.material_index_bytes;ca=B.vertex_index_bytes*4+B.material_index_bytes;pa=B.ntri_flat*e;R=B.ntri_smooth*(e+B.normal_index_bytes*3);ia= -B.ntri_flat_uv*(e+B.uv_index_bytes*3);aa=B.ntri_smooth_uv*(e+B.normal_index_bytes*3+B.uv_index_bytes*3);ma=B.nquad_flat*ca;e=B.nquad_smooth*(ca+B.normal_index_bytes*4);ca=B.nquad_flat_uv*(ca+B.uv_index_bytes*4);E+=function(e){for(var f,g,j,k=B.vertex_coordinate_bytes*3,m=e+B.nvertices*k;e>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=n(b,e),f=n(b,e+1),h=n(b,e+2);return(n(b,e+3)<<24)+(h<<16)+(f<<8)+c}function o(b,e){var c=n(b,e);return(n(b,e+1)<<8)+c}function p(b,e){var c=n(b,e);return c>127?c-256:c}function n(b, +e){return b.charCodeAt(e)&255}function t(e){var c,f,h;c=g(b,e);f=g(b,e+C);h=g(b,e+P);e=o(b,e+F);THREE.BinaryLoader.prototype.f3(z,c,f,h,e)}function u(e){var c,f,h,j,k,n;c=g(b,e);f=g(b,e+C);h=g(b,e+P);j=o(b,e+F);k=g(b,e+K);n=g(b,e+I);e=g(b,e+V);THREE.BinaryLoader.prototype.f3n(z,J,c,f,h,j,k,n,e)}function v(e){var c,f,h,j;c=g(b,e);f=g(b,e+E);h=g(b,e+$);j=g(b,e+Q);e=o(b,e+S);THREE.BinaryLoader.prototype.f4(z,c,f,h,j,e)}function x(e){var c,f,h,j,n,p,t,u;c=g(b,e);f=g(b,e+E);h=g(b,e+$);j=g(b,e+Q);n=o(b, +e+S);p=g(b,e+T);t=g(b,e+k);u=g(b,e+L);e=g(b,e+fa);THREE.BinaryLoader.prototype.f4n(z,J,c,f,h,j,n,p,t,u,e)}function y(e){var c,f;c=g(b,e);f=g(b,e+Y);e=g(b,e+ga);THREE.BinaryLoader.prototype.uv3(z.faceVertexUvs[0],G[c*2],G[c*2+1],G[f*2],G[f*2+1],G[e*2],G[e*2+1])}function w(e){var c,f,h;c=g(b,e);f=g(b,e+ea);h=g(b,e+ia);e=g(b,e+qa);THREE.BinaryLoader.prototype.uv4(z.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 z=this,H=0,A,J=[],G=[],C,P,F,K,I,V,E,$,Q,S,T,k,L,fa, +Y,ga,ea,ia,qa,ha,M,ma,aa,ca,ja;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,f,e);A={signature:b.substr(H,8),header_bytes:n(b,H+8),vertex_coordinate_bytes:n(b,H+9),normal_coordinate_bytes:n(b,H+10),uv_coordinate_bytes:n(b,H+11),vertex_index_bytes:n(b,H+12),normal_index_bytes:n(b,H+13),uv_index_bytes:n(b,H+14),material_index_bytes:n(b,H+15),nvertices:g(b,H+16),nnormals:g(b,H+16+4),nuvs:g(b,H+16+8),ntri_flat:g(b,H+16+12),ntri_smooth:g(b,H+16+16),ntri_flat_uv:g(b,H+16+20),ntri_smooth_uv:g(b, +H+16+24),nquad_flat:g(b,H+16+28),nquad_smooth:g(b,H+16+32),nquad_flat_uv:g(b,H+16+36),nquad_smooth_uv:g(b,H+16+40)};H+=A.header_bytes;C=A.vertex_index_bytes;P=A.vertex_index_bytes*2;F=A.vertex_index_bytes*3;K=A.vertex_index_bytes*3+A.material_index_bytes;I=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;V=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;E=A.vertex_index_bytes;$=A.vertex_index_bytes*2;Q=A.vertex_index_bytes*3;S=A.vertex_index_bytes*4;T=A.vertex_index_bytes* +4+A.material_index_bytes;k=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;L=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;fa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;Y=A.uv_index_bytes;ga=A.uv_index_bytes*2;ea=A.uv_index_bytes;ia=A.uv_index_bytes*2;qa=A.uv_index_bytes*3;e=A.vertex_index_bytes*3+A.material_index_bytes;ja=A.vertex_index_bytes*4+A.material_index_bytes;ha=A.ntri_flat*e;M=A.ntri_smooth*(e+A.normal_index_bytes*3);ma= +A.ntri_flat_uv*(e+A.uv_index_bytes*3);aa=A.ntri_smooth_uv*(e+A.normal_index_bytes*3+A.uv_index_bytes*3);ca=A.nquad_flat*ja;e=A.nquad_smooth*(ja+A.normal_index_bytes*4);ja=A.nquad_flat_uv*(ja+A.uv_index_bytes*4);H+=function(e){for(var f,g,j,k=A.vertex_coordinate_bytes*3,m=e+A.nvertices*k;e1&&(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;G1&&(I=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(C,I);object.name=v;object.position.set(A[0],A[1],A[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=H.visible;L.scene.addObject(object);L.objects[v]=object;H.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),L.scene.collisions.colliders.push(b)); +if(H.castsShadow)b=new THREE.ShadowVolume(C),L.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},L.triggers[object.name]=b)}}else A=H.position,r=H.rotation,q=H.quaternion,s=H.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(A[0],A[1],A[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=H.visible!==void 0?H.visible:!1,L.scene.addObject(object),L.objects[v]=object,L.empties[v]=object,H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},L.triggers[object.name]=b)}function o(b){return function(c){L.geometries[b]=c;m();Q-=1;e.onLoadComplete();n()}}function p(b){return function(e){L.geometries[b]=e}}function n(){e.callbackProgress({totalModels:T,totalTextures:k,loadedModels:T-Q,loadedTextures:k-S},L);e.onLoadProgress();Q==0&&S==0&&c(L)}var t, +u,v,x,y,w,z,H,A,J,G,C,P,F,K,I,V,E,$,Q,S,T,k,L;E=b.data;K=new THREE.BinaryLoader;$=new THREE.JSONLoader;S=Q=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in E.objects)if(H=E.objects[v],H.meshCollider){b=!0;break}if(b)L.scene.collisions=new THREE.CollisionSystem;if(E.transform){b=E.transform.position;J=E.transform.rotation;var fa=E.transform.scale;b&&L.scene.position.set(b[0],b[1],b[2]);J&&L.scene.rotation.set(J[0], +J[1],J[2]);fa&&L.scene.scale.set(fa[0],fa[1],fa[2]);(b||J||fa)&&L.scene.updateMatrix()}b=function(){S-=1;n();e.onLoadComplete()};for(y in E.cameras){J=E.cameras[y];if(J.type=="perspective")P=new THREE.Camera(J.fov,J.aspect,J.near,J.far);else if(J.type=="ortho")P=new THREE.Camera,P.projectionMatrix=THREE.Matrix4.makeOrtho(J.left,J.right,J.top,J.bottom,J.near,J.far);A=J.position;J=J.target;P.position.set(A[0],A[1],A[2]);P.target.position.set(J[0],J[1],J[2]);L.cameras[y]=P}for(x in E.lights)y=E.lights[x], +P=y.color!==void 0?y.color:16777215,J=y.intensity!==void 0?y.intensity:1,y.type=="directional"?(A=y.direction,V=new THREE.DirectionalLight(P,J),V.position.set(A[0],A[1],A[2]),V.position.normalize()):y.type=="point"?(A=y.position,d=y.distance,V=new THREE.PointLight(P,J,d),V.position.set(A[0],A[1],A[2])):y.type=="ambient"&&(V=new THREE.AmbientLight(P)),L.scene.addLight(V),L.lights[x]=V;for(w in E.fogs)x=E.fogs[w],x.type=="linear"?F=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(F=new THREE.FogExp2(0, +x.density)),J=x.color,F.color.setRGB(J[0],J[1],J[2]),L.fogs[w]=F;if(L.cameras&&E.defaults.camera)L.currentCamera=L.cameras[E.defaults.camera];if(L.fogs&&E.defaults.fog)L.scene.fog=L.fogs[E.defaults.fog];J=E.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(J[0],J[1],J[2]);L.bgColorAlpha=E.defaults.bgalpha;for(t in E.geometries)if(w=E.geometries[t],w.type=="bin_mesh"||w.type=="ascii_mesh")Q+=1,e.onLoadStart();T=Q;for(t in E.geometries)w=E.geometries[t],w.type=="cube"?(C=new THREE.CubeGeometry(w.width, +w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),L.geometries[t]=C):w.type=="plane"?(C=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),L.geometries[t]=C):w.type=="sphere"?(C=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),L.geometries[t]=C):w.type=="cylinder"?(C=new THREE.CylinderGeometry(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset),L.geometries[t]=C):w.type=="torus"?(C=new THREE.TorusGeometry(w.radius, +w.tube,w.segmentsR,w.segmentsT),L.geometries[t]=C):w.type=="icosahedron"?(C=new THREE.IcosahedronGeometry(w.subdivisions),L.geometries[t]=C):w.type=="bin_mesh"?K.load({model:f(w.url,E.urlBaseType),callback:o(t)}):w.type=="ascii_mesh"?$.load({model:f(w.url,E.urlBaseType),callback:o(t)}):w.type=="embedded_mesh"&&(w=E.embeds[w.id])&&$.createModel(w,p(t),"");for(z in E.textures)if(t=E.textures[z],t.url instanceof Array){S+=t.url.length;for(K=0;K=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,y,C,E,B;t0&&(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;j=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&&(o=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(n-m);v<1&&(v=1);m=Math.floor(n+m);m>this.size-1&&(m=this.size- +1);for(var x,y,w,z,H,A;t0&&(this.field[w+x]+=z)}}};this.addPlaneX=function(b,c){var g,j,h,m,o,p=this.size,n=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;jn&&(x=n);for(j=0;j0){o=j*t;for(g=0;gsize&&(dist=size);for(h=0;h0){o=zd*h;for(j=0;jj?this.hits.push(g):this.hits.unshift(g),j=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,j=0;j=m*g))return Number.MAX_VALUE;h/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(h);m.addSelf(b.origin);Math.abs(j.x)> +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,j=0;j=m*g))return Number.MAX_VALUE;h/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(h);m.addSelf(b.origin);Math.abs(j.x)> Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=m.y-c.y,j=e.y-c.y,g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(j.y)>Math.abs(j.z)?(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=j*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=j*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return h}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; -THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,j=0,h=0,m=0,n=0,p=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,h=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, -p=!1,m=1);e.origin.zc.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;g>f&&(p=1,f=g);j>f&&(p=2,f=j);switch(p){case 0:m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* -f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,n)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,j=0,h=0,m=0,o=0,p=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,h=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, +p=!1,m=1);e.origin.zc.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,p=!1,o=1);if(p)return-1;p=0;g>f&&(p=1,f=g);j>f&&(p=2,f=j);switch(p){case 0:m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* +f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,o)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq=0)return Math.abs(f)-Math.sqrt(e);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,e=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,j=new THREE.Camera,h=new THREE.Matrix4,m=new THREE.Matrix4,n,p,o;g.useTarget=j.useTarget=!1;g.matrixAutoUpdate=j.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.Camera(53,1,1,1E4);v.position.z= +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,j=new THREE.Camera,h=new THREE.Matrix4,m=new THREE.Matrix4,o,p,n;g.useTarget=j.useTarget=!1;g.matrixAutoUpdate=j.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.Camera(53,1,1,1E4);v.position.z= 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},mapRight:{type:"t",value:1,texture:u}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); -var x=new THREE.Scene;x.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;u.width=b;u.height=f};this.render=function(b,e){e.update(null,!0);if(n!==e.aspect||p!==e.near||o!==e.fov){n=e.aspect;p=e.near;o=e.fov;var C=e.projectionMatrix.clone(),E=125/30*0.5,B=E*p/125,I=p*Math.tan(o*Math.PI/360),F;h.n14=E;m.n14=-E;E=-I*n+B;F=I*n+B;C.n11=2*p/(F-E);C.n13=(F+E)/(F-E);g.projectionMatrix=C.clone();E=-I*n-B;F=I*n-B;C.n11=2*p/(F-E); -C.n13=(F+E)/(F-E);j.projectionMatrix=C.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(m);g.update(null,!0);g.position.copy(e.position);g.near=p;g.far=e.far;f.call(c,b,g,t,!0);j.matrix=e.matrixWorld.clone().multiplySelf(h);j.update(null,!0);j.position.copy(e.position);j.near=p;j.far=e.far;f.call(c,b,j,u,!0);f.call(c,x,v)}}; +var x=new THREE.Scene;x.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;u.width=b;u.height=f};this.render=function(b,e){e.update(null,!0);if(o!==e.aspect||p!==e.near||n!==e.fov){o=e.aspect;p=e.near;n=e.fov;var z=e.projectionMatrix.clone(),H=125/30*0.5,A=H*p/125,J=p*Math.tan(n*Math.PI/360),G;h.n14=H;m.n14=-H;H=-J*o+A;G=J*o+A;z.n11=2*p/(G-H);z.n13=(G+H)/(G-H);g.projectionMatrix=z.clone();H=-J*o-A;G=J*o-A;z.n11=2*p/(G-H); +z.n13=(G+H)/(G-H);j.projectionMatrix=z.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(m);g.update(null,!0);g.position.copy(e.position);g.near=p;g.far=e.far;f.call(c,b,g,t,!0);j.matrix=e.matrixWorld.clone().multiplySelf(h);j.update(null,!0);j.position.copy(e.position);j.near=p;j.far=e.far;f.call(c,b,j,u,!0);f.call(c,x,v)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,j,h=new THREE.Camera,m=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);g=b/2;j=f};this.render=function(b,e){this.clear();h.fov=e.fov;h.aspect=0.5*e.aspect;h.near=e.near;h.far=e.far; h.updateProjectionMatrix();h.position.copy(e.position);h.target.position.copy(e.target.position);h.translateX(c.separation);m.projectionMatrix=h.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,j);f.call(c,b,h);this.setViewport(g,0,g,j);f.call(c,b,m,!1)}}; diff --git a/build/custom/ThreeCanvas.js b/build/custom/ThreeCanvas.js index 770fd429..b1d36c4e 100644 --- a/build/custom/ThreeCanvas.js +++ b/build/custom/ThreeCanvas.js @@ -44,7 +44,7 @@ THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a. THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var e;e=new THREE.Matrix4;e.n11=2*f/(b-a);e.n12=0;e.n13=(b+a)/(b-a);e.n14=0;e.n21=0;e.n22=2*f/(d-c);e.n23=(d+c)/(d-c);e.n24=0;e.n31=0;e.n32=0;e.n33=-(g+f)/(g-f);e.n34=-2*g*f/(g-f);e.n41=0;e.n42=0;e.n43=-1;e.n44=0;return e};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var e,h,i,l;e=new THREE.Matrix4;h=b-a;i=c-d;l=g-f;e.n11=2/h;e.n12=0;e.n13=0;e.n14=-((b+a)/h);e.n21=0;e.n22=2/i;e.n23=0;e.n24=-((c+d)/i);e.n31=0;e.n32=0;e.n33=-2/l;e.n34=-((g+f)/l);e.n41=0;e.n42=0;e.n43=0;e.n44=1;return e};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion; -this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""}; +this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)=== -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c=0?p-1:f.length-1;var n=o-1>=0?o-1:m.length-1,y=[];y.push(m[o]);y.push(f[p]);y.push(f[b]);w=this.Triangulate.area(y);var u=[];u.push(m[o]);u.push(m[n]);u.push(f[p]);v=this.Triangulate.area(u);t=p;x=o;p+=1;o+=-1;p<0&&(p+=f.length);p%=f.length;o<0&&(o+=m.length);o%=f.length;b=p- 1>=0?p-1:f.length-1;n=o-1>=0?o-1:m.length-1;y=[];y.push(m[o]);y.push(f[p]);y.push(f[b]);y=this.Triangulate.area(y);u=[];u.push(m[o]);u.push(m[n]);u.push(f[p]);u=this.Triangulate.area(u);w+v>y+u&&(p=t,o=x,p<0&&(p+=f.length),p%=f.length,o<0&&(o+=m.length),o%=f.length,b=p-1>=0?p-1:f.length-1,n=o-1>=0?o-1:m.length-1);w=f.slice(0,p);v=f.slice(p);t=m.slice(o);x=m.slice(0,o);h.push(m[o]);h.push(f[p]);h.push(f[b]);h.push(m[o]);h.push(m[n]);h.push(f[p]);f=w.concat(t).concat(x).concat(v)}k.shape=f}o=[];p=[]; for(e=l=0;e=0;){if(m){if(m.equals(b[a])){m=null;k=this.Triangulate.area(g)>0;e.push(k);h.push(j.divideScalar(g.length));g=[];j=new THREE.Vector2;continue}}else m=b[a];j.addSelf(b[a]);g.push(b[a])}a=b.length;for(g= -0;--a>=0;)k=b[a],j=h[g],k=k.clone().subSelf(j),l=this.bevelSize/k.length(),e[g]?l+=1:l=1-l,l=k.multiplyScalar(l).addSelf(j),f.unshift(l),m?m.equals(b[a])&&(m=null,g++):m=b[a];c.bevel=f;return c},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,g){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,g)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3* -(1-a)*a*a*c},b3p3:function(a,c){return a*a*a*c},b3:function(a,c,b,g,f){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,g)+this.b3p3(a,f)},extractGlyphPoints:function(a,c,b,g,f){var h=[],e,j,k,l,m,n,o,p,w,t,v=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(v){if(v.o){c=v._cachedOutline||(v._cachedOutline=v.o.split(" "));k=c.length;for(a=0;a=0;){if(m){if(m.equals(b[a])){m=null;k=this.Triangulate.area(g)>0;e.push(k);h.push(j.divideScalar(g.length));g=[];j=new THREE.Vector2;continue}}else m=b[a];j.addSelf(b[a]);g.push(b[a])}a=b.length;for(g=0;--a>=0;)k=b[a], +j=h[g],k=k.clone().subSelf(j),l=this.bevelSize/k.length(),e[g]?l+=1:l=1-l,l=k.multiplyScalar(l).addSelf(j),f.unshift(l),m?m.equals(b[a])&&(m=null,g++):m=b[a];c.bevel=f;return c},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,g){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,g)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*(1-a)*a*a*c},b3p3:function(a, +c){return a*a*a*c},b3:function(a,c,b,g,f){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,g)+this.b3p3(a,f)},extractGlyphPoints:function(a,c,b,g,f){var h=[],e,j,k,l,m,n,o,p,w,t,v=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(v){if(v.o){c=v._cachedOutline||(v._cachedOutline=v.o.split(" "));k=c.length;for(a=0;a0)for(l=0;l2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(g)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,w=l,t=m,v=f,x=e,y=void 0,u=void 0,z=void 0, B=void 0,A=void 0,E=void 0,G=void 0,H=void 0,L=void 0,u=o[x[p]].x,z=o[x[p]].y,B=o[x[w]].x,A=o[x[w]].y,E=o[x[t]].x,G=o[x[t]].y;if(1.0E-10>(B-u)*(G-z)-(A-z)*(E-u))o=!1;else{for(y=0;y=0&&K>=0&&I>=0){o=!1;break a}}o=!0}}if(o){h.push([a[e[k]], a[e[l]],a[e[m]]]);j.push([e[k],e[l],e[m]]);k=l;for(m=l+1;m>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)}; +THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;this.updateHex()},setHSV:function(b,d,e){var f,h,i,g,j,o;if(e==0)f=h=i=0;else switch(g=Math.floor(b*6),j=b*6-g,b=e*(1-d),o=e*(1-d*j),d=e*(1-d*(1-j)),g){case 1:f=o;h=e;i=b;break;case 2:f=b;h=e;i=d;break;case 3:f=b;h=o;i=e;break;case 4:f=d;h=b;i=e;break;case 5:f=e;h=b;i=o;break;case 6:case 0:f=e,h=d,i=b}this.setRGB(f, +h,i)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)}; THREE.Vector2.prototype={set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,d){this.x=b.x+d.x;this.y=b.y+d.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,d){this.x=b.x-d.x;this.y=b.y-d.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this},divideScalar:function(b){b? (this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x,b=this.y-b.y;return d*d+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)}; @@ -14,73 +14,74 @@ THREE.Vector4.prototype={set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;this.w b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())}, setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,d){this.x+=(b.x-this.x)*d;this.y+=(b.y-this.y)*d;this.z+=(b.z-this.z)*d;this.w+=(b.w-this.w)*d;return this}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var d,e,f=[];d=0;for(e=b.length;d0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=d(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=d(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,i,h,j,o,k,p,n,v,t,z=b.geometry, -D=z.vertices,E=[],f=0;for(g=z.faces.length;f0:n<0))if(p=p.dot((new THREE.Vector3).sub(h,v))/n,v=v.addSelf(t.multiplyScalar(p)), -i instanceof THREE.Face3)e(v,h,j,o)&&(i={distance:this.origin.distanceTo(v),point:v,face:i,object:b},E.push(i));else if(i instanceof THREE.Face4&&(e(v,h,j,k)||e(v,j,o,k)))i={distance:this.origin.distanceTo(v),point:v,face:i,object:b},E.push(i);return E}else return[]}}; -THREE.Rectangle=function(){function b(){i=f-d;h=g-e}var d,e,f,g,i,h,j=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return h};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,i,p,n){j=!1;d=h;e=i;f=p;g=n;b()};this.addPoint=function(h,i){j?(j=!1,d=h,e=i,f=h,g=i):(d=dh?f:h,g=g>i?g:i);b()};this.add3Points= -function(h,i,p,n,v,t){j?(j=!1,d=hp?h>v?h:v:p>v?p:v,g=i>n?i>t?i:t:n>t?n:t):(d=hp?h>v?h>f?h:f:v>f?v:f:p>v?p>f?p:f:v>f?v:f,g=i>n?i>t?i>g?i:g:t>g?t:g:n>t?n>g?n:g:t>g?t:g);b()};this.addRectangle=function(h){j?(j=!1,d=h.getLeft(),e=h.getTop(),f=h.getRight(),g=h.getBottom()):(d=dh.getRight()?f:h.getRight(),g=g> -h.getBottom()?g:h.getBottom());b()};this.inflate=function(h){d-=h;e-=h;f+=h;g+=h;b()};this.minSelf=function(h){d=d>h.getLeft()?d: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(){j=!0;g=f=e=d=0;b()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};THREE.Matrix4=function(b,d,e,f,g,i,h,j,o,k,p,n,v,t,z,D){this.set(b||1,d||0,e||0,f||0,g||0,i||1,h||0,j||0,o||0,k||0,p||1,n||0,v||0,t||0,z||0,D||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,d,e,f,g,i,h,j,o,k,p,n,v,t,z,D){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=g;this.n22=i;this.n23=h;this.n24=j;this.n31=o;this.n32=k;this.n33=p;this.n34=n;this.n41=v;this.n42=t;this.n43=z;this.n44=D;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var f=THREE.Matrix4.__v1, -g=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,d).normalize();if(i.length()===0)i.z=1;f.cross(e,i).normalize();f.length()===0&&(i.x+=1.0E-4,f.cross(e,i).normalize());g.cross(i,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=i.x;this.n21=f.y;this.n22=g.y;this.n23=i.y;this.n31=f.z;this.n32=g.z;this.n33=i.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,f=b.z,g=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*e+this.n23* -f+this.n24)*g;b.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*e+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,e=b.y,f=b.z;b.x=d*this.n11+e*this.n12+f*this.n13;b.y=d*this.n21+e*this.n22+f*this.n23;b.z=d*this.n31+e*this.n32+f*this.n33;b.normalize(); -return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,f=b.n12,g=b.n13,i=b.n14,h=b.n21,j=b.n22,o=b.n23,k=b.n24,p=b.n31,n=b.n32,v=b.n33,t=b.n34,z=b.n41,D=b.n42,E=b.n43,C=b.n44,oa=d.n11,pa=d.n12,T=d.n13,I=d.n14,y=d.n21,K=d.n22, -G=d.n23,ca=d.n24,$=d.n31,qa=d.n32,R=d.n33,na=d.n34,H=d.n41,M=d.n42,c=d.n43,ua=d.n44;this.n11=e*oa+f*y+g*$+i*H;this.n12=e*pa+f*K+g*qa+i*M;this.n13=e*T+f*G+g*R+i*c;this.n14=e*I+f*ca+g*na+i*ua;this.n21=h*oa+j*y+o*$+k*H;this.n22=h*pa+j*K+o*qa+k*M;this.n23=h*T+j*G+o*R+k*c;this.n24=h*I+j*ca+o*na+k*ua;this.n31=p*oa+n*y+v*$+t*H;this.n32=p*pa+n*K+v*qa+t*M;this.n33=p*T+n*G+v*R+t*c;this.n34=p*I+n*ca+v*na+t*ua;this.n41=z*oa+D*y+E*$+C*H;this.n42=z*pa+D*K+E*qa+C*M;this.n43=z*T+D*G+E*R+C*c;this.n44=z*I+D*ca+E*na+ -C*ua;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);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,d=this.n12,e=this.n13,f=this.n14,g=this.n21,i=this.n22,h=this.n23,j=this.n24,o=this.n31,k=this.n32,p=this.n33,n=this.n34,v=this.n41,t=this.n42,z=this.n43,D=this.n44;return f*h*k*v-e*j*k*v-f*i*p*v+d*j*p*v+e*i*n*v-d*h*n*v-f*h*o*t+e*j*o*t+f*g*p*t-b*j*p*t-e*g*n*t+b*h*n*t+f*i*o*z-d*j*o*z-f*g*k*z+b*j*k*z+d*g*n*z-b*i*n*z-e*i*o*D+d*h*o*D+e*g*k*D-b*h*k*D-d*g*p*D+b*i*p*D}, +h=b.clone().subSelf(d),b=f.dot(f),d=f.dot(e),f=f.dot(h),g=e.dot(e),e=e.dot(h),h=1/(b*g-d*d),g=(g*f-d*e)*h,b=(b*e-d*f)*h;return g>0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var f=d(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=d(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 h,i,g,j,o,k,m,q,p,u,C=b.geometry, +D=C.vertices,E=[],f=0;for(h=C.faces.length;f0:q<0))if(m=m.dot((new THREE.Vector3).sub(g,p))/q,p=p.addSelf(u.multiplyScalar(m)), +i instanceof THREE.Face3)e(p,g,j,o)&&(i={distance:this.origin.distanceTo(p),point:p,face:i,object:b},E.push(i));else if(i instanceof THREE.Face4&&(e(p,g,j,k)||e(p,j,o,k)))i={distance:this.origin.distanceTo(p),point:p,face:i,object:b},E.push(i);return E}else return[]}}; +THREE.Rectangle=function(){function b(){i=f-d;g=h-e}var d,e,f,h,i,g,j=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return g};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(g,i,m,q){j=!1;d=g;e=i;f=m;h=q;b()};this.addPoint=function(g,i){j?(j=!1,d=g,e=i,f=g,h=i):(d=dg?f:g,h=h>i?h:i);b()};this.add3Points= +function(g,i,m,q,p,u){j?(j=!1,d=gm?g>p?g:p:m>p?m:p,h=i>q?i>u?i:u:q>u?q:u):(d=gm?g>p?g>f?g:f:p>f?p:f:m>p?m>f?m:f:p>f?p:f,h=i>q?i>u?i>h?i:h:u>h?u:h:q>u?q>h?q:h:u>h?u:h);b()};this.addRectangle=function(g){j?(j=!1,d=g.getLeft(),e=g.getTop(),f=g.getRight(),h=g.getBottom()):(d=dg.getRight()?f:g.getRight(),h=h> +g.getBottom()?h:g.getBottom());b()};this.inflate=function(g){d-=g;e-=g;f+=g;h+=g;b()};this.minSelf=function(g){d=d>g.getLeft()?d:g.getLeft();e=e>g.getTop()?e:g.getTop();f=f=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){j=!0;h=f=e=d=0;b()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]}; +THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};THREE.Matrix4=function(b,d,e,f,h,i,g,j,o,k,m,q,p,u,C,D){this.set(b||1,d||0,e||0,f||0,h||0,i||1,g||0,j||0,o||0,k||0,m||1,q||0,p||0,u||0,C||0,D||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,d,e,f,h,i,g,j,o,k,m,q,p,u,C,D){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=g;this.n24=j;this.n31=o;this.n32=k;this.n33=m;this.n34=q;this.n41=p;this.n42=u;this.n43=C;this.n44=D;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var f=THREE.Matrix4.__v1, +h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,d).normalize();if(i.length()===0)i.z=1;f.cross(e,i).normalize();f.length()===0&&(i.x+=1.0E-4,f.cross(e,i).normalize());h.cross(i,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=i.x;this.n21=f.y;this.n22=h.y;this.n23=i.y;this.n31=f.z;this.n32=h.z;this.n33=i.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,f=b.z,h=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*h;b.y=(this.n21*d+this.n22*e+this.n23* +f+this.n24)*h;b.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var d=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*d+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*d+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*d+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*d+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var d=b.x,e=b.y,f=b.z;b.x=d*this.n11+e*this.n12+f*this.n13;b.y=d*this.n21+e*this.n22+f*this.n23;b.z=d*this.n31+e*this.n32+f*this.n33;b.normalize(); +return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,o=b.n23,k=b.n24,m=b.n31,q=b.n32,p=b.n33,u=b.n34,C=b.n41,D=b.n42,E=b.n43,A=b.n44,T=d.n11,sa=d.n12,ea=d.n13,F=d.n14,v=d.n21,O=d.n22, +G=d.n23,M=d.n24,P=d.n31,ra=d.n32,ja=d.n33,$=d.n34,ua=d.n41,N=d.n42,H=d.n43,c=d.n44;this.n11=e*T+f*v+h*P+i*ua;this.n12=e*sa+f*O+h*ra+i*N;this.n13=e*ea+f*G+h*ja+i*H;this.n14=e*F+f*M+h*$+i*c;this.n21=g*T+j*v+o*P+k*ua;this.n22=g*sa+j*O+o*ra+k*N;this.n23=g*ea+j*G+o*ja+k*H;this.n24=g*F+j*M+o*$+k*c;this.n31=m*T+q*v+p*P+u*ua;this.n32=m*sa+q*O+p*ra+u*N;this.n33=m*ea+q*G+p*ja+u*H;this.n34=m*F+q*M+p*$+u*c;this.n41=C*T+D*v+E*P+A*ua;this.n42=C*sa+D*O+E*ra+A*N;this.n43=C*ea+D*G+E*ja+A*H;this.n44=C*F+D*M+E*$+A* +c;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);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,d=this.n12,e=this.n13,f=this.n14,h=this.n21,i=this.n22,g=this.n23,j=this.n24,o=this.n31,k=this.n32,m=this.n33,q=this.n34,p=this.n41,u=this.n42,C=this.n43,D=this.n44;return f*g*k*p-e*j*k*p-f*i*m*p+d*j*m*p+e*i*q*p-d*g*q*p-f*g*o*u+e*j*o*u+f*h*m*u-b*j*m*u-e*h*q*u+b*g*q*u+f*i*o*C-d*j*o*C-f*h*k*C+b*j*k*C+d*h*q*C-b*i*q*C-e*i*o*D+d*g*o*D+e*h*k*D-b*g*k*D-d*h*m*D+b*i*m*D}, transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34; b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11; b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34; b[d+15]=this.n44;return b},setTranslation:function(b,d,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,0,1);return this},setScale:function(b,d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0, -0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var e=Math.cos(d),f=Math.sin(d),g=1-e,i=b.x,h=b.y,j=b.z,o=g*i,k=g*h;this.set(o*i+e,o*h-f*j,o*j+f*h,0,o*h+f*j,k*h+e,k*j-f*i,0,o*j-f*h,k*j+f*i,g*j*j+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,d){var e=b.x,f=b.y,g=b.z,i=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),j=Math.cos(g),g=Math.sin(g);switch(d){case "YXZ":var o= -h*j,k=h*g,p=f*j,n=f*g;this.n11=o+n*e;this.n12=p*e-k;this.n13=i*f;this.n21=i*g;this.n22=i*j;this.n23=-e;this.n31=k*e-p;this.n32=n+o*e;this.n33=i*h;break;case "ZXY":o=h*j;k=h*g;p=f*j;n=f*g;this.n11=o-n*e;this.n12=-i*g;this.n13=p+k*e;this.n21=k+p*e;this.n22=i*j;this.n23=n-o*e;this.n31=-i*f;this.n32=e;this.n33=i*h;break;case "ZYX":o=i*j;k=i*g;p=e*j;n=e*g;this.n11=h*j;this.n12=p*f-k;this.n13=o*f+n;this.n21=h*g;this.n22=n*f+o;this.n23=k*f-p;this.n31=-f;this.n32=e*h;this.n33=i*h;break;case "YZX":o=i*h;k= -i*f;p=e*h;n=e*f;this.n11=h*j;this.n12=n-o*g;this.n13=p*g+k;this.n21=g;this.n22=i*j;this.n23=-e*j;this.n31=-f*j;this.n32=k*g+p;this.n33=o-n*g;break;case "XZY":o=i*h;k=i*f;p=e*h;n=e*f;this.n11=h*j;this.n12=-g;this.n13=f*j;this.n21=o*g+n;this.n22=i*j;this.n23=k*g-p;this.n31=p*g-k;this.n32=e*j;this.n33=n*g+o;break;default:o=i*j,k=i*g,p=e*j,n=e*g,this.n11=h*j,this.n12=-h*g,this.n13=f,this.n21=k+p*f,this.n22=o-n*f,this.n23=-e*h,this.n31=n-o*f,this.n32=p+k*f,this.n33=i*h}return this},setRotationFromQuaternion:function(b){var d= -b.x,e=b.y,f=b.z,g=b.w,i=d+d,h=e+e,j=f+f,b=d*i,o=d*h;d*=j;var k=e*h;e*=j;f*=j;i*=g;h*=g;g*=j;this.n11=1-(k+f);this.n12=o-g;this.n13=d+h;this.n21=o+g;this.n22=1-(b+f);this.n23=e-i;this.n31=d-h;this.n32=e+i;this.n33=1-(b+k);return this},scale:function(b){var d=b.x,e=b.y,b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;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,d){var e=1/d.x,f=1/d.y,g=1/d.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,d){var e=b.n11,f=b.n12,g=b.n13,i=b.n14,h=b.n21,j=b.n22,o=b.n23,k=b.n24,p=b.n31,n=b.n32,v=b.n33,t=b.n34,z=b.n41,D=b.n42,E=b.n43,C=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=o*t*D-k*v*D+k*n*E-j*t*E-o*n*C+j*v*C;d.n12=i*v*D-g*t*D-i*n*E+f*t*E+g*n*C-f*v*C;d.n13=g*k*D-i*o*D+i*j*E-f*k*E-g*j*C+f*o*C;d.n14=i*o*n-g*k*n-i*j*v+f*k*v+g*j*t-f*o*t;d.n21=k*v*z-o*t*z-k*p*E+h*t*E+o*p*C-h*v*C;d.n22=g*t*z-i*v*z+i*p*E-e*t*E-g*p*C+e*v*C;d.n23=i*o*z-g*k*z-i*h*E+e*k*E+g*h*C-e*o*C;d.n24= -g*k*p-i*o*p+i*h*v-e*k*v-g*h*t+e*o*t;d.n31=j*t*z-k*n*z+k*p*D-h*t*D-j*p*C+h*n*C;d.n32=i*n*z-f*t*z-i*p*D+e*t*D+f*p*C-e*n*C;d.n33=g*k*z-i*j*z+i*h*D-e*k*D-f*h*C+e*j*C;d.n34=i*j*p-f*k*p-i*h*n+e*k*n+f*h*t-e*j*t;d.n41=o*n*z-j*v*z-o*p*D+h*v*D+j*p*E-h*n*E;d.n42=f*v*z-g*n*z+g*p*D-e*v*D-f*p*E+e*n*E;d.n43=g*j*z-f*o*z-g*h*D+e*o*D+f*h*E-e*j*E;d.n44=f*o*p-g*j*p+g*h*n-e*o*n-f*h*v+e*j*v;d.multiplyScalar(1/b.determinant());return d}; -THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,h=-b.n33*b.n12+b.n32*b.n13,j=b.n33*b.n11-b.n31*b.n13,o=-b.n32*b.n11+b.n31*b.n12,k=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,n=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*h+b.n31*k;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*i;e[3]=b*h;e[4]=b*j;e[5]=b*o;e[6]=b*k;e[7]=b*p;e[8]=b*n;return d}; -THREE.Matrix4.makeFrustum=function(b,d,e,f,g,i){var h;h=new THREE.Matrix4;h.n11=2*g/(d-b);h.n12=0;h.n13=(d+b)/(d-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=-(i+g)/(i-g);h.n34=-2*i*g/(i-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(b,d,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,e,f)}; -THREE.Matrix4.makeOrtho=function(b,d,e,f,g,i){var h,j,o,k;h=new THREE.Matrix4;j=d-b;o=e-f;k=i-g;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((d+b)/j);h.n21=0;h.n22=2/o;h.n23=0;h.n24=-((e+f)/o);h.n31=0;h.n32=0;h.n33=-2/k;h.n34=-((i+g)/k);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; +0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var e=Math.cos(d),f=Math.sin(d),h=1-e,i=b.x,g=b.y,j=b.z,o=h*i,k=h*g;this.set(o*i+e,o*g-f*j,o*j+f*g,0,o*g+f*j,k*g+e,k*j-f*i,0,o*j-f*g,k*j+f*i,h*j*j+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= +new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,d){var e=b.x,f=b.y,h=b.z,i=Math.cos(e),e=Math.sin(e),g=Math.cos(f),f=Math.sin(f),j=Math.cos(h),h=Math.sin(h);switch(d){case "YXZ":var o= +g*j,k=g*h,m=f*j,q=f*h;this.n11=o+q*e;this.n12=m*e-k;this.n13=i*f;this.n21=i*h;this.n22=i*j;this.n23=-e;this.n31=k*e-m;this.n32=q+o*e;this.n33=i*g;break;case "ZXY":o=g*j;k=g*h;m=f*j;q=f*h;this.n11=o-q*e;this.n12=-i*h;this.n13=m+k*e;this.n21=k+m*e;this.n22=i*j;this.n23=q-o*e;this.n31=-i*f;this.n32=e;this.n33=i*g;break;case "ZYX":o=i*j;k=i*h;m=e*j;q=e*h;this.n11=g*j;this.n12=m*f-k;this.n13=o*f+q;this.n21=g*h;this.n22=q*f+o;this.n23=k*f-m;this.n31=-f;this.n32=e*g;this.n33=i*g;break;case "YZX":o=i*g;k= +i*f;m=e*g;q=e*f;this.n11=g*j;this.n12=q-o*h;this.n13=m*h+k;this.n21=h;this.n22=i*j;this.n23=-e*j;this.n31=-f*j;this.n32=k*h+m;this.n33=o-q*h;break;case "XZY":o=i*g;k=i*f;m=e*g;q=e*f;this.n11=g*j;this.n12=-h;this.n13=f*j;this.n21=o*h+q;this.n22=i*j;this.n23=k*h-m;this.n31=m*h-k;this.n32=e*j;this.n33=q*h+o;break;default:o=i*j,k=i*h,m=e*j,q=e*h,this.n11=g*j,this.n12=-g*h,this.n13=f,this.n21=k+m*f,this.n22=o-q*f,this.n23=-e*g,this.n31=q-o*f,this.n32=m+k*f,this.n33=i*g}return this},setRotationFromQuaternion:function(b){var d= +b.x,e=b.y,f=b.z,h=b.w,i=d+d,g=e+e,j=f+f,b=d*i,o=d*g;d*=j;var k=e*g;e*=j;f*=j;i*=h;g*=h;h*=j;this.n11=1-(k+f);this.n12=o-h;this.n13=d+g;this.n21=o+h;this.n22=1-(b+f);this.n23=e-i;this.n31=d-g;this.n32=e+i;this.n33=1-(b+k);return this},scale:function(b){var d=b.x,e=b.y,b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;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,d){var e=1/d.x,f=1/d.y,h=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}}; +THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,o=b.n23,k=b.n24,m=b.n31,q=b.n32,p=b.n33,u=b.n34,C=b.n41,D=b.n42,E=b.n43,A=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=o*u*D-k*p*D+k*q*E-j*u*E-o*q*A+j*p*A;d.n12=i*p*D-h*u*D-i*q*E+f*u*E+h*q*A-f*p*A;d.n13=h*k*D-i*o*D+i*j*E-f*k*E-h*j*A+f*o*A;d.n14=i*o*q-h*k*q-i*j*p+f*k*p+h*j*u-f*o*u;d.n21=k*p*C-o*u*C-k*m*E+g*u*E+o*m*A-g*p*A;d.n22=h*u*C-i*p*C+i*m*E-e*u*E-h*m*A+e*p*A;d.n23=i*o*C-h*k*C-i*g*E+e*k*E+h*g*A-e*o*A;d.n24= +h*k*m-i*o*m+i*g*p-e*k*p-h*g*u+e*o*u;d.n31=j*u*C-k*q*C+k*m*D-g*u*D-j*m*A+g*q*A;d.n32=i*q*C-f*u*C-i*m*D+e*u*D+f*m*A-e*q*A;d.n33=h*k*C-i*j*C+i*g*D-e*k*D-f*g*A+e*j*A;d.n34=i*j*m-f*k*m-i*g*q+e*k*q+f*g*u-e*j*u;d.n41=o*q*C-j*p*C-o*m*D+g*p*D+j*m*E-g*q*E;d.n42=f*p*C-h*q*C+h*m*D-e*p*D-f*m*E+e*q*E;d.n43=h*j*C-f*o*C-h*g*D+e*o*D+f*g*E-e*j*E;d.n44=f*o*m-h*j*m+h*g*q-e*o*q-f*g*p+e*j*p;d.multiplyScalar(1/b.determinant());return d}; +THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,g=-b.n33*b.n12+b.n32*b.n13,j=b.n33*b.n11-b.n31*b.n13,o=-b.n32*b.n11+b.n31*b.n12,k=b.n23*b.n12-b.n22*b.n13,m=-b.n23*b.n11+b.n21*b.n13,q=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*g+b.n31*k;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*i;e[3]=b*g;e[4]=b*j;e[5]=b*o;e[6]=b*k;e[7]=b*m;e[8]=b*q;return d}; +THREE.Matrix4.makeFrustum=function(b,d,e,f,h,i){var g;g=new THREE.Matrix4;g.n11=2*h/(d-b);g.n12=0;g.n13=(d+b)/(d-b);g.n14=0;g.n21=0;g.n22=2*h/(f-e);g.n23=(f+e)/(f-e);g.n24=0;g.n31=0;g.n32=0;g.n33=-(i+h)/(i-h);g.n34=-2*i*h/(i-h);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(b,d,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*d,b*d,h,b,e,f)}; +THREE.Matrix4.makeOrtho=function(b,d,e,f,h,i){var g,j,o,k;g=new THREE.Matrix4;j=d-b;o=e-f;k=i-h;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((d+b)/j);g.n21=0;g.n22=2/o;g.n23=0;g.n24=-((e+f)/o);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((i+h)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion; -this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""}; +this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)=== --1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d.parent!==void 0;)d=d.parent;d!==void 0&&d instanceof THREE.Scene&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1)b.parent=void 0,this.children.splice(d,1)},getChildByName:function(b,d){var e,f,g;e=0;for(f=this.children.length;e=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.0010)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;g=Math.sin((1-f)*i)/h;f=Math.sin(f*i)/h;e.w=b.w*g+d.w*f;e.x=b.x*g+d.x*f;e.y=b.y*g+d.y*f;e.z=b.z*g+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; -THREE.Face3=function(b,d,e,f,g,i){this.a=b;this.b=d;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3}; -THREE.Face4=function(b,d,e,f,g,i,h){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; +multiplySelf:function(b){var d=this.x,e=this.y,f=this.z,h=this.w,i=b.x,g=b.y,j=b.z,b=b.w;this.x=d*b+h*i+e*j-f*g;this.y=e*b+h*g+f*i-d*j;this.z=f*b+h*j+d*g-e*i;this.w=h*b-d*i-e*g-f*j;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,f=b.y,h=b.z,i=this.x,g=this.y,j=this.z,o=this.w,k=o*e+g*h-j*f,m= +o*f+j*e-i*h,q=o*h+i*f-g*e,e=-i*e-g*f-j*h;d.x=k*o+e*-i+m*-j-q*-g;d.y=m*o+e*-g+q*-i-k*-j;d.z=q*o+e*-j+k*-g-m*-i;return d}}; +THREE.Quaternion.slerp=function(b,d,e,f){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.0010)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;h=Math.sin((1-f)*i)/g;f=Math.sin(f*i)/g;e.w=b.w*h+d.w*f;e.x=b.x*h+d.x*f;e.y=b.y*h+d.y*f;e.z=b.z*h+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Face3=function(b,d,e,f,h,i){this.a=b;this.b=d;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,d,e,f,h,i,g){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var b,d,e;b=0;for(d=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var 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;dthis.points.length-2?i:i+1;e[3]=i>this.points.length-3?i:i+2;k=this.points[e[0]];p=this.points[e[1]]; -n=this.points[e[2]];v=this.points[e[3]];j=h*h;o=h*j;f.x=d(k.x,p.x,n.x,v.x,h,j,o);f.y=d(k.y,p.y,n.y,v.y,h,j,o);f.z=d(k.z,p.z,n.z,v.z,h,j,o);return f};this.getControlPointsArray=function(){var b,d,e=this.points.length,f=[];for(b=0;bthis.points.length-2?i:i+1;e[3]=i>this.points.length-3?i:i+2;k=this.points[e[0]];m=this.points[e[1]]; +q=this.points[e[2]];p=this.points[e[3]];j=g*g;o=g*j;f.x=d(k.x,m.x,q.x,p.x,g,j,o);f.y=d(k.y,m.y,q.y,p.y,g,j,o);f.z=d(k.z,m.z,q.z,p.z,g,j,o);return f};this.getControlPointsArray=function(){var b,d,e=this.points.length,f=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, this.LODs[f].object3D.visible=!0;else break;for(;fn&&(e=p,p=n,n=e):pt&&(e=v,v=t,t=e):vq&&(e=m,m=q,q=e):mu&&(e=p,p=u,u=e):p=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.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=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.Projector=function(){function b(){var b=o[j]=o[j]||new THREE.RenderableVertex;j++;return b}function d(b,d){return d.z-b.z}function e(b,d){var e=0,f=1,h=b.z+b.w,g=d.z+d.w,c=-b.z+b.w,i=-d.z+d.w;return h>=0&&g>=0&&c>=0&&i>=0?!0:h<0&&g<0||c<0&&i<0?!1:(h<0?e=Math.max(e,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),c<0?e=Math.max(e,c/(c-i)):i<0&&(f=Math.min(f,c/(c-i))),fN&&g.positionScreen.z0&&F.z<1))ta=sa[T]=sa[T]||new THREE.RenderableParticle,T++,A=ta,A.x=F.x/F.w,A.y=F.y/F.w,A.z=F.z,A.rotation=R.rotation.z,A.scale.x=R.scale.x*Math.abs(A.x- +(F.x+h.projectionMatrix.n11)/(F.w+h.projectionMatrix.n14)),A.scale.y=R.scale.y*Math.abs(A.y-(F.y+h.projectionMatrix.n22)/(F.w+h.projectionMatrix.n24)),A.materials=R.materials,ea.push(A);i&&ea.sort(d);return ea}}; 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,145 +157,155 @@ 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.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) )\ngl_FragColor = gl_FragColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord;\nuniform mat4 shadowMatrix;\n#endif", +shadowmap_vertex:"#ifdef USE_SHADOWMAP\nvShadowCoord = shadowMatrix * objectMatrix * vec4( position, 1.0 );\n#endif"}; +THREE.UniformsUtils={merge:function(b){var d,e,f,h={};for(d=0;d=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;n=0)c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else if(i.morphTargetBase){d=h.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[i.morphTargetBase]),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__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;fm&&(s=L,m=o[s]);c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[s]);c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]=m;k[s]=1;m=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&c.uniform1fv(h.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(j in g.__webglCustomAttributes)b[j]>=0&&(d=g.__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,g.__webglColorBuffer),c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,!1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)): +c.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB, +4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(h.wireframe?(c.lineWidth(h.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.drawElements(c.LINES,g.__webglLineCount,c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.drawElements(c.TRIANGLES, +g.__webglFaceCount,c.UNSIGNED_SHORT,0)),H.data.vertices+=g.__webglFaceCount,H.data.faces+=g.__webglFaceCount/3,H.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(h.linewidth),c.drawArrays(i,0,g.__webglLineCount),H.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,g.__webglParticleCount),H.data.drawCalls++):i instanceof THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,g.__webglVertexCount),H.data.drawCalls++)}}function h(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,g,h,i,j,k,o,s,m,p,q=b.count*3;for(p= +0;p0&&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,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,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,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,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, -e,d,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms); -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;b0&&v[0]0&&v[1]0.0010&&j.scale>0.0010)u[0]=j.x,u[1]=j.y,u[2]=j.z,p=j.size*j.scale/pa,q[0]=p*o,q[1]=p,c.uniform3fv(y.screenPosition,u),c.uniform2fv(y.scale,q),c.uniform1f(y.rotation,j.rotation),c.uniform1f(y.opacity,j.opacity),M(j.blending),ra(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT, +0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(I)}function T(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function sa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b0&&(c.bindBuffer(c.ARRAY_BUFFER, +h.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ia,j));oa&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,P,j));pa&&na.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,V,j));ga&&Q>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));ga&&R>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,aa,j));ma&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER, +O,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,S,j));z>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j));i.dynamic||(delete h.__inittedArrays, +delete h.__colorArray,delete h.__normalArray,delete h.__tangentArray,delete h.__uvArray,delete h.__uv2Array,delete h.__faceArray,delete h.__vertexArray,delete h.__lineArray,delete h.__skinVertexAArray,delete h.__skinVertexBArray,delete h.__skinIndexArray,delete h.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;ea(g)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices|| +f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;v=b.vertices;h=b.colors;y=v.length;i=h.length;A=b.__vertexArray;j=b.__colorArray;C=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k=0;d--)b[d].object==c&&b.splice(d,1)}function O(b){function c(b){var f=[];d=0;for(e=b.length;d65535&&(s[j].counter+=1,k=s[j].hash+"_"+s[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+=g}function G(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(b){if(b!=ca){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)}ca=b}}function P(b,d,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,N(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,N(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,N(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,N(d.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,ua(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,ua(d.minFilter)))}function ra(b,d){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),P(c.TEXTURE_2D,b,b.image),c.bindTexture(c.TEXTURE_2D,null),b.needsUpdate=!1;c.activeTexture(c.TEXTURE0+ +d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function ja(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,N(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,N(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER, +N(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,N(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,N(b.format),b.width,b.height,0,N(b.format),N(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 d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null, +e=ka,b=pa);d!=oa&&(c.bindFramebuffer(c.FRAMEBUFFER,d),c.viewport(Ga,Ha,e,b),oa=d)}function $(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER):b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function ua(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST; +default:return c.LINEAR}}function N(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 H=this,c,ga=[],Q=null,oa=null,I=!0,aa=null,J=null,ca=null,S=null,R=null,ta=null,Fa=null,Ga=0,Ha=0,ka=0,pa=0,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],va=new THREE.Matrix4,Ja=new Float32Array(16),Ka=new Float32Array(16),Ia=new THREE.Vector4,Ra={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"), +Pa=b.stencil!==void 0?b.stencil:!0,x=b.antialias!==void 0?b.antialias:!1,qa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),La=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;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=null;this.shadowMapEnabled= +!1;var ma,Ma=new THREE.Matrix4,b=THREE.ShaderLib.depthRGBA,Va=THREE.UniformsUtils.clone(b.uniforms),Na=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va}),Sa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va,morphTargets:!0});Na._shadowPass=!0;Sa._shadowPass=!0;try{if(!(c=wa.getContext("experimental-webgl",{antialias:x,stencil:Pa})))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(Xa){console.error(Xa)}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(qa.r,qa.g,qa.b,La);this.context=c;var Wa=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> +0;if(Pa){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,$("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(w.program,$("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);x=0;r.vertices[x++]=-1;r.vertices[x++]=-1;r.vertices[x++]=0;r.vertices[x++]=0;r.vertices[x++]=1;r.vertices[x++]=-1;r.vertices[x++]=1;r.vertices[x++]=0;r.vertices[x++]=1;r.vertices[x++]=1;r.vertices[x++]=1;r.vertices[x++]=1;r.vertices[x++]=-1;r.vertices[x++]=1;r.vertices[x++]=0;r.vertices[x++]=1;x=0;r.faces[x++]=0;r.faces[x++]=1;r.faces[x++]=2;r.faces[x++]=0;r.faces[x++]=2;r.faces[x++]=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,$("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(r.program,$("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(r.hasVertexTexture=!0,r.program=c.createProgram(),c.attachShader(r.program,$("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(r.program,$("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 Ua=!1,y={};y.vertices=new Float32Array(16);y.faces=new Uint16Array(6);x=0;y.vertices[x++]=-1;y.vertices[x++]=-1;y.vertices[x++]=0;y.vertices[x++]=1;y.vertices[x++]=1;y.vertices[x++]=-1;y.vertices[x++]=1;y.vertices[x++]=1;y.vertices[x++]=1;y.vertices[x++]=1;y.vertices[x++]=1;y.vertices[x++]=0;y.vertices[x++]=-1;y.vertices[x++]=1;y.vertices[x++]=0;x= +y.vertices[x++]=0;y.faces[x++]=0;y.faces[x++]=1;y.faces[x++]=2;y.faces[x++]=0;y.faces[x++]=2;y.faces[x++]=3;y.vertexBuffer=c.createBuffer();y.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,y.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,y.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,y.faces,c.STATIC_DRAW);y.program=c.createProgram();c.attachShader(y.program,$("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(y.program, +$("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(y.program);y.attributes={};y.uniforms={};y.attributes.position=c.getAttribLocation(y.program,"position");y.attributes.uv=c.getAttribLocation(y.program,"uv");y.uniforms.uvOffset=c.getUniformLocation(y.program,"uvOffset");y.uniforms.uvScale=c.getUniformLocation(y.program,"uvScale");y.uniforms.rotation=c.getUniformLocation(y.program,"rotation");y.uniforms.scale=c.getUniformLocation(y.program,"scale");y.uniforms.alignment=c.getUniformLocation(y.program, +"alignment");y.uniforms.map=c.getUniformLocation(y.program,"map");y.uniforms.opacity=c.getUniformLocation(y.program,"opacity");y.uniforms.useScreenCoordinates=c.getUniformLocation(y.program,"useScreenCoordinates");y.uniforms.affectedByDistance=c.getUniformLocation(y.program,"affectedByDistance");y.uniforms.screenPosition=c.getUniformLocation(y.program,"screenPosition");y.uniforms.modelViewMatrix=c.getUniformLocation(y.program,"modelViewMatrix");y.uniforms.projectionMatrix=c.getUniformLocation(y.program, +"projectionMatrix");var Ta=!1;this.setSize=function(b,c){wa.width=b;wa.height=c;this.setViewport(0,0,wa.width,wa.height)};this.setViewport=function(b,d,e,f){Ga=b;Ha=d;ka=e;pa=f;c.viewport(Ga,Ha,ka,pa)};this.setScissor=function(b,d,e,f){c.scissor(b,d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){I=b;c.depthMask(b)};this.setClearColorHex=function(b,d){qa.setHex(b);La=d;c.clearColor(qa.r,qa.g,qa.b,La)};this.setClearColor= +function(b,d){qa.copy(b);La=d;c.clearColor(qa.r,qa.g,qa.b,La)};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,d,e,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic": +b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,o,s;k=s=j=0;for(o=d.length;k=0&&c.enableVertexAttribArray(m.position);m.color>=0&&c.enableVertexAttribArray(m.color);m.normal>=0&&c.enableVertexAttribArray(m.normal); +m.tangent>=0&&c.enableVertexAttribArray(m.tangent);b.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0&&(c.enableVertexAttribArray(m.skinVertexA),c.enableVertexAttribArray(m.skinVertexB),c.enableVertexAttribArray(m.skinIndex),c.enableVertexAttribArray(m.skinWeight));if(b.attributes)for(h in b.attributes)m[h]!==void 0&&m[h]>=0&&c.enableVertexAttribArray(m[h]);if(b.morphTargets)b.numSupportedMorphTargets=0,m.morphTarget0>=0&&(c.enableVertexAttribArray(m.morphTarget0),b.numSupportedMorphTargets++), +m.morphTarget1>=0&&(c.enableVertexAttribArray(m.morphTarget1),b.numSupportedMorphTargets++),m.morphTarget2>=0&&(c.enableVertexAttribArray(m.morphTarget2),b.numSupportedMorphTargets++),m.morphTarget3>=0&&(c.enableVertexAttribArray(m.morphTarget3),b.numSupportedMorphTargets++),m.morphTarget4>=0&&(c.enableVertexAttribArray(m.morphTarget4),b.numSupportedMorphTargets++),m.morphTarget5>=0&&(c.enableVertexAttribArray(m.morphTarget5),b.numSupportedMorphTargets++),m.morphTarget6>=0&&(c.enableVertexAttribArray(m.morphTarget6), +b.numSupportedMorphTargets++),m.morphTarget7>=0&&(c.enableVertexAttribArray(m.morphTarget7),b.numSupportedMorphTargets++)};this.render=function(b,d,m,r){var v,y,w,x,F,G,s,L,I=b.lights,J=b.fog;this.shadowMapEnabled&&C(b,d);H.data.vertices=0;H.data.faces=0;H.data.drawCalls=0;d.matrixAutoUpdate&&d.update(void 0,!0);b.update(void 0,!1,d);d.matrixWorldInverse.flattenToArray(Ka);d.projectionMatrix.flattenToArray(Ja);va.multiply(d.projectionMatrix,d.matrixWorldInverse);o(va);this.initWebGLObjects(b);ja(m); +(this.autoClear||r)&&this.clear();F=b.__webglObjects.length;for(r=0;r0||r.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(r.faceUvs.length>1||r.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4), -i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(u*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0));i.__lineArray=new Uint16Array(v*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];r=0;for(p=i.numMorphTargets;r=0;g--)d[g]==e&&d.splice(g,1)}else e instanceof THREE.LensFlare?I(d.__webglLensFlares,e):e instanceof THREE.MarchingCubes&&I(d.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d0||r.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(r.faceUvs.length>1||r.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4), +i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(u*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0));i.__lineArray=new Uint16Array(x*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];r=0;for(q=i.numMorphTargets;r=0;g--)d[g]==e&&d.splice(g,1)}else e instanceof THREE.LensFlare?v(d.__webglLensFlares,e):e instanceof THREE.MarchingCubes&&v(d.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d 0 ) { @@ -2511,6 +2563,20 @@ THREE.WebGLRenderer = function ( parameters ) { }; + function refreshUniformsShadow( uniforms, material ) { + + if ( uniforms.shadowMatrix ) { + + uniforms.shadowMatrix.value.copy( _shadowMatrix ); + uniforms.shadowMap.texture = _this.shadowMap; + + uniforms.shadowDarkness.value = _this.shadowMapDarkness; + uniforms.shadowBias.value = _this.shadowMapBias; + + } + + }; + this.initMaterial = function ( material, lights, fog, object ) { var u, a, identifiers, i, parameters, maxLightCount, maxBones, shaderID; @@ -2563,6 +2629,7 @@ THREE.WebGLRenderer = function ( parameters ) { maxBones = allocateBones( object ); parameters = { + map: !!material.map, envMap: !!material.envMap, lightMap: !!material.lightMap, vertexColors: material.vertexColors, fog: fog, sizeAttenuation: material.sizeAttenuation, @@ -2570,7 +2637,9 @@ THREE.WebGLRenderer = function ( parameters ) { morphTargets: material.morphTargets, maxMorphTargets: this.maxMorphTargets, maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point, - maxBones: maxBones + maxBones: maxBones, + shadowMapEnabled: this.shadowMapEnabled && object.receiveShadow + }; material.program = buildProgram( shaderID, material.fragmentShader, material.vertexShader, material.uniforms, material.attributes, parameters ); @@ -2607,7 +2676,6 @@ THREE.WebGLRenderer = function ( parameters ) { material.numSupportedMorphTargets = 0; - if ( attributes.morphTarget0 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget0 ); @@ -2664,14 +2732,6 @@ THREE.WebGLRenderer = function ( parameters ) { } - object.__webglMorphTargetInfluences = new Float32Array( this.maxMorphTargets ); - - for ( var i = 0, il = this.maxMorphTargets; i < il; i ++ ) { - - object.__webglMorphTargetInfluences[ i ] = 0; - - } - } }; @@ -2684,6 +2744,22 @@ THREE.WebGLRenderer = function ( parameters ) { } + if ( material.morphTargets ) { + + if ( ! object.__webglMorphTargetInfluences ) { + + object.__webglMorphTargetInfluences = new Float32Array( _this.maxMorphTargets ); + + for ( var i = 0, il = this.maxMorphTargets; i < il; i ++ ) { + + object.__webglMorphTargetInfluences[ i ] = 0; + + } + + } + + } + var program = material.program, p_uniforms = program.uniforms, m_uniforms = material.uniforms; @@ -2752,6 +2828,13 @@ THREE.WebGLRenderer = function ( parameters ) { } else if ( material instanceof THREE.MeshNormalMaterial ) { m_uniforms.opacity.value = material.opacity; + + } + + if ( object.receiveShadow && ! material._shadowPass ) { + + refreshUniformsShadow( m_uniforms, material ); + } // load common uniforms @@ -2776,7 +2859,8 @@ THREE.WebGLRenderer = function ( parameters ) { if ( material instanceof THREE.MeshShaderMaterial || material.envMap || - material.skinning ) { + material.skinning || + object.receiveShadow ) { if ( p_uniforms.objectMatrix !== null ) { @@ -3098,6 +3182,7 @@ THREE.WebGLRenderer = function ( parameters ) { candidateInfluence = influences[ candidate ]; } + } _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglMorphTargetsBuffers[ candidate ] ); @@ -3108,7 +3193,9 @@ THREE.WebGLRenderer = function ( parameters ) { used[ candidate ] = 1; candidateInfluence = -1; m ++; + } + } // load updated influences uniform @@ -3384,6 +3471,166 @@ THREE.WebGLRenderer = function ( parameters ) { }; + function renderShadowMap( scene, camera ) { + + var i, il, light, + oil, + material, + o, ol, webglObject, object, + lights = scene.lights, + fog = null; + + if ( ! _cameraLight ) { + + _cameraLight = new THREE.Camera( _this.shadowCameraFov, camera.aspect, _this.shadowCameraNear, _this.shadowCameraFar ); + + } + + if ( ! _this.shadowMap ) { + + var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat }; + //var pars = { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat }; + _this.shadowMap = new THREE.WebGLRenderTarget( _this.shadowMapWidth, _this.shadowMapHeight, pars ); + + } + + for ( i = 0, il = lights.length; i < il; i ++ ) { + + light = lights[ i ]; + + if ( light instanceof THREE.SpotLight && light.castShadow ) { + + _cameraLight.position.copy( light.position ); + _cameraLight.target.position.copy( light.target.position ); + + _cameraLight.update( undefined, true ); + + scene.update( undefined, false, _cameraLight ); + + // compute shadow matrix + + _shadowMatrix.set( 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 ); + + _shadowMatrix.multiplySelf( _cameraLight.projectionMatrix ); + _shadowMatrix.multiplySelf( _cameraLight.matrixWorldInverse ); + + // render shadow map + + _cameraLight.matrixWorldInverse.flattenToArray( _viewMatrixArray ); + _cameraLight.projectionMatrix.flattenToArray( _projectionMatrixArray ); + + _projScreenMatrix.multiply( _cameraLight.projectionMatrix, _cameraLight.matrixWorldInverse ); + computeFrustum( _projScreenMatrix ); + + _this.initWebGLObjects( scene ); + + setRenderTarget( _this.shadowMap ); + + // using arbitrary clear color in depth pass + // creates variance in shadows + + _gl.clearColor( 1, 1, 1, 1 ); + //_gl.clearColor( 0, 0, 0, 1 ); + + _this.clear(); + + _gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha ); + + + // set matrices & frustum culling + + ol = scene.__webglObjects.length; + oil = scene.__webglObjectsImmediate.length; + + for ( o = 0; o < ol; o ++ ) { + + webglObject = scene.__webglObjects[ o ]; + object = webglObject.object; + + if ( object.visible && object.castShadow ) { + + if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) { + + object.matrixWorld.flattenToArray( object._objectMatrixArray ); + + setupMatrices( object, _cameraLight, false ); + + webglObject.render = true; + + } else { + + webglObject.render = false; + + } + + } else { + + webglObject.render = false; + + } + + } + + setDepthTest( true ); + setBlending( THREE.NormalBlending ); // maybe blending should be just disabled? + + //_gl.cullFace( _gl.FRONT ); + + for ( o = 0; o < ol; o ++ ) { + + webglObject = scene.__webglObjects[ o ]; + + if ( webglObject.render ) { + + object = webglObject.object; + buffer = webglObject.buffer; + + setObjectFaces( object ); + + material = object.geometry.morphTargets.length ? _depthMaterialMorph : _depthMaterial; + + renderBuffer( _cameraLight, lights, fog, material, buffer, object ); + + } + + } + + + for ( o = 0; o < oil; o++ ) { + + webglObject = scene.__webglObjectsImmediate[ o ]; + object = webglObject.object; + + if ( object.visible && object.castShadow ) { + + if( object.matrixAutoUpdate ) { + + object.matrixWorld.flattenToArray( object._objectMatrixArray ); + + } + + setupMatrices( object, _cameraLight, false ); + + setObjectFaces( object ); + + program = setProgram( _cameraLight, lights, fog, _depthMaterial, object ); + object.render( function( object ) { renderBufferImmediate( object, program, _depthMaterial.shading ); } ); + + } + + } + + //_gl.cullFace( _gl.BACK ); + + } + + } + + }; + this.render = function( scene, camera, renderTarget, forceClear ) { var i, program, opaque, transparent, material, @@ -3391,6 +3638,8 @@ THREE.WebGLRenderer = function ( parameters ) { lights = scene.lights, fog = scene.fog; + if ( this.shadowMapEnabled ) renderShadowMap( scene, camera ); + _this.data.vertices = 0; _this.data.faces = 0; _this.data.drawCalls = 0; @@ -3430,7 +3679,7 @@ THREE.WebGLRenderer = function ( parameters ) { object.matrixWorld.flattenToArray( object._objectMatrixArray ); - setupMatrices( object, camera ); + setupMatrices( object, camera, true ); unrollBufferMaterials( webglObject ); @@ -3488,7 +3737,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - setupMatrices( object, camera ); + setupMatrices( object, camera, true ); unrollImmediateBufferMaterials( webglObject ); @@ -4183,10 +4432,15 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function setupMatrices( object, camera ) { + function setupMatrices( object, camera, computeNormalMatrix ) { object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray ); - THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray ); + + if ( computeNormalMatrix ) { + + THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray ); + + } }; @@ -4795,6 +5049,7 @@ THREE.WebGLRenderer = function ( parameters ) { parameters.vertexColors ? "#define USE_COLOR" : "", parameters.skinning ? "#define USE_SKINNING" : "", parameters.morphTargets ? "#define USE_MORPHTARGETS" : "", + parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", parameters.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", @@ -4860,6 +5115,7 @@ THREE.WebGLRenderer = function ( parameters ) { parameters.envMap ? "#define USE_ENVMAP" : "", parameters.lightMap ? "#define USE_LIGHTMAP" : "", parameters.vertexColors ? "#define USE_COLOR" : "", + parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", "uniform mat4 viewMatrix;", "uniform vec3 cameraPosition;", @@ -4953,10 +5209,10 @@ THREE.WebGLRenderer = function ( parameters ) { for( u in uniforms ) { - location = program.uniforms[u]; + location = program.uniforms[ u ]; if ( !location ) continue; - uniform = uniforms[u]; + uniform = uniforms[ u ]; type = uniform.type; value = uniform.value; @@ -5608,6 +5864,7 @@ THREE.WebGLRenderer = function ( parameters ) { light = lights[ l ]; + if ( light instanceof THREE.SpotLight ) dirLights++; // hack, not a proper spotlight if ( light instanceof THREE.DirectionalLight ) dirLights++; if ( light instanceof THREE.PointLight ) pointLights++; diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js index c76eed30..b9de0286 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -6,7 +6,6 @@ THREE.ShaderChunk = { - // FOG fog_pars_fragment: [ @@ -16,10 +15,14 @@ THREE.ShaderChunk = { "uniform vec3 fogColor;", "#ifdef FOG_EXP2", + "uniform float fogDensity;", + "#else", + "uniform float fogNear;", "uniform float fogFar;", + "#endif", "#endif" @@ -33,11 +36,15 @@ THREE.ShaderChunk = { "float depth = gl_FragCoord.z / gl_FragCoord.w;", "#ifdef FOG_EXP2", + "const float LOG2 = 1.442695;", "float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );", "fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );", + "#else", + "float fogFactor = smoothstep( fogNear, fogFar, depth );", + "#endif", "gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );", @@ -53,6 +60,7 @@ THREE.ShaderChunk = { "#ifdef USE_ENVMAP", "varying vec3 vReflect;", + "uniform float reflectivity;", "uniform samplerCube envMap;", "uniform int combine;", @@ -69,7 +77,6 @@ THREE.ShaderChunk = { "if ( combine == 1 ) {", - //"gl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );", "gl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );", "} else {", @@ -87,6 +94,7 @@ THREE.ShaderChunk = { "#ifdef USE_ENVMAP", "varying vec3 vReflect;", + "uniform float refractionRatio;", "uniform bool useRefract;", @@ -244,7 +252,9 @@ THREE.ShaderChunk = { "uniform float pointLightDistance[ MAX_POINT_LIGHTS ];", "#ifdef PHONG", + "varying vec4 vPointLight[ MAX_POINT_LIGHTS ];", + "#endif", "#endif" @@ -384,11 +394,15 @@ THREE.ShaderChunk = { "vec4 totalLight = vec4( ambient, opacity );", "#if MAX_DIR_LIGHTS > 0", + "totalLight += dirDiffuse + dirSpecular;", + "#endif", "#if MAX_POINT_LIGHTS > 0", + "totalLight += pointDiffuse + pointSpecular;", + "#endif", "gl_FragColor = gl_FragColor * totalLight;" @@ -439,7 +453,7 @@ THREE.ShaderChunk = { ].join("\n"), - // skinning + // SKINNING skinning_pars_vertex: [ @@ -467,7 +481,7 @@ THREE.ShaderChunk = { ].join("\n"), - // morphing + // MORPHING morphtarget_pars_vertex: [ @@ -510,7 +524,78 @@ THREE.ShaderChunk = { "#endif", "#endif" - ].join("\n") + ].join("\n"), + + // SHADOW MAP + + // based on SpiderGL shadow map and Fabien Sanglard's GLSL shadow mapping examples + // http://spidergl.org/example.php?id=6 + // http://fabiensanglard.net/shadowmapping + + shadowmap_pars_fragment: [ + + "#ifdef USE_SHADOWMAP", + + "uniform sampler2D shadowMap;", + + "uniform float shadowDarkness;", + "uniform float shadowBias;", + + "varying vec4 vShadowCoord;", + + "float unpackDepth( const in vec4 rgba_depth ) {", + + "const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );", + "float depth = dot( rgba_depth, bit_shift );", + "return depth;", + + "}", + + "#endif" + + ].join("\n"), + + shadowmap_fragment: [ + + "#ifdef USE_SHADOWMAP", + + "vec3 shadowCoord = vShadowCoord.xyz / vShadowCoord.w;", + + "vec4 rgbaDepth = texture2D( shadowMap, shadowCoord.xy );", + "float fDepth = unpackDepth( rgbaDepth );", + + "if ( fDepth < ( shadowCoord.z + shadowBias ) && ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) )", + "gl_FragColor = gl_FragColor * vec4( vec3( shadowDarkness ), 1.0 );", + + // uncomment to see light frustum boundaries + //"if ( !( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) )", + // "gl_FragColor = gl_FragColor * vec4( 1.0, 0.0, 0.0, 1.0 );", + + + "#endif" + + ].join("\n"), + + shadowmap_pars_vertex: [ + + "#ifdef USE_SHADOWMAP", + + "varying vec4 vShadowCoord;", + "uniform mat4 shadowMatrix;", + + "#endif" + + ].join("\n"), + + shadowmap_vertex: [ + + "#ifdef USE_SHADOWMAP", + + "vShadowCoord = shadowMatrix * objectMatrix * vec4( position, 1.0 );", + + "#endif" + + ].join("\n"), }; @@ -633,6 +718,16 @@ THREE.UniformsLib = { "fogFar" : { type: "f", value: 2000 }, "fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) } + }, + + shadowmap: { + + "shadowMap": { type: "t", value: 3, texture: null }, + "shadowMatrix" : { type: "m4", value: new THREE.Matrix4() }, + + "shadowBias" : { type: "f", value: 0.0039 }, + "shadowDarkness": { type: "f", value: 0.2 } + } }; @@ -1030,7 +1125,8 @@ THREE.ShaderLib = { uniforms: THREE.UniformsUtils.merge( [ THREE.UniformsLib[ "common" ], - THREE.UniformsLib[ "fog" ] + THREE.UniformsLib[ "fog" ], + THREE.UniformsLib[ "shadowmap" ] ] ), @@ -1044,6 +1140,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "lightmap_pars_fragment" ], THREE.ShaderChunk[ "envmap_pars_fragment" ], THREE.ShaderChunk[ "fog_pars_fragment" ], + THREE.ShaderChunk[ "shadowmap_pars_fragment" ], "void main() {", @@ -1053,6 +1150,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "lightmap_fragment" ], THREE.ShaderChunk[ "color_fragment" ], THREE.ShaderChunk[ "envmap_fragment" ], + THREE.ShaderChunk[ "shadowmap_fragment" ], THREE.ShaderChunk[ "fog_fragment" ], "}" @@ -1067,6 +1165,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "color_pars_vertex" ], THREE.ShaderChunk[ "skinning_pars_vertex" ], THREE.ShaderChunk[ "morphtarget_pars_vertex" ], + THREE.ShaderChunk[ "shadowmap_pars_vertex" ], "void main() {", @@ -1079,6 +1178,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "skinning_vertex" ], THREE.ShaderChunk[ "morphtarget_vertex" ], THREE.ShaderChunk[ "default_vertex" ], + THREE.ShaderChunk[ "shadowmap_vertex" ], "}" @@ -1092,7 +1192,8 @@ THREE.ShaderLib = { THREE.UniformsLib[ "common" ], THREE.UniformsLib[ "fog" ], - THREE.UniformsLib[ "lights" ] + THREE.UniformsLib[ "lights" ], + THREE.UniformsLib[ "shadowmap" ] ] ), @@ -1108,6 +1209,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "lightmap_pars_fragment" ], THREE.ShaderChunk[ "envmap_pars_fragment" ], THREE.ShaderChunk[ "fog_pars_fragment" ], + THREE.ShaderChunk[ "shadowmap_pars_fragment" ], "void main() {", @@ -1118,6 +1220,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "lightmap_fragment" ], THREE.ShaderChunk[ "color_fragment" ], THREE.ShaderChunk[ "envmap_fragment" ], + THREE.ShaderChunk[ "shadowmap_fragment" ], THREE.ShaderChunk[ "fog_fragment" ], "}" @@ -1135,6 +1238,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "color_pars_vertex" ], THREE.ShaderChunk[ "skinning_pars_vertex" ], THREE.ShaderChunk[ "morphtarget_pars_vertex" ], + THREE.ShaderChunk[ "shadowmap_pars_vertex" ], "void main() {", @@ -1151,6 +1255,8 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "skinning_vertex" ], THREE.ShaderChunk[ "morphtarget_vertex" ], THREE.ShaderChunk[ "default_vertex" ], + THREE.ShaderChunk[ "shadowmap_vertex" ], + "}" @@ -1165,6 +1271,7 @@ THREE.ShaderLib = { THREE.UniformsLib[ "common" ], THREE.UniformsLib[ "fog" ], THREE.UniformsLib[ "lights" ], + THREE.UniformsLib[ "shadowmap" ], { "ambient" : { type: "c", value: new THREE.Color( 0x050505 ) }, @@ -1191,6 +1298,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "envmap_pars_fragment" ], THREE.ShaderChunk[ "fog_pars_fragment" ], THREE.ShaderChunk[ "lights_pars_fragment" ], + THREE.ShaderChunk[ "shadowmap_pars_fragment" ], "void main() {", @@ -1201,6 +1309,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "lightmap_fragment" ], THREE.ShaderChunk[ "color_fragment" ], THREE.ShaderChunk[ "envmap_fragment" ], + THREE.ShaderChunk[ "shadowmap_fragment" ], THREE.ShaderChunk[ "fog_fragment" ], "}" @@ -1222,6 +1331,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "color_pars_vertex" ], THREE.ShaderChunk[ "skinning_pars_vertex" ], THREE.ShaderChunk[ "morphtarget_pars_vertex" ], + THREE.ShaderChunk[ "shadowmap_pars_vertex" ], "void main() {", @@ -1245,6 +1355,7 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "skinning_vertex" ], THREE.ShaderChunk[ "morphtarget_vertex" ], THREE.ShaderChunk[ "default_vertex" ], + THREE.ShaderChunk[ "shadowmap_vertex" ], "}" @@ -1302,6 +1413,60 @@ THREE.ShaderLib = { ].join("\n") + }, + + // Depth encoding into RGBA texture + // based on SpiderGL shadow map example + // http://spidergl.org/example.php?id=6 + // originally from + // http://www.gamedev.net/topic/442138-packing-a-float-into-a-a8r8g8b8-texture-shader/page__whichpage__1%25EF%25BF%25BD + // see also here: + // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ + + 'depthRGBA': { + + uniforms: {}, + + fragmentShader: [ + + "vec4 pack_depth( const in float depth ) {", + + "const vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );", + "const vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );", + "vec4 res = fract( depth * bit_shift );", + "res -= res.xxyz * bit_mask;", + "return res;", + + "}", + + "void main() {", + + "gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );", + + //"gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z / gl_FragCoord.w );", + //"float z = ( ( gl_FragCoord.z / gl_FragCoord.w ) - 3.0 ) / ( 4000.0 - 3.0 );", + //"gl_FragData[ 0 ] = pack_depth( z );", + //"gl_FragData[ 0 ] = vec4( z, z, z, 1.0 );", + + "}" + + ].join("\n"), + + vertexShader: [ + + THREE.ShaderChunk[ "morphtarget_pars_vertex" ], + + "void main() {", + + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", + + THREE.ShaderChunk[ "morphtarget_vertex" ], + THREE.ShaderChunk[ "default_vertex" ], + + "}" + + ].join("\n") + } }; diff --git a/utils/build.py b/utils/build.py index 732056cd..f0d2742f 100644 --- a/utils/build.py +++ b/utils/build.py @@ -35,6 +35,7 @@ COMMON_FILES = [ 'lights/AmbientLight.js', 'lights/DirectionalLight.js', 'lights/PointLight.js', +'lights/SpotLight.js', 'lights/LensFlare.js', 'materials/Material.js', 'materials/Mappings.js', @@ -263,6 +264,7 @@ WEBGL_FILES = [ 'lights/AmbientLight.js', 'lights/DirectionalLight.js', 'lights/PointLight.js', +'lights/SpotLight.js', 'lights/LensFlare.js', 'materials/Material.js', 'materials/Mappings.js',