From bb332e5fcda34d1acc5af4b79d50304dc166b7eb Mon Sep 17 00:00:00 2001 From: alteredq Date: Sat, 2 Jul 2011 04:35:45 +0200 Subject: [PATCH] Extended Loader base class to handle normal map materials. Plus some more Loader changes: - fixed diffuse color and opacity being skipped when diffuse texture is present in JSON - more proper handling of Phong materials (now use ambient / diffuse / specular / shininess from JSON) - added handling of wrap / offset / repeat parameters for all textures Fixed broken multiple lights indices in new normal map shader and changed displacement scale and bias to saner values. Fixed broken postprocessing and Earth examples (were not yet translated to use new normal map shader). --- build/Three.js | 571 +++++++++++----------- build/custom/ThreeExtras.js | 308 ++++++------ examples/webgl_postprocessing.html | 10 +- examples/webgl_trackballcamera_earth.html | 26 +- src/extras/ShaderUtils.js | 18 +- src/extras/io/BinaryLoader.js | 2 + src/extras/io/JSONLoader.js | 8 +- src/extras/io/Loader.js | 240 ++++++--- 8 files changed, 642 insertions(+), 541 deletions(-) diff --git a/build/Three.js b/build/Three.js index 458ae2be..b4fc8e18 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,7 +1,7 @@ // Three.js r41/ROME - 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,h,k,m,n;if(e==0)f=g=h=0;else switch(k=Math.floor(b*6),m=b*6-k,b=e*(1-c),n=e*(1-c*m),c=e*(1-c*(1-m)),k){case 1:f=n;g=e;h=b;break;case 2:f=b;g=e;h=c;break;case 3:f=b;g=n;h=e;break;case 4:f=c;g=b;h=e;break;case 5:f=e;g=b;h=n;break;case 6:case 0:f=e,g=c,h=b}this.setRGB(f, -g,h)},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.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,k,h,m,n;if(e==0)f=g=k=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;k=b;break;case 2:f=b;g=e;k=c;break;case 3:f=b;g=n;k=e;break;case 4:f=c;g=b;k=e;break;case 5:f=e;g=b;k=n;break;case 6:case 0:f=e,g=c,k=b}this.setRGB(f, +g,k)},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)}, unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.set(b||0,c||0,e||0)}; @@ -14,65 +14,65 @@ 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,h,k,m,n,o,p,t,u,v,w=b.geometry, -A=w.vertices,B=[],f=0;for(g=w.faces.length;f0:t<0))if(p=p.dot((new THREE.Vector3).sub(k,u))/t,u=u.addSelf(v.multiplyScalar(p)), -h instanceof THREE.Face3)e(u,k,m,n)&&(h={distance:this.origin.distanceTo(u),point:u,face:h,object:b},B.push(h));else if(h instanceof THREE.Face4&&(e(u,k,m,o)||e(u,m,n,o)))h={distance:this.origin.distanceTo(u),point:u,face:h,object:b},B.push(h);return B}else return[]}}; -THREE.Rectangle=function(){function b(){h=f-c;k=g-e}var c,e,f,g,h,k,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,k,p,t){m=!1;c=h;e=k;f=p;g=t;b()};this.addPoint=function(h,k){m?(m=!1,c=h,e=k,f=h,g=k):(c=ch?f:h,g=g>k?g:k);b()};this.add3Points= -function(h,k,p,t,u,v){m?(m=!1,c=hp?h>u?h:u:p>u?p:u,g=k>t?k>v?k:v:t>v?t:v):(c=hp?h>u?h>f?h:f:u>f?u:f:p>u?p>f?p:f:u>f?u:f,g=k>t?k>v?k>g?k: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,k,h,m,n,p,o,t,u,v,w=b.geometry, +A=w.vertices,B=[],f=0;for(g=w.faces.length;f0:t<0))if(o=o.dot((new THREE.Vector3).sub(h,u))/t,u=u.addSelf(v.multiplyScalar(o)), +k instanceof THREE.Face3)e(u,h,m,n)&&(k={distance:this.origin.distanceTo(u),point:u,face:k,object:b},B.push(k));else if(k instanceof THREE.Face4&&(e(u,h,m,p)||e(u,m,n,p)))k={distance:this.origin.distanceTo(u),point:u,face:k,object:b},B.push(k);return B}else return[]}}; +THREE.Rectangle=function(){function b(){k=f-c;h=g-e}var c,e,f,g,k,h,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};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,k,o,t){m=!1;c=h;e=k;f=o;g=t;b()};this.addPoint=function(h,k){m?(m=!1,c=h,e=k,f=h,g=k):(c=ch?f:h,g=g>k?g:k);b()};this.add3Points= +function(h,k,o,t,u,v){m?(m=!1,c=ho?h>u?h:u:o>u?o:u,g=k>t?k>v?k: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=k>t?k>v?k>g?k: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,h,k,m,n,o,p,t,u,v,w,A){this.set(b||1,c||0,e||0,f||0,g||0,h||1,k||0,m||0,n||0,o||0,p||1,t||0,u||0,v||0,w||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,c,e,f,g,h,k,m,n,o,p,t,u,v,w,A){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=h;this.n23=k;this.n24=m;this.n31=n;this.n32=o;this.n33=p;this.n34=t;this.n41=u;this.n42=v;this.n43=w;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1, -g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;f.cross(e,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(e,h).normalize());g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var 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* +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,k,h,m,n,p,o,t,u,v,w,A){this.set(b||1,c||0,e||0,f||0,g||0,k||1,h||0,m||0,n||0,p||0,o||1,t||0,u||0,v||0,w||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,c,e,f,g,k,h,m,n,p,o,t,u,v,w,A){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=k;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=w;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1, +g=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());g.cross(k,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=k.x;this.n21=f.y;this.n22=g.y;this.n23=k.y;this.n31=f.z;this.n32=g.z;this.n33=k.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,h=b.n14,k=b.n21,m=b.n22,n=b.n23,o=b.n24,p=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,A=b.n42,B=b.n43,x=b.n44,G=c.n11,z=c.n12,E=c.n13,H=c.n14,C=c.n21,S=c.n22, -L=c.n23,F=c.n24,R=c.n31,O=c.n32,N=c.n33,j=c.n34;this.n11=e*G+f*C+g*R;this.n12=e*z+f*S+g*O;this.n13=e*E+f*L+g*N;this.n14=e*H+f*F+g*j+h;this.n21=k*G+m*C+n*R;this.n22=k*z+m*S+n*O;this.n23=k*E+m*L+n*N;this.n24=k*H+m*F+n*j+o;this.n31=p*G+t*C+u*R;this.n32=p*z+t*S+u*O;this.n33=p*E+t*L+u*N;this.n34=p*H+t*F+u*j+v;this.n41=w*G+A*C+B*R;this.n42=w*z+A*S+B*O;this.n43=w*E+A*L+B*N;this.n44=w*H+A*F+B*j+x;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]= +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,k=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,w=b.n41,A=b.n42,B=b.n43,x=b.n44,G=c.n11,z=c.n12,E=c.n13,H=c.n14,C=c.n21,S=c.n22, +L=c.n23,F=c.n24,R=c.n31,O=c.n32,N=c.n33,j=c.n34;this.n11=e*G+f*C+g*R;this.n12=e*z+f*S+g*O;this.n13=e*E+f*L+g*N;this.n14=e*H+f*F+g*j+k;this.n21=h*G+m*C+n*R;this.n22=h*z+m*S+n*O;this.n23=h*E+m*L+n*N;this.n24=h*H+m*F+n*j+p;this.n31=o*G+t*C+u*R;this.n32=o*z+t*S+u*O;this.n33=o*E+t*L+u*N;this.n34=o*H+t*F+u*j+v;this.n41=w*G+A*C+B*R;this.n42=w*z+A*S+B*O;this.n43=w*E+A*L+B*N;this.n44=w*H+A*F+B*j+x;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,h=this.n22,k=this.n23,m=this.n24,n=this.n31,o=this.n32,p=this.n33,t=this.n34,u=this.n41,v=this.n42,w=this.n43,A=this.n44;return f*k*o*u-e*m*o*u-f*h*p*u+c*m*p*u+e*h*t*u-c*k*t*u-f*k*n*v+e*m*n*v+f*g*p*v-b*m*p*v-e*g*t*v+b*k*t*v+f*h*n*w-c*m*n*w-f*g*o*w+b*m*o*w+c*g*t*w-b*h*t*w-e*h*n*A+c*k*n*A+e*g*o*A-b*k*o*A-c*g*p*A+b*h*p*A},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32= +this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,k=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,w=this.n43,A=this.n44;return f*h*p*u-e*m*p*u-f*k*o*u+c*m*o*u+e*k*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*k*n*w-c*m*n*w-f*g*p*w+b*m*p*w+c*g*t*w-b*k*t*w-e*k*n*A+c*h*n*A+e*g*p*A-b*h*p*A-c*g*o*A+b*k*o*A},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32= this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21; this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]= this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,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,h=b.x,k=b.y,m=b.z,n=g*h,o=g*k;this.set(n* -h+e,n*k-f*m,n*m+f*k,0,n*k+f*m,o*k+e,o*m-f*h,0,n*m-f*k,o*m+f*h,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){var c=b.x,e=b.y,f=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),k=b*e,m=c*e;this.n11=g*h;this.n12=-g*f;this.n13=e;this.n21=m*h+b*f;this.n22=-m*f+b*h;this.n23=-c*g;this.n31=-k*h+c*f;this.n32=k*f+c*h;this.n33=b*g;return this}, -setRotationFromQuaternion:function(b){var c=b.x,e=b.y,f=b.z,g=b.w,h=c+c,k=e+e,m=f+f,b=c*h,n=c*k;c*=m;var o=e*k;e*=m;f*=m;h*=g;k*=g;g*=m;this.n11=1-(o+f);this.n12=n-g;this.n13=c+k;this.n21=n+g;this.n22=1-(b+f);this.n23=e-h;this.n31=c-k;this.n32=e+h;this.n33=1-(b+o);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= +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,k=b.x,h=b.y,m=b.z,n=g*k,p=g*h;this.set(n* +k+e,n*h-f*m,n*m+f*h,0,n*h+f*m,p*h+e,p*m-f*k,0,n*m-f*h,p*m+f*k,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){var c=b.x,e=b.y,f=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(e),e=Math.sin(e),k=Math.cos(f),f=Math.sin(f),h=b*e,m=c*e;this.n11=g*k;this.n12=-g*f;this.n13=e;this.n21=m*k+b*f;this.n22=-m*f+b*k;this.n23=-c*g;this.n31=-h*k+c*f;this.n32=h*f+c*k;this.n33=b*g;return this}, +setRotationFromQuaternion:function(b){var c=b.x,e=b.y,f=b.z,g=b.w,k=c+c,h=e+e,m=f+f,b=c*k,n=c*h;c*=m;var p=e*h;e*=m;f*=m;k*=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-k;this.n31=c-h;this.n32=e+k;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,h=b.n14,k=b.n21,m=b.n22,n=b.n23,o=b.n24,p=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,A=b.n42,B=b.n43,x=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*A-o*u*A+o*t*B-m*v*B-n*t*x+m*u*x;c.n12=h*u*A-g*v*A-h*t*B+f*v*B+g*t*x-f*u*x;c.n13=g*o*A-h*n*A+h*m*B-f*o*B-g*m*x+f*n*x;c.n14=h*n*t-g*o*t-h*m*u+f*o*u+g*m*v-f*n*v;c.n21=o*u*w-n*v*w-o*p*B+k*v*B+n*p*x-k*u*x;c.n22=g*v*w-h*u*w+h*p*B-e*v*B-g*p*x+e*u*x;c.n23=h*n*w-g*o*w-h*k*B+e*o*B+g*k*x-e*n*x;c.n24= -g*o*p-h*n*p+h*k*u-e*o*u-g*k*v+e*n*v;c.n31=m*v*w-o*t*w+o*p*A-k*v*A-m*p*x+k*t*x;c.n32=h*t*w-f*v*w-h*p*A+e*v*A+f*p*x-e*t*x;c.n33=g*o*w-h*m*w+h*k*A-e*o*A-f*k*x+e*m*x;c.n34=h*m*p-f*o*p-h*k*t+e*o*t+f*k*v-e*m*v;c.n41=n*t*w-m*u*w-n*p*A+k*u*A+m*p*B-k*t*B;c.n42=f*u*w-g*t*w+g*p*A-e*u*A-f*p*B+e*t*B;c.n43=g*m*w-f*n*w-g*k*A+e*n*A+f*k*B-e*m*B;c.n44=f*n*p-g*m*p+g*k*t-e*n*t-f*k*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,h=b.n32*b.n21-b.n31*b.n22,k=-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,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*h;e[3]=b*k;e[4]=b*m;e[5]=b*n;e[6]=b*o;e[7]=b*p;e[8]=b*t;return c}; -THREE.Matrix4.makeFrustum=function(b,c,e,f,g,h){var k;k=new THREE.Matrix4;k.n11=2*g/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*g/(f-e);k.n23=(f+e)/(f-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(h+g)/(h-g);k.n34=-2*h*g/(h-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};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,h){var k,m,n,o;k=new THREE.Matrix4;m=c-b;n=e-f;o=h-g;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((e+f)/n);k.n31=0;k.n32=0;k.n33=-2/o;k.n34=-((h+g)/o);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,k=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,w=b.n41,A=b.n42,B=b.n43,x=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*A-p*u*A+p*t*B-m*v*B-n*t*x+m*u*x;c.n12=k*u*A-g*v*A-k*t*B+f*v*B+g*t*x-f*u*x;c.n13=g*p*A-k*n*A+k*m*B-f*p*B-g*m*x+f*n*x;c.n14=k*n*t-g*p*t-k*m*u+f*p*u+g*m*v-f*n*v;c.n21=p*u*w-n*v*w-p*o*B+h*v*B+n*o*x-h*u*x;c.n22=g*v*w-k*u*w+k*o*B-e*v*B-g*o*x+e*u*x;c.n23=k*n*w-g*p*w-k*h*B+e*p*B+g*h*x-e*n*x;c.n24= +g*p*o-k*n*o+k*h*u-e*p*u-g*h*v+e*n*v;c.n31=m*v*w-p*t*w+p*o*A-h*v*A-m*o*x+h*t*x;c.n32=k*t*w-f*v*w-k*o*A+e*v*A+f*o*x-e*t*x;c.n33=g*p*w-k*m*w+k*h*A-e*p*A-f*h*x+e*m*x;c.n34=k*m*o-f*p*o-k*h*t+e*p*t+f*h*v-e*m*v;c.n41=n*t*w-m*u*w-n*o*A+h*u*A+m*o*B-h*t*B;c.n42=f*u*w-g*t*w+g*o*A-e*u*A-f*o*B+e*t*B;c.n43=g*m*w-f*n*w-g*h*A+e*n*A+f*h*B-e*m*B;c.n44=f*n*o-g*m*o+g*h*t-e*n*t-f*h*u+e*m*u;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.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,k=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*k;e[3]=b*h;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*t;return c}; +THREE.Matrix4.makeFrustum=function(b,c,e,f,g,k){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=-(k+g)/(k-g);h.n34=-2*k*g/(k-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,k){var h,m,n,p;h=new THREE.Matrix4;m=c-b;n=e-f;p=k-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=-((k+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.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;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=""}; 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 h=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<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)*h)/k;f=Math.sin(f*h)/k;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,h){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=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; -THREE.Face4=function(b,c,e,f,g,h,k){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=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; +multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,g=this.w,k=b.x,h=b.y,m=b.z,b=b.w;this.x=c*b+g*k+e*m-f*h;this.y=e*b+g*h+f*k-c*m;this.z=f*b+g*m+c*h-e*k;this.w=g*b-c*k-e*h-f*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,f=b.y,g=b.z,k=this.x,h=this.y,m=this.z,n=this.w,p=n*e+h*g-m*f,o= +n*f+m*e-k*g,t=n*g+k*f-h*e,e=-k*e-h*f-m*g;c.x=p*n+e*-k+o*-m-t*-h;c.y=o*n+e*-h+t*-k-p*-m;c.z=t*n+e*-m+p*-h-o*-k;return c}}; +THREE.Quaternion.slerp=function(b,c,e,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=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)*k)/h;f=Math.sin(f*k)/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,k){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,c,e,f,g,k,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=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];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?h:h+1;e[3]=h>this.points.length-3?h:h+2;o=this.points[e[0]];p=this.points[e[1]]; -t=this.points[e[2]];u=this.points[e[3]];m=k*k;n=k*m;f.x=c(o.x,p.x,t.x,u.x,k,m,n);f.y=c(o.y,p.y,t.y,u.y,k,m,n);f.z=c(o.z,p.z,t.z,u.z,k,m,n);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;bthis.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+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;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=p,p=t,t=e):pv&&(e=u,u=v,v=e):ut&&(e=o,o=t,t=e):ov&&(e=u,u=v,v=e):u=0&&h>=0&&k>=0&&m>=0?!0:g<0&&h<0||k<0&&m<0?!1:(g<0?c=Math.max(c,g/(g-h)):h<0&&(f=Math.min(f,g/(g-h))),k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),fE&&k.positionScreen.z0&&H.z<1))Y=z[G]=z[G]||new THREE.RenderableParticle,G++,x=Y,x.x=H.x/H.w,x.y=H.y/H.w,x.z=H.z,x.rotation=I.rotation.z,x.scale.x=I.scale.x*Math.abs(x.x-(H.x+g.projectionMatrix.n11)/(H.w+ -g.projectionMatrix.n14)),x.scale.y=I.scale.y*Math.abs(x.y-(H.y+g.projectionMatrix.n22)/(H.w+g.projectionMatrix.n24)),x.materials=I.materials,h.push(x);j&&h.sort(c);return h}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,h;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;h=f/2};this.render=function(e,f){var n,o,p,t,u,v,w,A;b=c.projectScene(e,f);n=0;for(o=b.length;n>1,t=o.height>>1,h=j.scale.x* -u,n=j.scale.y*v,k=h*va,m=n*t,oa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(oa)&&(w.save(),w.translate(b.x,b.y),w.rotate(-j.rotation),w.scale(h,-n),w.translate(-va,-t),w.drawImage(o,0,0),w.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(k=j.scale.x*u,m=j.scale.y*v,oa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(oa)&&(f(h.color),g(h.color),w.save(),w.translate(b.x,b.y),w.rotate(-j.rotation),w.scale(k,m),h.program(w),w.restore()))}function x(b,j,g,h){c(h.opacity);e(h.blending);w.beginPath(); -w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(j.positionScreen.x,j.positionScreen.y);w.closePath();if(h instanceof THREE.LineBasicMaterial){b=h.linewidth;if(H!=b)w.lineWidth=H=b;b=h.linecap;if(C!=b)w.lineCap=C=b;b=h.linejoin;if(S!=b)w.lineJoin=S=b;f(h.color);w.stroke();oa.inflate(h.linewidth*2)}}function A(b,f,j,g,m,n,o,p,u){k.data.vertices+=3;k.data.faces++;c(p.opacity);e(p.blending);T=b.positionScreen.x;ca=b.positionScreen.y;ga=f.positionScreen.x;Z=f.positionScreen.y;K=j.positionScreen.x; -$=j.positionScreen.y;B(T,ca,ga,Z,K,$);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(ka=o.uvs[0],D(T,ca,ga,Z,K,$,p.map.image,ka[g].u,ka[g].v,ka[m].u,ka[m].v,ka[n].u,ka[n].v));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=h.matrixWorldInverse,pa.copy(o.vertexNormalsWorld[0]),ia=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,xa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(o.vertexNormalsWorld[1]),za=(pa.x*b.n11+pa.y* -b.n12+pa.z*b.n13)*0.5+0.5,Ba=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(o.vertexNormalsWorld[2]),da=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,P=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,D(T,ca,ga,Z,K,$,p.envMap.image,ia,xa,za,Ba,da,P)}else p.wireframe?E(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof THREE.UVMapping&&(ka=o.uvs[0],D(T,ca,ga,Z,K,$,p.map.image,ka[g].u, -ka[g].v,ka[m].u,ka[m].v,ka[n].u,ka[n].v)),e(THREE.SubtractiveBlending)),va?!p.wireframe&&p.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(Y.r=X.r=ja.r=sa.r,Y.g=X.g=ja.g=sa.g,Y.b=X.b=ja.b=sa.b,t(u,o.v1.positionWorld,o.vertexNormalsWorld[0],Y),t(u,o.v2.positionWorld,o.vertexNormalsWorld[1],X),t(u,o.v3.positionWorld,o.vertexNormalsWorld[2],ja),fa.r=(X.r+ja.r)*0.5,fa.g=(X.g+ja.g)*0.5,fa.b=(X.b+ja.b)*0.5,la=Ta(Y,X,ja,fa),D(T,ca,ga,Z,K,$,la,0,0,1,0,0,1)):(ua.r=sa.r,ua.g=sa.g,ua.b=sa.b,t(u, -o.centroidWorld,o.normalWorld,ua),I.r=Math.max(0,Math.min(p.color.r*ua.r,1)),I.g=Math.max(0,Math.min(p.color.g*ua.g,1)),I.b=Math.max(0,Math.min(p.color.b*ua.b,1)),I.updateHex(),p.wireframe?E(I,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(I)):p.wireframe?E(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color);else if(p instanceof THREE.MeshDepthMaterial)U=h.near,J=h.far,Y.r=Y.g=Y.b=1-y(b.positionScreen.z,U,J),X.r=X.g=X.b=1-y(f.positionScreen.z,U,J),ja.r= -ja.g=ja.b=1-y(j.positionScreen.z,U,J),fa.r=(X.r+ja.r)*0.5,fa.g=(X.g+ja.g)*0.5,fa.b=(X.b+ja.b)*0.5,la=Ta(Y,X,ja,fa),D(T,ca,ga,Z,K,$,la,0,0,1,0,0,1);else if(p instanceof THREE.MeshNormalMaterial)I.r=La(o.normalWorld.x),I.g=La(o.normalWorld.y),I.b=La(o.normalWorld.z),I.updateHex(),p.wireframe?E(I,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(I)}function z(b,f,j,g,m,n,o,p,u){k.data.vertices+=4;k.data.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)A(b,f,g,0,1,3,o,p,u),A(m,j,n, -1,2,3,o,p,u);else if(T=b.positionScreen.x,ca=b.positionScreen.y,ga=f.positionScreen.x,Z=f.positionScreen.y,K=j.positionScreen.x,$=j.positionScreen.y,V=g.positionScreen.x,W=g.positionScreen.y,aa=m.positionScreen.x,ma=m.positionScreen.y,ea=n.positionScreen.x,ha=n.positionScreen.y,p instanceof THREE.MeshBasicMaterial)G(T,ca,ga,Z,K,$,V,W),p.wireframe?E(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color);else if(p instanceof THREE.MeshLambertMaterial)va?!p.wireframe&&p.shading== -THREE.SmoothShading&&o.vertexNormalsWorld.length==4?(Y.r=X.r=ja.r=fa.r=sa.r,Y.g=X.g=ja.g=fa.g=sa.g,Y.b=X.b=ja.b=fa.b=sa.b,t(u,o.v1.positionWorld,o.vertexNormalsWorld[0],Y),t(u,o.v2.positionWorld,o.vertexNormalsWorld[1],X),t(u,o.v4.positionWorld,o.vertexNormalsWorld[3],ja),t(u,o.v3.positionWorld,o.vertexNormalsWorld[2],fa),la=Ta(Y,X,ja,fa),B(T,ca,ga,Z,V,W),D(T,ca,ga,Z,V,W,la,0,0,1,0,0,1),B(aa,ma,K,$,ea,ha),D(aa,ma,K,$,ea,ha,la,1,0,1,1,0,1)):(ua.r=sa.r,ua.g=sa.g,ua.b=sa.b,t(u,o.centroidWorld,o.normalWorld, -ua),I.r=Math.max(0,Math.min(p.color.r*ua.r,1)),I.g=Math.max(0,Math.min(p.color.g*ua.g,1)),I.b=Math.max(0,Math.min(p.color.b*ua.b,1)),I.updateHex(),G(T,ca,ga,Z,K,$,V,W),p.wireframe?E(I,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(I)):(G(T,ca,ga,Z,K,$,V,W),p.wireframe?E(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color));else if(p instanceof THREE.MeshNormalMaterial)I.r=La(o.normalWorld.x),I.g=La(o.normalWorld.y),I.b=La(o.normalWorld.z),I.updateHex(), -G(T,ca,ga,Z,K,$,V,W),p.wireframe?E(I,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(I);else if(p instanceof THREE.MeshDepthMaterial)U=h.near,J=h.far,Y.r=Y.g=Y.b=1-y(b.positionScreen.z,U,J),X.r=X.g=X.b=1-y(f.positionScreen.z,U,J),ja.r=ja.g=ja.b=1-y(g.positionScreen.z,U,J),fa.r=fa.g=fa.b=1-y(j.positionScreen.z,U,J),la=Ta(Y,X,ja,fa),B(T,ca,ga,Z,V,W),D(T,ca,ga,Z,V,W,la,0,0,1,0,0,1),B(aa,ma,K,$,ea,ha),D(aa,ma,K,$,ea,ha,la,1,0,1,1,0,1)}function B(b,e,c,f,j,g){w.beginPath();w.moveTo(b,e); -w.lineTo(c,f);w.lineTo(j,g);w.lineTo(b,e);w.closePath()}function G(b,e,c,f,j,g,h,k){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(j,g);w.lineTo(h,k);w.lineTo(b,e);w.closePath()}function E(b,e,c,j){if(H!=e)w.lineWidth=H=e;if(C!=c)w.lineCap=C=c;if(S!=j)w.lineJoin=S=j;f(b);w.stroke();oa.inflate(e*2)}function Da(b){g(b);w.fill()}function D(b,e,c,f,j,g,h,k,m,o,n,p,va){var t,u;t=h.width-1;u=h.height-1;k*=t;m*=u;o*=t;n*=u;p*=t;va*=u;c-=b;f-=e;j-=b;g-=e;o-=k;n-=m;p-=k;va-=m;t=o*va-p*n;t!=0&&(u=1/t,t= -(va*c-n*j)*u,n=(va*f-n*g)*u,c=(o*j-p*c)*u,f=(o*g-p*f)*u,b=b-t*k-c*m,e=e-n*k-f*m,w.save(),w.transform(t,n,c,f,b,e),w.clip(),w.drawImage(h,0,0),w.restore())}function Ta(b,e,c,f){var j=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),h=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),o=~~(f.r*255),p=~~(f.g*255),f=~~(f.b*255);wa[0]=j<0?0:j>255?255:j;wa[1]=g<0?0:g>255?255:g;wa[2]=b<0?0:b>255?255:b;wa[4]=h<0?0:h>255?255:h;wa[5]=k<0?0:k>255?255:k;wa[6]=e<0?0:e>255?255:e;wa[8]=m<0? -0:m>255?255:m;wa[9]=n<0?0:n>255?255:n;wa[10]=c<0?0:c>255?255:c;wa[12]=o<0?0:o>255?255:o;wa[13]=p<0?0:p>255?255:p;wa[14]=f<0?0:f>255?255:f;Oa.putImageData(Wa,0,0);Sa.drawImage(Na,0,0);return Pa}function y(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function La(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ea(b,e){var c=e.x-b.x,f=e.y-b.y,j=1/Math.sqrt(c*c+f*f);c*=j;f*=j;e.x+=c;e.y+=f;b.x-=c;b.y-=f}var Ua,Za,na,ya,Fa,Ma,Va,qa;this.autoClear?this.clear():w.setTransform(1,0,0,-1,u,v);k.data.vertices=0;k.data.faces= -0;m=n.projectScene(b,h,this.sortElements);(va=b.lights.length>0)&&o(b);Ua=0;for(Za=m.length;Ua=0&&h>=0&&k>=0&&m>=0?!0:g<0&&h<0||k<0&&m<0?!1:(g<0?c=Math.max(c,g/(g-h)):h<0&&(f=Math.min(f,g/(g-h))),k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),fE&&h.positionScreen.z0&&H.z<1))Y=z[G]=z[G]||new THREE.RenderableParticle,G++,x=Y,x.x=H.x/H.w,x.y=H.y/H.w,x.z=H.z,x.rotation=I.rotation.z,x.scale.x=I.scale.x*Math.abs(x.x-(H.x+g.projectionMatrix.n11)/(H.w+ +g.projectionMatrix.n14)),x.scale.y=I.scale.y*Math.abs(x.y-(H.y+g.projectionMatrix.n22)/(H.w+g.projectionMatrix.n24)),x.materials=I.materials,k.push(x);j&&k.sort(c);return k}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,k;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;k=f/2};this.render=function(e,f){var n,p,o,t,u,v,w,A;b=c.projectScene(e,f);n=0;for(p=b.length;n>1,o=p.height>>1,h=j.scale.x* +u,n=j.scale.y*v,k=h*va,m=n*o,oa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(oa)&&(w.save(),w.translate(b.x,b.y),w.rotate(-j.rotation),w.scale(h,-n),w.translate(-va,-o),w.drawImage(p,0,0),w.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(k=j.scale.x*u,m=j.scale.y*v,oa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(oa)&&(f(h.color),g(h.color),w.save(),w.translate(b.x,b.y),w.rotate(-j.rotation),w.scale(k,m),h.program(w),w.restore()))}function x(b,j,g,h){c(h.opacity);e(h.blending);w.beginPath(); +w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(j.positionScreen.x,j.positionScreen.y);w.closePath();if(h instanceof THREE.LineBasicMaterial){b=h.linewidth;if(H!=b)w.lineWidth=H=b;b=h.linecap;if(C!=b)w.lineCap=C=b;b=h.linejoin;if(S!=b)w.lineJoin=S=b;f(h.color);w.stroke();oa.inflate(h.linewidth*2)}}function A(b,f,j,g,m,n,p,t,u){h.data.vertices+=3;h.data.faces++;c(t.opacity);e(t.blending);T=b.positionScreen.x;ca=b.positionScreen.y;ga=f.positionScreen.x;Z=f.positionScreen.y;K=j.positionScreen.x; +$=j.positionScreen.y;z(T,ca,ga,Z,K,$);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(ka=p.uvs[0],D(T,ca,ga,Z,K,$,t.map.image,ka[g].u,ka[g].v,ka[m].u,ka[m].v,ka[n].u,ka[n].v));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=k.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),ia=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,xa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[1]),za=(pa.x*b.n11+pa.y* +b.n12+pa.z*b.n13)*0.5+0.5,Ba=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[2]),da=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,P=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,D(T,ca,ga,Z,K,$,t.envMap.image,ia,xa,za,Ba,da,P)}else t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof THREE.UVMapping&&(ka=p.uvs[0],D(T,ca,ga,Z,K,$,t.map.image,ka[g].u, +ka[g].v,ka[m].u,ka[m].v,ka[n].u,ka[n].v)),e(THREE.SubtractiveBlending)),va?!t.wireframe&&t.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(Y.r=X.r=ja.r=sa.r,Y.g=X.g=ja.g=sa.g,Y.b=X.b=ja.b=sa.b,o(u,p.v1.positionWorld,p.vertexNormalsWorld[0],Y),o(u,p.v2.positionWorld,p.vertexNormalsWorld[1],X),o(u,p.v3.positionWorld,p.vertexNormalsWorld[2],ja),fa.r=(X.r+ja.r)*0.5,fa.g=(X.g+ja.g)*0.5,fa.b=(X.b+ja.b)*0.5,la=Ta(Y,X,ja,fa),D(T,ca,ga,Z,K,$,la,0,0,1,0,0,1)):(ua.r=sa.r,ua.g=sa.g,ua.b=sa.b,o(u, +p.centroidWorld,p.normalWorld,ua),I.r=Math.max(0,Math.min(t.color.r*ua.r,1)),I.g=Math.max(0,Math.min(t.color.g*ua.g,1)),I.b=Math.max(0,Math.min(t.color.b*ua.b,1)),I.updateHex(),t.wireframe?E(I,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(I)):t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(t.color);else if(t instanceof THREE.MeshDepthMaterial)U=k.near,J=k.far,Y.r=Y.g=Y.b=1-y(b.positionScreen.z,U,J),X.r=X.g=X.b=1-y(f.positionScreen.z,U,J),ja.r= +ja.g=ja.b=1-y(j.positionScreen.z,U,J),fa.r=(X.r+ja.r)*0.5,fa.g=(X.g+ja.g)*0.5,fa.b=(X.b+ja.b)*0.5,la=Ta(Y,X,ja,fa),D(T,ca,ga,Z,K,$,la,0,0,1,0,0,1);else if(t instanceof THREE.MeshNormalMaterial)I.r=La(p.normalWorld.x),I.g=La(p.normalWorld.y),I.b=La(p.normalWorld.z),I.updateHex(),t.wireframe?E(I,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(I)}function B(b,f,j,g,m,n,p,t,u){h.data.vertices+=4;h.data.faces++;c(t.opacity);e(t.blending);if(t.map||t.envMap)A(b,f,g,0,1,3,p,t,u),A(m,j,n, +1,2,3,p,t,u);else if(T=b.positionScreen.x,ca=b.positionScreen.y,ga=f.positionScreen.x,Z=f.positionScreen.y,K=j.positionScreen.x,$=j.positionScreen.y,V=g.positionScreen.x,W=g.positionScreen.y,aa=m.positionScreen.x,ma=m.positionScreen.y,ea=n.positionScreen.x,ha=n.positionScreen.y,t instanceof THREE.MeshBasicMaterial)G(T,ca,ga,Z,K,$,V,W),t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(t.color);else if(t instanceof THREE.MeshLambertMaterial)va?!t.wireframe&&t.shading== +THREE.SmoothShading&&p.vertexNormalsWorld.length==4?(Y.r=X.r=ja.r=fa.r=sa.r,Y.g=X.g=ja.g=fa.g=sa.g,Y.b=X.b=ja.b=fa.b=sa.b,o(u,p.v1.positionWorld,p.vertexNormalsWorld[0],Y),o(u,p.v2.positionWorld,p.vertexNormalsWorld[1],X),o(u,p.v4.positionWorld,p.vertexNormalsWorld[3],ja),o(u,p.v3.positionWorld,p.vertexNormalsWorld[2],fa),la=Ta(Y,X,ja,fa),z(T,ca,ga,Z,V,W),D(T,ca,ga,Z,V,W,la,0,0,1,0,0,1),z(aa,ma,K,$,ea,ha),D(aa,ma,K,$,ea,ha,la,1,0,1,1,0,1)):(ua.r=sa.r,ua.g=sa.g,ua.b=sa.b,o(u,p.centroidWorld,p.normalWorld, +ua),I.r=Math.max(0,Math.min(t.color.r*ua.r,1)),I.g=Math.max(0,Math.min(t.color.g*ua.g,1)),I.b=Math.max(0,Math.min(t.color.b*ua.b,1)),I.updateHex(),G(T,ca,ga,Z,K,$,V,W),t.wireframe?E(I,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(I)):(G(T,ca,ga,Z,K,$,V,W),t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(t.color));else if(t instanceof THREE.MeshNormalMaterial)I.r=La(p.normalWorld.x),I.g=La(p.normalWorld.y),I.b=La(p.normalWorld.z),I.updateHex(), +G(T,ca,ga,Z,K,$,V,W),t.wireframe?E(I,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Da(I);else if(t instanceof THREE.MeshDepthMaterial)U=k.near,J=k.far,Y.r=Y.g=Y.b=1-y(b.positionScreen.z,U,J),X.r=X.g=X.b=1-y(f.positionScreen.z,U,J),ja.r=ja.g=ja.b=1-y(g.positionScreen.z,U,J),fa.r=fa.g=fa.b=1-y(j.positionScreen.z,U,J),la=Ta(Y,X,ja,fa),z(T,ca,ga,Z,V,W),D(T,ca,ga,Z,V,W,la,0,0,1,0,0,1),z(aa,ma,K,$,ea,ha),D(aa,ma,K,$,ea,ha,la,1,0,1,1,0,1)}function z(b,e,c,f,j,g){w.beginPath();w.moveTo(b,e); +w.lineTo(c,f);w.lineTo(j,g);w.lineTo(b,e);w.closePath()}function G(b,e,c,f,j,g,h,k){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(j,g);w.lineTo(h,k);w.lineTo(b,e);w.closePath()}function E(b,e,c,j){if(H!=e)w.lineWidth=H=e;if(C!=c)w.lineCap=C=c;if(S!=j)w.lineJoin=S=j;f(b);w.stroke();oa.inflate(e*2)}function Da(b){g(b);w.fill()}function D(b,e,c,f,j,g,h,k,m,t,p,n,va){var o,u;o=h.width-1;u=h.height-1;k*=o;m*=u;t*=o;p*=u;n*=o;va*=u;c-=b;f-=e;j-=b;g-=e;t-=k;p-=m;n-=k;va-=m;o=t*va-n*p;o!=0&&(u=1/o,o= +(va*c-p*j)*u,p=(va*f-p*g)*u,c=(t*j-n*c)*u,f=(t*g-n*f)*u,b=b-o*k-c*m,e=e-p*k-f*m,w.save(),w.transform(o,p,c,f,b,e),w.clip(),w.drawImage(h,0,0),w.restore())}function Ta(b,e,c,f){var j=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),h=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),t=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),n=~~(f.g*255),f=~~(f.b*255);wa[0]=j<0?0:j>255?255:j;wa[1]=g<0?0:g>255?255:g;wa[2]=b<0?0:b>255?255:b;wa[4]=h<0?0:h>255?255:h;wa[5]=k<0?0:k>255?255:k;wa[6]=e<0?0:e>255?255:e;wa[8]=m<0? +0:m>255?255:m;wa[9]=t<0?0:t>255?255:t;wa[10]=c<0?0:c>255?255:c;wa[12]=p<0?0:p>255?255:p;wa[13]=n<0?0:n>255?255:n;wa[14]=f<0?0:f>255?255:f;Oa.putImageData(Wa,0,0);Sa.drawImage(Na,0,0);return Pa}function y(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function La(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ea(b,e){var c=e.x-b.x,f=e.y-b.y,j=1/Math.sqrt(c*c+f*f);c*=j;f*=j;e.x+=c;e.y+=f;b.x-=c;b.y-=f}var Ua,Za,na,ya,Fa,Ma,Va,qa;this.autoClear?this.clear():w.setTransform(1,0,0,-1,u,v);h.data.vertices=0;h.data.faces= +0;m=n.projectScene(b,k,this.sortElements);(va=b.lights.length>0)&&p(b);Ua=0;for(Za=m.length;Ua0&&(c.r+=g.color.r*h,c.g+=g.color.g*h,c.b+=g.color.b*h)):g instanceof THREE.PointLight&&(O.sub(g.position,e.centroidWorld),O.normalize(),h=e.normalWorld.dot(O)*g.intensity,h>0&&(c.r+=g.color.r*h,c.g+=g.color.g*h,c.b+=g.color.b*h))}function c(e,c,j,m,n,p){k.data.vertices+=3;k.data.faces++;T=f(ca++);T.setAttribute("d", -"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?H.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?E?(C.r=S.r,C.g=S.g,C.b=S.b,b(p,m,C),H.r=Math.max(0,Math.min(n.color.r*C.r,1)),H.g=Math.max(0,Math.min(n.color.g*C.g,1)),H.b=Math.max(0,Math.min(n.color.b*C.b,1)),H.updateHex()):H.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(R=1-n.__2near/(n.__farPlusNear- -m.z*n.__farMinusNear),H.setRGB(R,R,R)):n instanceof THREE.MeshNormalMaterial&&H.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));n.wireframe?T.setAttribute("style","fill: none; stroke: #"+h(H.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):T.setAttribute("style","fill: #"+h(H.hex.toString(16))+"; fill-opacity: "+n.opacity);o.appendChild(T)}function e(e,c,j,m, -n,p,t){k.data.vertices+=4;k.data.faces++;T=f(ca++);T.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?H.hex=p.color.hex:p instanceof THREE.MeshLambertMaterial?E?(C.r=S.r,C.g=S.g,C.b=S.b,b(t,n,C),H.r=Math.max(0,Math.min(p.color.r*C.r,1)),H.g=Math.max(0,Math.min(p.color.g*C.g,1)),H.b=Math.max(0,Math.min(p.color.b* -C.b,1)),H.updateHex()):H.hex=p.color.hex:p instanceof THREE.MeshDepthMaterial?(R=1-p.__2near/(p.__farPlusNear-n.z*p.__farMinusNear),H.setRGB(R,R,R)):p instanceof THREE.MeshNormalMaterial&&H.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));p.wireframe?T.setAttribute("style","fill: none; stroke: #"+h(H.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):T.setAttribute("style", -"fill: #"+h(H.hex.toString(16))+"; fill-opacity: "+p.opacity);o.appendChild(T)}function f(b){N[b]==null&&(N[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),Z==0&&N[b].setAttribute("shape-rendering","crispEdges"));return N[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function h(b){for(;b.length<6;)b="0"+b;return b}var k=this,m=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,t,u,v,w,A,B,x,G=new THREE.Rectangle,z=new THREE.Rectangle,E= -!1,H=new THREE.Color(16777215),C=new THREE.Color(16777215),S=new THREE.Color(0),L=new THREE.Color(0),F=new THREE.Color(0),R,O=new THREE.Vector3,N=[],j=[],T,ca,ga,Z=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":Z=1;break;case "low":Z=0}};this.setSize=function(b,e){p=b;t=e;u=p/2;v=t/2;o.setAttribute("viewBox",-u+" "+-v+" "+p+" "+t);o.setAttribute("width",p);o.setAttribute("height",t);G.set(-u, --v,u,v)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(b,f){var g,p,t,H,C,R,I,N;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;m=n.projectScene(b,f,this.sortElements);ga=ca=0;if(E=b.lights.length>0){I=b.lights;S.setRGB(0,0,0);L.setRGB(0,0,0);F.setRGB(0,0,0);g=0;for(p=I.length;g0&&(c.r+=g.color.r*h,c.g+=g.color.g*h,c.b+=g.color.b*h)):g instanceof THREE.PointLight&&(O.sub(g.position,e.centroidWorld),O.normalize(),h=e.normalWorld.dot(O)*g.intensity,h>0&&(c.r+=g.color.r*h,c.g+=g.color.g*h,c.b+=g.color.b*h))}function c(e,c,j,m,t,n){h.data.vertices+=3;h.data.faces++;T=f(ca++);T.setAttribute("d", +"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?H.hex=t.color.hex:t instanceof THREE.MeshLambertMaterial?E?(C.r=S.r,C.g=S.g,C.b=S.b,b(n,m,C),H.r=Math.max(0,Math.min(t.color.r*C.r,1)),H.g=Math.max(0,Math.min(t.color.g*C.g,1)),H.b=Math.max(0,Math.min(t.color.b*C.b,1)),H.updateHex()):H.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(R=1-t.__2near/(t.__farPlusNear- +m.z*t.__farMinusNear),H.setRGB(R,R,R)):t instanceof THREE.MeshNormalMaterial&&H.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));t.wireframe?T.setAttribute("style","fill: none; stroke: #"+k(H.hex.toString(16))+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):T.setAttribute("style","fill: #"+k(H.hex.toString(16))+"; fill-opacity: "+t.opacity);p.appendChild(T)}function e(e,c,j,m, +t,n,o){h.data.vertices+=4;h.data.faces++;T=f(ca++);T.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?H.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?E?(C.r=S.r,C.g=S.g,C.b=S.b,b(o,t,C),H.r=Math.max(0,Math.min(n.color.r*C.r,1)),H.g=Math.max(0,Math.min(n.color.g*C.g,1)),H.b=Math.max(0,Math.min(n.color.b* +C.b,1)),H.updateHex()):H.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(R=1-n.__2near/(n.__farPlusNear-t.z*n.__farMinusNear),H.setRGB(R,R,R)):n instanceof THREE.MeshNormalMaterial&&H.setRGB(g(t.normalWorld.x),g(t.normalWorld.y),g(t.normalWorld.z));n.wireframe?T.setAttribute("style","fill: none; stroke: #"+k(H.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):T.setAttribute("style", +"fill: #"+k(H.hex.toString(16))+"; fill-opacity: "+n.opacity);p.appendChild(T)}function f(b){N[b]==null&&(N[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),Z==0&&N[b].setAttribute("shape-rendering","crispEdges"));return N[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function k(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,w,A,B,x,G=new THREE.Rectangle,z=new THREE.Rectangle,E= +!1,H=new THREE.Color(16777215),C=new THREE.Color(16777215),S=new THREE.Color(0),L=new THREE.Color(0),F=new THREE.Color(0),R,O=new THREE.Vector3,N=[],j=[],T,ca,ga,Z=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":Z=1;break;case "low":Z=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);G.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,H,C,R,I,N;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;m=n.projectScene(b,f,this.sortElements);ga=ca=0;if(E=b.lights.length>0){I=b.lights;S.setRGB(0,0,0);L.setRGB(0,0,0);F.setRGB(0,0,0);g=0;for(t=I.length;g=0)j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0);else{c=g.program.attributes;k.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]), -j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,n=k.morphTargetForcedOrder,p=k.morphTargetInfluences;fo&&(t=u,o=p[t]);j.bindBuffer(j.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[t]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=o;n[t]=1;o=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(g.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>= +j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,t=k.morphTargetForcedOrder,n=k.morphTargetInfluences;fp&&(o=u,p=n[o]);j.bindBuffer(j.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[o]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=p;t[o]=1;p=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(g.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>= 0&&(c=h.__webglCustomAttributes[m],j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[m],c.size,j.FLOAT,!1,0,0));b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglColorBuffer),j.vertexAttribPointer(b.color,3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER, h.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,h.__webglUV2Buffer),j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4, j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0));k instanceof THREE.Mesh?(g.wireframe?(j.lineWidth(g.wireframeLinewidth),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),j.drawElements(j.LINES,h.__webglLineCount, j.UNSIGNED_SHORT,0)):(j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),j.drawElements(j.TRIANGLES,h.__webglFaceCount,j.UNSIGNED_SHORT,0)),N.data.vertices+=h.__webglFaceCount,N.data.faces+=h.__webglFaceCount/3,N.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?j.LINE_STRIP:j.LINES,j.lineWidth(g.linewidth),j.drawArrays(k,0,h.__webglLineCount),N.data.drawCalls++):k instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,h.__webglParticleCount),N.data.drawCalls++):k instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,h.__webglVertexCount),N.data.drawCalls++)}}function g(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=j.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=j.createBuffer();b.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,b.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,b.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(e.attributes.position),j.vertexAttribPointer(e.attributes.position,3,j.FLOAT,!1,0,0));if(b.hasNormal){j.bindBuffer(j.ARRAY_BUFFER, -b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,g,k,m,n,p,o,t,u,v=b.count*3;for(u=0;u0&&x[0]0&&x[1]0.0010&&m.scale>0.0010)w[0]=m.x,w[1]=m.y,w[2]=m.z,u=m.size*m.scale/ha,v[0]=u*p,v[1]=u,j.uniform3fv(A.screenPosition,w),j.uniform2fv(A.scale,v),j.uniform1f(A.rotation,m.rotation),j.uniform1f(A.opacity,m.opacity),H(m.blending),S(m.texture,1),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0)}j.enable(j.CULL_FACE);j.enable(j.DEPTH_TEST);j.depthMask(Z)}function B(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} -function x(b){var e,f,h,g;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){h=f.geometryGroups[e];a:{for(var k=g=void 0,m=void 0,n=void 0,p=void 0,p=h.__materials,k=0,m=p.length;k0&&x[0]0&&x[1]0.0010&&m.scale>0.0010)w[0]=m.x,w[1]=m.y,w[2]=m.z,u=m.size*m.scale/ha,v[0]=u*n,v[1]=u,j.uniform3fv(A.screenPosition,w),j.uniform2fv(A.scale,v),j.uniform1f(A.rotation,m.rotation),j.uniform1f(A.opacity,m.opacity),H(m.blending),S(m.texture,1),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0)}j.enable(j.CULL_FACE);j.enable(j.DEPTH_TEST);j.depthMask(Z)}function B(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} +function x(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){g=f.geometryGroups[e];a:{for(var k=h=void 0,m=void 0,t=void 0,n=void 0,n=g.__materials,k=0,m=n.length;k0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Z,m));ta&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglNormalBuffer),j.bufferData(j.ARRAY_BUFFER,$,m));Ba&&ea.hasTangents&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglTangentBuffer),j.bufferData(j.ARRAY_BUFFER,ia,m));za&&R>0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,ca,m));za&&Q>0&&(j.bindBuffer(j.ARRAY_BUFFER, -g.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,da,m));oa&&(j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),j.bufferData(j.ELEMENT_ARRAY_BUFFER,fa,m),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),j.bufferData(j.ELEMENT_ARRAY_BUFFER,ha,m));M>0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,V,m),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,aa,m),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER, -X,m),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,Y,m));k.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;var ra;h=h.__materials;f=0;for(b=h.length;f=0;c--)b[c].object==e&&b.splice(c,1)}function z(b){function e(b){var g=[];c=0;for(f=b.length;c65535&&(t[m].counter+=1,n=t[m].hash+"_"+t[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(g),b.geometryGroups[n].vertices+=j}function E(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=V){switch(b){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD); +Aa[D].vertices[o.a].position,E=Aa[D].vertices[o.b].position,U=Aa[D].vertices[o.c].position,F=Aa[D].vertices[o.d].position,y=ja[D],y[ka+0]=C.x,y[ka+1]=C.y,y[ka+2]=C.z,y[ka+3]=E.x,y[ka+4]=E.y,y[ka+5]=E.z,y[ka+6]=U.x,y[ka+7]=U.y,y[ka+8]=U.z,y[ka+9]=F.x,y[ka+10]=F.y,y[ka+11]=F.z;ka+=12}if(Ca.length)D=Ca[o.a],J=Ca[o.b],y=Ca[o.c],I=Ca[o.d],Y[M]=D.x,Y[M+1]=D.y,Y[M+2]=D.z,Y[M+3]=D.w,Y[M+4]=J.x,Y[M+5]=J.y,Y[M+6]=J.z,Y[M+7]=J.w,Y[M+8]=y.x,Y[M+9]=y.y,Y[M+10]=y.z,Y[M+11]=y.w,Y[M+12]=I.x,Y[M+13]=I.y,Y[M+14]=I.z, +Y[M+15]=I.w,D=Ka[o.a],J=Ka[o.b],y=Ka[o.c],I=Ka[o.d],X[M]=D.x,X[M+1]=D.y,X[M+2]=D.z,X[M+3]=D.w,X[M+4]=J.x,X[M+5]=J.y,X[M+6]=J.z,X[M+7]=J.w,X[M+8]=y.x,X[M+9]=y.y,X[M+10]=y.z,X[M+11]=y.w,X[M+12]=I.x,X[M+13]=I.y,X[M+14]=I.z,X[M+15]=I.w,D=Ia[o.a],J=Ia[o.b],y=Ia[o.c],I=Ia[o.d],V[M]=D.x,V[M+1]=D.y,V[M+2]=D.z,V[M+3]=1,V[M+4]=J.x,V[M+5]=J.y,V[M+6]=J.z,V[M+7]=1,V[M+8]=y.x,V[M+9]=y.y,V[M+10]=y.z,V[M+11]=1,V[M+12]=I.x,V[M+13]=I.y,V[M+14]=I.z,V[M+15]=1,D=Ja[o.a],J=Ja[o.b],y=Ja[o.c],o=Ja[o.d],aa[M]=D.x,aa[M+1]= +D.y,aa[M+2]=D.z,aa[M+3]=1,aa[M+4]=J.x,aa[M+5]=J.y,aa[M+6]=J.z,aa[M+7]=1,aa[M+8]=y.x,aa[M+9]=y.y,aa[M+10]=y.z,aa[M+11]=1,aa[M+12]=o.x,aa[M+13]=o.y,aa[M+14]=o.z,aa[M+15]=1,M+=16;if(Xa&&B)v.length==4&&B==THREE.VertexColors?(o=v[0],D=v[1],J=v[2],v=v[3]):v=J=D=o=w,Z[W]=o.r,Z[W+1]=o.g,Z[W+2]=o.b,Z[W+3]=D.r,Z[W+4]=D.g,Z[W+5]=D.b,Z[W+6]=J.r,Z[W+7]=J.g,Z[W+8]=J.b,Z[W+9]=v.r,Z[W+10]=v.g,Z[W+11]=v.b,W+=12;if(Ba&&ea.hasTangents)v=x[0],w=x[1],o=x[2],x=x[3],ia[O]=v.x,ia[O+1]=v.y,ia[O+2]=v.z,ia[O+3]=v.w,ia[O+4]= +w.x,ia[O+5]=w.y,ia[O+6]=w.z,ia[O+7]=w.w,ia[O+8]=o.x,ia[O+9]=o.y,ia[O+10]=o.z,ia[O+11]=o.w,ia[O+12]=x.x,ia[O+13]=x.y,ia[O+14]=x.z,ia[O+15]=x.w,O+=16;if(ta&&z)if(p.length==4&&ma)for(x=0;x<4;x++)u=p[x],$[P]=u.x,$[P+1]=u.y,$[P+2]=u.z,P+=3;else for(x=0;x<4;x++)$[P]=u.x,$[P+1]=u.y,$[P+2]=u.z,P+=3;if(za&&H!==void 0&&A)for(x=0;x<4;x++)p=H[x],ca[R]=p.u,ca[R+1]=p.v,R+=2;if(za&&G!==void 0&&A)for(x=0;x<4;x++)p=G[x],da[Q]=p.u,da[Q+1]=p.v,Q+=2;oa&&(fa[la]=L,fa[la+1]=L+1,fa[la+2]=L+3,fa[la+3]=L+1,fa[la+4]=L+2,fa[la+ +5]=L+3,la+=6,ha[S]=L,ha[S+1]=L+1,ha[S+2]=L,ha[S+3]=L+3,ha[S+4]=L+1,ha[S+5]=L+2,ha[S+6]=L+2,ha[S+7]=L+3,S+=8,L+=4)}if(Ga){t=0;for(n=Ga.length;t0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Z,m));ta&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglNormalBuffer),j.bufferData(j.ARRAY_BUFFER,$,m));Ba&&ea.hasTangents&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglTangentBuffer),j.bufferData(j.ARRAY_BUFFER,ia,m));za&&R>0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,ca,m));za&&Q>0&&(j.bindBuffer(j.ARRAY_BUFFER, +h.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,da,m));oa&&(j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),j.bufferData(j.ELEMENT_ARRAY_BUFFER,fa,m),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),j.bufferData(j.ELEMENT_ARRAY_BUFFER,ha,m));M>0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,V,m),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,aa,m),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER, +X,m),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,Y,m));k.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;var ra;g=g.__materials;f=0;for(b=g.length;f=0;c--)b[c].object==e&&b.splice(c,1)}function z(b){function e(b){var g=[];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:p})),b.geometryGroups[t].faces.push(g),b.geometryGroups[t].vertices+=j}function E(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=V){switch(b){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD); j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);break;default:j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}V=b}}function C(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(j.texParameteri(b,j.TEXTURE_WRAP_S,O(e.wrapS)),j.texParameteri(b, j.TEXTURE_WRAP_T,O(e.wrapT)),j.texParameteri(b,j.TEXTURE_MAG_FILTER,O(e.magFilter)),j.texParameteri(b,j.TEXTURE_MIN_FILTER,O(e.minFilter)),j.generateMipmap(b)):(j.texParameteri(b,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(b,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(b,j.TEXTURE_MAG_FILTER,R(e.magFilter)),j.texParameteri(b,j.TEXTURE_MIN_FILTER,R(e.minFilter)))}function S(b,e){if(b.needsUpdate)b.__webglInit?(j.bindTexture(j.TEXTURE_2D,b.__webglTexture),j.texSubImage2D(j.TEXTURE_2D,0,0, 0,j.RGBA,j.UNSIGNED_BYTE,b.image)):(b.__webglTexture=j.createTexture(),j.bindTexture(j.TEXTURE_2D,b.__webglTexture),j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,b.image),b.__webglInit=!0),C(j.TEXTURE_2D,b,b.image),j.bindTexture(j.TEXTURE_2D,null),b.needsUpdate=!1;j.activeTexture(j.TEXTURE0+e);j.bindTexture(j.TEXTURE_2D,b.__webglTexture)}function L(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer= @@ -309,27 +309,27 @@ j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);j.bufferData(j.ELEMENT_ARRA "affectedByDistance");Q.uniforms.screenPosition=j.getUniformLocation(Q.program,"screenPosition");Q.uniforms.modelViewMatrix=j.getUniformLocation(Q.program,"modelViewMatrix");Q.uniforms.projectionMatrix=j.getUniformLocation(Q.program,"projectionMatrix");var oa=!1;this.setSize=function(b,e){J.width=b;J.height=e;this.setViewport(0,0,J.width,J.height)};this.setViewport=function(b,e,c,f){aa=b;ma=e;ea=c;ha=f;j.viewport(aa,ma,ea,ha)};this.setScissor=function(b,e,c,f){j.scissor(b,e,c,f)};this.enableScissorTest= function(b){b?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){Z=b;j.depthMask(b)};this.setClearColorHex=function(b,e){ia.setHex(b);xa=e;j.clearColor(ia.r,ia.g,ia.b,xa)};this.setClearColor=function(b,e){ia.copy(b);xa=e;j.clearColor(ia.r,ia.g,ia.b,xa)};this.clear=function(){j.clear(j.COLOR_BUFFER_BIT|j.DEPTH_BUFFER_BIT|j.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){da.darkness=b};this.getContext=function(){return j};this.initMaterial=function(b, e,c,f){var g,h,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?k="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms); -b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var n,t,p;n=p=m=0;for(t=e.length;n=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>= -0&&j.enableVertexAttribArray(o.normal);o.tangent>=0&&j.enableVertexAttribArray(o.tangent);b.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(b.attributes)for(g in b.attributes)o[g]!==void 0&&o[g]>=0&&j.enableVertexAttribArray(o[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;o.morphTarget0>=0&&(j.enableVertexAttribArray(o.morphTarget0), -b.numSupportedMorphTargets++);o.morphTarget1>=0&&(j.enableVertexAttribArray(o.morphTarget1),b.numSupportedMorphTargets++);o.morphTarget2>=0&&(j.enableVertexAttribArray(o.morphTarget2),b.numSupportedMorphTargets++);o.morphTarget3>=0&&(j.enableVertexAttribArray(o.morphTarget3),b.numSupportedMorphTargets++);o.morphTarget4>=0&&(j.enableVertexAttribArray(o.morphTarget4),b.numSupportedMorphTargets++);o.morphTarget5>=0&&(j.enableVertexAttribArray(o.morphTarget5),b.numSupportedMorphTargets++);o.morphTarget6>= -0&&(j.enableVertexAttribArray(o.morphTarget6),b.numSupportedMorphTargets++);o.morphTarget7>=0&&(j.enableVertexAttribArray(o.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b=0&&j.enableVertexAttribArray(n.position);n.color>=0&&j.enableVertexAttribArray(n.color);n.normal>= +0&&j.enableVertexAttribArray(n.normal);n.tangent>=0&&j.enableVertexAttribArray(n.tangent);b.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0&&(j.enableVertexAttribArray(n.skinVertexA),j.enableVertexAttribArray(n.skinVertexB),j.enableVertexAttribArray(n.skinIndex),j.enableVertexAttribArray(n.skinWeight));if(b.attributes)for(g in b.attributes)n[g]!==void 0&&n[g]>=0&&j.enableVertexAttribArray(n[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;n.morphTarget0>=0&&(j.enableVertexAttribArray(n.morphTarget0), +b.numSupportedMorphTargets++);n.morphTarget1>=0&&(j.enableVertexAttribArray(n.morphTarget1),b.numSupportedMorphTargets++);n.morphTarget2>=0&&(j.enableVertexAttribArray(n.morphTarget2),b.numSupportedMorphTargets++);n.morphTarget3>=0&&(j.enableVertexAttribArray(n.morphTarget3),b.numSupportedMorphTargets++);n.morphTarget4>=0&&(j.enableVertexAttribArray(n.morphTarget4),b.numSupportedMorphTargets++);n.morphTarget5>=0&&(j.enableVertexAttribArray(n.morphTarget5),b.numSupportedMorphTargets++);n.morphTarget6>= +0&&(j.enableVertexAttribArray(n.morphTarget6),b.numSupportedMorphTargets++);n.morphTarget7>=0&&(j.enableVertexAttribArray(n.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b -0||u.faceVertexUvs.length>0)k.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(n*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(n*4),k.__skinVertexBArray=new Float32Array(n*4),k.__skinIndexArray=new Float32Array(n*4),k.__skinWeightArray=new Float32Array(n*4);k.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(A*2); -if(k.numMorphTargets){k.__morphTargetsArrays=[];u=0;for(v=k.numMorphTargets;u +0||u.faceVertexUvs.length>0)k.__uvArray=new Float32Array(t*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(t*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(t*4),k.__skinVertexBArray=new Float32Array(t*4),k.__skinIndexArray=new Float32Array(t*4),k.__skinWeightArray=new Float32Array(t*4);k.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(A*2); +if(k.numMorphTargets){k.__morphTargetsArrays=[];u=0;for(v=k.numMorphTargets;u1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=k;c.v=h;return c}, +THREE.ColorUtils={adjustHSV:function(b,c,e,f){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,g);g.h=THREE.ColorUtils.clamp(g.h+c,0,1);g.s=THREE.ColorUtils.clamp(g.s+e,0,1);g.v=THREE.ColorUtils.clamp(g.v+f,0,1);b.setHSV(g.h,g.s,g.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,g=b.b,k=Math.max(Math.max(e,f),g),h=Math.min(Math.min(e,f),g);if(h==k)h=e=0;else{var m=k-h,h=m/k,e=e==k?(f-g)/m:f==k?2+(g-e)/m:4+(e-f)/m;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=h;c.v=k;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -var GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,h=b.vertices,k=g.vertices,m=b.faces,n=g.faces,o=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,t=k.length;p 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ 0 ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ 0 ].xyz + vViewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ 0 ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ 0 ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;\n}", +normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.lights,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c", +value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1}}]),fragmentShader:"uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;\n}", vertexShader:"attribute vec4 tangent;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t", value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(h=25);g=(h-1)*0.5;e=Array(h);for(c=f=0;c25&&(k=25);g=(k-1)*0.5;e=Array(k);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]+(h[0]-g[0])*f,e.y=g[1]+(h[1]-g[1])*f,e.z=g[2]+(h[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,k.index-1).pos,this.points[1]=g,this.points[2]=h,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,h,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(h[0]-g[0])*f,e.y=g[1]+(h[1]-g[1])*f,e.z=g[2]+(h[2]-g[2])*f}}if(this.JITCompile&&p[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?h:h+1;e[3]=h>b.length-3?h:h+2;h=b[e[0]];m=b[e[1]];n=b[e[2]];o=b[e[3]];e=g*g;k=g*e;f[0]=this.interpolate(h[0],m[0],n[0],o[0],g,e,k);f[1]=this.interpolate(h[1],m[1],n[1],o[1],g,e,k);f[2]=this.interpolate(h[2],m[2],n[2],o[2],g,e,k);return f}; -THREE.Animation.prototype.interpolate=function(b,c,e,f,g,h,k){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*k+(-3*(c-e)-2*b-f)*h+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=e1)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]+(k[0]-g[0])*f,e.y=g[1]+(k[1]-g[1])*f,e.z=g[2]+(k[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]=k,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,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(k[0]-g[0])*f,e.y=g[1]+(k[1]-g[1])*f,e.z=g[2]+(k[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?k:k+1;e[3]=k>b.length-3?k:k+2;k=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(k[0],m[0],n[0],p[0],g,e,h);f[1]=this.interpolate(k[1],m[1],n[1],p[1],g,e,h);f[2]=this.interpolate(k[2],m[2],n[2],p[2],g,e,h);return f}; +THREE.Animation.prototype.interpolate=function(b,c,e,f,g,k,h){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*h+(-3*(c-e)-2*b-f)*k+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.QuakeCamera=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= b.movementSpeed;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.noFly!==void 0)this.noFly=b.noFly;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.autoForward!==void 0)this.autoForward=b.autoForward;if(b.activeLook!==void 0)this.activeLook=b.activeLook;if(b.heightSpeed!==void 0)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==void 0)this.heightCoef=b.heightCoef;if(b.heightMin!==void 0)this.heightMin=b.heightMin;if(b.heightMax!==void 0)this.heightMax=b.heightMax;if(b.constrainVertical!== @@ -393,137 +393,140 @@ f,g=new THREE.Geometry;for(c=0;c=0?f:f+g;f=this.verticalAngleMap.srcRange;k=this.verticalAngleMap.dstRange;var m=k[1]-k[0];this.phi= -TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.horizontalAngleMap.srcRange;k=this.horizontalAngleMap.dstRange;m=k[1]-k[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[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}),k=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,k);b.position.set(0,10,0);this.animation= +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,k=Math.PI/180;this.update=function(b,e,c){var f,h;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*k;this.theta=this.lon*k;f=this.phi%g;this.phi=f>=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= 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= b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break; -case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),g=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- -c.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff* +case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),g=c.size[0]/2,k=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- +c.offset[1]-k)/k;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward|| this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",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,h=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Matrix4,n=!1,o=1,p=0,t=0,u=0,v=0,w=0,A=window.innerWidth/2,B=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*w));b=this.delta*this.movementSpeed;this.translateZ(b*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(b*t);this.translateY(b*u);n&&(this.roll+=this.rollSpeed*this.delta*o);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);this.translateY(b*u);n&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +else if(this.forward.y1?e.normalize():e.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(g).setLength(e.x));f.addSelf(g.setLength(e.z));return f}; -this.rotateCamera=function(){var b=Math.acos(h.dot(k)/h.length()/k.length());if(b){var c=(new THREE.Vector3).cross(h,k).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(g);e.multiplyVector3(this.up);e.multiplyVector3(k);this.staticMoving?h=k:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(h))}};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=p.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var c=g.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?o=p:o.addSelf(b.sub(p,o).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(k.dot(h)/k.length()/h.length());if(b){var c=(new THREE.Vector3).cross(k,h).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(g);e.multiplyVector3(this.up);e.multiplyVector3(h);this.staticMoving?k=h:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};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 c=g.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);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), g.lengthSq()0){k(0,0,-p-(h||0));for(n=b;n0){k(0,0,p+ -(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;n0){h(0,0,-o-(k||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;n0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);o.push(p)}c.push(o)}for(var v,w,A,g=c.length,e=0;e0)for(f=0;f1&&(v= -this.vertices[k].position.clone(),w=this.vertices[n].position.clone(),A=this.vertices[o].position.clone(),v.normalize(),w.normalize(),A.normalize(),this.faces.push(new THREE.Face3(k,n,o,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z)])),this.faceVertexUvs[0].push([p,t,B]))}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,k=Math.max(3,c||8),h=Math.max(2,e||6),c=[],e=0;e0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);p.push(o)}c.push(p)}for(var v,w,A,g=c.length,e=0;e0)for(f=0;f1&&(v= +this.vertices[h].position.clone(),w=this.vertices[n].position.clone(),A=this.vertices[p].position.clone(),v.normalize(),w.normalize(),A.normalize(),this.faces.push(new THREE.Face3(h,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z)])),this.faceVertexUvs[0].push([o,t,B]))}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,c,e){w.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function f(b,c,e,f){w.faces.push(new THREE.Face4(b,c,e,f))}this.text=b;var c=c||this.parameters,g=c.height!==void 0?c.height:50,h=c.curveSegments!==void 0?c.curveSegments:4,k=c.font!==void 0?c.font:"helvetiker",m=c.weight!==void 0?c.weight:"normal",n=c.style!==void 0?c.style:"normal",o=c.bezelThickness!==void 0?c.bezelThickness:10,p=c.bezelSize!==void 0?c.bezelSize:8,t=c.bezelEnabled!== -void 0?c.bezelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=k;THREE.FontUtils.weight=m;THREE.FontUtils.style=n;THREE.FontUtils.bezelSize=p;var m=THREE.FontUtils.drawText(b),h=m.points,u=m.faces,k=m.contour,v=m.bezel,w=this;w.vertices=[];w.faces=[];for(var A,n=h.length,B=u.length,p=v.length,m=0;m0;){if(x){if(x.equals(k[m])){x=null;continue}}else x=k[m];o=n*2+m;u=o-1;f(o,u,u+p,o+p);for(t=0;t0;){if(x){if(x.equals(k[m])){x=null;continue}}else x=k[m];for(t=0;t0;){if(x){if(x.equals(h[m])){x=null;continue}}else x=h[m];p=n*2+m;u=p-1;f(p,u,u+o,p+o);for(t=0;t0;){if(x){if(x.equals(h[m])){x=null;continue}}else x=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++}p&&m.push({shape:g,holes:f})}var u,v,w, -A,B,x;h=[];for(k=0;k=0?v-1:g.length-1;var t=u-1>=0?u-1:p.length-1,G=[];G.push(p[u]);G.push(g[v]);G.push(g[e]);w=this.Triangulate.area(G);var z=[];z.push(p[u]);z.push(p[t]);z.push(g[v]);B=this.Triangulate.area(z);A=v;x=u;v+=1;u+=-1;v<0&&(v+=g.length);v%=g.length;u<0&&(u+=p.length);u%=g.length;e=v- -1>=0?v-1:g.length-1;t=u-1>=0?u-1:p.length-1;G=[];G.push(p[u]);G.push(g[v]);G.push(g[e]);G=this.Triangulate.area(G);z=[];z.push(p[u]);z.push(p[t]);z.push(g[v]);z=this.Triangulate.area(z);w+B>G+z&&(v=A,u=x,v<0&&(v+=g.length),v%=g.length,u<0&&(u+=p.length),u%=g.length,e=v-1>=0?v-1:g.length-1,t=u-1>=0?u-1:p.length-1);w=g.slice(0,v);B=g.slice(v);A=p.slice(u);x=p.slice(0,u);h.push(p[u]);h.push(g[v]);h.push(g[e]);h.push(p[u]);h.push(p[t]);h.push(g[v]);g=w.concat(A).concat(x).concat(B)}n.shape=g}u=[];v=[]; -for(k=o=0;k=0;){if(o){if(o.equals(e[b])){o=null;n=this.Triangulate.area(f)>0;k.push(n);h.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;f=0;for(var p;--b>=0;)n=e[b],m=h[f],n=n.clone().subSelf(m), -p=this.bezelSize/n.length(),k[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.bezel=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){var g=[],h,k,m,n,o,p,t,u,v,w,A=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(A){if(A.o){c=A._cachedOutline||(A._cachedOutline=A.o.split(" "));m=c.length;for(b=0;b0&&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,w, +A,B,x;k=[];for(h=0;h=0?v-1:g.length-1;var t=u-1>=0?u-1:o.length-1,G=[];G.push(o[u]);G.push(g[v]);G.push(g[e]);w=this.Triangulate.area(G);var z=[];z.push(o[u]);z.push(o[t]);z.push(g[v]);B=this.Triangulate.area(z);A=v;x=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;G=[];G.push(o[u]);G.push(g[v]);G.push(g[e]);G=this.Triangulate.area(G);z=[];z.push(o[u]);z.push(o[t]);z.push(g[v]);z=this.Triangulate.area(z);w+B>G+z&&(v=A,u=x,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);w=g.slice(0,v);B=g.slice(v);A=o.slice(u);x=o.slice(0,u);k.push(o[u]);k.push(g[v]);k.push(g[e]);k.push(o[u]);k.push(o[t]);k.push(g[v]);g=w.concat(A).concat(x).concat(B)}n.shape=g}u=[];v=[]; +for(h=p=0;h=0;){if(p){if(p.equals(e[b])){p=null;n=this.Triangulate.area(f)>0;h.push(n);k.push(m.divideScalar(f.length));f=[];m=new THREE.Vector2;continue}}else p=e[b];m.addSelf(e[b]);f.push(e[b])}b=e.length;f=0;for(var o;--b>=0;)n=e[b],m=k[f],n=n.clone().subSelf(m), +o=this.bezelSize/n.length(),h[f]?o+=1:o=1-o,o=n.multiplyScalar(o).addSelf(m),g.unshift(o),p?p.equals(e[b])&&(p=null,f++):p=e[b];c.bezel=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){var g=[],k,h,m,n,p,o,t,u,v,w,A=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(A){if(A.o){c=A._cachedOutline||(A._cachedOutline=A.o.split(" "));m=c.length;for(b=0;b0)for(o=0;o2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return h}n=o;g<=n&&(n=0);o=n+1;g<=o&&(o=0);p=o+1;g<=p&&(p=0);var u;a:{u=b;var v=n,w=o,A=p,B=g,x=k,G=void 0,z=void 0,E=void 0, +(function(b){var c=function(b){for(var c=b.length,g=0,k=c-1,h=0;h0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return k}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,w=p,A=o,B=g,x=h,G=void 0,z=void 0,E=void 0, H=void 0,C=void 0,S=void 0,L=void 0,F=void 0,R=void 0,z=u[x[v]].x,E=u[x[v]].y,H=u[x[w]].x,C=u[x[w]].y,S=u[x[A]].x,L=u[x[A]].y;if(1.0E-10>(H-z)*(L-E)-(C-E)*(S-z))u=!1;else{for(G=0;G=0&&j>=0&&ca>=0){u=!1;break a}}u= -!0}}if(u){t=k[n];u=k[o];v=k[p];h.push(b[t]);h.push(b[u]);h.push(b[v]);m.push([k[n],k[o],k[p]]);n=o;for(p=o+1;p>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,c){var e=p(b,c),f=p(b,c+1),h=p(b,c+2);return(p(b,c+3)<<24)+(h<<16)+(f<<8)+e}function n(b,c){var e=p(b,c);return(p(b,c+1)<<8)+e}function o(b,c){var e=p(b,c);return e>127?e-256:e}function p(b, +this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,c,e){b.materials=[];for(var f=0;f>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,c){var e=o(b,c),f=o(b,c+1),h=o(b,c+2);return(o(b,c+3)<<24)+(h<<16)+(f<<8)+e}function n(b,c){var e=o(b,c);return(o(b,c+1)<<8)+e}function p(b,c){var e=o(b,c);return e>127?e-256:e}function o(b, c){return b.charCodeAt(c)&255}function t(c){var e,f,h;e=g(b,c);f=g(b,c+C);h=g(b,c+S);c=n(b,c+L);THREE.BinaryLoader.prototype.f3(x,e,f,h,c)}function u(c){var e,f,h,j,k,o;e=g(b,c);f=g(b,c+C);h=g(b,c+S);j=n(b,c+L);k=g(b,c+F);o=g(b,c+R);c=g(b,c+O);THREE.BinaryLoader.prototype.f3n(x,E,e,f,h,j,k,o,c)}function v(c){var e,f,h,k;e=g(b,c);f=g(b,c+N);h=g(b,c+j);k=g(b,c+T);c=n(b,c+ca);THREE.BinaryLoader.prototype.f4(x,e,f,h,k,c)}function w(c){var e,f,h,k,o,p,t,u;e=g(b,c);f=g(b,c+N);h=g(b,c+j);k=g(b,c+T);o=n(b, c+ca);p=g(b,c+ga);t=g(b,c+Z);u=g(b,c+K);c=g(b,c+$);THREE.BinaryLoader.prototype.f4n(x,E,e,f,h,k,o,p,t,u,c)}function A(c){var e,f;e=g(b,c);f=g(b,c+V);c=g(b,c+W);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],H[e*2],H[e*2+1],H[f*2],H[f*2+1],H[c*2],H[c*2+1])}function B(c){var e,f,h;e=g(b,c);f=g(b,c+aa);h=g(b,c+ma);c=g(b,c+ea);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],H[e*2],H[e*2+1],H[f*2],H[f*2+1],H[h*2],H[h*2+1],H[c*2],H[c*2+1])}var x=this,G=0,z,E=[],H=[],C,S,L,F,R,O,N,j,T,ca,ga,Z,K, -$,V,W,aa,ma,ea,ha,I,Y,X,ja,fa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,f,c);z={signature:b.substr(G,8),header_bytes:p(b,G+8),vertex_coordinate_bytes:p(b,G+9),normal_coordinate_bytes:p(b,G+10),uv_coordinate_bytes:p(b,G+11),vertex_index_bytes:p(b,G+12),normal_index_bytes:p(b,G+13),uv_index_bytes:p(b,G+14),material_index_bytes:p(b,G+15),nvertices:g(b,G+16),nnormals:g(b,G+16+4),nuvs:g(b,G+16+8),ntri_flat:g(b,G+16+12),ntri_smooth:g(b,G+16+16),ntri_flat_uv:g(b,G+16+20),ntri_smooth_uv:g(b, +$,V,W,aa,ma,ea,ha,I,Y,X,ja,fa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,f,c);z={signature:b.substr(G,8),header_bytes:o(b,G+8),vertex_coordinate_bytes:o(b,G+9),normal_coordinate_bytes:o(b,G+10),uv_coordinate_bytes:o(b,G+11),vertex_index_bytes:o(b,G+12),normal_index_bytes:o(b,G+13),uv_index_bytes:o(b,G+14),material_index_bytes:o(b,G+15),nvertices:g(b,G+16),nnormals:g(b,G+16+4),nuvs:g(b,G+16+8),ntri_flat:g(b,G+16+12),ntri_smooth:g(b,G+16+16),ntri_flat_uv:g(b,G+16+20),ntri_smooth_uv:g(b, G+16+24),nquad_flat:g(b,G+16+28),nquad_smooth:g(b,G+16+32),nquad_flat_uv:g(b,G+16+36),nquad_smooth_uv:g(b,G+16+40)};G+=z.header_bytes;C=z.vertex_index_bytes;S=z.vertex_index_bytes*2;L=z.vertex_index_bytes*3;F=z.vertex_index_bytes*3+z.material_index_bytes;R=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes;O=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*2;N=z.vertex_index_bytes;j=z.vertex_index_bytes*2;T=z.vertex_index_bytes*3;ca=z.vertex_index_bytes*4;ga=z.vertex_index_bytes* 4+z.material_index_bytes;Z=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes;K=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*2;$=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*3;V=z.uv_index_bytes;W=z.uv_index_bytes*2;aa=z.uv_index_bytes;ma=z.uv_index_bytes*2;ea=z.uv_index_bytes*3;c=z.vertex_index_bytes*3+z.material_index_bytes;fa=z.vertex_index_bytes*4+z.material_index_bytes;ha=z.ntri_flat*c;I=z.ntri_smooth*(c+z.normal_index_bytes*3);Y=z.ntri_flat_uv* -(c+z.uv_index_bytes*3);X=z.ntri_smooth_uv*(c+z.normal_index_bytes*3+z.uv_index_bytes*3);ja=z.nquad_flat*fa;c=z.nquad_smooth*(fa+z.normal_index_bytes*4);fa=z.nquad_flat_uv*(fa+z.uv_index_bytes*4);G+=function(c){for(var f,g,h,j=z.vertex_coordinate_bytes*3,m=c+z.nvertices*j;c1&&(R=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(C,R);object.name=v;object.position.set(z[0],z[1],z[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=G.visible;K.scene.addObject(object);K.objects[v]=object;G.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),K.scene.collisions.colliders.push(b)); if(G.castsShadow)b=new THREE.ShadowVolume(C),K.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},K.triggers[object.name]=b)}}else z=G.position,r=G.rotation,q=G.quaternion,s=G.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(z[0],z[1],z[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=G.visible!==void 0?G.visible:!1,K.scene.addObject(object),K.objects[v]=object,K.empties[v]=object,G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},K.triggers[object.name]=b)}function n(b){return function(c){K.geometries[b]=c;m();T-=1;e.onLoadComplete();p()}}function o(b){return function(c){K.geometries[b]=c}}function p(){e.callbackProgress({totalModels:ga,totalTextures:Z,loadedModels:ga-T,loadedTextures:Z-ca},K);e.onLoadProgress();T==0&&ca==0&&c(K)} +s[1],s[2]),object.visible=G.visible!==void 0?G.visible:!1,K.scene.addObject(object),K.objects[v]=object,K.empties[v]=object,G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},K.triggers[object.name]=b)}function n(b){return function(c){K.geometries[b]=c;m();T-=1;e.onLoadComplete();o()}}function p(b){return function(c){K.geometries[b]=c}}function o(){e.callbackProgress({totalModels:ga,totalTextures:Z,loadedModels:ga-T,loadedTextures:Z-ca},K);e.onLoadProgress();T==0&&ca==0&&c(K)} var t,u,v,w,A,B,x,G,z,E,H,C,S,L,F,R,O,N,j,T,ca,ga,Z,K;N=b.data;F=new THREE.BinaryLoader;j=new THREE.JSONLoader;ca=T=0;K={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in N.objects)if(G=N.objects[v],G.meshCollider){b=!0;break}if(b)K.scene.collisions=new THREE.CollisionSystem;if(N.transform){b=N.transform.position;E=N.transform.rotation;var $=N.transform.scale;b&&K.scene.position.set(b[0],b[1],b[2]);E&&K.scene.rotation.set(E[0], -E[1],E[2]);$&&K.scene.scale.set($[0],$[1],$[2]);(b||E||$)&&K.scene.updateMatrix()}b=function(){ca-=1;p();e.onLoadComplete()};for(A in N.cameras){E=N.cameras[A];if(E.type=="perspective")S=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho")S=new THREE.Camera,S.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far);z=E.position;E=E.target;S.position.set(z[0],z[1],z[2]);S.target.position.set(E[0],E[1],E[2]);K.cameras[A]=S}for(w in N.lights)A=N.lights[w], +E[1],E[2]);$&&K.scene.scale.set($[0],$[1],$[2]);(b||E||$)&&K.scene.updateMatrix()}b=function(){ca-=1;o();e.onLoadComplete()};for(A in N.cameras){E=N.cameras[A];if(E.type=="perspective")S=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho")S=new THREE.Camera,S.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far);z=E.position;E=E.target;S.position.set(z[0],z[1],z[2]);S.target.position.set(E[0],E[1],E[2]);K.cameras[A]=S}for(w in N.lights)A=N.lights[w], S=A.color!==void 0?A.color:16777215,E=A.intensity!==void 0?A.intensity:1,A.type=="directional"?(z=A.direction,O=new THREE.DirectionalLight(S,E),O.position.set(z[0],z[1],z[2]),O.position.normalize()):A.type=="point"?(z=A.position,d=A.distance,O=new THREE.PointLight(S,E,d),O.position.set(z[0],z[1],z[2])):A.type=="ambient"&&(O=new THREE.AmbientLight(S)),K.scene.addLight(O),K.lights[w]=O;for(B in N.fogs)w=N.fogs[B],w.type=="linear"?L=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(L=new THREE.FogExp2(0, w.density)),E=w.color,L.color.setRGB(E[0],E[1],E[2]),K.fogs[B]=L;if(K.cameras&&N.defaults.camera)K.currentCamera=K.cameras[N.defaults.camera];if(K.fogs&&N.defaults.fog)K.scene.fog=K.fogs[N.defaults.fog];E=N.defaults.bgcolor;K.bgColor=new THREE.Color;K.bgColor.setRGB(E[0],E[1],E[2]);K.bgColorAlpha=N.defaults.bgalpha;for(t in N.geometries)if(B=N.geometries[t],B.type=="bin_mesh"||B.type=="ascii_mesh")T+=1,e.onLoadStart();ga=T;for(t in N.geometries)B=N.geometries[t],B.type=="cube"?(C=new THREE.CubeGeometry(B.width, B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),K.geometries[t]=C):B.type=="plane"?(C=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),K.geometries[t]=C):B.type=="sphere"?(C=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),K.geometries[t]=C):B.type=="cylinder"?(C=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),K.geometries[t]=C):B.type=="torus"?(C=new THREE.TorusGeometry(B.radius, -B.tube,B.segmentsR,B.segmentsT),K.geometries[t]=C):B.type=="icosahedron"?(C=new THREE.IcosahedronGeometry(B.subdivisions),K.geometries[t]=C):B.type=="bin_mesh"?F.load({model:f(B.url,N.urlBaseType),callback:n(t)}):B.type=="ascii_mesh"?j.load({model:f(B.url,N.urlBaseType),callback:n(t)}):B.type=="embedded_mesh"&&(B=N.embeds[B.id])&&j.createModel(B,o(t),"");for(x in N.textures)if(t=N.textures[x],t.url instanceof Array){ca+=t.url.length;for(F=0;F=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(o-m);u<1&&(u=1);o=Math.floor(o+m);o>this.size-1&&(o=this.size-1);var v=Math.floor(p-m);v<1&&(v=1);m=Math.floor(p+m);m>this.size-1&&(m=this.size- -1);for(var w,A,B,x,G,z;t0&&(this.field[B+w]+=x)}}};this.addPlaneX=function(b,c){var g,h,k,m,n,o=this.size,p=this.yd,t=this.zd,u=this.field,v=o*Math.sqrt(b/c);v>o&&(v=o);for(g=0;g0)for(h=0;hp&&(w=p);for(h=0;h0){n=h*t;for(g=0;gsize&&(dist=size);for(k=0;k0){n=zd*k;for(h=0;h=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 w,A,B,x,G,z;t0&&(this.field[B+w]+=x)}}};this.addPlaneX=function(b,c){var g,k,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(k=0;ko&&(w=o);for(k=0;k0){n=k*t;for(g=0;gsize&&(dist=size);for(h=0;h0){n=zd*h;for(k=0;kh?this.hits.push(g):this.hits.unshift(g),h=f;return this.hits}; +THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,g,k=0;c=0;for(e=this.colliders.length;ck?this.hits.push(g):this.hits.unshift(g),k=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,h=0;h=m*g))return Number.MAX_VALUE;k/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(k);m.addSelf(b.origin);Math.abs(h.x)>Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=m.y-c.y,h=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,h=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(h.y)>Math.abs(h.z)?(b=m.x-c.x,h=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,h=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=h*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*=h*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return k}; +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,k=0;k=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(k.x)>Math.abs(k.y)?Math.abs(k.x)>Math.abs(k.z)?(b=m.y-c.y,k=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,k=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(k.y)>Math.abs(k.z)?(b=m.x-c.x,k=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,k=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=k*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*=k*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,h=0,k=0,m=0,n=0,o=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,o=!1,k=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, -o=!1,m=1);e.origin.zc.max.z&&(h=c.max.z-e.origin.z,h/=e.direction.z,o=!1,n=1);if(o)return-1;o=0;g>f&&(o=1,f=g);h>f&&(o=2,f=h);switch(o){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(k,0,0);break;case 1:k=e.origin.x+e.direction.x*f;if(kc.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:k=e.origin.x+e.direction.x*f;if(kc.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,k=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&&(k=c.max.z-e.origin.z,k/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;g>f&&(p=1,f=g);k>f&&(p=2,f=k);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.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,h=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.WebGLRenderTarget(512,512,b),n=new THREE.Camera(53,1,1,1E4);n.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:k},mapRight:{type:"t",value:1, -texture:m}},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 o= -new THREE.Scene;o.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);k.width=b;k.height=f;m.width=b;m.height=f};this.render=function(b,e){g.projectionMatrix=e.projectionMatrix;g.position.copy(e.position);g.target.position.copy(e.target.position);g.translateX(-10);h.projectionMatrix=e.projectionMatrix;h.position.copy(e.position);h.target.position.copy(e.target.position);h.translateX(10);f.call(c,b,g,k,!0);f.call(c,b,h,m,!0);f.call(c,o,n)}}; -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,h,k=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;h=f};this.render=function(b,e){this.clear();k.fov=e.fov;k.aspect=0.5*e.aspect;k.near=e.near;k.far=e.far; -k.updateProjectionMatrix();k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(c.separation);m.projectionMatrix=k.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,h);f.call(c,b,k);this.setViewport(g,0,g,h);f.call(c,b,m,!1)}}; +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,k=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},h=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.WebGLRenderTarget(512,512,b),n=new THREE.Camera(53,1,1,1E4);n.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:h},mapRight:{type:"t",value:1, +texture:m}},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 p= +new THREE.Scene;p.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);h.width=b;h.height=f;m.width=b;m.height=f};this.render=function(b,e){g.projectionMatrix=e.projectionMatrix;g.position.copy(e.position);g.target.position.copy(e.target.position);g.translateX(-10);k.projectionMatrix=e.projectionMatrix;k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(10);f.call(c,b,g,h,!0);f.call(c,b,k,m,!0);f.call(c,p,n)}}; +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,k,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;k=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,k);f.call(c,b,h);this.setViewport(g,0,g,k);f.call(c,b,m,!1)}}; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index cc9edf4a..3a71939b 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -1,186 +1,188 @@ // ThreeExtras.js r41/ROME - http://github.com/mrdoob/three.js -THREE.ColorUtils={adjustHSV:function(a,b,c,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+b,0,1);f.s=THREE.ColorUtils.clamp(f.s+c,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,f=a.b,g=Math.max(Math.max(c,e),f),h=Math.min(Math.min(c,e),f);if(h==g)h=c=0;else{var k=g-h,h=k/g,c=c==g?(e-f)/k:e==g?2+(f-c)/k:4+(c-e)/k;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=h;b.v=g;return b}, +THREE.ColorUtils={adjustHSV:function(a,b,c,f){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.ColorUtils.clamp(e.h+b,0,1);e.s=THREE.ColorUtils.clamp(e.s+c,0,1);e.v=THREE.ColorUtils.clamp(e.v+f,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,f=a.g,e=a.b,h=Math.max(Math.max(c,f),e),g=Math.min(Math.min(c,f),e);if(g==h)g=c=0;else{var k=h-g,g=k/h,c=c==h?(f-e)/k:f==h?2+(e-c)/k:4+(c-f)/k;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=h;return b}, clamp:function(a,b,c){return ac?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var l=0,n=h.length;l 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ 0 ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ 0 ].xyz + vViewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ 0 ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ 0 ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;\n}", +normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.lights,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c", +value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1}}]),fragmentShader:"uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;\n}", vertexShader:"attribute vec4 tangent;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t", value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=e=0;b25&&(h=25);e=(h-1)*0.5;c=Array(h);for(b=f=0;b1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(g[0]-f[0])*e,c.y=f[1]+(g[1]-f[1])*e,c.z=f[2]+(g[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",o,h.index-1).pos,this.points[1]=f,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",o,k.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),c.x=f[0],c.y=f[1],c.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(c=== -"rot")THREE.Quaternion.slerp(f,g,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=f[0]+(g[0]-f[0])*e,c.y=f[1]+(g[1]-f[1])*e,c.z=f[2]+(g[2]-f[2])*e}}if(this.JITCompile&&l[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(o=0;oa.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];k=a[c[1]];j=a[c[2]];m=a[c[3]];c=f*f;h=f*c;e[0]=this.interpolate(g[0],k[0],j[0],m[0],f,c,h);e[1]=this.interpolate(g[1],k[1],j[1],m[1],f,c,h);e[2]=this.interpolate(g[2],k[2],j[2],m[2],f,c,h);return e}; -THREE.Animation.prototype.interpolate=function(a,b,c,e,f,g,h){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*h+(-3*(b-c)-2*a-e)*g+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[e.length-1]}; +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,f,e,h,g,k,j,m,l=this.data.JIT.hierarchy,n,o;this.currentTime+=a*this.timeScale;o=this.currentTime;n=this.currentTime%=this.data.length;m=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,v=this.hierarchy.length;p1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+p),f=f<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(h[0]-e[0])*f,c.y=e[1]+(h[1]-e[1])*f,c.z=e[2]+(h[2]-e[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",p,g.index-1).pos,this.points[1]=e,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos,f=f*0.33+0.33,e=this.interpolateCatmullRom(this.points,f),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,f,0)}else if(c=== +"rot")THREE.Quaternion.slerp(e,h,a.quaternion,f);else if(c==="scl")c=a.scale,c.x=e[0]+(h[0]-e[0])*f,c.y=e[1]+(h[1]-e[1])*f,c.z=e[2]+(h[2]-e[2])*f}}if(this.JITCompile&&l[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;pa.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];k=a[c[1]];j=a[c[2]];m=a[c[3]];c=e*e;g=e*c;f[0]=this.interpolate(h[0],k[0],j[0],m[0],e,c,g);f[1]=this.interpolate(h[1],k[1],j[1],m[1],e,c,g);f[2]=this.interpolate(h[2],k[2],j[2],m[2],e,c,g);return f}; +THREE.Animation.prototype.interpolate=function(a,b,c,f,e,h,g){a=(c-a)*0.5;f=(f-b)*0.5;return(2*(b-c)+a+f)*g+(-3*(b-c)-2*a-f)*h+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var f=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][a]!==void 0)return f[c];return this.data.hierarchy[b].keys[f.length-1]}; THREE.QuakeCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.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(a){if(a.movementSpeed!==void 0)this.movementSpeed= a.movementSpeed;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.noFly!==void 0)this.noFly=a.noFly;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.autoForward!==void 0)this.autoForward=a.autoForward;if(a.activeLook!==void 0)this.activeLook=a.activeLook;if(a.heightSpeed!==void 0)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==void 0)this.heightCoef=a.heightCoef;if(a.heightMin!==void 0)this.heightMin=a.heightMin;if(a.heightMax!==void 0)this.heightMax=a.heightMax;if(a.constrainVertical!== void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this.verticalMin=a.verticalMin;if(a.verticalMax!==void 0)this.verticalMax=a.verticalMax;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){a.preventDefault(); a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.mouseX=a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward= !0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor= this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var b=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.translateZ(b);this.moveLeft&&this.translateX(-b);this.moveRight&&this.translateX(b);b=this.tdiff*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&& -(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi= -(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown), +(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi= +(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown), !1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; THREE.QuakeCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))}; -THREE.PathCamera=function(a){function b(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},f,h=c.getControlPointsArray(),k=c.getLength(),j=h.length,y=0;f=j-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[f]={time:e,pos:h[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?e:e+f;e=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var k=h[1]-h[0];this.phi= -TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(h[1]-h[0])/(e[1]-e[0])+h[0]-h[0])/k)*k+h[0];e=this.horizontalAngleMap.srcRange;h=this.horizontalAngleMap.dstRange;k=h[1]-h[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(h[1]-h[0])/(e[1]-e[0])+h[0]-h[0])/k)*k+h[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,c,b)};this.onMouseMove=function(a){this.mouseX= -a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),h=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.CubeGeometry(10,10,20),j=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation= -b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,c){return function(){c.apply(a,arguments)}}(this,this.onMouseMove), +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,h=Math.PI/180;this.update=function(a,c,b){var f,g;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;f=this.phi%e;this.phi=f>=0?f:f+e;f=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var k=g[1]-g[0];this.phi= +TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/k)*k+g[0];f=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;k=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/k)*k+g[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,a,c,b)};this.onMouseMove=function(a){this.mouseX= +a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),g=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.CubeGeometry(10,10,20),j=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation= +b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(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(a,c){return function(){c.apply(a,arguments)}}(this,this.onMouseMove), !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward= a.autoForward;if(a.domElement!==void 0)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break; -case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),f=b.size[0]/2,g=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-f)/f;this.moveState.pitchDown=(a.clientY- -b.offset[1]-g)/g;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,b=this.tdiff* +case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),e=b.size[0]/2,h=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-e)/e;this.moveState.pitchDown=(a.clientY- +b.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,b=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*b,this.rotationVector.y*b,this.rotationVector.z*b,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var a=this.moveState.forward|| this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,this.mouseup),!1);window.addEventListener("keydown",b(this,this.keydown),!1);window.addEventListener("keyup",b(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(a,b,c,e){THREE.Camera.call(this,a,b,c,e);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 f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Matrix4,j=!1,m=1,l=0,n=0,p=0,o=0,v=0,u=window.innerWidth/2,w=window.innerHeight/2;this.update= -function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*o),this.rotateVertically(a*v));a=this.delta*this.movementSpeed;this.translateZ(a*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(a*n);this.translateY(a*p);j&&(this.roll+=this.rollSpeed*this.delta*m);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(l<0)?1:l));this.translateX(a*n);this.translateY(a*o);j&&(this.roll+=this.rollSpeed*this.delta*m);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +else if(this.forward.y1?b.normalize():b.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(b.y);e.addSelf(this.up.clone().crossSelf(f).setLength(b.x));e.addSelf(f.setLength(b.z));return e}; -this.rotateCamera=function(){var a=Math.acos(g.dot(h)/g.length()/h.length());if(a){var c=(new THREE.Vector3).cross(g,h).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(f);b.multiplyVector3(this.up);b.multiplyVector3(h);this.staticMoving?g=h:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(g))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var a=l.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(f.length()*this.panSpeed);var c=f.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?m=l:m.addSelf(a.sub(l,m).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), -f.lengthSq()1?b.normalize():b.z=Math.sqrt(1-f*f);e=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(b.y);f.addSelf(this.up.clone().crossSelf(e).setLength(b.x));f.addSelf(e.setLength(b.z));return f}; +this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var c=(new THREE.Vector3).cross(h,g).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(e);b.multiplyVector3(this.up);b.multiplyVector3(g);this.staticMoving?h=g:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*this.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),this.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var a=l.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(e.length()*this.panSpeed);var c=e.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?m=l:m.addSelf(a.sub(l,m).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +e.lengthSq()0){h(0,0,-l-(g||0));for(j=a;j0){h(0,0,l+ -(f||0));for(j=a+a/2;j<2*a;j++)k.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0){g(0,0,-l-(h||0));for(j=a;j0){g(0,0,l+ +(e||0));for(j=a+a/2;j<2*a;j++)k.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,k,p)))-1);m.push(l)}b.push(m)}for(var o,v,u,f=b.length,c=0;c0)for(e=0;e1&&(o= -this.vertices[h].position.clone(),v=this.vertices[j].position.clone(),u=this.vertices[m].position.clone(),o.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([l,n,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,f,e=Math.PI,h=Math.max(3,b||8),g=Math.max(2,c||6),b=[],c=0;c0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,k,o)))-1);m.push(l)}b.push(m)}for(var p,v,u,e=b.length,c=0;c0)for(f=0;f1&&(p= +this.vertices[g].position.clone(),v=this.vertices[j].position.clone(),u=this.vertices[m].position.clone(),p.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(g,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([l,n,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(a,b){THREE.Geometry.call(this);this.parameters=b||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; -THREE.TextGeometry.prototype.set=function(a,b){function c(a,c,b){v.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function e(a,c,b,e){v.faces.push(new THREE.Face4(a,c,b,e))}this.text=a;var b=b||this.parameters,f=b.height!==void 0?b.height:50,g=b.curveSegments!==void 0?b.curveSegments:4,h=b.font!==void 0?b.font:"helvetiker",k=b.weight!==void 0?b.weight:"normal",j=b.style!==void 0?b.style:"normal",m=b.bezelThickness!==void 0?b.bezelThickness:10,l=b.bezelSize!==void 0?b.bezelSize:8,n=b.bezelEnabled!== -void 0?b.bezelEnabled:!1;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=g;THREE.FontUtils.face=h;THREE.FontUtils.weight=k;THREE.FontUtils.style=j;THREE.FontUtils.bezelSize=l;var k=THREE.FontUtils.drawText(a),g=k.points,p=k.faces,h=k.contour,o=k.bezel,v=this;v.vertices=[];v.faces=[];for(var u,j=g.length,w=p.length,l=o.length,k=0;k0;){if(x){if(x.equals(h[k])){x=null;continue}}else x=h[k];m=j*2+k;p=m-1;e(m,p,p+l,m+l);for(n=0;n0;){if(x){if(x.equals(h[k])){x=null;continue}}else x=h[k];for(n=0;n0;){if(x){if(x.equals(g[k])){x=null;continue}}else x=g[k];m=j*2+k;o=m-1;f(m,o,o+l,m+l);for(n=0;n0;){if(x){if(x.equals(g[k])){x=null;continue}}else x=g[k];for(n=0;n0&&k.push({shape:f,holes:e}),f=n,e=[]):e.push(n):this.Triangulate.area(n)<0?(k.push({shape:n,holes:e}),e=[]):e.push(n);c++}l&&k.push({shape:f,holes:e})}var p,o,v, -u,w,x;g=[];for(h=0;h=0?o-1:f.length-1;var n=p-1>=0?p-1:l.length-1,y=[];y.push(l[p]);y.push(f[o]);y.push(f[c]);v=this.Triangulate.area(y);var t=[];t.push(l[p]);t.push(l[n]);t.push(f[o]);w=this.Triangulate.area(t);u=o;x=p;o+=1;p+=-1;o<0&&(o+=f.length);o%=f.length;p<0&&(p+=l.length);p%=f.length;c=o- -1>=0?o-1:f.length-1;n=p-1>=0?p-1:l.length-1;y=[];y.push(l[p]);y.push(f[o]);y.push(f[c]);y=this.Triangulate.area(y);t=[];t.push(l[p]);t.push(l[n]);t.push(f[o]);t=this.Triangulate.area(t);v+w>y+t&&(o=u,p=x,o<0&&(o+=f.length),o%=f.length,p<0&&(p+=l.length),p%=f.length,c=o-1>=0?o-1:f.length-1,n=p-1>=0?p-1:l.length-1);v=f.slice(0,o);w=f.slice(o);u=l.slice(p);x=l.slice(0,p);g.push(l[p]);g.push(f[o]);g.push(f[c]);g.push(l[p]);g.push(l[n]);g.push(f[o]);f=v.concat(u).concat(x).concat(w)}j.shape=f}p=[];o=[]; -for(h=m=0;h=0;){if(m){if(m.equals(c[a])){m=null;j=this.Triangulate.area(e)>0;h.push(j);g.push(k.divideScalar(e.length));e=[];k=new THREE.Vector2;continue}}else m=c[a];k.addSelf(c[a]);e.push(c[a])}a=c.length;e=0;for(var l;--a>=0;)j=c[a],k=g[e],j=j.clone().subSelf(k), -l=this.bezelSize/j.length(),h[e]?l+=1:l=1-l,l=j.multiplyScalar(l).addSelf(k),f.unshift(l),m?m.equals(c[a])&&(m=null,e++):m=c[a];b.bezel=f;return b},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,e){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,e)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a* -b},b3:function(a,b,c,e,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,e)+this.b3p3(a,f)},extractGlyphPoints:function(a,b,c,e){var f=[],g,h,k,j,m,l,n,p,o,v,u=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(u){if(u.o){b=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=b.length;for(a=0;a0)for(m=0;m2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return g}j=m;f<=j&&(j=0);m=j+1;f<=m&&(m=0);l=m+1;f<=l&&(l=0);var p;a:{p=a;var o=j,v=m,u=l,w=f,x=h,y=void 0,t=void 0,z=void 0, -B=void 0,E=void 0,F=void 0,G=void 0,D=void 0,K=void 0,t=p[x[o]].x,z=p[x[o]].y,B=p[x[v]].x,E=p[x[v]].y,F=p[x[u]].x,G=p[x[u]].y;if(1.0E-10>(B-t)*(G-z)-(E-z)*(F-t))p=!1;else{for(y=0;y=0&&J>=0&&H>=0){p=!1;break a}}p=!0}}if(p){n= -h[j];p=h[m];o=h[l];g.push(a[n]);g.push(a[p]);g.push(a[o]);k.push([h[j],h[m],h[l]]);j=m;for(l=m+1;l0&&k.push({shape:e,holes:f}),e=n,f=[]):f.push(n):this.Triangulate.area(n)<0?(k.push({shape:n,holes:f}),f=[]):f.push(n);c++}l&&k.push({shape:e,holes:f})}var o,p,v, +u,w,x;h=[];for(g=0;g=0?p-1:e.length-1;var n=o-1>=0?o-1:l.length-1,y=[];y.push(l[o]);y.push(e[p]);y.push(e[c]);v=this.Triangulate.area(y);var t=[];t.push(l[o]);t.push(l[n]);t.push(e[p]);w=this.Triangulate.area(t);u=p;x=o;p+=1;o+=-1;p<0&&(p+=e.length);p%=e.length;o<0&&(o+=l.length);o%=e.length;c=p- +1>=0?p-1:e.length-1;n=o-1>=0?o-1:l.length-1;y=[];y.push(l[o]);y.push(e[p]);y.push(e[c]);y=this.Triangulate.area(y);t=[];t.push(l[o]);t.push(l[n]);t.push(e[p]);t=this.Triangulate.area(t);v+w>y+t&&(p=u,o=x,p<0&&(p+=e.length),p%=e.length,o<0&&(o+=l.length),o%=e.length,c=p-1>=0?p-1:e.length-1,n=o-1>=0?o-1:l.length-1);v=e.slice(0,p);w=e.slice(p);u=l.slice(o);x=l.slice(0,o);h.push(l[o]);h.push(e[p]);h.push(e[c]);h.push(l[o]);h.push(l[n]);h.push(e[p]);e=v.concat(u).concat(x).concat(w)}j.shape=e}o=[];p=[]; +for(g=m=0;g=0;){if(m){if(m.equals(c[a])){m=null;j=this.Triangulate.area(f)>0;g.push(j);h.push(k.divideScalar(f.length));f=[];k=new THREE.Vector2;continue}}else m=c[a];k.addSelf(c[a]);f.push(c[a])}a=c.length;f=0;for(var l;--a>=0;)j=c[a],k=h[f],j=j.clone().subSelf(k), +l=this.bezelSize/j.length(),g[f]?l+=1:l=1-l,l=j.multiplyScalar(l).addSelf(k),e.unshift(l),m?m.equals(c[a])&&(m=null,f++):m=c[a];b.bezel=e;return b},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,f){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,f)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a* +b},b3:function(a,b,c,f,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,f)+this.b3p3(a,e)},extractGlyphPoints:function(a,b,c,f){var e=[],h,g,k,j,m,l,n,o,p,v,u=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(u){if(u.o){b=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=b.length;for(a=0;a0)for(m=0;m2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return k;return h}j=m;e<=j&&(j=0);m=j+1;e<=m&&(m=0);l=m+1;e<=l&&(l=0);var o;a:{o=a;var p=j,v=m,u=l,w=e,x=g,y=void 0,t=void 0,z=void 0, +B=void 0,E=void 0,F=void 0,G=void 0,D=void 0,K=void 0,t=o[x[p]].x,z=o[x[p]].y,B=o[x[v]].x,E=o[x[v]].y,F=o[x[u]].x,G=o[x[u]].y;if(1.0E-10>(B-t)*(G-z)-(E-z)*(F-t))o=!1;else{for(y=0;y=0&&J>=0&&H>=0){o=!1;break a}}o=!0}}if(o){n= +g[j];o=g[m];p=g[l];h.push(a[n]);h.push(a[o]);h.push(a[p]);k.push([g[j],g[m],g[l]]);j=m;for(l=m+1;l>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function f(a,c){var b=l(a,c),e=l(a,c+1),g=l(a,c+2);return(l(a,c+3)<<24)+(g<<16)+(e<<8)+b}function j(a,c){var b=l(a,c);return(l(a,c+1)<<8)+b}function m(a,c){var b=l(a,c);return b>127?b-256:b}function l(a, -c){return a.charCodeAt(c)&255}function n(c){var b,e,g;b=f(a,c);e=f(a,c+E);g=f(a,c+F);c=j(a,c+G);THREE.BinaryLoader.prototype.f3(x,b,e,g,c)}function p(c){var b,e,g,h,m,l;b=f(a,c);e=f(a,c+E);g=f(a,c+F);h=j(a,c+G);m=f(a,c+D);l=f(a,c+K);c=f(a,c+I);THREE.BinaryLoader.prototype.f3n(x,z,b,e,g,h,m,l,c)}function o(c){var b,e,g,h;b=f(a,c);e=f(a,c+C);g=f(a,c+J);h=f(a,c+L);c=j(a,c+H);THREE.BinaryLoader.prototype.f4(x,b,e,g,h,c)}function v(c){var b,e,g,h,m,l,n,o;b=f(a,c);e=f(a,c+C);g=f(a,c+J);h=f(a,c+L);m=j(a, -c+H);l=f(a,c+N);n=f(a,c+O);o=f(a,c+A);c=f(a,c+P);THREE.BinaryLoader.prototype.f4n(x,z,b,e,g,h,m,l,n,o,c)}function u(c){var b,e;b=f(a,c);e=f(a,c+M);c=f(a,c+R);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],B[b*2],B[b*2+1],B[e*2],B[e*2+1],B[c*2],B[c*2+1])}function w(c){var b,e,g;b=f(a,c);e=f(a,c+S);g=f(a,c+Y);c=f(a,c+Z);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],B[b*2],B[b*2+1],B[e*2],B[e*2+1],B[g*2],B[g*2+1],B[c*2],B[c*2+1])}var x=this,y=0,t,z=[],B=[],E,F,G,D,K,I,C,J,L,H,N,O,A,P,M,R, -S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,c);t={signature:a.substr(y,8),header_bytes:l(a,y+8),vertex_coordinate_bytes:l(a,y+9),normal_coordinate_bytes:l(a,y+10),uv_coordinate_bytes:l(a,y+11),vertex_index_bytes:l(a,y+12),normal_index_bytes:l(a,y+13),uv_index_bytes:l(a,y+14),material_index_bytes:l(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a,y+16+20),ntri_smooth_uv:f(a,y+ -16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=t.header_bytes;E=t.vertex_index_bytes;F=t.vertex_index_bytes*2;G=t.vertex_index_bytes*3;D=t.vertex_index_bytes*3+t.material_index_bytes;K=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;I=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;J=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;H=t.vertex_index_bytes*4;N=t.vertex_index_bytes* +this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,b,c){a.materials=[];for(var f=0;f>7)-127;f|=(g&127)<<16|e<<8;if(f==0&&j==-127)return 0;return(1-2*(h>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,j)}function e(a,c){var b=l(a,c),f=l(a,c+1),g=l(a,c+2);return(l(a,c+3)<<24)+(g<<16)+(f<<8)+b}function j(a,c){var b=l(a,c);return(l(a,c+1)<<8)+b}function m(a,c){var b=l(a,c);return b>127?b-256:b}function l(a, +c){return a.charCodeAt(c)&255}function n(c){var b,f,g;b=e(a,c);f=e(a,c+E);g=e(a,c+F);c=j(a,c+G);THREE.BinaryLoader.prototype.f3(x,b,f,g,c)}function o(c){var b,f,g,h,l,m;b=e(a,c);f=e(a,c+E);g=e(a,c+F);h=j(a,c+G);l=e(a,c+D);m=e(a,c+K);c=e(a,c+I);THREE.BinaryLoader.prototype.f3n(x,z,b,f,g,h,l,m,c)}function p(c){var b,f,g,h;b=e(a,c);f=e(a,c+C);g=e(a,c+J);h=e(a,c+L);c=j(a,c+H);THREE.BinaryLoader.prototype.f4(x,b,f,g,h,c)}function v(c){var b,f,g,h,l,m,n,o;b=e(a,c);f=e(a,c+C);g=e(a,c+J);h=e(a,c+L);l=j(a, +c+H);m=e(a,c+N);n=e(a,c+O);o=e(a,c+A);c=e(a,c+P);THREE.BinaryLoader.prototype.f4n(x,z,b,f,g,h,l,m,n,o,c)}function u(c){var b,f;b=e(a,c);f=e(a,c+M);c=e(a,c+R);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],B[b*2],B[b*2+1],B[f*2],B[f*2+1],B[c*2],B[c*2+1])}function w(c){var b,f,g;b=e(a,c);f=e(a,c+S);g=e(a,c+Y);c=e(a,c+Z);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],B[b*2],B[b*2+1],B[f*2],B[f*2+1],B[g*2],B[g*2+1],B[c*2],B[c*2+1])}var x=this,y=0,t,z=[],B=[],E,F,G,D,K,I,C,J,L,H,N,O,A,P,M,R, +S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,f,c);t={signature:a.substr(y,8),header_bytes:l(a,y+8),vertex_coordinate_bytes:l(a,y+9),normal_coordinate_bytes:l(a,y+10),uv_coordinate_bytes:l(a,y+11),vertex_index_bytes:l(a,y+12),normal_index_bytes:l(a,y+13),uv_index_bytes:l(a,y+14),material_index_bytes:l(a,y+15),nvertices:e(a,y+16),nnormals:e(a,y+16+4),nuvs:e(a,y+16+8),ntri_flat:e(a,y+16+12),ntri_smooth:e(a,y+16+16),ntri_flat_uv:e(a,y+16+20),ntri_smooth_uv:e(a,y+ +16+24),nquad_flat:e(a,y+16+28),nquad_smooth:e(a,y+16+32),nquad_flat_uv:e(a,y+16+36),nquad_smooth_uv:e(a,y+16+40)};y+=t.header_bytes;E=t.vertex_index_bytes;F=t.vertex_index_bytes*2;G=t.vertex_index_bytes*3;D=t.vertex_index_bytes*3+t.material_index_bytes;K=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;I=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;J=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;H=t.vertex_index_bytes*4;N=t.vertex_index_bytes* 4+t.material_index_bytes;O=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;A=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;P=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;M=t.uv_index_bytes;R=t.uv_index_bytes*2;S=t.uv_index_bytes;Y=t.uv_index_bytes*2;Z=t.uv_index_bytes*3;c=t.vertex_index_bytes*3+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes;T=t.ntri_flat*c;U=t.ntri_smooth*(c+t.normal_index_bytes*3);V=t.ntri_flat_uv* -(c+t.uv_index_bytes*3);W=t.ntri_smooth_uv*(c+t.normal_index_bytes*3+t.uv_index_bytes*3);X=t.nquad_flat*Q;c=t.nquad_smooth*(Q+t.normal_index_bytes*4);Q=t.nquad_flat_uv*(Q+t.uv_index_bytes*4);y+=function(c){for(var e,f,g,j=t.vertex_coordinate_bytes*3,k=c+t.nvertices*j;c1&&(K=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,K);object.name=o;object.position.set(t[0],t[1],t[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=y.visible;A.scene.addObject(object);A.objects[o]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),A.scene.collisions.colliders.push(a)); -if(y.castsShadow)a=new THREE.ShadowVolume(E),A.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},A.triggers[object.name]=a)}}else t=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=o,object.position.set(t[0],t[1],t[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=y.visible!==void 0?y.visible:!1,A.scene.addObject(object),A.objects[o]=object,A.empties[o]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},A.triggers[object.name]=a)}function j(a){return function(b){A.geometries[a]=b;k();L-=1;c.onLoadComplete();l()}}function m(a){return function(c){A.geometries[a]=c}}function l(){c.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},A);c.onLoadProgress();L==0&&H==0&&b(A)}var n, -p,o,v,u,w,x,y,t,z,B,E,F,G,D,K,I,C,J,L,H,N,O,A;C=a.data;D=new THREE.BinaryLoader;J=new THREE.JSONLoader;H=L=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(o in C.objects)if(y=C.objects[o],y.meshCollider){a=!0;break}if(a)A.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;z=C.transform.rotation;var P=C.transform.scale;a&&A.scene.position.set(a[0],a[1],a[2]);z&&A.scene.rotation.set(z[0], +(c+t.uv_index_bytes*3);W=t.ntri_smooth_uv*(c+t.normal_index_bytes*3+t.uv_index_bytes*3);X=t.nquad_flat*Q;c=t.nquad_smooth*(Q+t.normal_index_bytes*4);Q=t.nquad_flat_uv*(Q+t.uv_index_bytes*4);y+=function(c){for(var f,e,h,j=t.vertex_coordinate_bytes*3,k=c+t.nvertices*j;c1&&(K=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,K);object.name=p;object.position.set(t[0],t[1],t[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=y.visible;A.scene.addObject(object);A.objects[p]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),A.scene.collisions.colliders.push(a)); +if(y.castsShadow)a=new THREE.ShadowVolume(E),A.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},A.triggers[object.name]=a)}}else t=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(t[0],t[1],t[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=y.visible!==void 0?y.visible:!1,A.scene.addObject(object),A.objects[p]=object,A.empties[p]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},A.triggers[object.name]=a)}function j(a){return function(b){A.geometries[a]=b;k();L-=1;c.onLoadComplete();l()}}function m(a){return function(c){A.geometries[a]=c}}function l(){c.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},A);c.onLoadProgress();L==0&&H==0&&b(A)}var n, +o,p,v,u,w,x,y,t,z,B,E,F,G,D,K,I,C,J,L,H,N,O,A;C=a.data;D=new THREE.BinaryLoader;J=new THREE.JSONLoader;H=L=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in C.objects)if(y=C.objects[p],y.meshCollider){a=!0;break}if(a)A.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;z=C.transform.rotation;var P=C.transform.scale;a&&A.scene.position.set(a[0],a[1],a[2]);z&&A.scene.rotation.set(z[0], z[1],z[2]);P&&A.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&A.scene.updateMatrix()}a=function(){H-=1;l();c.onLoadComplete()};for(u in C.cameras){z=C.cameras[u];if(z.type=="perspective")F=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")F=new THREE.Camera,F.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);t=z.position;z=z.target;F.position.set(t[0],t[1],t[2]);F.target.position.set(z[0],z[1],z[2]);A.cameras[u]=F}for(v in C.lights)u=C.lights[v], F=u.color!==void 0?u.color:16777215,z=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(t=u.direction,I=new THREE.DirectionalLight(F,z),I.position.set(t[0],t[1],t[2]),I.position.normalize()):u.type=="point"?(t=u.position,d=u.distance,I=new THREE.PointLight(F,z,d),I.position.set(t[0],t[1],t[2])):u.type=="ambient"&&(I=new THREE.AmbientLight(F)),A.scene.addLight(I),A.lights[v]=I;for(w in C.fogs)v=C.fogs[w],v.type=="linear"?G=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(G=new THREE.FogExp2(0, v.density)),z=v.color,G.color.setRGB(z[0],z[1],z[2]),A.fogs[w]=G;if(A.cameras&&C.defaults.camera)A.currentCamera=A.cameras[C.defaults.camera];if(A.fogs&&C.defaults.fog)A.scene.fog=A.fogs[C.defaults.fog];z=C.defaults.bgcolor;A.bgColor=new THREE.Color;A.bgColor.setRGB(z[0],z[1],z[2]);A.bgColorAlpha=C.defaults.bgalpha;for(n in C.geometries)if(w=C.geometries[n],w.type=="bin_mesh"||w.type=="ascii_mesh")L+=1,c.onLoadStart();N=L;for(n in C.geometries)w=C.geometries[n],w.type=="cube"?(E=new THREE.CubeGeometry(w.width, w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),A.geometries[n]=E):w.type=="plane"?(E=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),A.geometries[n]=E):w.type=="sphere"?(E=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),A.geometries[n]=E):w.type=="cylinder"?(E=new THREE.CylinderGeometry(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset),A.geometries[n]=E):w.type=="torus"?(E=new THREE.TorusGeometry(w.radius, -w.tube,w.segmentsR,w.segmentsT),A.geometries[n]=E):w.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(w.subdivisions),A.geometries[n]=E):w.type=="bin_mesh"?D.load({model:e(w.url,C.urlBaseType),callback:j(n)}):w.type=="ascii_mesh"?J.load({model:e(w.url,C.urlBaseType),callback:j(n)}):w.type=="embedded_mesh"&&(w=C.embeds[w.id])&&J.createModel(w,m(n),"");for(x in C.textures)if(n=C.textures[x],n.url instanceof Array){H+=n.url.length;for(D=0;D=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(j=this.size-1);var p=Math.floor(m-k);p<1&&(p=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var o=Math.floor(l-k);o<1&&(o=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size- -1);for(var v,u,w,x,y,t;n0&&(this.field[w+v]+=x)}}};this.addPlaneX=function(a,b){var f,g,h,k,j,m=this.size,l=this.yd,n=this.zd,p=this.field,o=m*Math.sqrt(a/b);o>m&&(o=m);for(f=0;f0)for(g=0;gl&&(v=l);for(g=0;g0){j=g*n;for(f=0;fsize&&(dist=size);for(h=0;h0){j=zd*h;for(g=0;g=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(j=this.size-1);var o=Math.floor(m-k);o<1&&(o=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(l-k);p<1&&(p=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size- +1);for(var v,u,w,x,y,t;n0&&(this.field[w+v]+=x)}}};this.addPlaneX=function(a,b){var e,h,g,k,j,m=this.size,l=this.yd,n=this.zd,o=this.field,p=m*Math.sqrt(a/b);p>m&&(p=m);for(e=0;e0)for(h=0;hl&&(v=l);for(h=0;h0){j=h*n;for(e=0;esize&&(dist=size);for(g=0;g0){j=zd*g;for(h=0;hg?this.hits.push(f):this.hits.unshift(f),g=e;return this.hits}; -THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,b[c]);if(e.distb.length)return null;return b[c]}; +THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var b,c,f,e,h=0;b=0;for(c=this.colliders.length;bh?this.hits.push(e):this.hits.unshift(e),h=f;return this.hits}; +THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var f=this.rayMesh(a,b[c]);if(f.distb.length)return null;return b[c]}; THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),e=Number.MAX_VALUE,f,g=0;g=k*f))return Number.MAX_VALUE;h/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(h);k.addSelf(a.origin);Math.abs(g.x)>Math.abs(g.y)?Math.abs(g.x)>Math.abs(g.z)?(a=k.y-b.y,g=c.y-b.y, -f=e.y-b.y,k=k.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=k.x-b.x,g=c.x-b.x,f=e.x-b.x,k=k.y-b.y,c=c.y-b.y,e=e.y-b.y):Math.abs(g.y)>Math.abs(g.z)?(a=k.x-b.x,g=c.x-b.x,f=e.x-b.x,k=k.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=k.x-b.x,g=c.x-b.x,f=e.x-b.x,k=k.y-b.y,c=c.y-b.y,e=e.y-b.y);b=g*e-c*f;if(b==0)return Number.MAX_VALUE;b=1/b;e=(a*e-k*f)*b;if(!(e>=0))return Number.MAX_VALUE;b*=g*k-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-e-b>=0))return Number.MAX_VALUE;return h}; -THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);c.multiplyVector3(e.origin);c.rotateAxis(e.direction);e.direction.normalize();return e}; -THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var e=0,f=0,g=0,h=0,k=0,j=0,m=!0;c.origin.xb.max.x&&(e=b.max.x-c.origin.x,e/=c.direction.x,m=!1,h=1);c.origin.yb.max.y&&(f=b.max.y-c.origin.y,f/=c.direction.y, -m=!1,k=1);c.origin.zb.max.z&&(g=b.max.z-c.origin.z,g/=c.direction.z,m=!1,j=1);if(m)return-1;m=0;f>e&&(m=1,e=f);g>e&&(m=2,e=g);switch(m){case 0:k=c.origin.y+c.direction.y*e;if(kb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(h,0,0);break;case 1:h=c.origin.x+c.direction.x*e;if(hb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* -e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,k,0);break;case 2:h=c.origin.x+c.direction.x*e;if(hb.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*e;if(kb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,j)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),e=b.point.dot(b.normal);if(c<0)c=(e-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; -THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(e)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; +THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),f=Number.MAX_VALUE,e,h=0;h=k*e))return Number.MAX_VALUE;g/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(g);k.addSelf(a.origin);Math.abs(h.x)>Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=k.y-b.y,h=c.y-b.y, +e=f.y-b.y,k=k.z-b.z,c=c.z-b.z,f=f.z-b.z):(a=k.x-b.x,h=c.x-b.x,e=f.x-b.x,k=k.y-b.y,c=c.y-b.y,f=f.y-b.y):Math.abs(h.y)>Math.abs(h.z)?(a=k.x-b.x,h=c.x-b.x,e=f.x-b.x,k=k.z-b.z,c=c.z-b.z,f=f.z-b.z):(a=k.x-b.x,h=c.x-b.x,e=f.x-b.x,k=k.y-b.y,c=c.y-b.y,f=f.y-b.y);b=h*f-c*e;if(b==0)return Number.MAX_VALUE;b=1/b;f=(a*f-k*e)*b;if(!(f>=0))return Number.MAX_VALUE;b*=h*k-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-f-b>=0))return Number.MAX_VALUE;return g}; +THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var f=THREE.CollisionSystem.__r;f.origin.copy(a.origin);f.direction.copy(a.direction);c.multiplyVector3(f.origin);c.rotateAxis(f.direction);f.direction.normalize();return f}; +THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var f=0,e=0,h=0,g=0,k=0,j=0,m=!0;c.origin.xb.max.x&&(f=b.max.x-c.origin.x,f/=c.direction.x,m=!1,g=1);c.origin.yb.max.y&&(e=b.max.y-c.origin.y,e/=c.direction.y, +m=!1,k=1);c.origin.zb.max.z&&(h=b.max.z-c.origin.z,h/=c.direction.z,m=!1,j=1);if(m)return-1;m=0;e>f&&(m=1,f=e);h>f&&(m=2,f=h);switch(m){case 0:k=c.origin.y+c.direction.y*f;if(kb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(g,0,0);break;case 1:g=c.origin.x+c.direction.x*f;if(gb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* +f;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,k,0);break;case 2:g=c.origin.x+c.direction.x*f;if(gb.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*f;if(kb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,j)}return f};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),f=b.point.dot(b.normal);if(c<0)c=(f-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(f)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,e=this.render,f=new THREE.Camera,g=new THREE.Camera,a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},h=new THREE.WebGLRenderTarget(512,512,a),k=new THREE.WebGLRenderTarget(512,512,a),j=new THREE.Camera(53,1,1,1E4);j.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:h},mapRight:{type:"t",value:1, +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,f=this.render,e=new THREE.Camera,h=new THREE.Camera,a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},g=new THREE.WebGLRenderTarget(512,512,a),k=new THREE.WebGLRenderTarget(512,512,a),j=new THREE.Camera(53,1,1,1E4);j.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:g},mapRight:{type:"t",value:1, texture:k}},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 m= -new THREE.Scene;m.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);h.width=a;h.height=e;k.width=a;k.height=e};this.render=function(a,c){f.projectionMatrix=c.projectionMatrix;f.position.copy(c.position);f.target.position.copy(c.target.position);f.translateX(-10);g.projectionMatrix=c.projectionMatrix;g.position.copy(c.position);g.target.position.copy(c.target.position);g.translateX(10);e.call(b,a,f,h,!0);e.call(b,a,g,k,!0);e.call(b,m,j)}}; -if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,e=this.render,f,g,h=new THREE.Camera,k=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,e){c.call(b,a,e);f=a/2;g=e};this.render=function(a,c){this.clear();h.fov=c.fov;h.aspect=0.5*c.aspect;h.near=c.near;h.far=c.far; -h.updateProjectionMatrix();h.position.copy(c.position);h.target.position.copy(c.target.position);h.translateX(b.separation);k.projectionMatrix=h.projectionMatrix;k.position.copy(c.position);k.target.position.copy(c.target.position);k.translateX(-b.separation);this.setViewport(0,0,f,g);e.call(b,a,h);this.setViewport(f,0,f,g);e.call(b,a,k,!1)}}; +new THREE.Scene;m.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);g.width=a;g.height=e;k.width=a;k.height=e};this.render=function(a,c){e.projectionMatrix=c.projectionMatrix;e.position.copy(c.position);e.target.position.copy(c.target.position);e.translateX(-10);h.projectionMatrix=c.projectionMatrix;h.position.copy(c.position);h.target.position.copy(c.target.position);h.translateX(10);f.call(b,a,e,g,!0);f.call(b,a,h,k,!0);f.call(b,m,j)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,f=this.render,e,h,g=new THREE.Camera,k=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,f){c.call(b,a,f);e=a/2;h=f};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=c.far; +g.updateProjectionMatrix();g.position.copy(c.position);g.target.position.copy(c.target.position);g.translateX(b.separation);k.projectionMatrix=g.projectionMatrix;k.position.copy(c.position);k.target.position.copy(c.target.position);k.translateX(-b.separation);this.setViewport(0,0,e,h);f.call(b,a,g);this.setViewport(e,0,e,h);f.call(b,a,k,!1)}}; diff --git a/examples/webgl_postprocessing.html b/examples/webgl_postprocessing.html index 0eb8e553..b2462510 100644 --- a/examples/webgl_postprocessing.html +++ b/examples/webgl_postprocessing.html @@ -222,21 +222,13 @@ uniforms[ "enableAO" ].value = false; uniforms[ "enableDiffuse" ].value = true; - uniforms[ "uPointLightPos" ].value = new THREE.Vector3(0,0,0); - uniforms[ "uPointLightColor" ].value = new THREE.Color(1,0,0); - - uniforms[ "uDirLightPos" ].value = directionalLight.position; - uniforms[ "uDirLightColor" ].value = directionalLight.color; - - uniforms[ "uAmbientLightColor" ].value = new THREE.Color(0,0,0); - uniforms[ "uDiffuseColor" ].value.setHex( diffuse ); uniforms[ "uSpecularColor" ].value.setHex( specular ); uniforms[ "uAmbientColor" ].value.setHex( ambient ); uniforms[ "uShininess" ].value = shininess; - var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms }; + var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true }; var mat2 = new THREE.MeshShaderMaterial( parameters ); mesh = new THREE.Mesh( geometry, mat2 ); diff --git a/examples/webgl_trackballcamera_earth.html b/examples/webgl_trackballcamera_earth.html index 3b82a64f..b020dda6 100644 --- a/examples/webgl_trackballcamera_earth.html +++ b/examples/webgl_trackballcamera_earth.html @@ -28,7 +28,7 @@ a { color: green; } b { color: green; } - + @@ -81,7 +81,7 @@ function init() { container = document.createElement( 'div' ); - document.body.appendChild( container ); + document.body.appendChild( container ); scene = new THREE.Scene(); @@ -96,7 +96,7 @@ camera = new THREE.TrackballCamera({ - fov: 25, + fov: 25, aspect: width / height, near: 50, far: 1e7, @@ -150,11 +150,6 @@ uniforms[ "enableDiffuse" ].value = true; uniforms[ "enableSpecular" ].value = true; - uniforms[ "uDirLightPos" ].value = dirLight.position; - uniforms[ "uDirLightColor" ].value = dirLight.color; - - uniforms[ "uAmbientLightColor" ].value = ambientLight.color; - uniforms[ "uDiffuseColor" ].value.setHex( 0xffffff ); uniforms[ "uSpecularColor" ].value.setHex( 0xaaaaaa ); uniforms[ "uAmbientColor" ].value.setHex( 0x000000 ); @@ -162,11 +157,12 @@ uniforms[ "uShininess" ].value = 30; var materialNormalMap = new THREE.MeshShaderMaterial({ - fragmentShader: shader.fragmentShader, - vertexShader: shader.vertexShader, - uniforms: uniforms + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + uniforms: uniforms, + lights: true }); - + // planet @@ -215,7 +211,7 @@ } var stars, - starsMaterials = [ + starsMaterials = [ new THREE.ParticleBasicMaterial( { color: 0x555555, size: 2, sizeAttenuation: false } ), new THREE.ParticleBasicMaterial( { color: 0x555555, size: 1, sizeAttenuation: false } ), new THREE.ParticleBasicMaterial( { color: 0x333333, size: 2, sizeAttenuation: false } ), @@ -272,7 +268,7 @@ function animate() { requestAnimationFrame( animate ); - + render(); stats.update(); @@ -284,7 +280,7 @@ dt = ( t - time ) / 1000; time = t; - meshPlanet.rotation.y += rotationSpeed * dt; + meshPlanet.rotation.y += rotationSpeed * dt; meshClouds.rotation.y += 1.25 * rotationSpeed * dt; var angle = dt * rotationSpeed; diff --git a/src/extras/ShaderUtils.js b/src/extras/ShaderUtils.js index 7d7a7758..e216ab52 100644 --- a/src/extras/ShaderUtils.js +++ b/src/extras/ShaderUtils.js @@ -3,6 +3,8 @@ * @author mr.doob / http://mrdoob.com/ */ +if ( THREE.WebGLRenderer ) { + THREE.ShaderUtils = { lib: { @@ -109,8 +111,8 @@ THREE.ShaderUtils = { "uNormalScale": { type: "f", value: 1.0 }, "tDisplacement": { type: "t", value: 5, texture: null }, - "uDisplacementBias": { type: "f", value: -0.5 }, - "uDisplacementScale": { type: "f", value: 2.5 }, + "uDisplacementBias": { type: "f", value: 0.0 }, + "uDisplacementScale": { type: "f", value: 1.0 }, "uDiffuseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) }, "uSpecularColor": { type: "c", value: new THREE.Color( 0x111111 ) }, @@ -196,8 +198,8 @@ THREE.ShaderUtils = { "for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {", - "vec3 pointVector = normalize( vPointLight[ 0 ].xyz );", - "vec3 pointHalfVector = normalize( vPointLight[ 0 ].xyz + vViewPosition );", + "vec3 pointVector = normalize( vPointLight[ i ].xyz );", + "vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );", "float pointDistance = vPointLight[ i ].w;", "float pointDotNormalHalf = dot( normal, pointHalfVector );", @@ -207,7 +209,7 @@ THREE.ShaderUtils = { "if ( pointDotNormalHalf >= 0.0 )", "pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );", - "pointTotal += pointDistance * vec4( pointLightColor[ 0 ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );", + "pointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );", "}", @@ -221,7 +223,7 @@ THREE.ShaderUtils = { "for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {", - "vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );", + "vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );", "vec3 dirVector = normalize( lDirection.xyz );", "vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );", @@ -233,7 +235,7 @@ THREE.ShaderUtils = { "if ( dirDotNormalHalf >= 0.0 )", "dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );", - "dirTotal += vec4( directionalLightColor[ 0 ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );", + "dirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );", "}", @@ -655,3 +657,5 @@ THREE.ShaderUtils = { } }; + +}; \ No newline at end of file diff --git a/src/extras/io/BinaryLoader.js b/src/extras/io/BinaryLoader.js index fe4597ea..e17ac993 100644 --- a/src/extras/io/BinaryLoader.js +++ b/src/extras/io/BinaryLoader.js @@ -227,6 +227,8 @@ THREE.BinaryLoader.prototype = { this.computeCentroids(); this.computeFaceNormals(); + if ( THREE.Loader.prototype.hasNormals( this ) ) this.computeTangents(); + //var e = (new Date).getTime(); //log( "binary data parse time: " + (e-s) + " ms" ); diff --git a/src/extras/io/JSONLoader.js b/src/extras/io/JSONLoader.js index 5e9459dd..52abdb60 100644 --- a/src/extras/io/JSONLoader.js +++ b/src/extras/io/JSONLoader.js @@ -26,7 +26,7 @@ THREE.JSONLoader.prototype.load = function ( parameters ) { var scope = this, url = parameters.model, - callback = parameters.callback, + callback = parameters.callback, texture_path = parameters.texture_path ? parameters.texture_path : this.extractUrlbase( url ), worker = new Worker( url ); @@ -59,6 +59,8 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path geometry.computeCentroids(); geometry.computeFaceNormals(); + if ( this.hasNormals( geometry ) ) geometry.computeTangents(); + // geometry.computeEdgeFaces(); function parseModel( scale ) { @@ -351,7 +353,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path } - } + } } @@ -376,7 +378,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path } - } + } } diff --git a/src/extras/io/Loader.js b/src/extras/io/Loader.js index 2ba667f5..9376cc93 100644 --- a/src/extras/io/Loader.js +++ b/src/extras/io/Loader.js @@ -19,15 +19,15 @@ THREE.Loader.prototype = { var e = document.createElement( "div" ); - e.style.position = "absolute"; - e.style.right = "0px"; - e.style.top = "0px"; - e.style.fontSize = "0.8em"; + e.style.position = "absolute"; + e.style.right = "0px"; + e.style.top = "0px"; + e.style.fontSize = "0.8em"; e.style.textAlign = "left"; - e.style.background = "rgba(0,0,0,0.25)"; - e.style.color = "#fff"; - e.style.width = "120px"; - e.style.padding = "0.5em 0.5em 0.5em 0.5em"; + e.style.background = "rgba(0,0,0,0.25)"; + e.style.color = "#fff"; + e.style.width = "120px"; + e.style.padding = "0.5em 0.5em 0.5em 0.5em"; e.style.zIndex = 1000; e.innerHTML = "Loading ..."; @@ -75,6 +75,22 @@ THREE.Loader.prototype = { }, + hasNormals: function( scope ) { + + var m, i, il = scope.materials.length; + + for( i = 0; i < il; i++ ) { + + m = scope.materials[ i ][ 0 ]; + + if ( m instanceof THREE.MeshShaderMaterial ) return true; + + } + + return false; + + }, + createMaterial: function ( m, texture_path ) { function is_pow2( n ) { @@ -120,7 +136,53 @@ THREE.Loader.prototype = { } - var material, mtype, mpars, texture, color, vertexColors; + function create_texture( where, name, sourceFile, repeat, offset, wrap ) { + + var texture = document.createElement( 'canvas' ); + + where[ name ] = new THREE.Texture( texture ); + where[ name ].sourceFile = sourceFile; + + if( repeat ) { + + where[ name ].repeat.set( repeat[ 0 ], repeat[ 1 ] ); + + if ( repeat[ 0 ] != 1 ) where[ name ].wrapS = THREE.RepeatWrapping; + if ( repeat[ 1 ] != 1 ) where[ name ].wrapT = THREE.RepeatWrapping; + + } + + if( offset ) { + + where[ name ].offset.set( offset[ 0 ], offset[ 1 ] ); + + } + + if( wrap ) { + + var wrapMap = { + "repeat" : THREE.RepeatWrapping, + "mirror" : THREE.MirroredRepeatWrapping + } + + if ( wrapMap[ wrap[ 0 ] ] !== undefined ) where[ name ].wrapS = wrapMap[ wrap[ 0 ] ]; + if ( wrapMap[ wrap[ 1 ] ] !== undefined ) where[ name ].wrapT = wrapMap[ wrap[ 1 ] ]; + + } + + load_image( where[ name ], texture_path + "/" + sourceFile ); + + } + + function rgb2hex( rgb ) { + + return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255; + + } + + var material, mtype, mpars, + color, specular, ambient, + vertexColors; // defaults @@ -128,7 +190,7 @@ THREE.Loader.prototype = { // vertexColors - mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, wireframe: m.wireframe }; + mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, wireframe: m.wireframe }; // parameters from model file @@ -173,47 +235,11 @@ THREE.Loader.prototype = { } - if ( m.mapDiffuse && texture_path ) { + // colors - texture = document.createElement( 'canvas' ); + if ( m.colorDiffuse ) { - mpars.map = new THREE.Texture( texture ); - mpars.map.sourceFile = m.mapDiffuse; - - if( m.mapDiffuseRepeat ) { - - mpars.map.repeat.set( m.mapDiffuseRepeat[ 0 ], m.mapDiffuseRepeat[ 1 ] ); - - if ( m.mapDiffuseRepeat[ 0 ] != 1 ) mpars.map.wrapS = THREE.RepeatWrapping; - if ( m.mapDiffuseRepeat[ 1 ] != 1 ) mpars.map.wrapT = THREE.RepeatWrapping; - - } - - if( m.mapDiffuseOffset ) { - - mpars.map.offset.set( m.mapDiffuseOffset[ 0 ], m.mapDiffuseOffset[ 1 ] ); - - } - - if( m.mapDiffuseWrap ) { - - var wrapMap = { - "repeat" : THREE.RepeatWrapping, - "mirror" : THREE.MirroredRepeatWrapping - } - - if ( wrapMap[ m.mapDiffuseWrap[ 0 ] ] !== undefined ) mpars.map.wrapS = wrapMap[ m.mapDiffuseWrap[ 0 ] ]; - if ( wrapMap[ m.mapDiffuseWrap[ 1 ] ] !== undefined ) mpars.map.wrapT = wrapMap[ m.mapDiffuseWrap[ 1 ] ]; - - } - - load_image( mpars.map, texture_path + "/" + m.mapDiffuse ); - - } else if ( m.colorDiffuse ) { - - color = ( m.colorDiffuse[ 0 ] * 255 << 16 ) + ( m.colorDiffuse[ 1 ] * 255 << 8 ) + m.colorDiffuse[ 2 ] * 255; - mpars.color = color; - mpars.opacity = m.transparency; + mpars.color = rgb2hex( m.colorDiffuse ); } else if ( m.DbgColor ) { @@ -221,31 +247,105 @@ THREE.Loader.prototype = { } - if ( m.mapLight && texture_path ) { + if ( m.colorSpecular ) { - texture = document.createElement( 'canvas' ); - - mpars.lightMap = new THREE.Texture( texture ); - mpars.lightMap.sourceFile = m.mapLight; - - if( m.mapLightmapRepeat ) { - - mpars.lightMap.repeat.set( m.mapLightRepeat[ 0 ], m.mapLightRepeat[ 1 ] ); - mpars.lightMap.wrapS = mpars.lightMap.wrapT = THREE.RepeatWrapping; - - } - - if( m.mapLightmapOffset ) { - - mpars.lightMap.offset.set( m.mapLightmapOffset[ 0 ], m.mapLightmapOffset[ 1 ] ); - - } - - load_image( mpars.lightMap, texture_path + "/" + m.mapLightmap ); + mpars.specular = rgb2hex( m.colorSpecular ); } - material = new THREE[ mtype ]( mpars ); + if ( m.colorAmbient ) { + + mpars.ambient = rgb2hex( m.colorAmbient ); + + } + + // modifiers + + if ( m.transparency ) { + + mpars.opacity = m.transparency; + + } + + if ( m.specularCoef ) { + + mpars.shininess = m.specularCoef; + + } + + // textures + + if ( m.mapDiffuse && texture_path ) { + + create_texture( mpars, "map", m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap ); + + } + + if ( m.mapLight && texture_path ) { + + create_texture( mpars, "lightMap", m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap ); + + } + + if ( m.mapNormal && texture_path ) { + + create_texture( mpars, "normalMap", m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap ); + + } + + // special case for normal mapped material + + if ( m.mapNormal ) { + + var shader = THREE.ShaderUtils.lib[ "normal" ]; + var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + var diffuse = mpars.color; + var specular = mpars.specular; + var ambient = mpars.ambient; + var shininess = mpars.shininess; + + uniforms[ "tNormal" ].texture = mpars.normalMap; + + if ( m.mapNormalFactor ) { + + uniforms[ "uNormalScale" ].value = m.mapNormalFactor; + + } + + if ( mpars.map ) { + + uniforms[ "tDiffuse" ].texture = mpars.map; + uniforms[ "enableDiffuse" ].value = true; + + } + + // for the moment don't handle specular, AO and displacement textures + + uniforms[ "enableAO" ].value = false; + uniforms[ "enableSpecular" ].value = false; + + uniforms[ "uDiffuseColor" ].value.setHex( diffuse ); + uniforms[ "uSpecularColor" ].value.setHex( specular ); + uniforms[ "uAmbientColor" ].value.setHex( ambient ); + + uniforms[ "uShininess" ].value = shininess; + + if ( mpars.opacity ) { + + uniforms[ "uOpacity" ].value = mpars.opacity; + + } + + var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true }; + + material = new THREE.MeshShaderMaterial( parameters ); + + } else { + + material = new THREE[ mtype ]( mpars ); + + } return material;