diff --git a/README.md b/README.md index ec398d1e..cabdfe2e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ three.js The aim of the project is to create a lightweight 3D engine with a very low level of complexity — in other words, for dummies. The engine can render using <canvas>, <svg> and WebGL. -[Contributors](https://github.com/mrdoob/three.js/contributors) — [Getting Started](http://www.aerotwist.com/lab/getting-started-with-three-js/) — [API Reference](https://github.com/mrdoob/three.js/wiki/API-Reference) +[Contributors](http://github.com/mrdoob/three.js/contributors) — [Getting Started](http://www.aerotwist.com/lab/getting-started-with-three-js/) — [API Reference](http://github.com/mrdoob/three.js/wiki/API-Reference) More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=three.js) @@ -135,13 +135,33 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a & ### Change Log ### -2011 07 06 - **r42** (277.852 KB, gzip, gzip: 69.469 KB) + +2011 08 14 - **r43** (298.199 KB, gzip: 74.805 KB) + +* Improved Blender exporter - 2.58 (and 2.59) support, normals maps, specular, ao maps... ([alteredq](http://github.com/alteredq)) +* Added [CORS](http://www.w3.org/TR/cors/) to `ImageUtils`. ([mrdoob](http://github.com/mrdoob)) +* Refactored `TextGeometry` and added `Shape`, `Curve`, `Path`, `ExtrudeGeometry`, `TextPath`. ([zz85](http://github.com/zz85) and [alteredq](http://github.com/alteredq)) +* Added handling of custom attributes for `ParticleSystems`. ([alteredq](http://github.com/alteredq)) +* Fixed `CanvasRenderer.setClearColor`. ([mrdoob](http://github.com/mrdoob), [StephenHopkins](http://github.com/StephenHopkins) and [sebleedelisle](http://github.com/sebleedelisle)) +* Improved uniform handling in `WebGLRenderer`. ([alteredq](http://github.com/alteredq)) +* Implemented Shadow Mapping in `WebGLRenderer`. ([alteredq](http://github.com/alteredq)) +* Added `Spotlight` light type. ([alteredq](http://github.com/alteredq)) +* Fixed constructor-less prototypes. ([pushmatrix](http://github.com/pushmatrix) +* Added `DataTexture`. ([alteredq](http://github.com/alteredq)) +* `WebGLRenderer` opaque pass now renders from front to back. ([alteredq](http://github.com/alteredq)) +* Simplified `Color`. ([mrdoob](http://github.com/mrdoob)) +* Added `preserveDrawingBuffer` option to `WebGLRenderer`. ([jeromeetienne](http://github.com/jeromeetienne)) +* Added `UTF8Loader` for loading the new, uber compressed, [UTF8 format](http://code.google.com/p/webgl-loader/). ([alteredq](http://github.com/alteredq)) +* `CanvasRenderer` now supports `RepeatWrapping`, `texture.offset` and `texture.repeat`. ([mrdoob](http://github.com/mrdoob)) +* Removed Stencil Shadows and Lensflare code. ([mrdoob](http://github.com/mrdoob)) + +2011 07 06 - **r42** (277.852 KB, gzip: 69.469 KB) * Added `AnaglypWebGLRenderer` and `CrosseyedWebGLRenderer`. ([mrdoob](http://github.com/mrdoob), [alteredq](http://github.com/alteredq) and [marklundin](http://github.com/marklundin)) * Added `TextGeometry`. ([zz85](http://github.com/zz85) and [alteredq](http://github.com/alteredq)) * Added `setViewOffset` method to `Camera`. ([greggman](http://github.com/greggman)) * Renamed geometries to `*Geometry`. ([mrdoob](http://github.com/mrdoob)) -* Improved Blender exporter. ([alteredq](http://github.com/alteredq), [sweetfish](http://github.com/sweetfish) and [Jhonnyg](https://github.com/Jhonnyg)) +* Improved Blender exporter. ([alteredq](http://github.com/alteredq), [sweetfish](http://github.com/sweetfish) and [Jhonnyg](http://github.com/Jhonnyg)) * Added Blender 2.58 exporter. ([georgik](http://github.com/georgik)) * Fixed `Matrix4.multiply()`. (thanks [lukem1](http://github.com/lukem1)) * Added support for additional Euler rotation orders in `Matrix4`. ([rectalogic](http://github.com/rectalogic)) diff --git a/REVISION b/REVISION index d81cc071..920a1396 100644 --- a/REVISION +++ b/REVISION @@ -1 +1 @@ -42 +43 diff --git a/build/Three.js b/build/Three.js index d41f91b2..6ab520a6 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,4 +1,4 @@ -// Three.js r42 - http://github.com/mrdoob/three.js +// Three.js r43 - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){b!==void 0&&this.setHex(b);return this}; THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;return this},setHSV:function(b,c,e){var f,g,j;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),g=b*6-f,b=e*(1-c),j=e*(1-c*g),c=e*(1-c*(1-g)),f){case 1:this.r=j;this.g=e;this.b=b;break;case 2:this.r=b;this.g=e;this.b=c;break;case 3:this.r=b;this.g=j;this.b=e;break;case 4:this.r=c;this.g=b;this.b=e;break;case 5:this.r= e;this.g=b;this.b=j;break;case 6:case 0:this.r=e,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; @@ -14,65 +14,65 @@ b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w=b.w-c.w;return this}, subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.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={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,j,h,m, -n,p,o,t,v,u,y=b.geometry,z=y.vertices,x=[],f=0;for(g=y.faces.length;f0:t<0))if(o=o.dot((new THREE.Vector3).sub(h, -v))/t,v=v.addSelf(u.multiplyScalar(o)),j instanceof THREE.Face3)e(v,h,m,n)&&(j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},x.push(j));else if(j instanceof THREE.Face4&&(e(v,h,m,p)||e(v,m,n,p)))j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},x.push(j);return x}else return[]}}; -THREE.Rectangle=function(){function b(){j=f-c;h=g-e}var c,e,f,g,j,h,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,j,o,t){m=!1;c=h;e=j;f=o;g=t;b()};this.addPoint=function(h,j){m?(m=!1,c=h,e=j,f=h,g=j):(c=ch?f:h,g=g>j?g:j);b()};this.add3Points= -function(h,j,o,t,v,u){m?(m=!1,c=ho?h>v?h:v:o>v?o:v,g=j>t?j>u?j:u:t>u?t:u):(c=ho?h>v?h>f?h:f:v>f?v:f:o>v?o>f?o:f:v>f?v:f,g=j>t?j>u?j>g?j:g:u>g?u:g:t>u?t>g?t:g:u>g?u: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={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,e,f,g,j,h,m,n,p,o,t,v,u,y,z){this.set(b||1,c||0,e||0,f||0,g||0,j||1,h||0,m||0,n||0,p||0,o||1,t||0,v||0,u||0,y||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,g,j,h,m,n,p,o,t,v,u,y,z){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=h;this.n24=m;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=v;this.n42=u;this.n43=y;this.n44=z;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, +THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,j,h,k, +o,m,p,u,v,t,w=b.geometry,x=w.vertices,B=[],f=0;for(g=w.faces.length;f0:u<0))if(p=p.dot((new THREE.Vector3).sub(h, +v))/u,v=v.addSelf(t.multiplyScalar(p)),j instanceof THREE.Face3)e(v,h,k,o)&&(j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},B.push(j));else if(j instanceof THREE.Face4&&(e(v,h,k,m)||e(v,k,o,m)))j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},B.push(j);return B}else return[]}}; +THREE.Rectangle=function(){function b(){j=f-c;h=g-e}var c,e,f,g,j,h,k=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,j,p,u){k=!1;c=h;e=j;f=p;g=u;b()};this.addPoint=function(h,j){k?(k=!1,c=h,e=j,f=h,g=j):(c=ch?f:h,g=g>j?g:j);b()};this.add3Points= +function(h,j,p,u,v,t){k?(k=!1,c=hp?h>v?h:v:p>v?p:v,g=j>u?j>t?j:t:u>t?u:t):(c=hp?h>v?h>f?h:f:v>f?v:f:p>v?p>f?p:f:v>f?v:f,g=j>u?j>t?j>g?j:g:t>g?t:g:u>t?u>g?u:g:t>g?t:g);b()};this.addRectangle=function(h){k?(k=!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(){k=!0;g=f=e=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,e,f,g,j,h,k,o,m,p,u,v,t,w,x){this.set(b||1,c||0,e||0,f||0,g||0,j||1,h||0,k||0,o||0,m||0,p||1,u||0,v||0,t||0,w||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,g,j,h,k,o,m,p,u,v,t,w,x){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=h;this.n24=k;this.n31=o;this.n32=m;this.n33=p;this.n34=u;this.n41=v;this.n42=t;this.n43=w;this.n44=x;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, c,e){var f=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;f.cross(e,j).normalize();f.length()===0&&(j.x+=1.0E-4,f.cross(e,j).normalize());g.cross(j,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=j.x;this.n21=f.y;this.n22=g.y;this.n23=j.y;this.n31=f.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g; b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*g;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+ -e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,v=b.n33,u=b.n34,y=b.n41,z=b.n42,x=b.n43,w=b.n44,H=c.n11,B=c.n12, -F=c.n13,J=c.n14,D=c.n21,L=c.n22,G=c.n23,I=c.n24,R=c.n31,da=c.n32,T=c.n33,C=c.n34,ea=c.n41,S=c.n42,P=c.n43,k=c.n44;this.n11=e*H+f*D+g*R+j*ea;this.n12=e*B+f*L+g*da+j*S;this.n13=e*F+f*G+g*T+j*P;this.n14=e*J+f*I+g*C+j*k;this.n21=h*H+m*D+n*R+p*ea;this.n22=h*B+m*L+n*da+p*S;this.n23=h*F+m*G+n*T+p*P;this.n24=h*J+m*I+n*C+p*k;this.n31=o*H+t*D+v*R+u*ea;this.n32=o*B+t*L+v*da+u*S;this.n33=o*F+t*G+v*T+u*P;this.n34=o*J+t*I+v*C+u*k;this.n41=y*H+z*D+x*R+w*ea;this.n42=y*B+z*L+x*da+w*S;this.n43=y*F+z*G+x*T+w*P;this.n44= -y*J+z*I+x*C+w*k;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*= -b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,j=this.n22,h=this.n23,m=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,v=this.n41,u=this.n42,y=this.n43,z=this.n44;return f*h*p*v-e*m*p*v-f*j*o*v+c*m*o*v+e*j*t*v-c*h*t*v-f*h*n*u+e*m*n*u+f*g*o*u-b*m*o*u-e*g*t*u+b*h*t*u+f*j*n*y-c*m*n*y-f*g*p*y+b*m*p*y+c*g*t*y-b*j*t*y-e*j*n*z+c*h*n*z+e*g*p*z-b*h*p*z-c*g* -o*z+b*j*o*z},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= +e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,k=b.n22,o=b.n23,m=b.n24,p=b.n31,u=b.n32,v=b.n33,t=b.n34,w=b.n41,x=b.n42,B=b.n43,A=b.n44,H=c.n11,y=c.n12, +G=c.n13,I=c.n14,E=c.n21,K=c.n22,D=c.n23,J=c.n24,S=c.n31,X=c.n32,R=c.n33,C=c.n34,n=c.n41,W=c.n42,V=c.n43,fa=c.n44;this.n11=e*H+f*E+g*S+j*n;this.n12=e*y+f*K+g*X+j*W;this.n13=e*G+f*D+g*R+j*V;this.n14=e*I+f*J+g*C+j*fa;this.n21=h*H+k*E+o*S+m*n;this.n22=h*y+k*K+o*X+m*W;this.n23=h*G+k*D+o*R+m*V;this.n24=h*I+k*J+o*C+m*fa;this.n31=p*H+u*E+v*S+t*n;this.n32=p*y+u*K+v*X+t*W;this.n33=p*G+u*D+v*R+t*V;this.n34=p*I+u*J+v*C+t*fa;this.n41=w*H+x*E+B*S+A*n;this.n42=w*y+x*K+B*X+A*W;this.n43=w*G+x*D+B*R+A*V;this.n44=w* +I+x*J+B*C+A*fa;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*= +b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,j=this.n22,h=this.n23,k=this.n24,o=this.n31,m=this.n32,p=this.n33,u=this.n34,v=this.n41,t=this.n42,w=this.n43,x=this.n44;return f*h*m*v-e*k*m*v-f*j*p*v+c*k*p*v+e*j*u*v-c*h*u*v-f*h*o*t+e*k*o*t+f*g*p*t-b*k*p*t-e*g*u*t+b*h*u*t+f*j*o*w-c*k*o*w-f*g*m*w+b*k*m*w+c*g*u*w-b*j*u*w-e*j*o*x+c*h*o*x+e*g*m*x-b*h*m*x-c*g* +p*x+b*j*p*x},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34= this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]= this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]= this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0, -0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),g=1-e,j=b.x,h=b.y,m=b.z,n=g*j,p=g*h;this.set(n*j+e,n*h-f*m,n*m+f*h,0,n*h+f*m,p*h+e,p*m-f*j,0,n*m-f*h,p*m+f*j,g*m*m+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var e=b.x,f=b.y,g=b.z,j=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),m=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var n= -h*m,p=h*g,o=f*m,t=f*g;this.n11=n+t*e;this.n12=o*e-p;this.n13=j*f;this.n21=j*g;this.n22=j*m;this.n23=-e;this.n31=p*e-o;this.n32=t+n*e;this.n33=j*h;break;case "ZXY":n=h*m;p=h*g;o=f*m;t=f*g;this.n11=n-t*e;this.n12=-j*g;this.n13=o+p*e;this.n21=p+o*e;this.n22=j*m;this.n23=t-n*e;this.n31=-j*f;this.n32=e;this.n33=j*h;break;case "ZYX":n=j*m;p=j*g;o=e*m;t=e*g;this.n11=h*m;this.n12=o*f-p;this.n13=n*f+t;this.n21=h*g;this.n22=t*f+n;this.n23=p*f-o;this.n31=-f;this.n32=e*h;this.n33=j*h;break;case "YZX":n=j*h;p= -j*f;o=e*h;t=e*f;this.n11=h*m;this.n12=t-n*g;this.n13=o*g+p;this.n21=g;this.n22=j*m;this.n23=-e*m;this.n31=-f*m;this.n32=p*g+o;this.n33=n-t*g;break;case "XZY":n=j*h;p=j*f;o=e*h;t=e*f;this.n11=h*m;this.n12=-g;this.n13=f*m;this.n21=n*g+t;this.n22=j*m;this.n23=p*g-o;this.n31=o*g-p;this.n32=e*m;this.n33=t*g+n;break;default:n=j*m,p=j*g,o=e*m,t=e*g,this.n11=h*m,this.n12=-h*g,this.n13=f,this.n21=p+o*f,this.n22=n-t*f,this.n23=-e*h,this.n31=t-n*f,this.n32=o+p*f,this.n33=j*h}return this},setRotationFromQuaternion:function(b){var c= -b.x,e=b.y,f=b.z,g=b.w,j=c+c,h=e+e,m=f+f,b=c*j,n=c*h;c*=m;var p=e*h;e*=m;f*=m;j*=g;h*=g;g*=m;this.n11=1-(p+f);this.n12=n-g;this.n13=c+h;this.n21=n+g;this.n22=1-(b+f);this.n23=e-j;this.n31=c-h;this.n32=e+j;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34}, +0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),g=1-e,j=b.x,h=b.y,k=b.z,o=g*j,m=g*h;this.set(o*j+e,o*h-f*k,o*k+f*h,0,o*h+f*k,m*h+e,m*k-f*j,0,o*k-f*h,m*k+f*j,g*k*k+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= +new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var e=b.x,f=b.y,g=b.z,j=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),k=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var o= +h*k,m=h*g,p=f*k,u=f*g;this.n11=o+u*e;this.n12=p*e-m;this.n13=j*f;this.n21=j*g;this.n22=j*k;this.n23=-e;this.n31=m*e-p;this.n32=u+o*e;this.n33=j*h;break;case "ZXY":o=h*k;m=h*g;p=f*k;u=f*g;this.n11=o-u*e;this.n12=-j*g;this.n13=p+m*e;this.n21=m+p*e;this.n22=j*k;this.n23=u-o*e;this.n31=-j*f;this.n32=e;this.n33=j*h;break;case "ZYX":o=j*k;m=j*g;p=e*k;u=e*g;this.n11=h*k;this.n12=p*f-m;this.n13=o*f+u;this.n21=h*g;this.n22=u*f+o;this.n23=m*f-p;this.n31=-f;this.n32=e*h;this.n33=j*h;break;case "YZX":o=j*h;m= +j*f;p=e*h;u=e*f;this.n11=h*k;this.n12=u-o*g;this.n13=p*g+m;this.n21=g;this.n22=j*k;this.n23=-e*k;this.n31=-f*k;this.n32=m*g+p;this.n33=o-u*g;break;case "XZY":o=j*h;m=j*f;p=e*h;u=e*f;this.n11=h*k;this.n12=-g;this.n13=f*k;this.n21=o*g+u;this.n22=j*k;this.n23=m*g-p;this.n31=p*g-m;this.n32=e*k;this.n33=u*g+o;break;default:o=j*k,m=j*g,p=e*k,u=e*g,this.n11=h*k,this.n12=-h*g,this.n13=f,this.n21=m+p*f,this.n22=o-u*f,this.n23=-e*h,this.n31=u-o*f,this.n32=p+m*f,this.n33=j*h}return this},setRotationFromQuaternion:function(b){var c= +b.x,e=b.y,f=b.z,g=b.w,j=c+c,h=e+e,k=f+f,b=c*j,o=c*h;c*=k;var m=e*h;e*=k;f*=k;j*=g;h*=g;g*=k;this.n11=1-(m+f);this.n12=o-g;this.n13=c+h;this.n21=o+g;this.n22=1-(b+f);this.n23=e-j;this.n31=c-h;this.n32=e+j;this.n33=1-(b+m);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34}, extractRotation:function(b,c){var e=1/c.x,f=1/c.y,g=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,v=b.n33,u=b.n34,y=b.n41,z=b.n42,x=b.n43,w=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*u*z-p*v*z+p*t*x-m*u*x-n*t*w+m*v*w;c.n12=j*v*z-g*u*z-j*t*x+f*u*x+g*t*w-f*v*w;c.n13=g*p*z-j*n*z+j*m*x-f*p*x-g*m*w+f*n*w;c.n14=j*n*t-g*p*t-j*m*v+f*p*v+g*m*u-f*n*u;c.n21=p*v*y-n*u*y-p*o*x+h*u*x+n*o*w-h*v*w;c.n22=g*u*y-j*v*y+j*o*x-e*u*x-g*o*w+e*v*w;c.n23=j*n*y-g*p*y-j*h*x+e*p*x+g*h*w-e*n*w;c.n24= -g*p*o-j*n*o+j*h*v-e*p*v-g*h*u+e*n*u;c.n31=m*u*y-p*t*y+p*o*z-h*u*z-m*o*w+h*t*w;c.n32=j*t*y-f*u*y-j*o*z+e*u*z+f*o*w-e*t*w;c.n33=g*p*y-j*m*y+j*h*z-e*p*z-f*h*w+e*m*w;c.n34=j*m*o-f*p*o-j*h*t+e*p*t+f*h*u-e*m*u;c.n41=n*t*y-m*v*y-n*o*z+h*v*z+m*o*x-h*t*x;c.n42=f*v*y-g*t*y+g*o*z-e*v*z-f*o*x+e*t*x;c.n43=g*m*y-f*n*y-g*h*z+e*n*z+f*h*x-e*m*x;c.n44=f*n*o-g*m*o+g*h*t-e*n*t-f*h*v+e*m*v;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,h=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*h+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*j;e[3]=b*h;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*t;return c}; +THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,k=b.n22,o=b.n23,m=b.n24,p=b.n31,u=b.n32,v=b.n33,t=b.n34,w=b.n41,x=b.n42,B=b.n43,A=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=o*t*x-m*v*x+m*u*B-k*t*B-o*u*A+k*v*A;c.n12=j*v*x-g*t*x-j*u*B+f*t*B+g*u*A-f*v*A;c.n13=g*m*x-j*o*x+j*k*B-f*m*B-g*k*A+f*o*A;c.n14=j*o*u-g*m*u-j*k*v+f*m*v+g*k*t-f*o*t;c.n21=m*v*w-o*t*w-m*p*B+h*t*B+o*p*A-h*v*A;c.n22=g*t*w-j*v*w+j*p*B-e*t*B-g*p*A+e*v*A;c.n23=j*o*w-g*m*w-j*h*B+e*m*B+g*h*A-e*o*A;c.n24= +g*m*p-j*o*p+j*h*v-e*m*v-g*h*t+e*o*t;c.n31=k*t*w-m*u*w+m*p*x-h*t*x-k*p*A+h*u*A;c.n32=j*u*w-f*t*w-j*p*x+e*t*x+f*p*A-e*u*A;c.n33=g*m*w-j*k*w+j*h*x-e*m*x-f*h*A+e*k*A;c.n34=j*k*p-f*m*p-j*h*u+e*m*u+f*h*t-e*k*t;c.n41=o*u*w-k*v*w-o*p*x+h*v*x+k*p*B-h*u*B;c.n42=f*v*w-g*u*w+g*p*x-e*v*x-f*p*B+e*u*B;c.n43=g*k*w-f*o*w-g*h*x+e*o*x+f*h*B-e*k*B;c.n44=f*o*p-g*k*p+g*h*u-e*o*u-f*h*v+e*k*v;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,h=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,o=-b.n32*b.n11+b.n31*b.n12,m=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*h+b.n31*m;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*j;e[3]=b*h;e[4]=b*k;e[5]=b*o;e[6]=b*m;e[7]=b*p;e[8]=b*u;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,g,j){var h;h=new THREE.Matrix4;h.n11=2*g/(c-b);h.n12=0;h.n13=(c+b)/(c-b);h.n14=0;h.n21=0;h.n22=2*g/(f-e);h.n23=(f+e)/(f-e);h.n24=0;h.n31=0;h.n32=0;h.n33=-(j+g)/(j-g);h.n34=-2*j*g/(j-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(b,c,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,e,f)}; -THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var h,m,n,p;h=new THREE.Matrix4;m=c-b;n=e-f;p=j-g;h.n11=2/m;h.n12=0;h.n13=0;h.n14=-((c+b)/m);h.n21=0;h.n22=2/n;h.n23=0;h.n24=-((e+f)/n);h.n31=0;h.n32=0;h.n33=-2/p;h.n34=-((j+g)/p);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var h,k,o,m;h=new THREE.Matrix4;k=c-b;o=e-f;m=j-g;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+b)/k);h.n21=0;h.n22=2/o;h.n23=0;h.n24=-((e+f)/o);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((j+g)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion; this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)=== -1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var e,f,g;e=0;for(f=this.children.length;e=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.001)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*j)/h;f=Math.sin(f*j)/h;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,c,e,f,g,j){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,e,f,g,j,h){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; THREE.UV.prototype={constructor:THREE.UV,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.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,c,e;b=0;for(c=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?j:j+1;e[3]=j>this.points.length-3?j:j+2;p=this.points[e[0]];o=this.points[e[1]]; -t=this.points[e[2]];v=this.points[e[3]];m=h*h;n=h*m;f.x=c(p.x,o.x,t.x,v.x,h,m,n);f.y=c(p.y,o.y,t.y,v.y,h,m,n);f.z=c(p.z,o.z,t.z,v.z,h,m,n);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;bthis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?j:j+1;e[3]=j>this.points.length-3?j:j+2;m=this.points[e[0]];p=this.points[e[1]]; +u=this.points[e[2]];v=this.points[e[3]];k=h*h;o=h*k;f.x=c(m.x,p.x,u.x,v.x,h,k,o);f.y=c(m.y,p.y,u.y,v.y,h,k,o);f.z=c(m.z,p.z,u.z,v.z,h,k,o);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, -this.LODs[f].object3D.visible=!0;else break;for(;ft&&(e=o,o=t,t=e):ou&&(e=v,v=u,u=e):v=0&&g>=0&&k>=0&&j>=0?!0:h<0&&g<0||k<0&&j<0?!1:(h<0?c=Math.max(c,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),k<0?c=Math.max(c,k/(k-j)):j<0&&(f=Math.min(f,k/(k-j))),fS&&h.positionScreen.z0&&J.z<1))ca=B[H]=B[H]||new THREE.RenderableParticle,H++,w=ca,w.x=J.x/J.w,w.y=J.y/J.w,w.z=J.z,w.rotation=X.rotation.z,w.scale.x=X.scale.x*Math.abs(w.x-(J.x+g.projectionMatrix.n11)/ -(J.w+g.projectionMatrix.n14)),w.scale.y=X.scale.y*Math.abs(w.y-(J.y+g.projectionMatrix.n22)/(J.w+g.projectionMatrix.n24)),w.materials=X.materials,F.push(w);j&&F.sort(c);return F}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var n,p,o,t,v,u,y,z;b=c.projectScene(e,f);n=0;for(p=b.length;n0&&(e(THREE.NormalBlending),c(1),g("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b* -255)+","+z+")"),u.fillRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(b,n){function p(b){var e,c,f,h=b.lights;ra.setRGB(0,0,0);xa.setRGB(0,0,0);Ba.setRGB(0,0,0);b=0;for(e=h.length;b>1,o=p.height>>1,j=h.scale.x*t,n=h.scale.y*v,k=j*va,m=n*o,na.set(b.x-k,b.y-m,b.x+k,b.y+m),W.instersects(na)&&(u.save(),u.translate(b.x,b.y),u.rotate(-h.rotation),u.scale(j,-n),u.translate(-va,-o),u.drawImage(p,0,0),u.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*t,m=h.scale.y*v,na.set(b.x-k,b.y-m,b.x+k,b.y+m),W.instersects(na)&&(f(j.color.getContextStyle()),g(j.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-h.rotation),u.scale(k,m), -j.program(u),u.restore()))}function Ya(b,h,g,j){c(j.opacity);e(j.blending);u.beginPath();u.moveTo(b.positionScreen.x,b.positionScreen.y);u.lineTo(h.positionScreen.x,h.positionScreen.y);u.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(F!=b)u.lineWidth=F=b;b=j.linecap;if(J!=b)u.lineCap=J=b;b=j.linejoin;if(D!=b)u.lineJoin=D=b;f(j.color.getContextStyle());u.stroke();na.inflate(j.linewidth*2)}}function y(b,f,h,g,m,t,p,u,v){j.data.vertices+=3;j.data.faces++;c(u.opacity);e(u.blending); -C=b.positionScreen.x;ea=b.positionScreen.y;S=f.positionScreen.x;P=f.positionScreen.y;k=h.positionScreen.x;M=h.positionScreen.y;z(C,ea,S,P,k,M);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ja=p.uvs[0],H(C,ea,S,P,k,M,ja[g].u,ja[g].v,ja[m].u,ja[m].v,ja[t].u,ja[t].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=n.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),qa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5, -wa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[1]),Aa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,La=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[2]),za=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Oa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,H(C,ea,S,P,k,M,qa,wa,Aa,La,za,Oa,u.envMap)}else u.wireframe?B(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&& -(u.map.mapping instanceof THREE.UVMapping&&(ja=p.uvs[0],H(C,ea,S,P,k,M,ja[g].u,ja[g].v,ja[m].u,ja[m].v,ja[t].u,ja[t].v,u.map)),e(THREE.SubtractiveBlending)),ua?!u.wireframe&&u.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(X.r=ca.r=ma.r=ra.r,X.g=ca.g=ma.g=ra.g,X.b=ca.b=ma.b=ra.b,o(v,p.v1.positionWorld,p.vertexNormalsWorld[0],X),o(v,p.v2.positionWorld,p.vertexNormalsWorld[1],ca),o(v,p.v3.positionWorld,p.vertexNormalsWorld[2],ma),la.r=(ca.r+ma.r)*0.5,la.g=(ca.g+ma.g)*0.5,la.b=(ca.b+ma.b)* -0.5,ga=Ta(X,ca,ma,la),Pa(C,ea,S,P,k,M,0,0,1,0,0,1,ga)):(ia.r=ra.r,ia.g=ra.g,ia.b=ra.b,o(v,p.centroidWorld,p.normalWorld,ia),U.r=Math.max(0,Math.min(u.color.r*ia.r,1)),U.g=Math.max(0,Math.min(u.color.g*ia.g,1)),U.b=Math.max(0,Math.min(u.color.b*ia.b,1)),u.wireframe?B(U,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(U)):u.wireframe?B(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(u.color);else if(u instanceof THREE.MeshDepthMaterial)K=n.near,V=n.far,X.r=X.g= -X.b=1-Ma(b.positionScreen.z,K,V),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,K,V),ma.r=ma.g=ma.b=1-Ma(h.positionScreen.z,K,V),la.r=(ca.r+ma.r)*0.5,la.g=(ca.g+ma.g)*0.5,la.b=(ca.b+ma.b)*0.5,ga=Ta(X,ca,ma,la),Pa(C,ea,S,P,k,M,0,0,1,0,0,1,ga);else if(u instanceof THREE.MeshNormalMaterial)U.r=Qa(p.normalWorld.x),U.g=Qa(p.normalWorld.y),U.b=Qa(p.normalWorld.z),u.wireframe?B(U,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(U)}function w(b,f,h,g,m,p,u,t,v){j.data.vertices+=4;j.data.faces++;c(t.opacity); -e(t.blending);if(t.map||t.envMap)y(b,f,g,0,1,3,u,t,v),y(m,h,p,1,2,3,u,t,v);else if(C=b.positionScreen.x,ea=b.positionScreen.y,S=f.positionScreen.x,P=f.positionScreen.y,k=h.positionScreen.x,M=h.positionScreen.y,Y=g.positionScreen.x,aa=g.positionScreen.y,Z=m.positionScreen.x,ha=m.positionScreen.y,ka=p.positionScreen.x,fa=p.positionScreen.y,t instanceof THREE.MeshBasicMaterial)x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(t.color);else if(t instanceof -THREE.MeshLambertMaterial)ua?!t.wireframe&&t.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4?(X.r=ca.r=ma.r=la.r=ra.r,X.g=ca.g=ma.g=la.g=ra.g,X.b=ca.b=ma.b=la.b=ra.b,o(v,u.v1.positionWorld,u.vertexNormalsWorld[0],X),o(v,u.v2.positionWorld,u.vertexNormalsWorld[1],ca),o(v,u.v4.positionWorld,u.vertexNormalsWorld[3],ma),o(v,u.v3.positionWorld,u.vertexNormalsWorld[2],la),ga=Ta(X,ca,ma,la),z(C,ea,S,P,Y,aa),Pa(C,ea,S,P,Y,aa,0,0,1,0,0,1,ga),z(Z,ha,k,M,ka,fa),Pa(Z,ha,k,M,ka,fa,1,0,1,1,0,1,ga)): -(ia.r=ra.r,ia.g=ra.g,ia.b=ra.b,o(v,u.centroidWorld,u.normalWorld,ia),U.r=Math.max(0,Math.min(t.color.r*ia.r,1)),U.g=Math.max(0,Math.min(t.color.g*ia.g,1)),U.b=Math.max(0,Math.min(t.color.b*ia.b,1)),x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(U,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(U)):(x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(t.color));else if(t instanceof THREE.MeshNormalMaterial)U.r=Qa(u.normalWorld.x),U.g=Qa(u.normalWorld.y), -U.b=Qa(u.normalWorld.z),x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(U,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(U);else if(t instanceof THREE.MeshDepthMaterial)K=n.near,V=n.far,X.r=X.g=X.b=1-Ma(b.positionScreen.z,K,V),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,K,V),ma.r=ma.g=ma.b=1-Ma(g.positionScreen.z,K,V),la.r=la.g=la.b=1-Ma(h.positionScreen.z,K,V),ga=Ta(X,ca,ma,la),z(C,ea,S,P,Y,aa),Pa(C,ea,S,P,Y,aa,0,0,1,0,0,1,ga),z(Z,ha,k,M,ka,fa),Pa(Z,ha,k,M,ka,fa,1,0,1,1,0,1,ga)}function z(b,e,c,f, -h,g){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(h,g);u.lineTo(b,e);u.closePath()}function x(b,e,c,f,h,g,j,k){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(h,g);u.lineTo(j,k);u.lineTo(b,e);u.closePath()}function B(b,e,c,h){if(F!=e)u.lineWidth=F=e;if(J!=c)u.lineCap=J=c;if(D!=h)u.lineJoin=D=h;f(b.getContextStyle());u.stroke();na.inflate(e*2)}function Ha(b){g(b.getContextStyle());u.fill()}function H(b,e,c,f,h,j,k,m,n,t,p,va,o){if(o.image.width!=0){if(o.needsUpdate==!0||sa[o.id]==void 0){var v= -o.wrapS==THREE.RepeatWrapping,Sa=o.wrapT==THREE.RepeatWrapping;sa[o.id]=u.createPattern(o.image,v&&Sa?"repeat":v&&!Sa?"repeat-x":!v&&Sa?"repeat-y":"no-repeat");o.needsUpdate=!1}g(sa[o.id]);v=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;k*=v;m*=o;n*=v;t*=o;p*=v;va*=o;c-=b;f-=e;h-=b;j-=e;n-=k;t-=m;p-=k;va-=m;v=1/(n*va-p*t);o=(va*c-t*h)*v;t=(va*f-t*j)*v;c=(n*h-p*c)*v;f=(n*j-p*f)*v;b=b-o*k-c*m;e=e-t*k-f*m;u.save();u.transform(o,t,c,f,b,e);u.fill();u.restore()}}function Pa(b,e,c,f,h,g, -j,k,m,n,t,p,o){var va,v;va=o.width-1;v=o.height-1;j*=va;k*=v;m*=va;n*=v;t*=va;p*=v;c-=b;f-=e;h-=b;g-=e;m-=j;n-=k;t-=j;p-=k;v=1/(m*p-t*n);va=(p*c-n*h)*v;n=(p*f-n*g)*v;c=(m*h-t*c)*v;f=(m*g-t*f)*v;b=b-va*j-c*k;e=e-n*j-f*k;u.save();u.transform(va,n,c,f,b,e);u.clip();u.drawImage(o,0,0);u.restore()}function Ta(b,e,c,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),p=~~(f.g*255),f=~~(f.b*255);Q[0]=h<0?0:h>255? -255:h;Q[1]=g<0?0:g>255?255:g;Q[2]=b<0?0:b>255?255:b;Q[4]=j<0?0:j>255?255:j;Q[5]=k<0?0:k>255?255:k;Q[6]=e<0?0:e>255?255:e;Q[8]=m<0?0:m>255?255:m;Q[9]=n<0?0:n>255?255:n;Q[10]=c<0?0:c>255?255:c;Q[12]=t<0?0:t>255?255:t;Q[13]=p<0?0:p>255?255:p;Q[14]=f<0?0:f>255?255:f;Da.putImageData($,0,0);O.drawImage(ya,0,0);return Ea}function Ma(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Qa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ia(b,e){var c=e.x-b.x,f=e.y-b.y,h=c*c+f*f;h!=0&&(h=1/Math.sqrt(h),c*=h,f*=h, -e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ua,Xa,oa,Ca,Ja,Ra,Va,E;this.autoClear?this.clear():u.setTransform(1,0,0,-1,t,v);j.data.vertices=0;j.data.faces=0;h=m.projectScene(b,n,this.sortElements);(ua=b.lights.length>0)&&p(b);Ua=0;for(Xa=h.length;Ua0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j)):g instanceof THREE.PointLight&&(R.sub(g.position,e.centroidWorld),R.normalize(),j=e.normalWorld.dot(R)*g.intensity,j>0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j))}function c(e,c,h,m,t,p){j.data.vertices+=3;j.data.faces++;C=f(ea++);C.setAttribute("d", -"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?F.copy(t.color):t instanceof THREE.MeshLambertMaterial?B?(J.r=D.r,J.g=D.g,J.b=D.b,b(p,m,J),F.r=Math.max(0,Math.min(t.color.r*J.r,1)),F.g=Math.max(0,Math.min(t.color.g*J.g,1)),F.b=Math.max(0,Math.min(t.color.b*J.b,1))):F.copy(t.color):t instanceof THREE.MeshDepthMaterial?(I=1-t.__2near/(t.__farPlusNear-m.z*t.__farMinusNear), -F.setRGB(I,I,I)):t instanceof THREE.MeshNormalMaterial&&F.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));t.wireframe?C.setAttribute("style","fill: none; stroke: "+F.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):C.setAttribute("style","fill: "+F.getContextStyle()+"; fill-opacity: "+t.opacity);n.appendChild(C)}function e(e,c,h,m,t,p,u){j.data.vertices+=4;j.data.faces++; -C=f(ea++);C.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?F.copy(p.color):p instanceof THREE.MeshLambertMaterial?B?(J.r=D.r,J.g=D.g,J.b=D.b,b(u,t,J),F.r=Math.max(0,Math.min(p.color.r*J.r,1)),F.g=Math.max(0,Math.min(p.color.g*J.g,1)),F.b=Math.max(0,Math.min(p.color.b*J.b,1))):F.copy(p.color):p instanceof -THREE.MeshDepthMaterial?(I=1-p.__2near/(p.__farPlusNear-t.z*p.__farMinusNear),F.setRGB(I,I,I)):p instanceof THREE.MeshNormalMaterial&&F.setRGB(g(t.normalWorld.x),g(t.normalWorld.y),g(t.normalWorld.z));p.wireframe?C.setAttribute("style","fill: none; stroke: "+F.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):C.setAttribute("style","fill: "+F.getContextStyle()+"; fill-opacity: "+ -p.opacity);n.appendChild(C)}function f(b){da[b]==null&&(da[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),P==0&&da[b].setAttribute("shape-rendering","crispEdges"));return da[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var j=this,h=null,m=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,o,t,v,u,y,z,x,w=new THREE.Rectangle,H=new THREE.Rectangle,B=!1,F=new THREE.Color(16777215),J=new THREE.Color(16777215),D=new THREE.Color(0),L=new THREE.Color(0), -G=new THREE.Color(0),I,R=new THREE.Vector3,da=[],T=[],C,ea,S,P=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":P=1;break;case "low":P=0}};this.setSize=function(b,e){p=b;o=e;t=p/2;v=o/2;n.setAttribute("viewBox",-t+" "+-v+" "+p+" "+o);n.setAttribute("width",p);n.setAttribute("height",o);w.set(-t,-v,t,v)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render= -function(b,f){var g,p,o,F,J,I,U,X;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;h=m.projectScene(b,f,this.sortElements);S=ea=0;if(B=b.lights.length>0){U=b.lights;D.setRGB(0,0,0);L.setRGB(0,0,0);G.setRGB(0,0,0);g=0;for(p=U.length;g=0&&g>=0&&j>=0&&k>=0?!0:h<0&&g<0||j<0&&k<0?!1:(h<0?e=Math.max(e,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),j<0?e=Math.max(e,j/(j-k)):k<0&&(f=Math.min(f,j/(j-k))),fG&&h.positionScreen.z0&&I.z<1))aa=y[H]=y[H]||new THREE.RenderableParticle,H++,A=aa,A.x=I.x/I.w,A.y=I.y/I.w,A.z=I.z,A.rotation=P.rotation.z,A.scale.x= +P.scale.x*Math.abs(A.x-(I.x+g.projectionMatrix.n11)/(I.w+g.projectionMatrix.n14)),A.scale.y=P.scale.y*Math.abs(A.y-(I.y+g.projectionMatrix.n22)/(I.w+g.projectionMatrix.n24)),A.materials=P.materials,n.push(A);j&&n.sort(c);return n}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var o,m,p,u,v,t,w,x;b=c.projectScene(e,f);o=0;for(m=b.length;o0&&(e(THREE.NormalBlending),c(1),g("rgba("+Math.floor(w.r*255)+","+Math.floor(w.g*255)+","+Math.floor(w.b* +255)+","+x+")"),t.fillRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()))),$.empty())};this.render=function(b,o){function m(b){var c,e,f,h=b.lights;ma.setRGB(0,0,0);Ga.setRGB(0,0,0);Da.setRGB(0,0,0);b=0;for(c=h.length;b>1,ga=m.height>>1,j=h.scale.x*u,o=h.scale.y*v,k=j*p,n=o*ga,ta.set(b.x-k,b.y-n,b.x+k,b.y+n),ya.instersects(ta)&&(t.save(),t.translate(b.x,b.y),t.rotate(-h.rotation),t.scale(j,-o),t.translate(-p,-ga),t.drawImage(m,0,0),t.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,n=h.scale.y*v,ta.set(b.x-k,b.y-n,b.x+k,b.y+n),ya.instersects(ta)&&(f(j.color.getContextStyle()),g(j.color.getContextStyle()),t.save(),t.translate(b.x,b.y),t.rotate(-h.rotation),t.scale(k, +n),j.program(t),t.restore()))}function x(b,h,g,j){c(j.opacity);e(j.blending);t.beginPath();t.moveTo(b.positionScreen.x,b.positionScreen.y);t.lineTo(h.positionScreen.x,h.positionScreen.y);t.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(G!=b)t.lineWidth=G=b;b=j.linecap;if(I!=b)t.lineCap=I=b;b=j.linejoin;if(E!=b)t.lineJoin=E=b;f(j.color.getContextStyle());t.stroke();ta.inflate(j.linewidth*2)}}function A(b,f,h,g,k,m,u,t,ga){j.data.vertices+=3;j.data.faces++;c(t.opacity);e(t.blending); +C=b.positionScreen.x;n=b.positionScreen.y;W=f.positionScreen.x;V=f.positionScreen.y;fa=h.positionScreen.x;L=h.positionScreen.y;y(C,n,W,V,fa,L);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(pa=u.uvs[0],Za(C,n,W,V,fa,L,pa[g].u,pa[g].v,pa[k].u,pa[k].v,pa[m].u,pa[m].v,t.map));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=o.matrixWorldInverse,N.copy(u.vertexNormalsWorld[0]),sa=(N.x*b.n11+N.y*b.n12+N.z*b.n13)*0.5+0.5,ua= +-(N.x*b.n21+N.y*b.n22+N.z*b.n23)*0.5+0.5,N.copy(u.vertexNormalsWorld[1]),Ia=(N.x*b.n11+N.y*b.n12+N.z*b.n13)*0.5+0.5,Ja=-(N.x*b.n21+N.y*b.n22+N.z*b.n23)*0.5+0.5,N.copy(u.vertexNormalsWorld[2]),Ka=(N.x*b.n11+N.y*b.n12+N.z*b.n13)*0.5+0.5,va=-(N.x*b.n21+N.y*b.n22+N.z*b.n23)*0.5+0.5,Za(C,n,W,V,fa,L,sa,ua,Ia,Ja,Ka,va,t.envMap)}else t.wireframe?La(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ma(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof +THREE.UVMapping&&(pa=u.uvs[0],Za(C,n,W,V,fa,L,pa[g].u,pa[g].v,pa[k].u,pa[k].v,pa[m].u,pa[m].v,t.map)),e(THREE.SubtractiveBlending)),Ea?!t.wireframe&&t.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3?(P.r=aa.r=Y.r=ma.r,P.g=aa.g=Y.g=ma.g,P.b=aa.b=Y.b=ma.b,p(ga,u.v1.positionWorld,u.vertexNormalsWorld[0],P),p(ga,u.v2.positionWorld,u.vertexNormalsWorld[1],aa),p(ga,u.v3.positionWorld,u.vertexNormalsWorld[2],Y),Z.r=(aa.r+Y.r)*0.5,Z.g=(aa.g+Y.g)*0.5,Z.b=(aa.b+Y.b)*0.5,ka=Wa(P,aa,Y,Z),Ta(C,n, +W,V,fa,L,0,0,1,0,0,1,ka)):(oa.r=ma.r,oa.g=ma.g,oa.b=ma.b,p(ga,u.centroidWorld,u.normalWorld,oa),M.r=Math.max(0,Math.min(t.color.r*oa.r,1)),M.g=Math.max(0,Math.min(t.color.g*oa.g,1)),M.b=Math.max(0,Math.min(t.color.b*oa.b,1)),t.wireframe?La(M,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ma(M)):t.wireframe?La(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ma(t.color);else if(t instanceof THREE.MeshDepthMaterial)ja=o.near,la=o.far,P.r=P.g=P.b=1-Oa(b.positionScreen.z, +ja,la),aa.r=aa.g=aa.b=1-Oa(f.positionScreen.z,ja,la),Y.r=Y.g=Y.b=1-Oa(h.positionScreen.z,ja,la),Z.r=(aa.r+Y.r)*0.5,Z.g=(aa.g+Y.g)*0.5,Z.b=(aa.b+Y.b)*0.5,ka=Wa(P,aa,Y,Z),Ta(C,n,W,V,fa,L,0,0,1,0,0,1,ka);else if(t instanceof THREE.MeshNormalMaterial)M.r=Ua(u.normalWorld.x),M.g=Ua(u.normalWorld.y),M.b=Ua(u.normalWorld.z),t.wireframe?La(M,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ma(M)}function B(b,f,h,g,k,u,t,m,ga){j.data.vertices+=4;j.data.faces++;c(m.opacity);e(m.blending);if(m.map|| +m.envMap)A(b,f,g,0,1,3,t,m,ga),A(k,h,u,1,2,3,t,m,ga);else if(C=b.positionScreen.x,n=b.positionScreen.y,W=f.positionScreen.x,V=f.positionScreen.y,fa=h.positionScreen.x,L=h.positionScreen.y,ea=g.positionScreen.x,T=g.positionScreen.y,U=k.positionScreen.x,da=k.positionScreen.y,ha=u.positionScreen.x,ia=u.positionScreen.y,m instanceof THREE.MeshBasicMaterial)H(C,n,W,V,fa,L,ea,T),m.wireframe?La(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Ma(m.color);else if(m instanceof THREE.MeshLambertMaterial)Ea? +!m.wireframe&&m.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(P.r=aa.r=Y.r=Z.r=ma.r,P.g=aa.g=Y.g=Z.g=ma.g,P.b=aa.b=Y.b=Z.b=ma.b,p(ga,t.v1.positionWorld,t.vertexNormalsWorld[0],P),p(ga,t.v2.positionWorld,t.vertexNormalsWorld[1],aa),p(ga,t.v4.positionWorld,t.vertexNormalsWorld[3],Y),p(ga,t.v3.positionWorld,t.vertexNormalsWorld[2],Z),ka=Wa(P,aa,Y,Z),y(C,n,W,V,ea,T),Ta(C,n,W,V,ea,T,0,0,1,0,0,1,ka),y(U,da,fa,L,ha,ia),Ta(U,da,fa,L,ha,ia,1,0,1,1,0,1,ka)):(oa.r=ma.r,oa.g=ma.g,oa.b=ma.b,p(ga, +t.centroidWorld,t.normalWorld,oa),M.r=Math.max(0,Math.min(m.color.r*oa.r,1)),M.g=Math.max(0,Math.min(m.color.g*oa.g,1)),M.b=Math.max(0,Math.min(m.color.b*oa.b,1)),H(C,n,W,V,fa,L,ea,T),m.wireframe?La(M,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Ma(M)):(H(C,n,W,V,fa,L,ea,T),m.wireframe?La(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Ma(m.color));else if(m instanceof THREE.MeshNormalMaterial)M.r=Ua(t.normalWorld.x),M.g=Ua(t.normalWorld.y),M.b=Ua(t.normalWorld.z), +H(C,n,W,V,fa,L,ea,T),m.wireframe?La(M,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Ma(M);else if(m instanceof THREE.MeshDepthMaterial)ja=o.near,la=o.far,P.r=P.g=P.b=1-Oa(b.positionScreen.z,ja,la),aa.r=aa.g=aa.b=1-Oa(f.positionScreen.z,ja,la),Y.r=Y.g=Y.b=1-Oa(g.positionScreen.z,ja,la),Z.r=Z.g=Z.b=1-Oa(h.positionScreen.z,ja,la),ka=Wa(P,aa,Y,Z),y(C,n,W,V,ea,T),Ta(C,n,W,V,ea,T,0,0,1,0,0,1,ka),y(U,da,fa,L,ha,ia),Ta(U,da,fa,L,ha,ia,1,0,1,1,0,1,ka)}function y(b,c,e,f,h,g){t.beginPath();t.moveTo(b, +c);t.lineTo(e,f);t.lineTo(h,g);t.lineTo(b,c);t.closePath()}function H(b,c,e,f,h,g,j,k){t.beginPath();t.moveTo(b,c);t.lineTo(e,f);t.lineTo(h,g);t.lineTo(j,k);t.lineTo(b,c);t.closePath()}function La(b,c,e,h){if(G!=c)t.lineWidth=G=c;if(I!=e)t.lineCap=I=e;if(E!=h)t.lineJoin=E=h;f(b.getContextStyle());t.stroke();ta.inflate(c*2)}function Ma(b){g(b.getContextStyle());t.fill()}function Za(b,c,e,f,h,j,k,n,o,m,u,p,ga){if(ga.image.width!=0){if(ga.needsUpdate==!0||ca[ga.id]==void 0){var v=ga.wrapS==THREE.RepeatWrapping, +Ba=ga.wrapT==THREE.RepeatWrapping;ca[ga.id]=t.createPattern(ga.image,v&&Ba?"repeat":v&&!Ba?"repeat-x":!v&&Ba?"repeat-y":"no-repeat");ga.needsUpdate=!1}g(ca[ga.id]);var v=ga.offset.x/ga.repeat.x,Ba=ga.offset.y/ga.repeat.y,w=(ga.image.width-1)*ga.repeat.x,ga=(ga.image.height-1)*ga.repeat.y,k=(k+v)*w,n=(n+Ba)*ga,o=(o+v)*w,m=(m+Ba)*ga,u=(u+v)*w,p=(p+Ba)*ga;e-=b;f-=c;h-=b;j-=c;o-=k;m-=n;u-=k;p-=n;v=1/(o*p-u*m);ga=(p*e-m*h)*v;m=(p*f-m*j)*v;e=(o*h-u*e)*v;f=(o*j-u*f)*v;b=b-ga*k-e*n;c=c-m*k-f*n;t.save();t.transform(ga, +m,e,f,b,c);t.fill();t.restore()}}function Ta(b,c,e,f,h,g,j,k,n,o,m,u,ga){var p,v;p=ga.width-1;v=ga.height-1;j*=p;k*=v;n*=p;o*=v;m*=p;u*=v;e-=b;f-=c;h-=b;g-=c;n-=j;o-=k;m-=j;u-=k;v=1/(n*u-m*o);p=(u*e-o*h)*v;o=(u*f-o*g)*v;e=(n*h-m*e)*v;f=(n*g-m*f)*v;b=b-p*j-e*k;c=c-o*j-f*k;t.save();t.transform(p,o,e,f,b,c);t.clip();t.drawImage(ga,0,0);t.restore()}function Wa(b,c,e,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(c.r*255),k=~~(c.g*255),c=~~(c.b*255),n=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),m=~~(f.r* +255),u=~~(f.g*255),f=~~(f.b*255);Aa[0]=h<0?0:h>255?255:h;Aa[1]=g<0?0:g>255?255:g;Aa[2]=b<0?0:b>255?255:b;Aa[4]=j<0?0:j>255?255:j;Aa[5]=k<0?0:k>255?255:k;Aa[6]=c<0?0:c>255?255:c;Aa[8]=n<0?0:n>255?255:n;Aa[9]=o<0?0:o>255?255:o;Aa[10]=e<0?0:e>255?255:e;Aa[12]=m<0?0:m>255?255:m;Aa[13]=u<0?0:u>255?255:u;Aa[14]=f<0?0:f>255?255:f;ga.putImageData(Ya,0,0);Va.drawImage(za,0,0);return Ba}function Oa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Ua(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Na(b,c){var e= +c.x-b.x,f=c.y-b.y,h=e*e+f*f;h!=0&&(h=1/Math.sqrt(h),e*=h,f*=h,c.x+=e,c.y+=f,b.x-=e,b.y-=f)}var Xa,$a,na,Ca,F,z,Q,wa;this.autoClear?this.clear():t.setTransform(1,0,0,-1,u,v);j.data.vertices=0;j.data.faces=0;h=k.projectScene(b,o,this.sortElements);(Ea=b.lights.length>0)&&m(b);Xa=0;for($a=h.length;Xa<$a;Xa++){na=h[Xa];ta.empty();if(na instanceof THREE.RenderableParticle){K=na;K.x*=u;K.y*=v;Ca=0;for(F=na.materials.length;Ca0&&(e.r+=g.color.r*j,e.g+=g.color.g*j,e.b+=g.color.b*j)):g instanceof THREE.PointLight&&(S.sub(g.position,c.centroidWorld),S.normalize(),j=c.normalWorld.dot(S)*g.intensity,j>0&&(e.r+=g.color.r*j,e.g+=g.color.g*j,e.b+=g.color.b*j))}function c(c,e,h,k,m,u){j.data.vertices+=3;j.data.faces++;C=f(n++);C.setAttribute("d", +"M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?G.copy(m.color):m instanceof THREE.MeshLambertMaterial?y?(I.r=E.r,I.g=E.g,I.b=E.b,b(u,k,I),G.r=Math.max(0,Math.min(m.color.r*I.r,1)),G.g=Math.max(0,Math.min(m.color.g*I.g,1)),G.b=Math.max(0,Math.min(m.color.b*I.b,1))):G.copy(m.color):m instanceof THREE.MeshDepthMaterial?(J=1-m.__2near/(m.__farPlusNear-k.z*m.__farMinusNear), +G.setRGB(J,J,J)):m instanceof THREE.MeshNormalMaterial&&G.setRGB(g(k.normalWorld.x),g(k.normalWorld.y),g(k.normalWorld.z));m.wireframe?C.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):C.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+m.opacity);o.appendChild(C)}function e(c,e,h,k,m,u,t){j.data.vertices+=4;j.data.faces++; +C=f(n++);C.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");u instanceof THREE.MeshBasicMaterial?G.copy(u.color):u instanceof THREE.MeshLambertMaterial?y?(I.r=E.r,I.g=E.g,I.b=E.b,b(t,m,I),G.r=Math.max(0,Math.min(u.color.r*I.r,1)),G.g=Math.max(0,Math.min(u.color.g*I.g,1)),G.b=Math.max(0,Math.min(u.color.b*I.b,1))):G.copy(u.color):u instanceof +THREE.MeshDepthMaterial?(J=1-u.__2near/(u.__farPlusNear-m.z*u.__farMinusNear),G.setRGB(J,J,J)):u instanceof THREE.MeshNormalMaterial&&G.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));u.wireframe?C.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+u.wireframeLinewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: "+u.wireframeLinecap+"; stroke-linejoin: "+u.wireframeLinejoin):C.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+ +u.opacity);o.appendChild(C)}function f(b){X[b]==null&&(X[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&X[b].setAttribute("shape-rendering","crispEdges"));return X[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var j=this,h=null,k=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,u,v,t,w,x,B,A=new THREE.Rectangle,H=new THREE.Rectangle,y=!1,G=new THREE.Color(16777215),I=new THREE.Color(16777215),E=new THREE.Color(0),K=new THREE.Color(0), +D=new THREE.Color(0),J,S=new THREE.Vector3,X=[],R=[],C,n,W,V=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":V=1;break;case "low":V=0}};this.setSize=function(b,c){m=b;p=c;u=m/2;v=p/2;o.setAttribute("viewBox",-u+" "+-v+" "+m+" "+p);o.setAttribute("width",m);o.setAttribute("height",p);A.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,m,p,G,I,J,M,P;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;h=k.projectScene(b,f,this.sortElements);W=n=0;if(y=b.lights.length>0){M=b.lights;E.setRGB(0,0,0);K.setRGB(0,0,0);D.setRGB(0,0,0);g=0;for(m=M.length;g=0)k.bindBuffer(k.ARRAY_BUFFER,g.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0);else if(j.morphTargetBase){c=h.program.attributes;j.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[j.morphTargetBase]),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f= -0,n=j.morphTargetForcedOrder,t=j.morphTargetInfluences;fp&&(u=o,p=t[u]);k.bindBuffer(k.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[u]); -k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]=p;n[u]=1;p=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(h.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(m in g.__webglCustomAttributes)b[m]>=0&&(c=g.__webglCustomAttributes[m],k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[m],c.size,k.FLOAT,!1,0,0));b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglColorBuffer), -k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER, -g.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex, -4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0));j instanceof THREE.Mesh?(h.wireframe?(k.lineWidth(h.wireframeLinewidth),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),k.drawElements(k.LINES,g.__webglLineCount,k.UNSIGNED_SHORT,0)):(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),k.drawElements(k.TRIANGLES,g.__webglFaceCount,k.UNSIGNED_SHORT,0)),P.data.vertices+=g.__webglFaceCount,P.data.faces+=g.__webglFaceCount/ -3,P.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?k.LINE_STRIP:k.LINES,k.lineWidth(h.linewidth),k.drawArrays(j,0,g.__webglLineCount),P.data.drawCalls++):j instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,g.__webglParticleCount),P.data.drawCalls++):j instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,g.__webglVertexCount),P.data.drawCalls++)}}function g(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=k.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer= -k.createBuffer();b.hasPos&&(k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,b.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(c.attributes.position),k.vertexAttribPointer(c.attributes.position,3,k.FLOAT,!1,0,0));if(b.hasNormal){k.bindBuffer(k.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,g,h,j,m,n,t,p,u,o,v=b.count*3;for(o=0;o0&&w[0]0&&w[1]0.001&&m.scale>0.001)y[0]=m.x,y[1]=m.y,y[2]=m.z,u=m.size*m.scale/V,v[0]=u*t,v[1]=u,k.uniform3fv(x.screenPosition,y),k.uniform2fv(x.scale,v),k.uniform1f(x.rotation,m.rotation),k.uniform1f(x.opacity,m.opacity),I(m.blending),da(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(Z)}function H(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse, -b.matrixWorld,b._modelViewMatrixArray);e&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function B(b){var c,e,f,g;g=b.__materials;b=0;for(e=g.length;b0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,aa,j));ra&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglNormalBuffer),k.bufferData(k.ARRAY_BUFFER, -ka,j));Aa&&ia.hasTangents&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglTangentBuffer),k.bufferData(k.ARRAY_BUFFER,W,j));wa&&X>0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,da,j));wa&&Q>0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,ea,j));pa&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,qa,j),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,la,j)); -N>0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,Y,j),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,fa,j),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,ca,j),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,$,j));m&&(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;F(g)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;x=b.vertices;h=b.colors;z=x.length;j=h.length;H=b.__vertexArray;m=b.__colorArray; -G=b.__dirtyColors;if(b.__dirtyVertices){for(n=0;n=0;c--)b[c].object==e&&b.splice(c,1)}function L(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(o[m].counter+=1,n=o[m].hash+"_"+o[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:t})),b.geometryGroups[n].faces.push(h),b.geometryGroups[n].vertices+=j}function G(b,c,e){b.push({buffer:c,object:e, -opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=fa){switch(b){case THREE.AdditiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR);break;default:k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}fa= -b}}function R(b,c,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(k.texParameteri(b,k.TEXTURE_WRAP_S,S(c.wrapS)),k.texParameteri(b,k.TEXTURE_WRAP_T,S(c.wrapT)),k.texParameteri(b,k.TEXTURE_MAG_FILTER,S(c.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,S(c.minFilter)),k.generateMipmap(b)):(k.texParameteri(b,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_MAG_FILTER,ea(c.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,ea(c.minFilter)))} -function da(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture=k.createTexture(),b.__webglInit=!0;k.bindTexture(k.TEXTURE_2D,b.__webglTexture);b.image.data?k.texImage2D(k.TEXTURE_2D,0,S(b.format),b.image.width,b.image.height,0,S(b.format),k.UNSIGNED_BYTE,b.image.data):k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image);R(k.TEXTURE_2D,b,b.image);k.bindTexture(k.TEXTURE_2D,null);b.needsUpdate=!1}k.activeTexture(k.TEXTURE0+c);k.bindTexture(k.TEXTURE_2D,b.__webglTexture)}function T(b){if(b&& -!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=k.createFramebuffer();b.__webglRenderbuffer=k.createRenderbuffer();b.__webglTexture=k.createTexture();k.bindTexture(k.TEXTURE_2D,b.__webglTexture);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,S(b.wrapS));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,S(b.wrapT));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,S(b.magFilter));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER, -S(b.minFilter));k.texImage2D(k.TEXTURE_2D,0,S(b.format),b.width,b.height,0,S(b.format),S(b.type),null);k.bindRenderbuffer(k.RENDERBUFFER,b.__webglRenderbuffer);k.bindFramebuffer(k.FRAMEBUFFER,b.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)): -b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_STENCIL,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height);k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}var c,e;b?(c=b.__webglFramebuffer,e=b.width,b=b.height):(c=null,e=K,b=V);c!=aa&&(k.bindFramebuffer(k.FRAMEBUFFER,c),k.viewport(la, -sa,e,b),aa=c)}function C(b,c){var e;b=="fragment"?e=k.createShader(k.FRAGMENT_SHADER):b=="vertex"&&(e=k.createShader(k.VERTEX_SHADER));k.shaderSource(e,c);k.compileShader(e);if(!k.getShaderParameter(e,k.COMPILE_STATUS))return console.error(k.getShaderInfoLog(e)),console.error(c),null;return e}function ea(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST;default:return k.LINEAR}}function S(b){switch(b){case THREE.RepeatWrapping:return k.REPEAT; -case THREE.ClampToEdgeWrapping:return k.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return k.MIRRORED_REPEAT;case THREE.NearestFilter:return k.NEAREST;case THREE.NearestMipMapNearestFilter:return k.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return k.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return k.LINEAR;case THREE.LinearMipMapNearestFilter:return k.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return k.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return k.BYTE; -case THREE.UnsignedByteType:return k.UNSIGNED_BYTE;case THREE.ShortType:return k.SHORT;case THREE.UnsignedShortType:return k.UNSIGNED_SHORT;case THREE.IntType:return k.INT;case THREE.UnsignedShortType:return k.UNSIGNED_INT;case THREE.FloatType:return k.FLOAT;case THREE.AlphaFormat:return k.ALPHA;case THREE.RGBFormat:return k.RGB;case THREE.RGBAFormat:return k.RGBA;case THREE.LuminanceFormat:return k.LUMINANCE;case THREE.LuminanceAlphaFormat:return k.LUMINANCE_ALPHA}return 0}var P=this,k,M=[],Y=null, -aa=null,Z=!0,ha=null,ka=null,fa=null,U=null,X=null,ca=null,ma=null,la=0,sa=0,K=0,V=0,ga=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Matrix4,qa=new Float32Array(16),wa=new Float32Array(16),Aa=new THREE.Vector4,La={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},za=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Oa=b.stencil!==void 0? -b.stencil:!0,W=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,ta=b.antialias!==void 0?b.antialias:!1,na=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ua=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=za;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov= -50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ia,ra=[],b=THREE.ShaderLib.depthRGBA,xa=THREE.UniformsUtils.clone(b.uniforms),Ba=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa}),pa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa,morphTargets:!0});Ba._shadowPass=!0;pa._shadowPass=!0;try{if(!(k=za.getContext("experimental-webgl",{antialias:ta,stencil:Oa,preserveDrawingBuffer:W})))throw"Error creating WebGL context."; -console.log(navigator.userAgent+" | "+k.getParameter(k.VERSION)+" | "+k.getParameter(k.VENDOR)+" | "+k.getParameter(k.RENDERER)+" | "+k.getParameter(k.SHADING_LANGUAGE_VERSION))}catch(ya){console.error(ya)}k.clearColor(0,0,0,1);k.clearDepth(1);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(na.r,na.g,na.b,ua);this.context=k;var Da=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> -0;if(Oa){var $={};$.vertices=new Float32Array(12);$.faces=new Uint16Array(6);$.darkness=0.5;$.vertices[0]=-20;$.vertices[1]=-20;$.vertices[2]=-1;$.vertices[3]=20;$.vertices[4]=-20;$.vertices[5]=-1;$.vertices[6]=20;$.vertices[7]=20;$.vertices[8]=-1;$.vertices[9]=-20;$.vertices[10]=20;$.vertices[11]=-1;$.faces[0]=0;$.faces[1]=1;$.faces[2]=2;$.faces[3]=0;$.faces[4]=2;$.faces[5]=3;$.vertexBuffer=k.createBuffer();$.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,$.vertexBuffer);k.bufferData(k.ARRAY_BUFFER, -$.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,$.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,$.faces,k.STATIC_DRAW);$.program=k.createProgram();k.attachShader($.program,C("fragment",THREE.ShaderLib.shadowPost.fragmentShader));k.attachShader($.program,C("vertex",THREE.ShaderLib.shadowPost.vertexShader));k.linkProgram($.program);$.vertexLocation=k.getAttribLocation($.program,"position");$.projectionLocation=k.getUniformLocation($.program,"projectionMatrix");$.darknessLocation= -k.getUniformLocation($.program,"darkness")}var Q={};Q.vertices=new Float32Array(16);Q.faces=new Uint16Array(6);W=0;Q.vertices[W++]=-1;Q.vertices[W++]=-1;Q.vertices[W++]=0;Q.vertices[W++]=0;Q.vertices[W++]=1;Q.vertices[W++]=-1;Q.vertices[W++]=1;Q.vertices[W++]=0;Q.vertices[W++]=1;Q.vertices[W++]=1;Q.vertices[W++]=1;Q.vertices[W++]=1;Q.vertices[W++]=-1;Q.vertices[W++]=1;Q.vertices[W++]=0;Q.vertices[W++]=1;W=0;Q.faces[W++]=0;Q.faces[W++]=1;Q.faces[W++]=2;Q.faces[W++]=0;Q.faces[W++]=2;Q.faces[W++]=3; -Q.vertexBuffer=k.createBuffer();Q.elementBuffer=k.createBuffer();Q.tempTexture=k.createTexture();Q.occlusionTexture=k.createTexture();k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,Q.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Q.faces,k.STATIC_DRAW);k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGB,16,16,0,k.RGB,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S, -k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGBA,16,16,0,k.RGBA,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST); -k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(Q.hasVertexTexture=!1,Q.program=k.createProgram(),k.attachShader(Q.program,C("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),k.attachShader(Q.program,C("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(Q.hasVertexTexture=!0,Q.program=k.createProgram(),k.attachShader(Q.program,C("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),k.attachShader(Q.program,C("vertex", -THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));k.linkProgram(Q.program);Q.attributes={};Q.uniforms={};Q.attributes.vertex=k.getAttribLocation(Q.program,"position");Q.attributes.uv=k.getAttribLocation(Q.program,"UV");Q.uniforms.renderType=k.getUniformLocation(Q.program,"renderType");Q.uniforms.map=k.getUniformLocation(Q.program,"map");Q.uniforms.occlusionMap=k.getUniformLocation(Q.program,"occlusionMap");Q.uniforms.opacity=k.getUniformLocation(Q.program,"opacity");Q.uniforms.scale=k.getUniformLocation(Q.program, -"scale");Q.uniforms.rotation=k.getUniformLocation(Q.program,"rotation");Q.uniforms.screenPosition=k.getUniformLocation(Q.program,"screenPosition");var Ea=!1,O={};O.vertices=new Float32Array(16);O.faces=new Uint16Array(6);W=0;O.vertices[W++]=-1;O.vertices[W++]=-1;O.vertices[W++]=0;O.vertices[W++]=1;O.vertices[W++]=1;O.vertices[W++]=-1;O.vertices[W++]=1;O.vertices[W++]=1;O.vertices[W++]=1;O.vertices[W++]=1;O.vertices[W++]=1;O.vertices[W++]=0;O.vertices[W++]=-1;O.vertices[W++]=1;O.vertices[W++]=0;W= -O.vertices[W++]=0;O.faces[W++]=0;O.faces[W++]=1;O.faces[W++]=2;O.faces[W++]=0;O.faces[W++]=2;O.faces[W++]=3;O.vertexBuffer=k.createBuffer();O.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,O.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,O.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,O.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,O.faces,k.STATIC_DRAW);O.program=k.createProgram();k.attachShader(O.program,C("fragment",THREE.ShaderLib.sprite.fragmentShader));k.attachShader(O.program, -C("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(O.program);O.attributes={};O.uniforms={};O.attributes.position=k.getAttribLocation(O.program,"position");O.attributes.uv=k.getAttribLocation(O.program,"uv");O.uniforms.uvOffset=k.getUniformLocation(O.program,"uvOffset");O.uniforms.uvScale=k.getUniformLocation(O.program,"uvScale");O.uniforms.rotation=k.getUniformLocation(O.program,"rotation");O.uniforms.scale=k.getUniformLocation(O.program,"scale");O.uniforms.alignment=k.getUniformLocation(O.program, -"alignment");O.uniforms.map=k.getUniformLocation(O.program,"map");O.uniforms.opacity=k.getUniformLocation(O.program,"opacity");O.uniforms.useScreenCoordinates=k.getUniformLocation(O.program,"useScreenCoordinates");O.uniforms.affectedByDistance=k.getUniformLocation(O.program,"affectedByDistance");O.uniforms.screenPosition=k.getUniformLocation(O.program,"screenPosition");O.uniforms.modelViewMatrix=k.getUniformLocation(O.program,"modelViewMatrix");O.uniforms.projectionMatrix=k.getUniformLocation(O.program, -"projectionMatrix");var Wa=!1;this.setSize=function(b,c){za.width=b;za.height=c;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(b,c,e,f){la=b;sa=c;K=e;V=f;k.viewport(la,sa,K,V)};this.setScissor=function(b,c,e,f){k.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){Z=b;k.depthMask(b)};this.setClearColorHex=function(b,c){na.setHex(b);ua=c;k.clearColor(na.r,na.g,na.b,ua)};this.setClearColor= -function(b,c){na.copy(b);ua=c;k.clearColor(na.r,na.g,na.b,ua)};this.clear=function(){k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT|k.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){$.darkness=b};this.getContext=function(){return k};this.initMaterial=function(b,c,e,f){var h,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic": -b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var m=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var n,o,t;n=t=m=0;for(o=c.length;n=0)n.bindBuffer(n.ARRAY_BUFFER,g.__webglVertexBuffer),n.vertexAttribPointer(b.position,3,n.FLOAT,!1,0,0);else if(j.morphTargetBase){c=h.program.attributes;j.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[j.morphTargetBase]),n.vertexAttribPointer(c.position, +3,n.FLOAT,!1,0,0)):c.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglVertexBuffer),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,m=j.morphTargetForcedOrder,o=j.morphTargetInfluences;fu&&(t=p,u=o[t]);n.bindBuffer(n.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[t]);n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]=u;m[t]=1;u=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(h.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(k in g.__webglCustomAttributes)b[k]>= +0&&(c=g.__webglCustomAttributes[k],n.bindBuffer(n.ARRAY_BUFFER,c.buffer),n.vertexAttribPointer(b[k],c.size,n.FLOAT,!1,0,0));b.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglColorBuffer),n.vertexAttribPointer(b.color,3,n.FLOAT,!1,0,0));b.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglNormalBuffer),n.vertexAttribPointer(b.normal,3,n.FLOAT,!1,0,0));b.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglTangentBuffer),n.vertexAttribPointer(b.tangent,4,n.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER, +g.__webglUVBuffer),n.vertexAttribPointer(b.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv)):n.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,g.__webglUV2Buffer),n.vertexAttribPointer(b.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv2)):n.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinVertexABuffer),n.vertexAttribPointer(b.skinVertexA,4, +n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),n.vertexAttribPointer(b.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),n.vertexAttribPointer(b.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),n.vertexAttribPointer(b.skinWeight,4,n.FLOAT,!1,0,0));j instanceof THREE.Mesh?(h.wireframe?(n.lineWidth(h.wireframeLinewidth),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),n.drawElements(n.LINES,g.__webglLineCount, +n.UNSIGNED_SHORT,0)):(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),n.drawElements(n.TRIANGLES,g.__webglFaceCount,n.UNSIGNED_SHORT,0)),C.data.vertices+=g.__webglFaceCount,C.data.faces+=g.__webglFaceCount/3,C.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?n.LINE_STRIP:n.LINES,n.lineWidth(h.linewidth),n.drawArrays(j,0,g.__webglLineCount),C.data.drawCalls++):j instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,g.__webglParticleCount),C.data.drawCalls++):j instanceof +THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,g.__webglVertexCount),C.data.drawCalls++)}}function g(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=n.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=n.createBuffer();b.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,b.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(c.attributes.position),n.vertexAttribPointer(c.attributes.position,3,n.FLOAT,!1,0,0));if(b.hasNormal){n.bindBuffer(n.ARRAY_BUFFER, +b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,g,h,j,k,m,o,u,t,p,v=b.count*3;for(p=0;p=0;e--)b[e].object==c&&b.splice(e,1)}function G(b){function c(b){var g=[];e=0;for(f=b.length;e65535&&(o[n].counter+=1,m=o[n].hash+"_"+o[n].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:k,vertices:0,numMorphTargets:u})),b.geometryGroups[m].faces.push(g),b.geometryGroups[m].vertices+=j}function I(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[], +count:0}})}function E(b){if(b!=U){switch(b){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}U=b}}function K(b,c,e){(e.width& +e.width-1)==0&&(e.height&e.height-1)==0?(n.texParameteri(b,n.TEXTURE_WRAP_S,R(c.wrapS)),n.texParameteri(b,n.TEXTURE_WRAP_T,R(c.wrapT)),n.texParameteri(b,n.TEXTURE_MAG_FILTER,R(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,R(c.minFilter)),n.generateMipmap(b)):(n.texParameteri(b,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_MAG_FILTER,X(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,X(c.minFilter)))}function D(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture= +n.createTexture(),b.__webglInit=!0;n.bindTexture(n.TEXTURE_2D,b.__webglTexture);b.image.data?n.texImage2D(n.TEXTURE_2D,0,R(b.format),b.image.width,b.image.height,0,R(b.format),n.UNSIGNED_BYTE,b.image.data):n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,b.image);K(n.TEXTURE_2D,b,b.image);n.bindTexture(n.TEXTURE_2D,null);b.needsUpdate=!1}n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_2D,b.__webglTexture)}function J(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer= +!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=n.createFramebuffer();b.__webglRenderbuffer=n.createRenderbuffer();b.__webglTexture=n.createTexture();n.bindTexture(n.TEXTURE_2D,b.__webglTexture);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,R(b.wrapS));n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,R(b.wrapT));n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,R(b.magFilter));n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,R(b.minFilter));n.texImage2D(n.TEXTURE_2D,0,R(b.format), +b.width,b.height,0,R(b.format),R(b.type),null);n.bindRenderbuffer(n.RENDERBUFFER,b.__webglRenderbuffer);n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer);n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER, +n.DEPTH_STENCIL,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):n.renderbufferStorage(n.RENDERBUFFER,n.RGBA4,b.width,b.height);n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}var c,e;b?(c=b.__webglFramebuffer,e=b.width,b=b.height):(c=null,e=Y,b=Z);c!=fa&&(n.bindFramebuffer(n.FRAMEBUFFER,c),n.viewport(P,aa,e,b),fa=c)}function S(b,c){var e;b=="fragment"?e=n.createShader(n.FRAGMENT_SHADER): +b=="vertex"&&(e=n.createShader(n.VERTEX_SHADER));n.shaderSource(e,c);n.compileShader(e);if(!n.getShaderParameter(e,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(e)),console.error(c),null;return e}function X(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST;default:return n.LINEAR}}function R(b){switch(b){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT; +case THREE.NearestFilter:return n.NEAREST;case THREE.NearestMipMapNearestFilter:return n.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return n.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return n.LINEAR;case THREE.LinearMipMapNearestFilter:return n.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return n.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return n.BYTE;case THREE.UnsignedByteType:return n.UNSIGNED_BYTE;case THREE.ShortType:return n.SHORT;case THREE.UnsignedShortType:return n.UNSIGNED_SHORT; +case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0}var C=this,n,W=[],V=null,fa=null,L=!0,ea=null,T=null,U=null,da=null,ha=null,ia=null,M=null,P=0,aa=0,Y=0,Z=0,ca=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Matrix4,la=new Float32Array(16),ka=new Float32Array(16),pa=new THREE.Vector4,sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ua=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Ia=b.stencil!==void 0?b.stencil:!0,Ja=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Ka=b.antialias!==void 0?b.antialias:!1,va=b.clearColor!==void 0?new THREE.Color(b.clearColor): +new THREE.Color(0),ya=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=ua;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var $,ta=[],b=THREE.ShaderLib.depthRGBA,Ea=THREE.UniformsUtils.clone(b.uniforms),oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader, +vertexShader:b.vertexShader,uniforms:Ea}),ma=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Ea,morphTargets:!0});oa._shadowPass=!0;ma._shadowPass=!0;try{if(!(n=ua.getContext("experimental-webgl",{antialias:Ka,stencil:Ia,preserveDrawingBuffer:Ja})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Ga){console.error(Ga)}n.clearColor(0, +0,0,1);n.clearDepth(1);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(va.r,va.g,va.b,ya);this.context=n;var Da=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,N={};N.vertices=new Float32Array(16);N.faces=new Uint16Array(6);i=0;N.vertices[i++]=-1;N.vertices[i++]=-1;N.vertices[i++]=0;N.vertices[i++]=1;N.vertices[i++]=1;N.vertices[i++]= +-1;N.vertices[i++]=1;N.vertices[i++]=1;N.vertices[i++]=1;N.vertices[i++]=1;N.vertices[i++]=1;N.vertices[i++]=0;N.vertices[i++]=-1;N.vertices[i++]=1;N.vertices[i++]=0;i=N.vertices[i++]=0;N.faces[i++]=0;N.faces[i++]=1;N.faces[i++]=2;N.faces[i++]=0;N.faces[i++]=2;N.faces[i++]=3;N.vertexBuffer=n.createBuffer();N.elementBuffer=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,N.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,N.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,N.elementBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER, +N.faces,n.STATIC_DRAW);N.program=n.createProgram();n.attachShader(N.program,S("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(N.program,S("vertex",THREE.ShaderLib.sprite.vertexShader));n.linkProgram(N.program);N.attributes={};N.uniforms={};N.attributes.position=n.getAttribLocation(N.program,"position");N.attributes.uv=n.getAttribLocation(N.program,"uv");N.uniforms.uvOffset=n.getUniformLocation(N.program,"uvOffset");N.uniforms.uvScale=n.getUniformLocation(N.program,"uvScale");N.uniforms.rotation= +n.getUniformLocation(N.program,"rotation");N.uniforms.scale=n.getUniformLocation(N.program,"scale");N.uniforms.alignment=n.getUniformLocation(N.program,"alignment");N.uniforms.map=n.getUniformLocation(N.program,"map");N.uniforms.opacity=n.getUniformLocation(N.program,"opacity");N.uniforms.useScreenCoordinates=n.getUniformLocation(N.program,"useScreenCoordinates");N.uniforms.affectedByDistance=n.getUniformLocation(N.program,"affectedByDistance");N.uniforms.screenPosition=n.getUniformLocation(N.program, +"screenPosition");N.uniforms.modelViewMatrix=n.getUniformLocation(N.program,"modelViewMatrix");N.uniforms.projectionMatrix=n.getUniformLocation(N.program,"projectionMatrix");var za=!1;this.setSize=function(b,c){ua.width=b;ua.height=c;this.setViewport(0,0,ua.width,ua.height)};this.setViewport=function(b,c,e,f){P=b;aa=c;Y=e;Z=f;n.viewport(P,aa,Y,Z)};this.setScissor=function(b,c,e,f){n.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.enableDepthBufferWrite= +function(b){L=b;n.depthMask(b)};this.setClearColorHex=function(b,c){va.setHex(b);ya=c;n.clearColor(va.r,va.g,va.b,ya)};this.setClearColor=function(b,c){va.copy(b);ya=c;n.clearColor(va.r,va.g,va.b,ya)};this.clear=function(){n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)};this.getContext=function(){return n};this.initMaterial=function(b,c,e,f){var g,h,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial? +j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,o,u;m=u=k=0;for(o=c.length;m=0&&k.enableVertexAttribArray(u.position);u.color>=0&&k.enableVertexAttribArray(u.color);u.normal>=0&&k.enableVertexAttribArray(u.normal);u.tangent>=0&&k.enableVertexAttribArray(u.tangent);b.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(k.enableVertexAttribArray(u.skinVertexA),k.enableVertexAttribArray(u.skinVertexB),k.enableVertexAttribArray(u.skinIndex), -k.enableVertexAttribArray(u.skinWeight));if(b.attributes)for(h in b.attributes)u[h]!==void 0&&u[h]>=0&&k.enableVertexAttribArray(u[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h=0&&(k.enableVertexAttribArray(u[w]),b.numSupportedMorphTargets++)};this.render=function(b,c,o,B){var K,C,F,D,G,J,V,L,M=b.lights,ga=b.fog;this.shadowMapEnabled&&y(b,c);P.data.vertices=0;P.data.faces=0;P.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0, -!1,c);c.matrixWorldInverse.flattenToArray(wa);c.projectionMatrix.flattenToArray(qa);ja.multiply(c.projectionMatrix,c.matrixWorldInverse);n(ja);this.initWebGLObjects(b);T(o);(this.autoClear||B)&&this.clear();G=b.__webglObjects.length;for(B=0;B=0;B--)if(K=b.__webglObjects[B],K.render){V=K.object;L=K.buffer;F=K.opaque;j(V);for(K=0;K0||p.faceVertexUvs.length>0)j.__uvArray=new Float32Array(n*2);if(p.faceUvs.length>1||p.faceVertexUvs.length> -1)j.__uv2Array=new Float32Array(n*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(n*4),j.__skinVertexBArray=new Float32Array(n*4),j.__skinIndexArray=new Float32Array(n*4),j.__skinWeightArray=new Float32Array(n*4);j.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(y*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];p=0;for(v=j.numMorphTargets;p=0;h--)e[h]==c&&e.splice(h,1)}else c instanceof THREE.LensFlare?D(e.__webglLensFlares, -c):c instanceof THREE.MarchingCubes&&D(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;e=0&&n.enableVertexAttribArray(p.position);p.color>=0&&n.enableVertexAttribArray(p.color);p.normal>=0&&n.enableVertexAttribArray(p.normal);p.tangent>=0&&n.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(n.enableVertexAttribArray(p.skinVertexA),n.enableVertexAttribArray(p.skinVertexB),n.enableVertexAttribArray(p.skinIndex), +n.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(g in b.attributes)p[g]!==void 0&&p[g]>=0&&n.enableVertexAttribArray(p[g]);if(b.morphTargets)for(g=b.numSupportedMorphTargets=0;g=0&&(n.enableVertexAttribArray(p[w]),b.numSupportedMorphTargets++)};this.render=function(b,c,p,A){var y,G,H,I,D,L,K,N,M=b.lights,P=b.fog;this.shadowMapEnabled&&w(b,c);C.data.vertices=0;C.data.faces=0;C.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0, +!1,c);c.matrixWorldInverse.flattenToArray(ka);c.projectionMatrix.flattenToArray(la);ja.multiply(c.projectionMatrix,c.matrixWorldInverse);o(ja);this.initWebGLObjects(b);J(p);(this.autoClear||A)&&this.clear();D=b.__webglObjects.length;for(A=0;A=0;A--)if(y=b.__webglObjects[A],y.render){K=y.object;N=y.buffer;H=y.opaque;j(K);for(y=0;y0||v.faceVertexUvs.length>0)k.__uvArray=new Float32Array(o*2);if(v.faceUvs.length>1||v.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(o*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(o*4), +k.__skinVertexBArray=new Float32Array(o*4),k.__skinIndexArray=new Float32Array(o*4),k.__skinWeightArray=new Float32Array(o*4);k.__faceArray=new Uint16Array(x*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(B*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];v=0;for(w=k.numMorphTargets;v=0;h--)e[h]==f&&e.splice(h,1)}else f instanceof THREE.MarchingCubes&&y(e.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER, +sa,o));Ja&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,da,o));Ka&&xa.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,Z,o));za&&pa>0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,ea,o));za&&X>0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER,fa,o));Ia&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,oa,o),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, +m.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,ma,o));O>0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,ca,o),n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,$,o),n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,qa,o),n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER,ra,o));ja&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray, +delete m.__tangentArray,delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;H(k)}else if(g instanceof THREE.Ribbon){h=g.geometry;if(h.__dirtyVertices||h.__dirtyColors){g=h;j=n.DYNAMIC_DRAW;k=B=x=x= +void 0;v=g.vertices;m=g.colors;u=v.length;o=m.length;p=g.__vertexArray;ja=g.__colorArray;w=g.__dirtyColors;if(g.__dirtyVertices){for(x=0;x1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=h;c.v=j;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,j=Math.max(Math.max(e,f),g),h=Math.min(Math.min(e,f),g);if(h==j)h=e=0;else{var k=j-h,h=k/j,e=e==j?(f-g)/k:f==j?2+(g-e)/k:4+(e-f)/k;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=j;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,j=b.vertices,h=g.vertices,m=b.faces,n=g.faces,p=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,t=h.length;o1&&(f=1-f,g=1-g);j=1-f-g;h.copy(b);h.multiplyScalar(f);m.copy(c);m.multiplyScalar(g);h.addSelf(m);m.copy(e);m.multiplyScalar(j);h.addSelf(m);return h},randomPointInFace:function(b, +THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,j=b.vertices,h=g.vertices,k=b.faces,o=g.faces,m=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,u=h.length;p1&&(f=1-f,g=1-g);j=1-f-g;h.copy(b);h.multiplyScalar(f);k.copy(c);k.multiplyScalar(g);h.addSelf(k);k.copy(e);k.multiplyScalar(j);h.addSelf(k);return h},randomPointInFace:function(b, c,e){var f,g,j;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,g=c.vertices[b.b].position,j=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,g,j);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;g=c.vertices[b.b].position;j=c.vertices[b.c].position;var c=c.vertices[b.d].position,h;e?b._area1&&b._area2?(e=b._area1,h=b._area2):(e=THREE.GeometryUtils.triangleArea(f,g,c),h=THREE.GeometryUtils.triangleArea(g,j,c),b._area1=e,b._area2=h):(e=THREE.GeometryUtils.triangleArea(f, -g,c),h=THREE.GeometryUtils.triangleArea(g,j,c));return THREE.GeometryUtils.random()*(e+h)b?e(c,h-1):p[h]b?c(e,g-1):m[g]25&&(j=25);g=(j-1)*0.5;e=Array(j);for(c=f=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",u,h.index-1).pos,this.points[1]=g,this.points[2]=j,this.points[3]=this.getNextKeyWith("pos",u,m.index+1).pos,f=f*0.33+0.33,g=this.interpolateCatmullRom(this.points,f),e.x=g[0],e.y=g[1],e.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== -"rot")THREE.Quaternion.slerp(g,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&o[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ub.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=g*g;h=g*e;f[0]=this.interpolate(j[0],m[0],n[0],p[0],g,e,h);f[1]=this.interpolate(j[1],m[1],n[1],p[1],g,e,h);f[2]=this.interpolate(j[2],m[2],n[2],p[2],g,e,h);return f}; +THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,g,j,h,k,o,m,p=this.data.JIT.hierarchy,u,v;this.currentTime+=b*this.timeScale;v=this.currentTime;u=this.currentTime%=this.data.length;m=parseInt(Math.min(u*this.data.fps,this.data.length*this.data.fps),10);for(var t=0,w=this.hierarchy.length;t1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+t),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",t,h.index-1).pos,this.points[1]=g,this.points[2]=j,this.points[3]=this.getNextKeyWith("pos",t,k.index+1).pos,f=f*0.33+0.33,g=this.interpolateCatmullRom(this.points,f),e.x=g[0],e.y=g[1],e.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== +"rot")THREE.Quaternion.slerp(g,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&p[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(t=0;tb.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];k=b[e[1]];o=b[e[2]];m=b[e[3]];e=g*g;h=g*e;f[0]=this.interpolate(j[0],k[0],o[0],m[0],g,e,h);f[1]=this.interpolate(j[1],k[1],o[1],m[1],g,e,h);f[2]=this.interpolate(j[2],k[2],o[2],m[2],g,e,h);return f}; THREE.Animation.prototype.interpolate=function(b,c,e,f,g,j,h){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*h+(-3*(c-e)-2*b-f)*j+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]}; THREE.FirstPersonCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.005;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= @@ -407,15 +375,15 @@ this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown 1;this.constrainVertical&&(b=3.14/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))}; -THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},g,j=e.getControlPointsArray(),m=e.getLength(),n=j.length,H=0;g=n-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[g]={time:f,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g=0?f:f+g;f=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var m=h[1]-h[0];this.phi= -TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h[0])/m)*m+h[0];f=this.horizontalAngleMap.srcRange;h=this.horizontalAngleMap.dstRange;m=h[1]-h[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h[0])/m)*m+h[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,e,c)};this.onMouseMove=function(b){this.mouseX= -b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),h=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),n=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,h);b.position.set(0,10,0);this.animation= -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), +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,j=Math.PI/180;this.update=function(b,c,e){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)*j;this.theta=this.lon*j;f=this.phi%g;this.phi=f>=0?f:f+g;f=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var k=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])/k)*k+h[0];f=this.horizontalAngleMap.srcRange;h=this.horizontalAngleMap.dstRange;k=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])/k)*k+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,c,e)};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}),k=new THREE.CubeGeometry(10,10,20),o=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(o,h);b.position.set(0,10,0);this.animation= +c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,c){return function(){c.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.005;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= @@ -427,27 +395,27 @@ this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVec this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,o=0,t=0,v=0,u=0,y=0,z=window.innerWidth/2,x=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*u),this.rotateVertically(b*y));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);this.translateY(b*v);n&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(p<0)?1:p));this.translateX(b*u);this.translateY(b*v);o&&(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?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(j.dot(h)/j.length()/h.length());if(b){var c=(new THREE.Vector3).cross(j,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?j=h:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(n.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var b=o.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var 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), +this.rotateCamera=function(){var b=Math.acos(j.dot(h)/j.length()/h.length());if(b){var c=(new THREE.Vector3).cross(j,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?j=h:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(o.y-k.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?k=o:k.y+=(o.y-k.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var b=p.clone().subSelf(m);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?m=p:m.addSelf(b.sub(p,m).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)m=f-1;else{m=f;break}f=m;if(e[f]==j)return f/(g-1);h=e[f];return e=(f+(j-h)/(e[f+1]-h))/(g-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; +THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,g=e.length,j;j=c?c:b*e[g-1];time=Date.now();for(var h=0,k=g-1,o;h<=k;)if(f=Math.floor(h+(k-h)/2),o=e[f]-j,o<0)h=f+1;else if(o>0)k=f-1;else{k=f;break}f=k;if(e[f]==j)return f/(g-1);h=e[f];return e=(f+(j-h)/(e[f+1]-h))/(g-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; THREE.Curve.prototype.getTangent=function(b){var c=b-1.0E-4;b+=1.0E-4;c<0&&(c=0);b>1&&(b=1);var c=this.getPoint(c),b=this.getPoint(b),e=new THREE.Vector2;e.sub(b,c);return e.unit()};THREE.LineCurve=function(b,c){b instanceof THREE.Vector2?(this.v1=b,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(b,c,e,f){this.constructor(new THREE.Vector2(b,c),new THREE.Vector2(e,f))};THREE.LineCurve.prototype=new THREE.Curve; THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(b).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(b){return this.getPoint(b)};THREE.LineCurve.prototype.getTangent=function(){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.normalize();return b}; THREE.QuadraticBezierCurve=function(b,c,e){if(!(c instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),b=new THREE.Vector2(f[0],f[1]),c=new THREE.Vector2(f[2],f[3]),e=new THREE.Vector2(f[4],f[5]);this.v0=b;this.v1=c;this.v2=e};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; @@ -462,140 +430,140 @@ THREE.Curve.create=function(b,c){b.prototype=new THREE.Curve;b.prototype.constru THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,c,e){this.v0=b;this.v1=c;this.v2=e},function(b){var c,e;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);e=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,e,b)});THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(b){this.curves.push(b)}; THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){};THREE.CurvePath.prototype.getPoint=function(b){for(var c=b*this.getLength(),e=this.getCurveLengths(),b=0;b=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null};THREE.CurvePath.prototype.getLength=function(){var b=this.getCurveLengths();return b[b.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var b=[],c=0,e,f=this.curves.length;for(e=0;ec)c=j.x;else if(j.xe)e=j.y;else if(j.yc)c=j.x;else if(j.xe)e=j.y;else if(j.y0?(h=e[e.length-1],u=h.x,y=h.y):(h=this.actions[f-1].args,u=h[h.length-2],y=h[h.length-1]);for(h=1;h<=b;h++)z=h/b,j=THREE.Shape.Utils.b2(z,u,t,m),z=THREE.Shape.Utils.b2(z,y,v, -n),e.push(new THREE.Vector2(j,z));break;case THREE.PathActions.BEZIER_CURVE_TO:m=j[4];n=j[5];t=j[0];v=j[1];p=j[2];o=j[3];e.length>0?(h=e[e.length-1],u=h.x,y=h.y):(h=this.actions[f-1].args,u=h[h.length-2],y=h[h.length-1]);for(h=1;h<=b;h++)z=h/b,j=THREE.Shape.Utils.b3(z,u,t,p,m),z=THREE.Shape.Utils.b3(z,y,v,o,n),e.push(new THREE.Vector2(j,z));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[f-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];z=b*j[0].length;h=h.concat(j[0]);j=new THREE.SplineCurve(h); -for(h=1;h<=z;h++)e.push(j.getPointAt(h/z));break;case THREE.PathActions.ARC:h=this.actions[f-1].args;m=j[0];n=j[1];p=j[2];t=j[3];z=j[4];v=!!j[5];o=h[h.length-2];u=h[h.length-1];h.length==0&&(o=u=0);y=z-t;var x=b*2;for(h=1;h<=x;h++)z=h/x,v||(z=1-z),z=t+z*y,j=o+m+p*Math.cos(z),z=u+n+p*Math.sin(z),e.push(new THREE.Vector2(j,z))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; -THREE.Path.prototype.nltransform=function(b,c,e,f,g,j){var h=this.getPoints(),m,n,p,o,t;m=0;for(n=h.length;m0?(h=e[e.length-1],t=h.x,w=h.y):(h=this.actions[f-1].args,t=h[h.length-2],w=h[h.length-1]);for(h=1;h<=b;h++)x=h/b,j=THREE.Shape.Utils.b2(x,t,u,k),x=THREE.Shape.Utils.b2(x,w,v, +o),e.push(new THREE.Vector2(j,x));break;case THREE.PathActions.BEZIER_CURVE_TO:k=j[4];o=j[5];u=j[0];v=j[1];m=j[2];p=j[3];e.length>0?(h=e[e.length-1],t=h.x,w=h.y):(h=this.actions[f-1].args,t=h[h.length-2],w=h[h.length-1]);for(h=1;h<=b;h++)x=h/b,j=THREE.Shape.Utils.b3(x,t,u,m,k),x=THREE.Shape.Utils.b3(x,w,v,p,o),e.push(new THREE.Vector2(j,x));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[f-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];x=b*j[0].length;h=h.concat(j[0]);j=new THREE.SplineCurve(h); +for(h=1;h<=x;h++)e.push(j.getPointAt(h/x));break;case THREE.PathActions.ARC:h=this.actions[f-1].args;k=j[0];o=j[1];m=j[2];u=j[3];x=j[4];v=!!j[5];p=h[h.length-2];t=h[h.length-1];h.length==0&&(p=t=0);w=x-u;var B=b*2;for(h=1;h<=B;h++)x=h/B,v||(x=1-x),x=u+x*w,j=p+k+m*Math.cos(x),x=t+o+m*Math.sin(x),e.push(new THREE.Vector2(j,x))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; +THREE.Path.prototype.nltransform=function(b,c,e,f,g,j){var h=this.getPoints(),k,o,m,p,u;k=0;for(o=h.length;k=0?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;var z=[p[h],e[m],e[g]];t=THREE.FontUtils.Triangulate.area(z);var x=[p[h],p[j],e[m]];v=THREE.FontUtils.Triangulate.area(x);u=m;o=h;m+=1;h+=-1;m<0&&(m+=e.length);m%= -e.length;h<0&&(h+=p.length);h%=p.length;g=m-1>=0?m-1:e.length-1;j=h-1>=0?h-1:p.length-1;z=[p[h],e[m],e[g]];z=THREE.FontUtils.Triangulate.area(z);x=[p[h],p[j],e[m]];x=THREE.FontUtils.Triangulate.area(x);t+v>z+x&&(m=u,h=o,m<0&&(m+=e.length),m%=e.length,h<0&&(h+=p.length),h%=p.length,g=m-1>=0?m-1:e.length-1,j=h-1>=0?h-1:p.length-1);t=e.slice(0,m);v=e.slice(m);u=p.slice(h);o=p.slice(0,h);j=[p[h],p[j],e[m]];y.push([p[h],e[m],e[g]]);y.push(j);e=t.concat(u).concat(o).concat(v)}return{shape:e,isolatedPts:y, -allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,g=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),j,h,m,n,p={};j=0;for(h=f.length;j=0?k-1:e.length-1;j=h-1>=0?h-1:m.length-1;var x=[m[h],e[k],e[g]];u=THREE.FontUtils.Triangulate.area(x);var B=[m[h],m[j],e[k]];v=THREE.FontUtils.Triangulate.area(B);t=k;p=h;k+=1;h+=-1;k<0&&(k+=e.length);k%= +e.length;h<0&&(h+=m.length);h%=m.length;g=k-1>=0?k-1:e.length-1;j=h-1>=0?h-1:m.length-1;x=[m[h],e[k],e[g]];x=THREE.FontUtils.Triangulate.area(x);B=[m[h],m[j],e[k]];B=THREE.FontUtils.Triangulate.area(B);u+v>x+B&&(k=t,h=p,k<0&&(k+=e.length),k%=e.length,h<0&&(h+=m.length),h%=m.length,g=k-1>=0?k-1:e.length-1,j=h-1>=0?h-1:m.length-1);u=e.slice(0,k);v=e.slice(k);t=m.slice(h);p=m.slice(0,h);j=[m[h],m[j],e[k]];w.push([m[h],e[k],e[g]]);w.push(j);e=u.concat(t).concat(p).concat(v)}return{shape:e,isolatedPts:w, +allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,g=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),j,h,k,o,m={};j=0;for(h=f.length;j0){h(0,0,-o-(j||0));for(n=b;n0){h(0,0,o+ -(g||0));for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n0){h(0,0,-p-(j||0));for(o=b;o0){h(0,0,p+ +(g||0));for(o=b+b/2;o<2*b;o++)k.faces.push(new THREE.Face4(2*b+1,(2*o-2*b+2)%b+b,(2*o-2*b+1)%b+b,(2*o-2*b)%b+b))}o=0;for(b=this.faces.length;ob&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(j).addSelf(k).subSelf(b).clone()}function g(b){for(G=b.length;--G>=0;){aa=G;Z=G-1;Z<0&&(Z=b.length- -1);for(var c=0,c=0;c=0;R--){da=R/o;T=n*(1-da);da=p*Math.sin(da*Math.PI/2);G=0;for(I=H.length;Gb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(j).addSelf(k).subSelf(b).clone()}function g(b){for(D=b.length;--D>=0;){T=D;U=D-1;U<0&&(U=b.length- +1);for(var c=0,c=0;c=0;S--){X=S/p;R=o*(1-X);X=m*Math.sin(X*Math.PI/2);D=0;for(J=H.length;D0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,v)))-1);p.push(o)}c.push(p)}for(var u,y,z,g=c.length,e=0;e0)for(f=0;f1&&(u= -this.vertices[h].position.clone(),y=this.vertices[n].position.clone(),z=this.vertices[p].position.clone(),u.normalize(),y.normalize(),z.normalize(),this.faces.push(new THREE.Face3(h,n,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([o,t,x]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,g=Math.PI,j=Math.max(3,c||8),h=Math.max(2,e||6),c=[],e=0;e0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,v)))-1);m.push(p)}c.push(m)}for(var t,w,x,g=c.length,e=0;e0)for(f=0;f1&&(t= +this.vertices[h].position.clone(),w=this.vertices[o].position.clone(),x=this.vertices[m].position.clone(),t.normalize(),w.normalize(),x.normalize(),this.faces.push(new THREE.Face3(h,o,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([p,u,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){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var f=e[e.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c= -this.getFace(),e=this.size/c.resolution,f=0,g=String(b).split(""),j=g.length,h=[],b=0;b0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return j}n=p;g<=n&&(n=0);p=n+1;g<=p&&(p=0);o=p+1;g<=o&&(o=0);var v;a:{v=b;var u=n,y=p,z=o,x=g,w=h,H=void 0,B=void 0,F=void 0, -J=void 0,D=void 0,L=void 0,G=void 0,I=void 0,R=void 0,B=v[w[u]].x,F=v[w[u]].y,J=v[w[y]].x,D=v[w[y]].y,L=v[w[z]].x,G=v[w[z]].y;if(1.0E-10>(J-B)*(G-F)-(D-F)*(L-B))v=!1;else{for(H=0;H=0&&C>=0&&S>=0){v=!1; -break a}}v=!0}}if(v){j.push([b[h[n]],b[h[p]],b[h[o]]]);m.push([h[n],h[p],h[o]]);n=p;for(o=p+1;o0)for(m=0;m2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return k;return j}o=m;g<=o&&(o=0);m=o+1;g<=m&&(m=0);p=m+1;g<=p&&(p=0);var v;a:{v=b;var t=o,w=m,x=p,B=g,A=h,H=void 0,y=void 0,G=void 0, +I=void 0,E=void 0,K=void 0,D=void 0,J=void 0,S=void 0,y=v[A[t]].x,G=v[A[t]].y,I=v[A[w]].x,E=v[A[w]].y,K=v[A[x]].x,D=v[A[x]].y;if(1.0E-10>(I-y)*(D-G)-(E-G)*(K-y))v=!1;else{for(H=0;H=0&&C>=0&&W>=0){v=!1;break a}}v= +!0}}if(v){j.push([b[h[o]],b[h[m]],b[h[p]]]);k.push([h[o],h[m],h[p]]);o=m;for(p=m+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=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+D);h=g(b,c+L);c=n(b,c+G);THREE.BinaryLoader.prototype.f3(w,e,f,h,c)}function v(c){var e,f,h,j,k,o;e=g(b,c);f=g(b,c+D);h=g(b,c+L);j=n(b,c+G);k=g(b,c+I);o=g(b,c+R);c=g(b,c+da);THREE.BinaryLoader.prototype.f3n(w,F,e,f,h,j,k,o,c)}function u(c){var e,f,h,j;e=g(b,c);f=g(b,c+T);h=g(b,c+C);j=g(b,c+ea);c=n(b,c+S);THREE.BinaryLoader.prototype.f4(w,e,f,h,j,c)}function y(c){var e,f,h,j,o,p,t,u;e=g(b,c);f=g(b,c+T);h=g(b,c+C);j=g(b,c+ea);o= -n(b,c+S);p=g(b,c+P);t=g(b,c+k);u=g(b,c+M);c=g(b,c+Y);THREE.BinaryLoader.prototype.f4n(w,F,e,f,h,j,o,p,t,u,c)}function z(c){var e,f;e=g(b,c);f=g(b,c+aa);c=g(b,c+Z);THREE.BinaryLoader.prototype.uv3(w.faceVertexUvs[0],J[e*2],J[e*2+1],J[f*2],J[f*2+1],J[c*2],J[c*2+1])}function x(c){var e,f,h;e=g(b,c);f=g(b,c+ha);h=g(b,c+ka);c=g(b,c+fa);THREE.BinaryLoader.prototype.uv4(w.faceVertexUvs[0],J[e*2],J[e*2+1],J[f*2],J[f*2+1],J[h*2],J[h*2+1],J[c*2],J[c*2+1])}var w=this,H=0,B,F=[],J=[],D,L,G,I,R,da,T,C,ea,S,P, -k,M,Y,aa,Z,ha,ka,fa,U,X,ca,ma,la,sa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,f,c);B={signature:b.substr(H,8),header_bytes:o(b,H+8),vertex_coordinate_bytes:o(b,H+9),normal_coordinate_bytes:o(b,H+10),uv_coordinate_bytes:o(b,H+11),vertex_index_bytes:o(b,H+12),normal_index_bytes:o(b,H+13),uv_index_bytes:o(b,H+14),material_index_bytes:o(b,H+15),nvertices:g(b,H+16),nnormals:g(b,H+16+4),nuvs:g(b,H+16+8),ntri_flat:g(b,H+16+12),ntri_smooth:g(b,H+16+16),ntri_flat_uv:g(b,H+16+20),ntri_smooth_uv:g(b, -H+16+24),nquad_flat:g(b,H+16+28),nquad_smooth:g(b,H+16+32),nquad_flat_uv:g(b,H+16+36),nquad_smooth_uv:g(b,H+16+40)};H+=B.header_bytes;D=B.vertex_index_bytes;L=B.vertex_index_bytes*2;G=B.vertex_index_bytes*3;I=B.vertex_index_bytes*3+B.material_index_bytes;R=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;da=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;T=B.vertex_index_bytes;C=B.vertex_index_bytes*2;ea=B.vertex_index_bytes*3;S=B.vertex_index_bytes*4;P=B.vertex_index_bytes* -4+B.material_index_bytes;k=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;M=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;Y=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;aa=B.uv_index_bytes;Z=B.uv_index_bytes*2;ha=B.uv_index_bytes;ka=B.uv_index_bytes*2;fa=B.uv_index_bytes*3;c=B.vertex_index_bytes*3+B.material_index_bytes;sa=B.vertex_index_bytes*4+B.material_index_bytes;U=B.ntri_flat*c;X=B.ntri_smooth*(c+B.normal_index_bytes*3);ca=B.ntri_flat_uv* -(c+B.uv_index_bytes*3);ma=B.ntri_smooth_uv*(c+B.normal_index_bytes*3+B.uv_index_bytes*3);la=B.nquad_flat*sa;c=B.nquad_smooth*(sa+B.normal_index_bytes*4);sa=B.nquad_flat_uv*(sa+B.uv_index_bytes*4);H+=function(c){for(var f,g,j,k=B.vertex_coordinate_bytes*3,m=c+B.nvertices*k;c>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 o(b,c){var e=p(b,c);return(p(b,c+1)<<8)+e}function m(b,c){var e=p(b,c);return e>127?e-256:e}function p(b, +c){return b.charCodeAt(c)&255}function u(c){var e,f,h;e=g(b,c);f=g(b,c+E);h=g(b,c+K);c=o(b,c+D);THREE.BinaryLoader.prototype.f3(A,e,f,h,c)}function v(c){var e,f,h,j,m,n;e=g(b,c);f=g(b,c+E);h=g(b,c+K);j=o(b,c+D);m=g(b,c+J);n=g(b,c+S);c=g(b,c+X);THREE.BinaryLoader.prototype.f3n(A,G,e,f,h,j,m,n,c)}function t(c){var e,f,h,j;e=g(b,c);f=g(b,c+R);h=g(b,c+C);j=g(b,c+n);c=o(b,c+W);THREE.BinaryLoader.prototype.f4(A,e,f,h,j,c)}function w(c){var e,f,h,j,m,p,t,u;e=g(b,c);f=g(b,c+R);h=g(b,c+C);j=g(b,c+n);m=o(b, +c+W);p=g(b,c+V);t=g(b,c+fa);u=g(b,c+L);c=g(b,c+ea);THREE.BinaryLoader.prototype.f4n(A,G,e,f,h,j,m,p,t,u,c)}function x(c){var e,f;e=g(b,c);f=g(b,c+T);c=g(b,c+U);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],I[e*2],I[e*2+1],I[f*2],I[f*2+1],I[c*2],I[c*2+1])}function B(c){var e,f,h;e=g(b,c);f=g(b,c+da);h=g(b,c+ha);c=g(b,c+ia);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],I[e*2],I[e*2+1],I[f*2],I[f*2+1],I[h*2],I[h*2+1],I[c*2],I[c*2+1])}var A=this,H=0,y,G=[],I=[],E,K,D,J,S,X,R,C,n,W,V,fa,L, +ea,T,U,da,ha,ia,M,P,aa,Y,Z,ca;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,f,c);y={signature:b.substr(H,8),header_bytes:p(b,H+8),vertex_coordinate_bytes:p(b,H+9),normal_coordinate_bytes:p(b,H+10),uv_coordinate_bytes:p(b,H+11),vertex_index_bytes:p(b,H+12),normal_index_bytes:p(b,H+13),uv_index_bytes:p(b,H+14),material_index_bytes:p(b,H+15),nvertices:g(b,H+16),nnormals:g(b,H+16+4),nuvs:g(b,H+16+8),ntri_flat:g(b,H+16+12),ntri_smooth:g(b,H+16+16),ntri_flat_uv:g(b,H+16+20),ntri_smooth_uv:g(b, +H+16+24),nquad_flat:g(b,H+16+28),nquad_smooth:g(b,H+16+32),nquad_flat_uv:g(b,H+16+36),nquad_smooth_uv:g(b,H+16+40)};H+=y.header_bytes;E=y.vertex_index_bytes;K=y.vertex_index_bytes*2;D=y.vertex_index_bytes*3;J=y.vertex_index_bytes*3+y.material_index_bytes;S=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes;X=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*2;R=y.vertex_index_bytes;C=y.vertex_index_bytes*2;n=y.vertex_index_bytes*3;W=y.vertex_index_bytes*4;V=y.vertex_index_bytes* +4+y.material_index_bytes;fa=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes;L=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*2;ea=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*3;T=y.uv_index_bytes;U=y.uv_index_bytes*2;da=y.uv_index_bytes;ha=y.uv_index_bytes*2;ia=y.uv_index_bytes*3;c=y.vertex_index_bytes*3+y.material_index_bytes;ca=y.vertex_index_bytes*4+y.material_index_bytes;M=y.ntri_flat*c;P=y.ntri_smooth*(c+y.normal_index_bytes*3);aa= +y.ntri_flat_uv*(c+y.uv_index_bytes*3);Y=y.ntri_smooth_uv*(c+y.normal_index_bytes*3+y.uv_index_bytes*3);Z=y.nquad_flat*ca;c=y.nquad_smooth*(ca+y.normal_index_bytes*4);ca=y.nquad_flat_uv*(ca+y.uv_index_bytes*4);H+=function(c){for(var f,g,j,k=y.vertex_coordinate_bytes*3,m=c+y.nvertices*k;c1&&(R=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(D,R);object.name=u;object.position.set(B[0],B[1],B[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=H.visible;M.scene.addObject(object);M.objects[u]=object;H.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),M.scene.collisions.colliders.push(b)); -if(H.castsShadow)b=new THREE.ShadowVolume(D),M.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},M.triggers[object.name]=b)}}else B=H.position,r=H.rotation,q=H.quaternion,s=H.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(B[0],B[1],B[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=H.visible!==void 0?H.visible:!1,M.scene.addObject(object),M.objects[u]=object,M.empties[u]=object,H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},M.triggers[object.name]=b)}function n(b){return function(c){M.geometries[b]=c;m();ea-=1;e.onLoadComplete();o()}}function p(b){return function(c){M.geometries[b]=c}}function o(){e.callbackProgress({totalModels:P,totalTextures:k,loadedModels:P-ea,loadedTextures:k-S},M);e.onLoadProgress();ea==0&&S==0&&c(M)} -var t,v,u,y,z,x,w,H,B,F,J,D,L,G,I,R,da,T,C,ea,S,P,k,M;T=b.data;I=new THREE.BinaryLoader;C=new THREE.JSONLoader;S=ea=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(u in T.objects)if(H=T.objects[u],H.meshCollider){b=!0;break}if(b)M.scene.collisions=new THREE.CollisionSystem;if(T.transform){b=T.transform.position;F=T.transform.rotation;var Y=T.transform.scale;b&&M.scene.position.set(b[0],b[1],b[2]);F&&M.scene.rotation.set(F[0], -F[1],F[2]);Y&&M.scene.scale.set(Y[0],Y[1],Y[2]);(b||F||Y)&&M.scene.updateMatrix()}b=function(){S-=1;o();e.onLoadComplete()};for(z in T.cameras){F=T.cameras[z];if(F.type=="perspective")L=new THREE.Camera(F.fov,F.aspect,F.near,F.far);else if(F.type=="ortho")L=new THREE.Camera,L.projectionMatrix=THREE.Matrix4.makeOrtho(F.left,F.right,F.top,F.bottom,F.near,F.far);B=F.position;F=F.target;L.position.set(B[0],B[1],B[2]);L.target.position.set(F[0],F[1],F[2]);M.cameras[z]=L}for(y in T.lights)z=T.lights[y], -L=z.color!==void 0?z.color:16777215,F=z.intensity!==void 0?z.intensity:1,z.type=="directional"?(B=z.direction,da=new THREE.DirectionalLight(L,F),da.position.set(B[0],B[1],B[2]),da.position.normalize()):z.type=="point"?(B=z.position,d=z.distance,da=new THREE.PointLight(L,F,d),da.position.set(B[0],B[1],B[2])):z.type=="ambient"&&(da=new THREE.AmbientLight(L)),M.scene.addLight(da),M.lights[y]=da;for(x in T.fogs)y=T.fogs[x],y.type=="linear"?G=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(G=new THREE.FogExp2(0, -y.density)),F=y.color,G.color.setRGB(F[0],F[1],F[2]),M.fogs[x]=G;if(M.cameras&&T.defaults.camera)M.currentCamera=M.cameras[T.defaults.camera];if(M.fogs&&T.defaults.fog)M.scene.fog=M.fogs[T.defaults.fog];F=T.defaults.bgcolor;M.bgColor=new THREE.Color;M.bgColor.setRGB(F[0],F[1],F[2]);M.bgColorAlpha=T.defaults.bgalpha;for(t in T.geometries)if(x=T.geometries[t],x.type=="bin_mesh"||x.type=="ascii_mesh")ea+=1,e.onLoadStart();P=ea;for(t in T.geometries)x=T.geometries[t],x.type=="cube"?(D=new THREE.CubeGeometry(x.width, -x.height,x.depth,x.segmentsWidth,x.segmentsHeight,x.segmentsDepth,null,x.flipped,x.sides),M.geometries[t]=D):x.type=="plane"?(D=new THREE.PlaneGeometry(x.width,x.height,x.segmentsWidth,x.segmentsHeight),M.geometries[t]=D):x.type=="sphere"?(D=new THREE.SphereGeometry(x.radius,x.segmentsWidth,x.segmentsHeight),M.geometries[t]=D):x.type=="cylinder"?(D=new THREE.CylinderGeometry(x.numSegs,x.topRad,x.botRad,x.height,x.topOffset,x.botOffset),M.geometries[t]=D):x.type=="torus"?(D=new THREE.TorusGeometry(x.radius, -x.tube,x.segmentsR,x.segmentsT),M.geometries[t]=D):x.type=="icosahedron"?(D=new THREE.IcosahedronGeometry(x.subdivisions),M.geometries[t]=D):x.type=="bin_mesh"?I.load({model:f(x.url,T.urlBaseType),callback:n(t)}):x.type=="ascii_mesh"?C.load({model:f(x.url,T.urlBaseType),callback:n(t)}):x.type=="embedded_mesh"&&(x=T.embeds[x.id])&&C.createModel(x,p(t),"");for(w in T.textures)if(t=T.textures[w],t.url instanceof Array){S+=t.url.length;for(I=0;I1&&(S=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,S);object.name=t;object.position.set(y[0],y[1],y[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=H.visible;L.scene.addObject(object);L.objects[t]=object;H.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),L.scene.collisions.colliders.push(b)); +if(H.castsShadow)b=new THREE.ShadowVolume(E),L.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},L.triggers[object.name]=b)}}else y=H.position,r=H.rotation,q=H.quaternion,s=H.scale,q=0,object=new THREE.Object3D,object.name=t,object.position.set(y[0],y[1],y[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], +s[1],s[2]),object.visible=H.visible!==void 0?H.visible:!1,L.scene.addObject(object),L.objects[t]=object,L.empties[t]=object,H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},L.triggers[object.name]=b)}function o(b){return function(c){L.geometries[b]=c;k();n-=1;e.onLoadComplete();p()}}function m(b){return function(c){L.geometries[b]=c}}function p(){e.callbackProgress({totalModels:V,totalTextures:fa,loadedModels:V-n,loadedTextures:fa-W},L);e.onLoadProgress();n==0&&W==0&&c(L)} +var u,v,t,w,x,B,A,H,y,G,I,E,K,D,J,S,X,R,C,n,W,V,fa,L;R=b.data;J=new THREE.BinaryLoader;C=new THREE.JSONLoader;W=n=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(t in R.objects)if(H=R.objects[t],H.meshCollider){b=!0;break}if(b)L.scene.collisions=new THREE.CollisionSystem;if(R.transform){b=R.transform.position;G=R.transform.rotation;var ea=R.transform.scale;b&&L.scene.position.set(b[0],b[1],b[2]);G&&L.scene.rotation.set(G[0], +G[1],G[2]);ea&&L.scene.scale.set(ea[0],ea[1],ea[2]);(b||G||ea)&&L.scene.updateMatrix()}b=function(){W-=1;p();e.onLoadComplete()};for(x in R.cameras){G=R.cameras[x];if(G.type=="perspective")K=new THREE.Camera(G.fov,G.aspect,G.near,G.far);else if(G.type=="ortho")K=new THREE.Camera,K.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);y=G.position;G=G.target;K.position.set(y[0],y[1],y[2]);K.target.position.set(G[0],G[1],G[2]);L.cameras[x]=K}for(w in R.lights)x=R.lights[w], +K=x.color!==void 0?x.color:16777215,G=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(y=x.direction,X=new THREE.DirectionalLight(K,G),X.position.set(y[0],y[1],y[2]),X.position.normalize()):x.type=="point"?(y=x.position,d=x.distance,X=new THREE.PointLight(K,G,d),X.position.set(y[0],y[1],y[2])):x.type=="ambient"&&(X=new THREE.AmbientLight(K)),L.scene.addLight(X),L.lights[w]=X;for(B in R.fogs)w=R.fogs[B],w.type=="linear"?D=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(D=new THREE.FogExp2(0, +w.density)),G=w.color,D.color.setRGB(G[0],G[1],G[2]),L.fogs[B]=D;if(L.cameras&&R.defaults.camera)L.currentCamera=L.cameras[R.defaults.camera];if(L.fogs&&R.defaults.fog)L.scene.fog=L.fogs[R.defaults.fog];G=R.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(G[0],G[1],G[2]);L.bgColorAlpha=R.defaults.bgalpha;for(u in R.geometries)if(B=R.geometries[u],B.type=="bin_mesh"||B.type=="ascii_mesh")n+=1,e.onLoadStart();V=n;for(u in R.geometries)B=R.geometries[u],B.type=="cube"?(E=new THREE.CubeGeometry(B.width, +B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),L.geometries[u]=E):B.type=="plane"?(E=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),L.geometries[u]=E):B.type=="sphere"?(E=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),L.geometries[u]=E):B.type=="cylinder"?(E=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),L.geometries[u]=E):B.type=="torus"?(E=new THREE.TorusGeometry(B.radius, +B.tube,B.segmentsR,B.segmentsT),L.geometries[u]=E):B.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(B.subdivisions),L.geometries[u]=E):B.type=="bin_mesh"?J.load({model:f(B.url,R.urlBaseType),callback:o(u)}):B.type=="ascii_mesh"?C.load({model:f(B.url,R.urlBaseType),callback:o(u)}):B.type=="embedded_mesh"&&(B=R.embeds[B.id])&&C.createModel(B,m(u),"");for(A in R.textures)if(u=R.textures[A],u.url instanceof Array){W+=u.url.length;for(J=0;J=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,g=0;g<8;g++){for(var j=0,h=0;h>1^-(m&1);e[8*h+g]=j}f+=c}c=b.length-f;j=new Uint16Array(c);for(g=h=0;g=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,g=0;g<8;g++){for(var j=0,h=0;h>1^-(k&1);e[8*h+g]=j}f+=c}c=b.length-f;j=new Uint16Array(c);for(g=h=0;g=this.maxCount-3&&m(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(n=this.size-1);var v=Math.floor(p-m);v<1&&(v=1);p=Math.floor(p+m);p>this.size-1&&(p=this.size-1);var u=Math.floor(o-m);u<1&&(u=1);m=Math.floor(o+m);m>this.size-1&&(m=this.size- -1);for(var y,z,x,w,H,B;t0&&(this.field[x+y]+=w)}}};this.addPlaneX=function(b,c){var g,j,h,m,n,p=this.size,o=this.yd,t=this.zd,v=this.field,u=p*Math.sqrt(b/c);u>p&&(u=p);for(g=0;g0)for(j=0;jo&&(y=o);for(j=0;j0){n=j*t;for(g=0;gsize&&(dist=size);for(h=0;h0){n=zd*h;for(j=0;j=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(o=this.size-1);var v=Math.floor(m-k);v<1&&(v=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var t=Math.floor(p-k);t<1&&(t=1);k=Math.floor(p+k);k>this.size-1&&(k=this.size- +1);for(var w,x,B,A,H,y;u0&&(this.field[B+w]+=A)}}};this.addPlaneX=function(b,c){var g,j,h,k,o,m=this.size,p=this.yd,u=this.zd,v=this.field,t=m*Math.sqrt(b/c);t>m&&(t=m);for(g=0;g0)for(j=0;jp&&(w=p);for(j=0;j0){o=j*u;for(g=0;gsize&&(dist=size);for(h=0;h0){o=zd*h;for(j=0;jj?this.hits.push(g):this.hits.unshift(g),j=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,j=0;j=m*g))return Number.MAX_VALUE;h/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(h);m.addSelf(b.origin);Math.abs(j.x)> -Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=m.y-c.y,j=e.y-c.y,g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(j.y)>Math.abs(j.z)?(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=j*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=j*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return h}; +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,j=0;j=k*g))return Number.MAX_VALUE;h/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(h);k.addSelf(b.origin);Math.abs(j.x)> +Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=k.y-c.y,j=e.y-c.y,g=f.y-c.y,k=k.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=k.x-c.x,j=e.x-c.x,g=f.x-c.x,k=k.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(j.y)>Math.abs(j.z)?(b=k.x-c.x,j=e.x-c.x,g=f.x-c.x,k=k.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=k.x-c.x,j=e.x-c.x,g=f.x-c.x,k=k.y-c.y,e=e.y-c.y,f=f.y-c.y);c=j*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-k*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=j*k-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return h}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; -THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,j=0,h=0,m=0,n=0,p=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,h=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, -p=!1,m=1);e.origin.zc.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;g>f&&(p=1,f=g);j>f&&(p=2,f=j);switch(p){case 0:m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* -f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,n)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,j=0,h=0,k=0,o=0,m=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,m=!1,h=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, +m=!1,k=1);e.origin.zc.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,m=!1,o=1);if(m)return-1;m=0;g>f&&(m=1,f=g);j>f&&(m=2,f=j);switch(m){case 0:k=e.origin.y+e.direction.y*f;if(kc.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,k,0);break;case 2:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;k=e.origin.y+e.direction.y*f;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,o)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq=0)return Math.abs(f)-Math.sqrt(e);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,e=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,j=new THREE.Camera,h=new THREE.Matrix4,m=new THREE.Matrix4,n,p,o;g.useTarget=j.useTarget=!1;g.matrixAutoUpdate=j.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.Camera(53,1,1,1E4);u.position.z= -2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},mapRight:{type:"t",value:1,texture:v}},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 y=new THREE.Scene;y.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;v.width=b;v.height=f};this.render=function(b,e){e.update(null,!0);if(n!==e.aspect||p!==e.near||o!==e.fov){n=e.aspect;p=e.near;o=e.fov;var w=e.projectionMatrix.clone(),H=125/30*0.5,B=H*p/125,F=p*Math.tan(o*Math.PI/360),J;h.n14=H;m.n14=-H;H=-F*n+B;J=F*n+B;w.n11=2*p/(J-H);w.n13=(J+H)/(J-H);g.projectionMatrix=w.clone();H=-F*n-B;J=F*n-B;w.n11=2*p/(J-H); -w.n13=(J+H)/(J-H);j.projectionMatrix=w.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(m);g.update(null,!0);g.position.copy(e.position);g.near=p;g.far=e.far;f.call(c,b,g,t,!0);j.matrix=e.matrixWorld.clone().multiplySelf(h);j.update(null,!0);j.position.copy(e.position);j.near=p;j.far=e.far;f.call(c,b,j,v,!0);f.call(c,y,u)}}; -if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,j,h=new THREE.Camera,m=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);g=b/2;j=f};this.render=function(b,e){this.clear();h.fov=e.fov;h.aspect=0.5*e.aspect;h.near=e.near;h.far=e.far; -h.updateProjectionMatrix();h.position.copy(e.position);h.target.position.copy(e.target.position);h.translateX(c.separation);m.projectionMatrix=h.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,j);f.call(c,b,h);this.setViewport(g,0,g,j);f.call(c,b,m,!1)}}; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,j=new THREE.Camera,h=new THREE.Matrix4,k=new THREE.Matrix4,o,m,p;g.useTarget=j.useTarget=!1;g.matrixAutoUpdate=j.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},u=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.WebGLRenderTarget(512,512,b),t=new THREE.Camera(53,1,1,1E4);t.position.z= +2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:u},mapRight:{type:"t",value:1,texture:v}},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 w=new THREE.Scene;w.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);u.width=b;u.height=f;v.width=b;v.height=f};this.render=function(b,e){e.update(null,!0);if(o!==e.aspect||m!==e.near||p!==e.fov){o=e.aspect;m=e.near;p=e.fov;var A=e.projectionMatrix.clone(),H=125/30*0.5,y=H*m/125,G=m*Math.tan(p*Math.PI/360),I;h.n14=H;k.n14=-H;H=-G*o+y;I=G*o+y;A.n11=2*m/(I-H);A.n13=(I+H)/(I-H);g.projectionMatrix=A.clone();H=-G*o-y;I=G*o-y;A.n11=2*m/(I-H); +A.n13=(I+H)/(I-H);j.projectionMatrix=A.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(k);g.update(null,!0);g.position.copy(e.position);g.near=m;g.far=e.far;f.call(c,b,g,u,!0);j.matrix=e.matrixWorld.clone().multiplySelf(h);j.update(null,!0);j.position.copy(e.position);j.near=m;j.far=e.far;f.call(c,b,j,v,!0);f.call(c,w,t)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,j,h=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);g=b/2;j=f};this.render=function(b,e){this.clear();h.fov=e.fov;h.aspect=0.5*e.aspect;h.near=e.near;h.far=e.far; +h.updateProjectionMatrix();h.position.copy(e.position);h.target.position.copy(e.target.position);h.translateX(c.separation);k.projectionMatrix=h.projectionMatrix;k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(-c.separation);this.setViewport(0,0,g,j);f.call(c,b,h);this.setViewport(g,0,g,j);f.call(c,b,k,!1)}}; diff --git a/build/custom/ThreeCanvas.js b/build/custom/ThreeCanvas.js index ac8c2b05..1c1407c6 100644 --- a/build/custom/ThreeCanvas.js +++ b/build/custom/ThreeCanvas.js @@ -1,4 +1,4 @@ -// ThreeCanvas.js r42 - http://github.com/mrdoob/three.js +// ThreeCanvas.js r43 - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this}; THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),f=a*6-d,a=c*(1-b),g=c*(1-b*f),b=c*(1-b*(1-f)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r= c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; @@ -16,34 +16,34 @@ subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this} setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b0&&a>0&&e+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a);if(!d||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a);if(!d||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return[];var f,g,e,h, -k,l,m,i,n,j,p=a.geometry,q=p.vertices,v=[],d=0;for(f=p.faces.length;d0:i<0))if(m=m.dot((new THREE.Vector3).sub(e, -n))/i,n=n.addSelf(j.multiplyScalar(m)),g instanceof THREE.Face3)c(n,e,h,k)&&(g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},v.push(g));else if(g instanceof THREE.Face4&&(c(n,e,h,l)||c(n,h,k,l)))g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},v.push(g);return v}else return[]}}; +j,l,m,i,n,k,p=a.geometry,q=p.vertices,v=[],d=0;for(f=p.faces.length;d0:i<0))if(m=m.dot((new THREE.Vector3).sub(e, +n))/i,n=n.addSelf(k.multiplyScalar(m)),g instanceof THREE.Face3)c(n,e,h,j)&&(g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},v.push(g));else if(g instanceof THREE.Face4&&(c(n,e,h,l)||c(n,h,j,l)))g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},v.push(g);return v}else return[]}}; THREE.Rectangle=function(){function a(){g=d-b;e=f-c}var b,c,d,f,g,e,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return e};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,m,i){h=!1;b=e;c=g;d=m;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= -function(e,g,m,i,n,j){h?(h=!1,b=em?e>n?e:n:m>n?m:n,f=g>i?g>j?g:j:i>j?i:j):(b=em?e>n?e>d?e:d:n>d?n:d:m>n?m>d?m:d:n>d?n:d,f=g>i?g>j?g>f?g:f:j>f?j:f:i>j?i>f?i:f:j>f?j:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> +function(e,g,m,i,n,k){h?(h=!1,b=em?e>n?e:n:m>n?m:n,f=g>i?g>k?g:k:i>k?i:k):(b=em?e>n?e>d?e:d:n>d?n:d:m>n?m>d?m:d:n>d?n:d,f=g>i?g>k?g>f?g:f:k>f?k:f:i>k?i>f?i:f:k>f?k:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,g,e,h,k,l,m,i,n,j,p,q){this.set(a||1,b||0,c||0,d||0,f||0,g||1,e||0,h||0,k||0,l||0,m||1,i||0,n||0,j||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,g,e,h,k,l,m,i,n,j,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=e;this.n24=h;this.n31=k;this.n32=l;this.n33=m;this.n34=i;this.n41=n;this.n42=j;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,g,e,h,j,l,m,i,n,k,p,q){this.set(a||1,b||0,c||0,d||0,f||0,g||1,e||0,h||0,j||0,l||0,m||1,i||0,n||0,k||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,g,e,h,j,l,m,i,n,k,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=e;this.n24=h;this.n31=j;this.n32=l;this.n33=m;this.n34=i;this.n41=n;this.n42=k;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f; a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ -c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,k=a.n23,l=a.n24,m=a.n31,i=a.n32,n=a.n33,j=a.n34,p=a.n41,q=a.n42,v=a.n43,s=a.n44,O=b.n11,P=b.n12, -y=b.n13,B=b.n14,o=b.n21,t=b.n22,r=b.n23,x=b.n24,E=b.n31,Z=b.n32,$=b.n33,I=b.n34,D=b.n41,J=b.n42,M=b.n43,F=b.n44;this.n11=c*O+d*o+f*E+g*D;this.n12=c*P+d*t+f*Z+g*J;this.n13=c*y+d*r+f*$+g*M;this.n14=c*B+d*x+f*I+g*F;this.n21=e*O+h*o+k*E+l*D;this.n22=e*P+h*t+k*Z+l*J;this.n23=e*y+h*r+k*$+l*M;this.n24=e*B+h*x+k*I+l*F;this.n31=m*O+i*o+n*E+j*D;this.n32=m*P+i*t+n*Z+j*J;this.n33=m*y+i*r+n*$+j*M;this.n34=m*B+i*x+n*I+j*F;this.n41=p*O+q*o+v*E+s*D;this.n42=p*P+q*t+v*Z+s*J;this.n43=p*y+q*r+v*$+s*M;this.n44=p*B+q* +c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,j=a.n23,l=a.n24,m=a.n31,i=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,v=a.n43,s=a.n44,O=b.n11,P=b.n12, +y=b.n13,B=b.n14,o=b.n21,t=b.n22,r=b.n23,x=b.n24,E=b.n31,Z=b.n32,$=b.n33,I=b.n34,D=b.n41,J=b.n42,M=b.n43,F=b.n44;this.n11=c*O+d*o+f*E+g*D;this.n12=c*P+d*t+f*Z+g*J;this.n13=c*y+d*r+f*$+g*M;this.n14=c*B+d*x+f*I+g*F;this.n21=e*O+h*o+j*E+l*D;this.n22=e*P+h*t+j*Z+l*J;this.n23=e*y+h*r+j*$+l*M;this.n24=e*B+h*x+j*I+l*F;this.n31=m*O+i*o+n*E+k*D;this.n32=m*P+i*t+n*Z+k*J;this.n33=m*y+i*r+n*$+k*M;this.n34=m*B+i*x+n*I+k*F;this.n41=p*O+q*o+v*E+s*D;this.n42=p*P+q*t+v*Z+s*J;this.n43=p*y+q*r+v*$+s*M;this.n44=p*B+q* x+v*I+s*F;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*= -a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,e=this.n23,h=this.n24,k=this.n31,l=this.n32,m=this.n33,i=this.n34,n=this.n41,j=this.n42,p=this.n43,q=this.n44;return d*e*l*n-c*h*l*n-d*g*m*n+b*h*m*n+c*g*i*n-b*e*i*n-d*e*k*j+c*h*k*j+d*f*m*j-a*h*m*j-c*f*i*j+a*e*i*j+d*g*k*p-b*h*k*p-d*f*l*p+a*h*l*p+b*f*i*p-a*g*i*p-c*g*k*q+b*e*k*q+c*f*l*q-a*e*l*q-b*f*m*q+a*g*m*q}, +a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,e=this.n23,h=this.n24,j=this.n31,l=this.n32,m=this.n33,i=this.n34,n=this.n41,k=this.n42,p=this.n43,q=this.n44;return d*e*l*n-c*h*l*n-d*g*m*n+b*h*m*n+c*g*i*n-b*e*i*n-d*e*j*k+c*h*j*k+d*f*m*k-a*h*m*k-c*f*i*k+a*e*i*k+d*g*j*p-b*h*j*p-d*f*l*p+a*h*l*p+b*f*i*p-a*g*i*p-c*g*j*q+b*e*j*q+c*f*l*q-a*e*l*q-b*f*m*q+a*g*m*q}, transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34; a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11; a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34; a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0, -0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,e=a.y,h=a.z,k=f*g,l=f*e;this.set(k*g+c,k*e-d*h,k*h+d*e,0,k*e+d*h,l*e+c,l*h-d*g,0,k*h-d*e,l*h+d*g,f*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,g=Math.cos(c),c=Math.sin(c),e=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var k= -e*h,l=e*f,m=d*h,i=d*f;this.n11=k+i*c;this.n12=m*c-l;this.n13=g*d;this.n21=g*f;this.n22=g*h;this.n23=-c;this.n31=l*c-m;this.n32=i+k*c;this.n33=g*e;break;case "ZXY":k=e*h;l=e*f;m=d*h;i=d*f;this.n11=k-i*c;this.n12=-g*f;this.n13=m+l*c;this.n21=l+m*c;this.n22=g*h;this.n23=i-k*c;this.n31=-g*d;this.n32=c;this.n33=g*e;break;case "ZYX":k=g*h;l=g*f;m=c*h;i=c*f;this.n11=e*h;this.n12=m*d-l;this.n13=k*d+i;this.n21=e*f;this.n22=i*d+k;this.n23=l*d-m;this.n31=-d;this.n32=c*e;this.n33=g*e;break;case "YZX":k=g*e;l= -g*d;m=c*e;i=c*d;this.n11=e*h;this.n12=i-k*f;this.n13=m*f+l;this.n21=f;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*f+m;this.n33=k-i*f;break;case "XZY":k=g*e;l=g*d;m=c*e;i=c*d;this.n11=e*h;this.n12=-f;this.n13=d*h;this.n21=k*f+i;this.n22=g*h;this.n23=l*f-m;this.n31=m*f-l;this.n32=c*h;this.n33=i*f+k;break;default:k=g*h,l=g*f,m=c*h,i=c*f,this.n11=e*h,this.n12=-e*f,this.n13=d,this.n21=l+m*d,this.n22=k-i*d,this.n23=-c*e,this.n31=i-k*d,this.n32=m+l*d,this.n33=g*e}return this},setRotationFromQuaternion:function(a){var b= -a.x,c=a.y,d=a.z,f=a.w,g=b+b,e=c+c,h=d+d,a=b*g,k=b*e;b*=h;var l=c*e;c*=h;d*=h;g*=f;e*=f;f*=h;this.n11=1-(l+d);this.n12=k-f;this.n13=b+e;this.n21=k+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-e;this.n32=c+g;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34}, +0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,e=a.y,h=a.z,j=f*g,l=f*e;this.set(j*g+c,j*e-d*h,j*h+d*e,0,j*e+d*h,l*e+c,l*h-d*g,0,j*h-d*e,l*h+d*g,f*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= +new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,g=Math.cos(c),c=Math.sin(c),e=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var j= +e*h,l=e*f,m=d*h,i=d*f;this.n11=j+i*c;this.n12=m*c-l;this.n13=g*d;this.n21=g*f;this.n22=g*h;this.n23=-c;this.n31=l*c-m;this.n32=i+j*c;this.n33=g*e;break;case "ZXY":j=e*h;l=e*f;m=d*h;i=d*f;this.n11=j-i*c;this.n12=-g*f;this.n13=m+l*c;this.n21=l+m*c;this.n22=g*h;this.n23=i-j*c;this.n31=-g*d;this.n32=c;this.n33=g*e;break;case "ZYX":j=g*h;l=g*f;m=c*h;i=c*f;this.n11=e*h;this.n12=m*d-l;this.n13=j*d+i;this.n21=e*f;this.n22=i*d+j;this.n23=l*d-m;this.n31=-d;this.n32=c*e;this.n33=g*e;break;case "YZX":j=g*e;l= +g*d;m=c*e;i=c*d;this.n11=e*h;this.n12=i-j*f;this.n13=m*f+l;this.n21=f;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*f+m;this.n33=j-i*f;break;case "XZY":j=g*e;l=g*d;m=c*e;i=c*d;this.n11=e*h;this.n12=-f;this.n13=d*h;this.n21=j*f+i;this.n22=g*h;this.n23=l*f-m;this.n31=m*f-l;this.n32=c*h;this.n33=i*f+j;break;default:j=g*h,l=g*f,m=c*h,i=c*f,this.n11=e*h,this.n12=-e*f,this.n13=d,this.n21=l+m*d,this.n22=j-i*d,this.n23=-c*e,this.n31=i-j*d,this.n32=m+l*d,this.n33=g*e}return this},setRotationFromQuaternion:function(a){var b= +a.x,c=a.y,d=a.z,f=a.w,g=b+b,e=c+c,h=d+d,a=b*g,j=b*e;b*=h;var l=c*e;c*=h;d*=h;g*=f;e*=f;f*=h;this.n11=1-(l+d);this.n12=j-f;this.n13=b+e;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-e;this.n32=c+g;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34}, extractRotation:function(a,b){var c=1/b.x,d=1/b.y,f=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,k=a.n23,l=a.n24,m=a.n31,i=a.n32,n=a.n33,j=a.n34,p=a.n41,q=a.n42,v=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=k*j*q-l*n*q+l*i*v-h*j*v-k*i*s+h*n*s;b.n12=g*n*q-f*j*q-g*i*v+d*j*v+f*i*s-d*n*s;b.n13=f*l*q-g*k*q+g*h*v-d*l*v-f*h*s+d*k*s;b.n14=g*k*i-f*l*i-g*h*n+d*l*n+f*h*j-d*k*j;b.n21=l*n*p-k*j*p-l*m*v+e*j*v+k*m*s-e*n*s;b.n22=f*j*p-g*n*p+g*m*v-c*j*v-f*m*s+c*n*s;b.n23=g*k*p-f*l*p-g*e*v+c*l*v+f*e*s-c*k*s;b.n24= -f*l*m-g*k*m+g*e*n-c*l*n-f*e*j+c*k*j;b.n31=h*j*p-l*i*p+l*m*q-e*j*q-h*m*s+e*i*s;b.n32=g*i*p-d*j*p-g*m*q+c*j*q+d*m*s-c*i*s;b.n33=f*l*p-g*h*p+g*e*q-c*l*q-d*e*s+c*h*s;b.n34=g*h*m-d*l*m-g*e*i+c*l*i+d*e*j-c*h*j;b.n41=k*i*p-h*n*p-k*m*q+e*n*q+h*m*v-e*i*v;b.n42=d*n*p-f*i*p+f*m*q-c*n*q-d*m*v+c*i*v;b.n43=f*h*p-d*k*p-f*e*q+c*k*q+d*e*v-c*h*v;b.n44=d*k*m-f*h*m+f*e*i-c*k*i-d*e*n+c*h*n;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,e=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*e+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*e;c[4]=a*h;c[5]=a*k;c[6]=a*l;c[7]=a*m;c[8]=a*i;return b}; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,j=a.n23,l=a.n24,m=a.n31,i=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,v=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=j*k*q-l*n*q+l*i*v-h*k*v-j*i*s+h*n*s;b.n12=g*n*q-f*k*q-g*i*v+d*k*v+f*i*s-d*n*s;b.n13=f*l*q-g*j*q+g*h*v-d*l*v-f*h*s+d*j*s;b.n14=g*j*i-f*l*i-g*h*n+d*l*n+f*h*k-d*j*k;b.n21=l*n*p-j*k*p-l*m*v+e*k*v+j*m*s-e*n*s;b.n22=f*k*p-g*n*p+g*m*v-c*k*v-f*m*s+c*n*s;b.n23=g*j*p-f*l*p-g*e*v+c*l*v+f*e*s-c*j*s;b.n24= +f*l*m-g*j*m+g*e*n-c*l*n-f*e*k+c*j*k;b.n31=h*k*p-l*i*p+l*m*q-e*k*q-h*m*s+e*i*s;b.n32=g*i*p-d*k*p-g*m*q+c*k*q+d*m*s-c*i*s;b.n33=f*l*p-g*h*p+g*e*q-c*l*q-d*e*s+c*h*s;b.n34=g*h*m-d*l*m-g*e*i+c*l*i+d*e*k-c*h*k;b.n41=j*i*p-h*n*p-j*m*q+e*n*q+h*m*v-e*i*v;b.n42=d*n*p-f*i*p+f*m*q-c*n*q-d*m*v+c*i*v;b.n43=f*h*p-d*j*p-f*e*q+c*j*q+d*e*v-c*h*v;b.n44=d*j*m-f*h*m+f*e*i-c*j*i-d*e*n+c*h*n;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,e=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*e+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*e;c[4]=a*h;c[5]=a*j;c[6]=a*l;c[7]=a*m;c[8]=a*i;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var e;e=new THREE.Matrix4;e.n11=2*f/(b-a);e.n12=0;e.n13=(b+a)/(b-a);e.n14=0;e.n21=0;e.n22=2*f/(d-c);e.n23=(d+c)/(d-c);e.n24=0;e.n31=0;e.n32=0;e.n33=-(g+f)/(g-f);e.n34=-2*g*f/(g-f);e.n41=0;e.n42=0;e.n43=-1;e.n44=0;return e};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var e,h,k,l;e=new THREE.Matrix4;h=b-a;k=c-d;l=g-f;e.n11=2/h;e.n12=0;e.n13=0;e.n14=-((b+a)/h);e.n21=0;e.n22=2/k;e.n23=0;e.n24=-((c+d)/k);e.n31=0;e.n32=0;e.n33=-2/l;e.n34=-((g+f)/l);e.n41=0;e.n42=0;e.n43=0;e.n44=1;return e};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var e,h,j,l;e=new THREE.Matrix4;h=b-a;j=c-d;l=g-f;e.n11=2/h;e.n12=0;e.n13=0;e.n14=-((b+a)/h);e.n21=0;e.n22=2/j;e.n23=0;e.n24=-((c+d)/j);e.n31=0;e.n32=0;e.n33=-2/l;e.n34=-((g+f)/l);e.n41=0;e.n42=0;e.n43=0;e.n44=1;return e};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion; this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)=== @@ -53,17 +53,17 @@ this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matri THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),e=a*b,h=d*f;this.w=e*g-h*c;this.x=e*c+h*g;this.y=d*b*g+a*f*c;this.z=a*f*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*= a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z, -k=this.w,l=k*c+e*f-h*d,m=k*d+h*c-g*f,i=k*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=l*k+c*-g+m*-h-i*-e;b.y=m*k+c*-e+i*-g-l*-h;b.z=i*k+c*-h+l*-e-m*-g;return b}}; +j=this.w,l=j*c+e*f-h*d,m=j*d+h*c-g*f,i=j*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=l*j+c*-g+m*-h-i*-e;b.y=m*j+c*-e+i*-g-l*-h;b.z=i*j+c*-h+l*-e-m*-g;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.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.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dJ&&e.positionScreen.zJ&&e.positionScreen.z0&&B.z<1))A=P[O]=P[O]||new THREE.RenderableParticle,O++,s=A,s.x=B.x/B.w,s.y=B.y/B.w,s.z=B.z,s.rotation=u.rotation.z,s.scale.x=u.scale.x*Math.abs(s.x-(B.x+f.projectionMatrix.n11)/(B.w+f.projectionMatrix.n14)),s.scale.y=u.scale.y*Math.abs(s.y-(B.y+ f.projectionMatrix.n22)/(B.w+f.projectionMatrix.n24)),s.materials=u.materials,D.push(s);g&&D.sort(b);return D}}; -THREE.CanvasRenderer=function(a){function b(a){if(v!=a)j.globalAlpha=v=a}function c(a){if(s!=a){switch(a){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}s=a}}function d(a){if(O!=a)j.strokeStyle=O=a}function f(a){if(P!=a)j.fillStyle=P=a}var g=this,e=null,h=new THREE.Projector,a=a||{},k=a.canvas!==void 0?a.canvas:document.createElement("canvas"), -l,m,i,n,j=k.getContext("2d"),p=new THREE.Color(0),q=0,v=1,s=0,O=null,P=null,y=null,B=null,o=null,t,r,x,E,Z=new THREE.RenderableVertex,$=new THREE.RenderableVertex,I,D,J,M,F,K,G,Q,w,N,L,pa,C=new THREE.Color(0),u=new THREE.Color(0),A=new THREE.Color(0),H=new THREE.Color(0),S=new THREE.Color(0),la=[],V,ca,W,aa,Da,Ea,Fa,Ga,Ha,Ia,ja=new THREE.Rectangle,X=new THREE.Rectangle,U=new THREE.Rectangle,za=!1,ba=new THREE.Color,Y=new THREE.Color,ta=new THREE.Color,ua=new THREE.Color,R=new THREE.Vector3,qa,ra, -Aa,da,sa,va,a=16;qa=document.createElement("canvas");qa.width=qa.height=2;ra=qa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0,0,2,2);Aa=ra.getImageData(0,0,2,2);da=Aa.data;sa=document.createElement("canvas");sa.width=sa.height=a;va=sa.getContext("2d");va.translate(-a/2,-a/2);va.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(a,b){l=a;m=b;i=Math.floor(l/2);n=Math.floor(m/2);k.width=l;k.height=m; -ja.set(-i,-n,i,n);X.set(-i,-n,i,n);v=1;s=0;o=B=y=P=O=null};this.setClearColor=function(a,b){p.copy(a);q=b;X.set(-i,-n,i,n)};this.setClearColorHex=function(a,b){p.setHex(a);q=b;X.set(-i,-n,i,n)};this.clear=function(){j.setTransform(1,0,0,-1,i,n);X.isEmpty()||(X.inflate(2),X.minSelf(ja),q<1&&j.clearRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight())),q>0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b* -255)+","+q+")"),j.fillRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight()))),X.empty())};this.render=function(a,l){function k(a){var b,c,d,f=a.lights;Y.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);a=0;for(b=f.length;a>1,o=k.height>>1,g=e.scale.x*i,m=e.scale.y*n,h=g*Ba,l=m*o,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(g,-m),j.translate(-Ba,-o),j.drawImage(k,0,0),j.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*i,l=e.scale.y*n,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(h,l),g.program(j), -j.restore()))}function q(a,e,f,g){b(g.opacity);c(g.blending);j.beginPath();j.moveTo(a.positionScreen.x,a.positionScreen.y);j.lineTo(e.positionScreen.x,e.positionScreen.y);j.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)j.lineWidth=y=a;a=g.linecap;if(B!=a)j.lineCap=B=a;a=g.linejoin;if(o!=a)j.lineJoin=o=a;d(g.color.getContextStyle());j.stroke();U.inflate(g.linewidth*2)}}function s(a,d,e,f,h,j,i,k,n){g.data.vertices+=3;g.data.faces++;b(k.opacity);c(k.blending);I=a.positionScreen.x; -D=a.positionScreen.y;J=d.positionScreen.x;M=d.positionScreen.y;F=e.positionScreen.x;K=e.positionScreen.y;O(I,D,J,M,F,K);if(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,k.map));else if(k.envMap){if(k.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(i.vertexNormalsWorld[0]),Da=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ea=-(R.x*a.n21+R.y*a.n22+R.z* -a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[1]),Fa=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ga=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[2]),Ha=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ia=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,Ca(I,D,J,M,F,K,Da,Ea,Fa,Ga,Ha,Ia,k.envMap)}else k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&& -(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,k.map)),c(THREE.SubtractiveBlending)),za?!k.wireframe&&k.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(u.r=A.r=H.r=Y.r,u.g=A.g=H.g=Y.g,u.b=A.b=H.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],H),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W)):(ba.r=Y.r, -ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(k.color.r*ba.r,1)),C.g=Math.max(0,Math.min(k.color.g*ba.g,1)),C.b=Math.max(0,Math.min(k.color.b*ba.b,1)),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)):k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z, -V,ca),H.r=H.g=H.b=1-ka(e.positionScreen.z,V,ca),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W);else if(k instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)}function v(a,d,e,f,h,k,i,j,n){g.data.vertices+=4;g.data.faces++;b(j.opacity);c(j.blending);if(j.map||j.envMap)s(a,d,f,0,1,3,i,j,n),s(h,e,k,1,2,3,i,j,n);else if(I= -a.positionScreen.x,D=a.positionScreen.y,J=d.positionScreen.x,M=d.positionScreen.y,F=e.positionScreen.x,K=e.positionScreen.y,G=f.positionScreen.x,Q=f.positionScreen.y,w=h.positionScreen.x,N=h.positionScreen.y,L=k.positionScreen.x,pa=k.positionScreen.y,j instanceof THREE.MeshBasicMaterial)P(I,D,J,M,F,K,G,Q),j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length== -4?(u.r=A.r=H.r=S.r=Y.r,u.g=A.g=H.g=S.g=Y.g,u.b=A.b=H.b=S.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v4.positionWorld,i.vertexNormalsWorld[3],H),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],S),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)):(ba.r=Y.r,ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(j.color.r*ba.r,1)),C.g=Math.max(0,Math.min(j.color.g* -ba.g,1)),C.b=Math.max(0,Math.min(j.color.b*ba.b,1)),P(I,D,J,M,F,K,G,Q),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)):(P(I,D,J,M,F,K,G,Q),j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color));else if(j instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),P(I,D,J,M,F,K,G,Q),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C);else if(j instanceof -THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,V,ca),H.r=H.g=H.b=1-ka(f.positionScreen.z,V,ca),S.r=S.g=S.b=1-ka(e.positionScreen.z,V,ca),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)}function O(a,b,c,d,e,f){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,f);j.lineTo(a,b);j.closePath()}function P(a,b,c,d,e,f,g,h){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e, -f);j.lineTo(g,h);j.lineTo(a,b);j.closePath()}function fa(a,b,c,e){if(y!=b)j.lineWidth=y=b;if(B!=c)j.lineCap=B=c;if(o!=e)j.lineJoin=o=e;d(a.getContextStyle());j.stroke();U.inflate(b*2)}function ga(a){f(a.getContextStyle());j.fill()}function Ca(a,b,c,d,e,g,h,k,i,l,m,n,o){if(o.image.width!=0){if(o.needsUpdate==!0||la[o.id]==void 0){var p=o.wrapS==THREE.RepeatWrapping,q=o.wrapT==THREE.RepeatWrapping;la[o.id]=j.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate= -!1}f(la[o.id]);p=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;h*=p;k*=o;i*=p;l*=o;m*=p;n*=o;c-=a;d-=b;e-=a;g-=b;i-=h;l-=k;m-=h;n-=k;p=1/(i*n-m*l);o=(n*c-l*e)*p;l=(n*d-l*g)*p;c=(i*e-m*c)*p;d=(i*g-m*d)*p;a=a-o*h-c*k;b=b-l*h-d*k;j.save();j.transform(o,l,c,d,a,b);j.fill();j.restore()}}function ma(a,b,c,d,e,f,g,h,k,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;k*=o;i*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;k-=g;i-=h;l-=g;m-=h;p=1/(k*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(k*e-l*c)*p;d=(k* -f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;j.save();j.transform(o,i,c,d,a,b);j.clip();j.drawImage(n,0,0);j.restore()}function wa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);da[0]=e<0?0:e>255?255:e;da[1]=f<0?0:f>255?255:f;da[2]=a<0?0:a>255?255:a;da[4]=g<0?0:g>255?255:g;da[5]=h<0?0:h>255?255:h;da[6]=b<0?0:b>255?255:b;da[8]=i<0?0:i>255?255:i;da[9]=j<0?0:j>255?255:j;da[10]=c< -0?0:c>255?255:c;da[12]=k<0?0:k>255?255:k;da[13]=l<0?0:l>255?255:l;da[14]=d<0?0:d>255?255:d;ra.putImageData(Aa,0,0);va.drawImage(qa,0,0);return sa}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ja,z,ea,ia,oa,ya,T;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);g.data.vertices=0;g.data.faces=0;e=h.projectScene(a,l,this.sortElements); -(za=a.lights.length>0)&&k(a);xa=0;for(Ja=e.length;xa0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b* +255)+","+q+")"),k.fillRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight()))),X.empty())};this.render=function(a,l){function j(a){var b,c,d,f=a.lights;Y.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);a=0;for(b=f.length;a>1,o=j.height>>1,g=e.scale.x*i,m=e.scale.y*n,h=g*Ba,l=m*o,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-m),k.translate(-Ba,-o),k.drawImage(j,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*i,l=e.scale.y*n,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,l),g.program(k), +k.restore()))}function q(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)k.lineWidth=y=a;a=g.linecap;if(B!=a)k.lineCap=B=a;a=g.linejoin;if(o!=a)k.lineJoin=o=a;d(g.color.getContextStyle());k.stroke();U.inflate(g.linewidth*2)}}function s(a,d,e,f,h,k,i,j,n){g.data.vertices+=3;g.data.faces++;b(j.opacity);c(j.blending);I=a.positionScreen.x; +D=a.positionScreen.y;J=d.positionScreen.x;M=d.positionScreen.y;F=e.positionScreen.x;K=e.positionScreen.y;O(I,D,J,M,F,K);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[k].u,aa[k].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(i.vertexNormalsWorld[0]),Da=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ea=-(R.x*a.n21+R.y*a.n22+R.z* +a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[1]),Fa=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ga=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[2]),Ha=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ia=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,Ca(I,D,J,M,F,K,Da,Ea,Fa,Ga,Ha,Ia,j.envMap)}else j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof THREE.UVMapping&& +(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[k].u,aa[k].v,j.map)),c(THREE.SubtractiveBlending)),za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(u.r=A.r=H.r=Y.r,u.g=A.g=H.g=Y.g,u.b=A.b=H.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],H),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W)):(ba.r=Y.r, +ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(j.color.r*ba.r,1)),C.g=Math.max(0,Math.min(j.color.g*ba.g,1)),C.b=Math.max(0,Math.min(j.color.b*ba.b,1)),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)):j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z, +V,ca),H.r=H.g=H.b=1-ka(e.positionScreen.z,V,ca),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W);else if(j instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)}function v(a,d,e,f,h,j,i,k,n){g.data.vertices+=4;g.data.faces++;b(k.opacity);c(k.blending);if(k.map||k.envMap)s(a,d,f,0,1,3,i,k,n),s(h,e,j,1,2,3,i,k,n);else if(I= +a.positionScreen.x,D=a.positionScreen.y,J=d.positionScreen.x,M=d.positionScreen.y,F=e.positionScreen.x,K=e.positionScreen.y,G=f.positionScreen.x,Q=f.positionScreen.y,w=h.positionScreen.x,N=h.positionScreen.y,L=j.positionScreen.x,pa=j.positionScreen.y,k instanceof THREE.MeshBasicMaterial)P(I,D,J,M,F,K,G,Q),k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshLambertMaterial)za?!k.wireframe&&k.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length== +4?(u.r=A.r=H.r=S.r=Y.r,u.g=A.g=H.g=S.g=Y.g,u.b=A.b=H.b=S.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v4.positionWorld,i.vertexNormalsWorld[3],H),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],S),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)):(ba.r=Y.r,ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(k.color.r*ba.r,1)),C.g=Math.max(0,Math.min(k.color.g* +ba.g,1)),C.b=Math.max(0,Math.min(k.color.b*ba.b,1)),P(I,D,J,M,F,K,G,Q),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)):(P(I,D,J,M,F,K,G,Q),k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color));else if(k instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),P(I,D,J,M,F,K,G,Q),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C);else if(k instanceof +THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,V,ca),H.r=H.g=H.b=1-ka(f.positionScreen.z,V,ca),S.r=S.g=S.b=1-ka(e.positionScreen.z,V,ca),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)}function O(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function P(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e, +f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function fa(a,b,c,e){if(y!=b)k.lineWidth=y=b;if(B!=c)k.lineCap=B=c;if(o!=e)k.lineJoin=o=e;d(a.getContextStyle());k.stroke();U.inflate(b*2)}function ga(a){f(a.getContextStyle());k.fill()}function Ca(a,b,c,d,e,g,h,j,i,l,m,n,o){if(o.image.width!=0){if(o.needsUpdate==!0||la[o.id]==void 0){var p=o.wrapS==THREE.RepeatWrapping,q=o.wrapT==THREE.RepeatWrapping;la[o.id]=k.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate= +!1}f(la[o.id]);var p=o.offset.x/o.repeat.x,q=o.offset.y/o.repeat.y,r=(o.image.width-1)*o.repeat.x,o=(o.image.height-1)*o.repeat.y,h=(h+p)*r,j=(j+q)*o,i=(i+p)*r,l=(l+q)*o,m=(m+p)*r,n=(n+q)*o;c-=a;d-=b;e-=a;g-=b;i-=h;l-=j;m-=h;n-=j;p=1/(i*n-m*l);o=(n*c-l*e)*p;l=(n*d-l*g)*p;c=(i*e-m*c)*p;d=(i*g-m*d)*p;a=a-o*h-c*j;b=b-l*h-d*j;k.save();k.transform(o,l,c,d,a,b);k.fill();k.restore()}}function ma(a,b,c,d,e,f,g,h,j,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;j*=o;i*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b; +j-=g;i-=h;l-=g;m-=h;p=1/(j*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(j*e-l*c)*p;d=(j*f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;k.save();k.transform(o,i,c,d,a,b);k.clip();k.drawImage(n,0,0);k.restore()}function wa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);da[0]=e<0?0:e>255?255:e;da[1]=f<0?0:f>255?255:f;da[2]=a<0?0:a>255?255:a;da[4]=g<0?0:g>255?255:g;da[5]=h<0?0:h>255?255:h; +da[6]=b<0?0:b>255?255:b;da[8]=i<0?0:i>255?255:i;da[9]=j<0?0:j>255?255:j;da[10]=c<0?0:c>255?255:c;da[12]=k<0?0:k>255?255:k;da[13]=l<0?0:l>255?255:l;da[14]=d<0?0:d>255?255:d;ra.putImageData(Aa,0,0);va.drawImage(qa,0,0);return sa}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ja,z,ea,ia,oa,ya,T;this.autoClear?this.clear():k.setTransform(1, +0,0,-1,i,n);g.data.vertices=0;g.data.faces=0;e=h.projectScene(a,l,this.sortElements);(za=a.lights.length>0)&&j(a);xa=0;for(Ja=e.length;xa>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index a984335c..dbb0ec04 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -1,4 +1,4 @@ -// ThreeExtras.js r42 - http://github.com/mrdoob/three.js +// ThreeExtras.js r43 - 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,h=Math.max(Math.max(c,e),f),g=Math.min(Math.min(c,e),f);if(g==h)g=c=0;else{var j=h-g,g=j/h,c=c==h?(e-f)/j:e==h?2+(f-c)/j:4+(c-e)/j;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}; THREE.GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,h=a.vertices,g=f.vertices,j=a.faces,k=f.faces,l=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var m=0,n=g.length;m=0;J--){I=J/m;E=k*(1-I);I=l*Math.sin(I*Math.PI/2);A=0;for(D=x.length;A(B-p)*(A-z)-(G-z)*(H-p))o=!1;else{for(x=0;x=0&&F>=0&&M>=0){o=!1;break a}}o=!0}}if(o){h.push([a[g[k]], a[g[l]],a[g[m]]]);j.push([g[k],g[l],g[m]]);k=l;for(m=l+1;m>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index 26d17e4a..c59e35c2 100644 --- a/build/custom/ThreeWebGL.js +++ b/build/custom/ThreeWebGL.js @@ -1,88 +1,85 @@ -// ThreeWebGL.js r42 - http://github.com/mrdoob/three.js +// ThreeWebGL.js r43 - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){b!==void 0&&this.setHex(b);return this}; -THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;return this},setHSV:function(b,d,e){var f,h,i;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),h=b*6-f,b=e*(1-d),i=e*(1-d*h),d=e*(1-d*(1-h)),f){case 1:this.r=i;this.g=e;this.b=b;break;case 2:this.r=b;this.g=e;this.b=d;break;case 3:this.r=b;this.g=i;this.b=e;break;case 4:this.r=d;this.g=b;this.b=e;break;case 5:this.r= -e;this.g=b;this.b=i;break;case 6:case 0:this.r=e,this.g=d,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; -THREE.Vector2=function(b,d){this.set(b||0,d||0)}; -THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,d){this.x=b.x+d.x;this.y=b.y+d.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,d){this.x=b.x-d.x;this.y=b.y-d.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this}, -divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x,b=this.y-b.y;return d*d+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, -unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)}; -THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,d,e){this.x=b;this.y=d;this.z=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,d){this.x=b.x+d.x;this.y=b.y+d.y;this.z=b.z+d.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,d){this.x=b.x-d.x;this.y=b.y-d.y;this.z= -b.z-d.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,d){this.x=b.x*d.x;this.y=b.y*d.y;this.z=b.z*d.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){return this.divide(this,b)},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)}, -dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},cross:function(b,d){this.x=b.y*d.z-b.z*d.y;this.y=b.z*d.x-b.x*d.z;this.z=b.x*d.y-b.y*d.x;return this},crossSelf:function(b){return this.set(this.y* -b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var d=Math.cos(this.y);this.y=Math.asin(b.n13);Math.abs(d)>1.0E-5?(this.x=Math.atan2(-b.n23/d,b.n33/d),this.z=Math.atan2(-b.n12/d,b.n11/d)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()< -1.0E-4}};THREE.Vector4=function(b,d,e,f){this.set(b||0,d||0,e||0,f||1)}; -THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;this.w=f;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,d){this.x=b.x+d.x;this.y=b.y+d.y;this.z=b.z+d.z;this.w=b.w+d.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,d){this.x=b.x-d.x;this.y=b.y-d.y;this.z=b.z-d.z;this.w=b.w-d.w;return this}, +THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,d){this.r=b;this.g=c;this.b=d;return this},setHSV:function(b,c,d){var e,h,j;if(d==0)this.r=this.g=this.b=0;else switch(e=Math.floor(b*6),h=b*6-e,b=d*(1-c),j=d*(1-c*h),c=d*(1-c*(1-h)),e){case 1:this.r=j;this.g=d;this.b=b;break;case 2:this.r=b;this.g=d;this.b=c;break;case 3:this.r=b;this.g=j;this.b=d;break;case 4:this.r=c;this.g=b;this.b=d;break;case 5:this.r= +d;this.g=b;this.b=j;break;case 6:case 0:this.r=d,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; +THREE.Vector2=function(b,c){this.set(b||0,c||0)}; +THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this}, +divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, +unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,d){this.set(b||0,c||0,d||0)}; +THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,c,d){this.x=b;this.y=c;this.z=d;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z= +b.z-c.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){return this.divide(this,b)},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)}, +dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y* +b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13);Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()< +1.0E-4}};THREE.Vector4=function(b,c,d,e){this.set(b||0,c||0,d||0,e||1)}; +THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w=b.w-c.w;return this}, subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())}, -setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,d){this.x+=(b.x-this.x)*d;this.y+=(b.y-this.y)*d;this.z+=(b.z-this.z)*d;this.w+=(b.w-this.w)*d;return this}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var d,e,f=[];d=0;for(e=b.length;d0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var f=d(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=d(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var h,i,g,j, -k,q,n,r,t,o,F=b.geometry,x=F.vertices,G=[],f=0;for(h=F.faces.length;f0:r<0))if(n=n.dot((new THREE.Vector3).sub(g, -t))/r,t=t.addSelf(o.multiplyScalar(n)),i instanceof THREE.Face3)e(t,g,j,k)&&(i={distance:this.origin.distanceTo(t),point:t,face:i,object:b},G.push(i));else if(i instanceof THREE.Face4&&(e(t,g,j,q)||e(t,j,k,q)))i={distance:this.origin.distanceTo(t),point:t,face:i,object:b},G.push(i);return G}else return[]}}; -THREE.Rectangle=function(){function b(){i=f-d;g=h-e}var d,e,f,h,i,g,j=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return g};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(g,i,n,r){j=!1;d=g;e=i;f=n;h=r;b()};this.addPoint=function(g,i){j?(j=!1,d=g,e=i,f=g,h=i):(d=dg?f:g,h=h>i?h:i);b()};this.add3Points= -function(g,i,n,r,t,o){j?(j=!1,d=gn?g>t?g:t:n>t?n:t,h=i>r?i>o?i:o:r>o?r:o):(d=gn?g>t?g>f?g:f:t>f?t:f:n>t?n>f?n:f:t>f?t:f,h=i>r?i>o?i>h?i:h:o>h?o:h:r>o?r>h?r:h:o>h?o:h);b()};this.addRectangle=function(g){j?(j=!1,d=g.getLeft(),e=g.getTop(),f=g.getRight(),h=g.getBottom()):(d=dg.getRight()?f:g.getRight(),h=h> -g.getBottom()?h:g.getBottom());b()};this.inflate=function(g){d-=g;e-=g;f+=g;h+=g;b()};this.minSelf=function(g){d=d>g.getLeft()?d:g.getLeft();e=e>g.getTop()?e:g.getTop();f=f=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){j=!0;h=f=e=d=0;b()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};THREE.Matrix4=function(b,d,e,f,h,i,g,j,k,q,n,r,t,o,F,x){this.set(b||1,d||0,e||0,f||0,h||0,i||1,g||0,j||0,k||0,q||0,n||1,r||0,t||0,o||0,F||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,d,e,f,h,i,g,j,k,q,n,r,t,o,F,x){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=g;this.n24=j;this.n31=k;this.n32=q;this.n33=n;this.n34=r;this.n41=t;this.n42=o;this.n43=F;this.n44=x;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, -d,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,d).normalize();if(i.length()===0)i.z=1;f.cross(e,i).normalize();f.length()===0&&(i.x+=1.0E-4,f.cross(e,i).normalize());h.cross(i,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=i.x;this.n21=f.y;this.n22=h.y;this.n23=i.y;this.n31=f.z;this.n32=h.z;this.n33=i.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,f=b.z,h=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*h; -b.y=(this.n21*d+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var d=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*d+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*d+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*d+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*d+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var d=b.x,e=b.y,f=b.z;b.x=d*this.n11+e*this.n12+f*this.n13;b.y=d*this.n21+e*this.n22+f*this.n23;b.z=d*this.n31+ -e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,k=b.n23,q=b.n24,n=b.n31,r=b.n32,t=b.n33,o=b.n34,F=b.n41,x=b.n42,G=b.n43,E=b.n44,U=d.n11,ta=d.n12, -fa=d.n13,I=d.n14,w=d.n21,P=d.n22,J=d.n23,M=d.n24,Q=d.n31,ra=d.n32,ka=d.n33,aa=d.n34,va=d.n41,N=d.n42,K=d.n43,c=d.n44;this.n11=e*U+f*w+h*Q+i*va;this.n12=e*ta+f*P+h*ra+i*N;this.n13=e*fa+f*J+h*ka+i*K;this.n14=e*I+f*M+h*aa+i*c;this.n21=g*U+j*w+k*Q+q*va;this.n22=g*ta+j*P+k*ra+q*N;this.n23=g*fa+j*J+k*ka+q*K;this.n24=g*I+j*M+k*aa+q*c;this.n31=n*U+r*w+t*Q+o*va;this.n32=n*ta+r*P+t*ra+o*N;this.n33=n*fa+r*J+t*ka+o*K;this.n34=n*I+r*M+t*aa+o*c;this.n41=F*U+x*w+G*Q+E*va;this.n42=F*ta+x*P+G*ra+E*N;this.n43=F*fa+ -x*J+G*ka+E*K;this.n44=F*I+x*M+G*aa+E*c;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*= -b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,h=this.n21,i=this.n22,g=this.n23,j=this.n24,k=this.n31,q=this.n32,n=this.n33,r=this.n34,t=this.n41,o=this.n42,F=this.n43,x=this.n44;return f*g*q*t-e*j*q*t-f*i*n*t+d*j*n*t+e*i*r*t-d*g*r*t-f*g*k*o+e*j*k*o+f*h*n*o-b*j*n*o-e*h*r*o+b*g*r*o+f*i*k*F-d*j*k*F-f*h*q*F+b*j*q*F+d*h*r*F-b*i*r*F-e*i*k*x+d*g* -k*x+e*h*q*x-b*g*q*x-d*h*n*x+b*i*n*x},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; +setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; +THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,d,e=[];c=0;for(d=b.length;c0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var e=c(this.origin,this.direction,b);if(!e||e>b.scale.x)return[];return[{distance:e,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){e=c(this.origin,this.direction,b);if(!e||e>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var h,j,g,k, +q,m,o,p,r,v,C=b.geometry,x=C.vertices,E=[],e=0;for(h=C.faces.length;e0:p<0))if(o=o.dot((new THREE.Vector3).sub(g, +r))/p,r=r.addSelf(v.multiplyScalar(o)),j instanceof THREE.Face3)d(r,g,k,q)&&(j={distance:this.origin.distanceTo(r),point:r,face:j,object:b},E.push(j));else if(j instanceof THREE.Face4&&(d(r,g,k,m)||d(r,k,q,m)))j={distance:this.origin.distanceTo(r),point:r,face:j,object:b},E.push(j);return E}else return[]}}; +THREE.Rectangle=function(){function b(){j=e-c;g=h-d}var c,d,e,h,j,g,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return g};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(g,j,o,p){k=!1;c=g;d=j;e=o;h=p;b()};this.addPoint=function(g,j){k?(k=!1,c=g,d=j,e=g,h=j):(c=cg?e:g,h=h>j?h:j);b()};this.add3Points= +function(g,j,o,p,r,v){k?(k=!1,c=go?g>r?g:r:o>r?o:r,h=j>p?j>v?j:v:p>v?p:v):(c=go?g>r?g>e?g:e:r>e?r:e:o>r?o>e?o:e:r>e?r:e,h=j>p?j>v?j>h?j:h:v>h?v:h:p>v?p>h?p:h:v>h?v:h);b()};this.addRectangle=function(g){k?(k=!1,c=g.getLeft(),d=g.getTop(),e=g.getRight(),h=g.getBottom()):(c=cg.getRight()?e:g.getRight(),h=h> +g.getBottom()?h:g.getBottom());b()};this.inflate=function(g){c-=g;d-=g;e+=g;h+=g;b()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e=0&&Math.min(h,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;h=e=d=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,e,h,j,g,k,q,m,o,p,r,v,C,x){this.set(b||1,c||0,d||0,e||0,h||0,j||1,g||0,k||0,q||0,m||0,o||1,p||0,r||0,v||0,C||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,d,e,h,j,g,k,q,m,o,p,r,v,C,x){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=h;this.n22=j;this.n23=g;this.n24=k;this.n31=q;this.n32=m;this.n33=o;this.n34=p;this.n41=r;this.n42=v;this.n43=C;this.n44=x;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, +c,d){var e=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;e.cross(d,j).normalize();e.length()===0&&(j.x+=1.0E-4,e.cross(d,j).normalize());h.cross(j,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=j.x;this.n21=e.y;this.n22=h.y;this.n23=j.y;this.n31=e.z;this.n32=h.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,h=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*h; +b.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*h;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,h=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*h;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*h;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*h;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*h;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+ +d*this.n32+e*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,e=b.n12,h=b.n13,j=b.n14,g=b.n21,k=b.n22,q=b.n23,m=b.n24,o=b.n31,p=b.n32,r=b.n33,v=b.n34,C=b.n41,x=b.n42,E=b.n43,J=b.n44,ya=c.n11,za= +c.n12,sa=c.n13,V=c.n14,u=c.n21,Q=c.n22,O=c.n23,T=c.n24,U=c.n31,qa=c.n32,N=c.n33,L=c.n34,f=c.n41,ua=c.n42,Aa=c.n43,ta=c.n44;this.n11=d*ya+e*u+h*U+j*f;this.n12=d*za+e*Q+h*qa+j*ua;this.n13=d*sa+e*O+h*N+j*Aa;this.n14=d*V+e*T+h*L+j*ta;this.n21=g*ya+k*u+q*U+m*f;this.n22=g*za+k*Q+q*qa+m*ua;this.n23=g*sa+k*O+q*N+m*Aa;this.n24=g*V+k*T+q*L+m*ta;this.n31=o*ya+p*u+r*U+v*f;this.n32=o*za+p*Q+r*qa+v*ua;this.n33=o*sa+p*O+r*N+v*Aa;this.n34=o*V+p*T+r*L+v*ta;this.n41=C*ya+x*u+E*U+J*f;this.n42=C*za+x*Q+E*qa+J*ua;this.n43= +C*sa+x*O+E*N+J*Aa;this.n44=C*V+x*T+E*L+J*ta;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},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,d=this.n13,e=this.n14,h=this.n21,j=this.n22,g=this.n23,k=this.n24,q=this.n31,m=this.n32,o=this.n33,p=this.n34,r=this.n41,v=this.n42,C=this.n43,x=this.n44;return e*g*m*r-d*k*m*r-e*j*o*r+c*k*o*r+d*j*p*r-c*g*p*r-e*g*q*v+d*k*q*v+e*h*o*v-b*k*o*v-d*h*p*v+b*g*p*v+e*j*q*C-c*k*q*C-e*h*m*C+b*k*m*C+c*h*p*C-b*j*p*C-d*j*q*x+c*g* +q*x+d*h*m*x-b*g*m*x-c*h*o*x+b*j*o*x},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32; b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]= -this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]= -this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,0,1);return this},setScale:function(b,d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(d,-b,0, -0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var e=Math.cos(d),f=Math.sin(d),h=1-e,i=b.x,g=b.y,j=b.z,k=h*i,q=h*g;this.set(k*i+e,k*g-f*j,k*j+f*g,0,k*g+f*j,q*g+e,q*j-f*i,0,k*j-f*g,q*j+f*i,h*j*j+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= -new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,d){var e=b.x,f=b.y,h=b.z,i=Math.cos(e),e=Math.sin(e),g=Math.cos(f),f=Math.sin(f),j=Math.cos(h),h=Math.sin(h);switch(d){case "YXZ":var k= -g*j,q=g*h,n=f*j,r=f*h;this.n11=k+r*e;this.n12=n*e-q;this.n13=i*f;this.n21=i*h;this.n22=i*j;this.n23=-e;this.n31=q*e-n;this.n32=r+k*e;this.n33=i*g;break;case "ZXY":k=g*j;q=g*h;n=f*j;r=f*h;this.n11=k-r*e;this.n12=-i*h;this.n13=n+q*e;this.n21=q+n*e;this.n22=i*j;this.n23=r-k*e;this.n31=-i*f;this.n32=e;this.n33=i*g;break;case "ZYX":k=i*j;q=i*h;n=e*j;r=e*h;this.n11=g*j;this.n12=n*f-q;this.n13=k*f+r;this.n21=g*h;this.n22=r*f+k;this.n23=q*f-n;this.n31=-f;this.n32=e*g;this.n33=i*g;break;case "YZX":k=i*g;q= -i*f;n=e*g;r=e*f;this.n11=g*j;this.n12=r-k*h;this.n13=n*h+q;this.n21=h;this.n22=i*j;this.n23=-e*j;this.n31=-f*j;this.n32=q*h+n;this.n33=k-r*h;break;case "XZY":k=i*g;q=i*f;n=e*g;r=e*f;this.n11=g*j;this.n12=-h;this.n13=f*j;this.n21=k*h+r;this.n22=i*j;this.n23=q*h-n;this.n31=n*h-q;this.n32=e*j;this.n33=r*h+k;break;default:k=i*j,q=i*h,n=e*j,r=e*h,this.n11=g*j,this.n12=-g*h,this.n13=f,this.n21=q+n*f,this.n22=k-r*f,this.n23=-e*g,this.n31=r-k*f,this.n32=n+q*f,this.n33=i*g}return this},setRotationFromQuaternion:function(b){var d= -b.x,e=b.y,f=b.z,h=b.w,i=d+d,g=e+e,j=f+f,b=d*i,k=d*g;d*=j;var q=e*g;e*=j;f*=j;i*=h;g*=h;h*=j;this.n11=1-(q+f);this.n12=k-h;this.n13=d+g;this.n21=k+h;this.n22=1-(b+f);this.n23=e-i;this.n31=d-g;this.n32=e+i;this.n33=1-(b+q);return this},scale:function(b){var d=b.x,e=b.y,b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34}, -extractRotation:function(b,d){var e=1/d.x,f=1/d.y,h=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}}; -THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,k=b.n23,q=b.n24,n=b.n31,r=b.n32,t=b.n33,o=b.n34,F=b.n41,x=b.n42,G=b.n43,E=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=k*o*x-q*t*x+q*r*G-j*o*G-k*r*E+j*t*E;d.n12=i*t*x-h*o*x-i*r*G+f*o*G+h*r*E-f*t*E;d.n13=h*q*x-i*k*x+i*j*G-f*q*G-h*j*E+f*k*E;d.n14=i*k*r-h*q*r-i*j*t+f*q*t+h*j*o-f*k*o;d.n21=q*t*F-k*o*F-q*n*G+g*o*G+k*n*E-g*t*E;d.n22=h*o*F-i*t*F+i*n*G-e*o*G-h*n*E+e*t*E;d.n23=i*k*F-h*q*F-i*g*G+e*q*G+h*g*E-e*k*E;d.n24= -h*q*n-i*k*n+i*g*t-e*q*t-h*g*o+e*k*o;d.n31=j*o*F-q*r*F+q*n*x-g*o*x-j*n*E+g*r*E;d.n32=i*r*F-f*o*F-i*n*x+e*o*x+f*n*E-e*r*E;d.n33=h*q*F-i*j*F+i*g*x-e*q*x-f*g*E+e*j*E;d.n34=i*j*n-f*q*n-i*g*r+e*q*r+f*g*o-e*j*o;d.n41=k*r*F-j*t*F-k*n*x+g*t*x+j*n*G-g*r*G;d.n42=f*t*F-h*r*F+h*n*x-e*t*x-f*n*G+e*r*G;d.n43=h*j*F-f*k*F-h*g*x+e*k*x+f*g*G-e*j*G;d.n44=f*k*n-h*j*n+h*g*r-e*k*r-f*g*t+e*j*t;d.multiplyScalar(1/b.determinant());return d}; -THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,g=-b.n33*b.n12+b.n32*b.n13,j=b.n33*b.n11-b.n31*b.n13,k=-b.n32*b.n11+b.n31*b.n12,q=b.n23*b.n12-b.n22*b.n13,n=-b.n23*b.n11+b.n21*b.n13,r=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*g+b.n31*q;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*i;e[3]=b*g;e[4]=b*j;e[5]=b*k;e[6]=b*q;e[7]=b*n;e[8]=b*r;return d}; -THREE.Matrix4.makeFrustum=function(b,d,e,f,h,i){var g;g=new THREE.Matrix4;g.n11=2*h/(d-b);g.n12=0;g.n13=(d+b)/(d-b);g.n14=0;g.n21=0;g.n22=2*h/(f-e);g.n23=(f+e)/(f-e);g.n24=0;g.n31=0;g.n32=0;g.n33=-(i+h)/(i-h);g.n34=-2*i*h/(i-h);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(b,d,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*d,b*d,h,b,e,f)}; -THREE.Matrix4.makeOrtho=function(b,d,e,f,h,i){var g,j,k,q;g=new THREE.Matrix4;j=d-b;k=e-f;q=i-h;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((d+b)/j);g.n21=0;g.n22=2/k;g.n23=0;g.n24=-((e+f)/k);g.n31=0;g.n32=0;g.n33=-2/q;g.n34=-((i+h)/q);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +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,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0, +0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),h=1-d,j=b.x,g=b.y,k=b.z,q=h*j,m=h*g;this.set(q*j+d,q*g-e*k,q*k+e*g,0,q*g+e*k,m*g+d,m*k-e*j,0,q*k-e*g,m*k+e*j,h*k*k+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= +new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var d=b.x,e=b.y,h=b.z,j=Math.cos(d),d=Math.sin(d),g=Math.cos(e),e=Math.sin(e),k=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var q= +g*k,m=g*h,o=e*k,p=e*h;this.n11=q+p*d;this.n12=o*d-m;this.n13=j*e;this.n21=j*h;this.n22=j*k;this.n23=-d;this.n31=m*d-o;this.n32=p+q*d;this.n33=j*g;break;case "ZXY":q=g*k;m=g*h;o=e*k;p=e*h;this.n11=q-p*d;this.n12=-j*h;this.n13=o+m*d;this.n21=m+o*d;this.n22=j*k;this.n23=p-q*d;this.n31=-j*e;this.n32=d;this.n33=j*g;break;case "ZYX":q=j*k;m=j*h;o=d*k;p=d*h;this.n11=g*k;this.n12=o*e-m;this.n13=q*e+p;this.n21=g*h;this.n22=p*e+q;this.n23=m*e-o;this.n31=-e;this.n32=d*g;this.n33=j*g;break;case "YZX":q=j*g;m= +j*e;o=d*g;p=d*e;this.n11=g*k;this.n12=p-q*h;this.n13=o*h+m;this.n21=h;this.n22=j*k;this.n23=-d*k;this.n31=-e*k;this.n32=m*h+o;this.n33=q-p*h;break;case "XZY":q=j*g;m=j*e;o=d*g;p=d*e;this.n11=g*k;this.n12=-h;this.n13=e*k;this.n21=q*h+p;this.n22=j*k;this.n23=m*h-o;this.n31=o*h-m;this.n32=d*k;this.n33=p*h+q;break;default:q=j*k,m=j*h,o=d*k,p=d*h,this.n11=g*k,this.n12=-g*h,this.n13=e,this.n21=m+o*e,this.n22=q-p*e,this.n23=-d*g,this.n31=p-q*e,this.n32=o+m*e,this.n33=j*g}return this},setRotationFromQuaternion:function(b){var c= +b.x,d=b.y,e=b.z,h=b.w,j=c+c,g=d+d,k=e+e,b=c*j,q=c*g;c*=k;var m=d*g;d*=k;e*=k;j*=h;g*=h;h*=k;this.n11=1-(m+e);this.n12=q-h;this.n13=c+g;this.n21=q+h;this.n22=1-(b+e);this.n23=d-j;this.n31=c-g;this.n32=d+j;this.n33=1-(b+m);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34}, +extractRotation:function(b,c){var d=1/c.x,e=1/c.y,h=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}}; +THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,h=b.n13,j=b.n14,g=b.n21,k=b.n22,q=b.n23,m=b.n24,o=b.n31,p=b.n32,r=b.n33,v=b.n34,C=b.n41,x=b.n42,E=b.n43,J=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=q*v*x-m*r*x+m*p*E-k*v*E-q*p*J+k*r*J;c.n12=j*r*x-h*v*x-j*p*E+e*v*E+h*p*J-e*r*J;c.n13=h*m*x-j*q*x+j*k*E-e*m*E-h*k*J+e*q*J;c.n14=j*q*p-h*m*p-j*k*r+e*m*r+h*k*v-e*q*v;c.n21=m*r*C-q*v*C-m*o*E+g*v*E+q*o*J-g*r*J;c.n22=h*v*C-j*r*C+j*o*E-d*v*E-h*o*J+d*r*J;c.n23=j*q*C-h*m*C-j*g*E+d*m*E+h*g*J-d*q*J;c.n24= +h*m*o-j*q*o+j*g*r-d*m*r-h*g*v+d*q*v;c.n31=k*v*C-m*p*C+m*o*x-g*v*x-k*o*J+g*p*J;c.n32=j*p*C-e*v*C-j*o*x+d*v*x+e*o*J-d*p*J;c.n33=h*m*C-j*k*C+j*g*x-d*m*x-e*g*J+d*k*J;c.n34=j*k*o-e*m*o-j*g*p+d*m*p+e*g*v-d*k*v;c.n41=q*p*C-k*r*C-q*o*x+g*r*x+k*o*E-g*p*E;c.n42=e*r*C-h*p*C+h*o*x-d*r*x-e*o*E+d*p*E;c.n43=h*k*C-e*q*C-h*g*x+d*q*x+e*g*E-d*k*E;c.n44=e*q*o-h*k*o+h*g*p-d*q*p-e*g*r+d*k*r;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,g=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,m=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,p=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*g+b.n31*m;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*h;d[2]=b*j;d[3]=b*g;d[4]=b*k;d[5]=b*q;d[6]=b*m;d[7]=b*o;d[8]=b*p;return c}; +THREE.Matrix4.makeFrustum=function(b,c,d,e,h,j){var g;g=new THREE.Matrix4;g.n11=2*h/(c-b);g.n12=0;g.n13=(c+b)/(c-b);g.n14=0;g.n21=0;g.n22=2*h/(e-d);g.n23=(e+d)/(e-d);g.n24=0;g.n31=0;g.n32=0;g.n33=-(j+h)/(j-h);g.n34=-2*j*h/(j-h);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(b,c,d,e){var h,b=d*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,d,e)}; +THREE.Matrix4.makeOrtho=function(b,c,d,e,h,j){var g,k,q,m;g=new THREE.Matrix4;k=c-b;q=d-e;m=j-h;g.n11=2/k;g.n12=0;g.n13=0;g.n14=-((c+b)/k);g.n21=0;g.n22=2/q;g.n23=0;g.n24=-((d+e)/q);g.n31=0;g.n32=0;g.n33=-2/m;g.n34=-((j+h)/m);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion; this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; -THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)=== --1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d.parent!==void 0;)d=d.parent;d!==void 0&&d instanceof THREE.Scene&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1)b.parent=void 0,this.children.splice(d,1)},getChildByName:function(b,d){var e,f,h;e=0;for(f=this.children.length;e=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.001)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;h=Math.sin((1-f)*i)/g;f=Math.sin(f*i)/g;e.w=b.w*h+d.w*f;e.x=b.x*h+d.x*f;e.y=b.y*h+d.y*f;e.z=b.z*h+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; -THREE.Face3=function(b,d,e,f,h,i){this.a=b;this.b=d;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3}; -THREE.Face4=function(b,d,e,f,h,i,g){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; -THREE.UV.prototype={constructor:THREE.UV,set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; -THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,d,e;b=0;for(d=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;dthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,d=0,e=this.vertices.length;dthis.points.length-2?i:i+1;e[3]=i>this.points.length-3?i:i+2;q=this.points[e[0]];n=this.points[e[1]]; -r=this.points[e[2]];t=this.points[e[3]];j=g*g;k=g*j;f.x=d(q.x,n.x,r.x,t.x,g,j,k);f.y=d(q.y,n.y,r.y,t.y,g,j,k);f.z=d(q.z,n.z,r.z,t.z,g,j,k);return f};this.getControlPointsArray=function(){var b,d,e=this.points.length,f=[];for(b=0;b=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var j=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.001)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;h=Math.sin((1-e)*j)/g;e=Math.sin(e*j)/g;d.w=b.w*h+c.w*e;d.x=b.x*h+c.x*e;d.y=b.y*h+c.y*e;d.z=b.z*h+c.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Face3=function(b,c,d,e,h,j){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,c,d,e,h,j,g){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; +THREE.UV.prototype={constructor:THREE.UV,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.dynamic=this.hasTangents=!1}; +THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,c,d;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,d=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,d=this.vertices.length;cthis.points.length-2?j:j+1;d[3]=j>this.points.length-3?j:j+2;m=this.points[d[0]];o=this.points[d[1]]; +p=this.points[d[2]];r=this.points[d[3]];k=g*g;q=g*k;e.x=c(m.x,o.x,p.x,r.x,g,k,q);e.y=c(m.y,o.y,p.y,r.y,g,k,q);e.z=c(m.z,o.z,p.z,r.z,g,k,q);return e};this.getControlPointsArray=function(){var b,c,d=this.points.length,e=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, -this.LODs[f].object3D.visible=!0;else break;for(;fr&&(e=n,n=r,r=e):no&&(e=t,t=o,o=e):t1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1, +this.LODs[e].object3D.visible=!0;else break;for(;e=0&&g>=0&&c>=0&&i>=0?!0:h<0&&g<0||c<0&&i<0?!1:(h<0?e=Math.max(e,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),c<0?e=Math.max(e,c/(c-i)):i<0&&(f=Math.min(f,c/(c-i))),fN&&g.positionScreen.z0&&I.z<1))ua=ta[U]=ta[U]||new THREE.RenderableParticle,U++,E=ua,E.x=I.x/I.w,E.y=I.y/I.w,E.z=I.z,E.rotation=S.rotation.z,E.scale.x=S.scale.x*Math.abs(E.x- -(I.x+h.projectionMatrix.n11)/(I.w+h.projectionMatrix.n14)),E.scale.y=S.scale.y*Math.abs(E.y-(I.y+h.projectionMatrix.n22)/(I.w+h.projectionMatrix.n24)),E.materials=S.materials,fa.push(E);i&&fa.sort(d);return fa}}; +THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1)this.objects.push(b),this.__objectsAdded.push(b);for(var c=0;c=0&&h>=0&&g>=0&&j>=0?!0:e<0&&h<0||g<0&&j<0?!1:(e<0?d=Math.max(d,e/(e-h)):h<0&&(f=Math.min(f,e/(e-h))),g<0?d=Math.max(d,g/(g-j)):j<0&&(f=Math.min(f,g/(g-j))),fsa&&g.positionScreen.z0&&V.z<1))Ba=za[ya]=za[ya]||new THREE.RenderableParticle,ya++,J=Ba,J.x=V.x/V.w,J.y=V.y/V.w,J.z=V.z,J.rotation=K.rotation.z,J.scale.x=K.scale.x*Math.abs(J.x- +(V.x+h.projectionMatrix.n11)/(V.w+h.projectionMatrix.n14)),J.scale.y=K.scale.y*Math.abs(J.y-(V.y+h.projectionMatrix.n22)/(V.w+h.projectionMatrix.n24)),J.materials=K.materials,f.push(J);j&&f.sort(c);return f}}; THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif", @@ -161,7 +147,7 @@ morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInflu default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif", shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec4 shadowColor = vec4( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec4( vec3( ( 1.0 - shadowDarkness * shadow ) ), 1.0 );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) )\nshadowColor = shadowColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif\n}\n}\ngl_FragColor = gl_FragColor * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif"}; -THREE.UniformsUtils={merge:function(b){var d,e,f,h={};for(d=0;d=0)c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else if(i.morphTargetBase){d=h.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[i.morphTargetBase]),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length)for(var f= -0,k=i.morphTargetForcedOrder,q=i.morphTargetInfluences;fD&&(p=n,D=q[p]);c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[p]); -c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]=D;k[p]=1;D=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&c.uniform1fv(h.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(j in g.__webglCustomAttributes)b[j]>=0&&(d=g.__webglCustomAttributes[j],c.bindBuffer(c.ARRAY_BUFFER,d.buffer),c.vertexAttribPointer(b[j],d.size,c.FLOAT,!1,0,0));b.color>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer), -c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,!1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)):c.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER, -g.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex, -4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(h.wireframe?(c.lineWidth(h.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.drawElements(c.LINES,g.__webglLineCount,c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.drawElements(c.TRIANGLES,g.__webglFaceCount,c.UNSIGNED_SHORT,0)),K.data.vertices+=g.__webglFaceCount,K.data.faces+=g.__webglFaceCount/ -3,K.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(h.linewidth),c.drawArrays(i,0,g.__webglLineCount),K.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,g.__webglParticleCount),K.data.drawCalls++):i instanceof THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,g.__webglVertexCount),K.data.drawCalls++)}}function h(b,d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer= -c.createBuffer();b.hasPos&&(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,b.positionArray,c.DYNAMIC_DRAW),c.enableVertexAttribArray(d.attributes.position),c.vertexAttribPointer(d.attributes.position,3,c.FLOAT,!1,0,0));if(b.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,g,h,i,j,k,q,p,n,C,r=b.count*3;for(C=0;C0&&w[0]0&&w[1]0.001&&j.scale>0.001)o[0]=j.x,o[1]=j.y,o[2]=j.z,r=j.size*j.scale/qa,t[0]=r*q,t[1]=r,c.uniform3fv(v.screenPosition,o),c.uniform2fv(v.scale,t),c.uniform1f(v.rotation,j.rotation),c.uniform1f(v.opacity,j.opacity),M(j.blending),ra(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE); -c.enable(c.DEPTH_TEST);c.depthMask(L)}function U(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function ta(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ja,i));pa&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,Q,i));qa&&oa.hasTangents&& -(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,W,i));ha&&R>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,aa,i));ha&&S>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,ca,i));na&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,P,i),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,T,i));z>0&&(c.bindBuffer(c.ARRAY_BUFFER, -h.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,X,i),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,Y,i),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Z,i),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,$,i));j&&(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;fa(g)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;w=b.vertices;h=b.colors;v=w.length;i=h.length;A=b.__vertexArray;j=b.__colorArray;E=b.__dirtyColors;if(b.__dirtyVertices){for(k= -0;k=0;d--)b[d].object==c&&b.splice(d,1)}function P(b){function c(b){var f=[];d=0;for(e=b.length;d65535&&(p[j].counter+=1,k=p[j].hash+"_"+p[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=g}function J(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[], -count:0}})}function M(b){if(b!=da){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}da=b}}function Q(b,d,e){(e.width& -e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,N(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,N(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,N(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,N(d.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,va(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,va(d.minFilter)))}function ra(b,d){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture= -c.createTexture(),b.__webglInit=!0;c.bindTexture(c.TEXTURE_2D,b.__webglTexture);b.image.data?c.texImage2D(c.TEXTURE_2D,0,N(b.format),b.image.width,b.image.height,0,N(b.format),c.UNSIGNED_BYTE,b.image.data):c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image);Q(c.TEXTURE_2D,b,b.image);c.bindTexture(c.TEXTURE_2D,null);b.needsUpdate=!1}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function ka(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer= -!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,N(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,N(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,N(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,N(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,N(b.format), -b.width,b.height,0,N(b.format),N(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER, -c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null,e=la,b=qa);d!=pa&&(c.bindFramebuffer(c.FRAMEBUFFER,d),c.viewport(Ha,Ia,e,b),pa=d)}function aa(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER): -b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function va(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function N(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT; -case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT; -case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var K=this,c,ha=[],R=null,pa=null,L=!0,ca=null,O=null,da=null,T=null,S=null,ua=null,Ga=null,Ha=0,Ia=0,la=0,qa=0,ma=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],wa=new THREE.Matrix4,Ka=new Float32Array(16),La=new Float32Array(16),Ja=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},xa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Pa=b.stencil!==void 0?b.stencil:!0,y=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Xa=b.antialias!==void 0?b.antialias:!1,sa=b.clearColor!==void 0?new THREE.Color(b.clearColor): -new THREE.Color(0),Ma=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=xa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var na,Na=[],b=THREE.ShaderLib.depthRGBA,Va=THREE.UniformsUtils.clone(b.uniforms),Oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader, -vertexShader:b.vertexShader,uniforms:Va}),Sa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va,morphTargets:!0});Oa._shadowPass=!0;Sa._shadowPass=!0;try{if(!(c=xa.getContext("experimental-webgl",{antialias:Xa,stencil:Pa,preserveDrawingBuffer:y})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION))}catch(Ya){console.error(Ya)}c.clearColor(0, -0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(sa.r,sa.g,sa.b,Ma);this.context=c;var Wa=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Pa){var u={};u.vertices=new Float32Array(12);u.faces=new Uint16Array(6);u.darkness=0.5;u.vertices[0]=-20;u.vertices[1]=-20;u.vertices[2]=-1;u.vertices[3]=20;u.vertices[4]=-20; -u.vertices[5]=-1;u.vertices[6]=20;u.vertices[7]=20;u.vertices[8]=-1;u.vertices[9]=-20;u.vertices[10]=20;u.vertices[11]=-1;u.faces[0]=0;u.faces[1]=1;u.faces[2]=2;u.faces[3]=0;u.faces[4]=2;u.faces[5]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,u.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);u.program=c.createProgram(); -c.attachShader(u.program,aa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(u.program,aa("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(u.program);u.vertexLocation=c.getAttribLocation(u.program,"position");u.projectionLocation=c.getUniformLocation(u.program,"projectionMatrix");u.darknessLocation=c.getUniformLocation(u.program,"darkness")}var A={};A.vertices=new Float32Array(16);A.faces=new Uint16Array(6);y=0;A.vertices[y++]=-1;A.vertices[y++]=-1;A.vertices[y++]= -0;A.vertices[y++]=0;A.vertices[y++]=1;A.vertices[y++]=-1;A.vertices[y++]=1;A.vertices[y++]=0;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=-1;A.vertices[y++]=1;A.vertices[y++]=0;A.vertices[y++]=1;y=0;A.faces[y++]=0;A.faces[y++]=1;A.faces[y++]=2;A.faces[y++]=0;A.faces[y++]=2;A.faces[y++]=3;A.vertexBuffer=c.createBuffer();A.elementBuffer=c.createBuffer();A.tempTexture=c.createTexture();A.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,A.vertexBuffer); -c.bufferData(c.ARRAY_BUFFER,A.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,A.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, -c.NEAREST);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(A.hasVertexTexture=!1,A.program=c.createProgram(),c.attachShader(A.program, -aa("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(A.program,aa("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(A.hasVertexTexture=!0,A.program=c.createProgram(),c.attachShader(A.program,aa("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(A.program,aa("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(A.program);A.attributes={};A.uniforms={};A.attributes.vertex=c.getAttribLocation(A.program,"position");A.attributes.uv= -c.getAttribLocation(A.program,"UV");A.uniforms.renderType=c.getUniformLocation(A.program,"renderType");A.uniforms.map=c.getUniformLocation(A.program,"map");A.uniforms.occlusionMap=c.getUniformLocation(A.program,"occlusionMap");A.uniforms.opacity=c.getUniformLocation(A.program,"opacity");A.uniforms.scale=c.getUniformLocation(A.program,"scale");A.uniforms.rotation=c.getUniformLocation(A.program,"rotation");A.uniforms.screenPosition=c.getUniformLocation(A.program,"screenPosition");var Ua=!1,v={};v.vertices= -new Float32Array(16);v.faces=new Uint16Array(6);y=0;v.vertices[y++]=-1;v.vertices[y++]=-1;v.vertices[y++]=0;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=-1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=0;v.vertices[y++]=-1;v.vertices[y++]=1;v.vertices[y++]=0;y=v.vertices[y++]=0;v.faces[y++]=0;v.faces[y++]=1;v.faces[y++]=2;v.faces[y++]=0;v.faces[y++]=2;v.faces[y++]=3;v.vertexBuffer=c.createBuffer();v.elementBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,v.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,v.faces,c.STATIC_DRAW);v.program=c.createProgram();c.attachShader(v.program,aa("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(v.program,aa("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(v.program);v.attributes={};v.uniforms={};v.attributes.position=c.getAttribLocation(v.program,"position"); -v.attributes.uv=c.getAttribLocation(v.program,"uv");v.uniforms.uvOffset=c.getUniformLocation(v.program,"uvOffset");v.uniforms.uvScale=c.getUniformLocation(v.program,"uvScale");v.uniforms.rotation=c.getUniformLocation(v.program,"rotation");v.uniforms.scale=c.getUniformLocation(v.program,"scale");v.uniforms.alignment=c.getUniformLocation(v.program,"alignment");v.uniforms.map=c.getUniformLocation(v.program,"map");v.uniforms.opacity=c.getUniformLocation(v.program,"opacity");v.uniforms.useScreenCoordinates= -c.getUniformLocation(v.program,"useScreenCoordinates");v.uniforms.affectedByDistance=c.getUniformLocation(v.program,"affectedByDistance");v.uniforms.screenPosition=c.getUniformLocation(v.program,"screenPosition");v.uniforms.modelViewMatrix=c.getUniformLocation(v.program,"modelViewMatrix");v.uniforms.projectionMatrix=c.getUniformLocation(v.program,"projectionMatrix");var Ta=!1;this.setSize=function(b,c){xa.width=b;xa.height=c;this.setViewport(0,0,xa.width,xa.height)};this.setViewport=function(b,d, -e,f){Ha=b;Ia=d;la=e;qa=f;c.viewport(Ha,Ia,la,qa)};this.setScissor=function(b,d,e,f){c.scissor(b,d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){L=b;c.depthMask(b)};this.setClearColorHex=function(b,d){sa.setHex(b);Ma=d;c.clearColor(sa.r,sa.g,sa.b,Ma)};this.setClearColor=function(b,d){sa.copy(b);Ma=d;c.clearColor(sa.r,sa.g,sa.b,Ma)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)}; -this.setStencilShadowDarkness=function(b){u.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b,d,e,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof -THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,n,p;k=p=j=0;for(n=d.length;k=0&&c.enableVertexAttribArray(o.position);o.color>=0&&c.enableVertexAttribArray(o.color);o.normal>=0&&c.enableVertexAttribArray(o.normal);o.tangent>=0&&c.enableVertexAttribArray(o.tangent);b.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(c.enableVertexAttribArray(o.skinVertexA),c.enableVertexAttribArray(o.skinVertexB),c.enableVertexAttribArray(o.skinIndex), -c.enableVertexAttribArray(o.skinWeight));if(b.attributes)for(h in b.attributes)o[h]!==void 0&&o[h]>=0&&c.enableVertexAttribArray(o[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h=0&&(c.enableVertexAttribArray(o[t]),b.numSupportedMorphTargets++)};this.render=function(b,d,n,w){var v,A,y,u,H,D,p,I,C=b.lights,J=b.fog;this.shadowMapEnabled&&F(b,d);K.data.vertices=0;K.data.faces=0;K.data.drawCalls=0;d.matrixAutoUpdate&&d.update(void 0,!0);b.update(void 0, -!1,d);d.matrixWorldInverse.flattenToArray(La);d.projectionMatrix.flattenToArray(Ka);wa.multiply(d.projectionMatrix,d.matrixWorldInverse);k(wa);this.initWebGLObjects(b);ka(n);(this.autoClear||w)&&this.clear();H=b.__webglObjects.length;for(w=0;w=0;w--)if(v=b.__webglObjects[w],v.render){p=v.object;I=v.buffer;y=v.opaque;i(p);for(v=0;v0||r.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(r.faceUvs.length>1||r.faceVertexUvs.length> -1)i.__uv2Array=new Float32Array(k*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(t*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0));i.__lineArray=new Uint16Array(v*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];r=0;for(q=i.numMorphTargets;r=0;g--)d[g]==e&&d.splice(g,1)}else e instanceof THREE.LensFlare?w(d.__webglLensFlares, -e):e instanceof THREE.MarchingCubes&&w(d.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d=0)f.bindBuffer(f.ARRAY_BUFFER,g.__webglVertexBuffer),f.vertexAttribPointer(b.position,3,f.FLOAT,!1,0,0);else if(j.morphTargetBase){c=h.program.attributes;j.morphTargetBase!==-1?(f.bindBuffer(f.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[j.morphTargetBase]),f.vertexAttribPointer(c.position, +3,f.FLOAT,!1,0,0)):c.position>=0&&(f.bindBuffer(f.ARRAY_BUFFER,g.__webglVertexBuffer),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var e=0,A=j.morphTargetForcedOrder,m=j.morphTargetInfluences;eq&&(B=F,q=m[B]);f.bindBuffer(f.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[B]);f.vertexAttribPointer(c["morphTarget"+e],3,f.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[e]=q;A[B]=1;q=-1;e++}}h.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(h.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(k in g.__webglCustomAttributes)b[k]>= +0&&(c=g.__webglCustomAttributes[k],f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(b[k],c.size,f.FLOAT,!1,0,0));b.color>=0&&(f.bindBuffer(f.ARRAY_BUFFER,g.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));b.normal>=0&&(f.bindBuffer(f.ARRAY_BUFFER,g.__webglNormalBuffer),f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));b.tangent>=0&&(f.bindBuffer(f.ARRAY_BUFFER,g.__webglTangentBuffer),f.vertexAttribPointer(b.tangent,4,f.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(f.bindBuffer(f.ARRAY_BUFFER, +g.__webglUVBuffer),f.vertexAttribPointer(b.uv,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv)):f.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(f.bindBuffer(f.ARRAY_BUFFER,g.__webglUV2Buffer),f.vertexAttribPointer(b.uv2,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv2)):f.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(f.bindBuffer(f.ARRAY_BUFFER,g.__webglSkinVertexABuffer),f.vertexAttribPointer(b.skinVertexA,4, +f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0));j instanceof THREE.Mesh?(h.wireframe?(f.lineWidth(h.wireframeLinewidth),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),f.drawElements(f.LINES,g.__webglLineCount, +f.UNSIGNED_SHORT,0)):(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),f.drawElements(f.TRIANGLES,g.__webglFaceCount,f.UNSIGNED_SHORT,0)),L.data.vertices+=g.__webglFaceCount,L.data.faces+=g.__webglFaceCount/3,L.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?f.LINE_STRIP:f.LINES,f.lineWidth(h.linewidth),f.drawArrays(j,0,g.__webglLineCount),L.data.drawCalls++):j instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,g.__webglParticleCount),L.data.drawCalls++):j instanceof +THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,g.__webglVertexCount),L.data.drawCalls++)}}function h(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=f.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=f.createBuffer();b.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,b.positionArray,f.DYNAMIC_DRAW),f.enableVertexAttribArray(c.attributes.position),f.vertexAttribPointer(c.attributes.position,3,f.FLOAT,!1,0,0));if(b.hasNormal){f.bindBuffer(f.ARRAY_BUFFER, +b.__webglNormalBuffer);if(d==THREE.FlatShading){var e,g,h,j,k,m,q,B,F,p,r=b.count*3;for(p=0;p=0;d--)b[d].object==c&&b.splice(d,1)}function sa(b){function c(b){var e=[];d=0;for(f=b.length;d65535&&(p[k].counter+=1,m=p[k].hash+"_"+p[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,vertices:0,numMorphTargets:q})),b.geometryGroups[m].faces.push(e),b.geometryGroups[m].vertices+=h}function V(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[], +count:0}})}function u(b){if(b!=D){switch(b){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}D=b}}function Q(b,c,d){(d.width& +d.width-1)==0&&(d.height&d.height-1)==0?(f.texParameteri(b,f.TEXTURE_WRAP_S,N(c.wrapS)),f.texParameteri(b,f.TEXTURE_WRAP_T,N(c.wrapT)),f.texParameteri(b,f.TEXTURE_MAG_FILTER,N(c.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,N(c.minFilter)),f.generateMipmap(b)):(f.texParameteri(b,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_MAG_FILTER,qa(c.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,qa(c.minFilter)))}function O(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture= +f.createTexture(),b.__webglInit=!0;f.bindTexture(f.TEXTURE_2D,b.__webglTexture);b.image.data?f.texImage2D(f.TEXTURE_2D,0,N(b.format),b.image.width,b.image.height,0,N(b.format),f.UNSIGNED_BYTE,b.image.data):f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,b.image);Q(f.TEXTURE_2D,b,b.image);f.bindTexture(f.TEXTURE_2D,null);b.needsUpdate=!1}f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_2D,b.__webglTexture)}function T(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer= +!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=f.createFramebuffer();b.__webglRenderbuffer=f.createRenderbuffer();b.__webglTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,b.__webglTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,N(b.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,N(b.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,N(b.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,N(b.minFilter));f.texImage2D(f.TEXTURE_2D,0,N(b.format), +b.width,b.height,0,N(b.format),N(b.type),null);f.bindRenderbuffer(f.RENDERBUFFER,b.__webglRenderbuffer);f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER, +f.DEPTH_STENCIL,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,b.__webglRenderbuffer)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var c,d;b?(c=b.__webglFramebuffer,d=b.width,b=b.height):(c=null,d=Ea,b=wa);c!=ta&&(f.bindFramebuffer(f.FRAMEBUFFER,c),f.viewport(K,Ba,d,b),ta=c)}function U(b,c){var d;b=="fragment"?d=f.createShader(f.FRAGMENT_SHADER): +b=="vertex"&&(d=f.createShader(f.VERTEX_SHADER));f.shaderSource(d,c);f.compileShader(d);if(!f.getShaderParameter(d,f.COMPILE_STATUS))return console.error(f.getShaderInfoLog(d)),console.error(c),null;return d}function qa(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function N(b){switch(b){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT; +case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT; +case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var L=this,f,ua=[],Aa=null,ta=null,va=!0,Y=null,pa=null,D=null,W=null,P=null,S=null,fa=null,K=0,Ba=0,Ea=0,wa=0,ha=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Z=new THREE.Matrix4,Fa=new Float32Array(16),Da=new Float32Array(16),Ha=new THREE.Vector4,Ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ia=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Ya=b.stencil!==void 0?b.stencil:!0,Za=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,$a=b.antialias!==void 0?b.antialias:!1,xa=b.clearColor!==void 0?new THREE.Color(b.clearColor): +new THREE.Color(0),Ja=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ia;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ma,Qa=[],b=THREE.ShaderLib.depthRGBA,Wa=THREE.UniformsUtils.clone(b.uniforms),Ra=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader, +vertexShader:b.vertexShader,uniforms:Wa}),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Wa,morphTargets:!0});Ra._shadowPass=!0;Ua._shadowPass=!0;try{if(!(f=Ia.getContext("experimental-webgl",{antialias:$a,stencil:Ya,preserveDrawingBuffer:Za})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(ab){console.error(ab)}f.clearColor(0, +0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(xa.r,xa.g,xa.b,Ja);this.context=f;var Xa=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,t={};t.vertices=new Float32Array(16);t.faces=new Uint16Array(6);i=0;t.vertices[i++]=-1;t.vertices[i++]=-1;t.vertices[i++]=0;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]= +-1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=0;t.vertices[i++]=-1;t.vertices[i++]=1;t.vertices[i++]=0;i=t.vertices[i++]=0;t.faces[i++]=0;t.faces[i++]=1;t.faces[i++]=2;t.faces[i++]=0;t.faces[i++]=2;t.faces[i++]=3;t.vertexBuffer=f.createBuffer();t.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,t.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,t.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,t.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER, +t.faces,f.STATIC_DRAW);t.program=f.createProgram();f.attachShader(t.program,U("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(t.program,U("vertex",THREE.ShaderLib.sprite.vertexShader));f.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.position=f.getAttribLocation(t.program,"position");t.attributes.uv=f.getAttribLocation(t.program,"uv");t.uniforms.uvOffset=f.getUniformLocation(t.program,"uvOffset");t.uniforms.uvScale=f.getUniformLocation(t.program,"uvScale");t.uniforms.rotation= +f.getUniformLocation(t.program,"rotation");t.uniforms.scale=f.getUniformLocation(t.program,"scale");t.uniforms.alignment=f.getUniformLocation(t.program,"alignment");t.uniforms.map=f.getUniformLocation(t.program,"map");t.uniforms.opacity=f.getUniformLocation(t.program,"opacity");t.uniforms.useScreenCoordinates=f.getUniformLocation(t.program,"useScreenCoordinates");t.uniforms.affectedByDistance=f.getUniformLocation(t.program,"affectedByDistance");t.uniforms.screenPosition=f.getUniformLocation(t.program, +"screenPosition");t.uniforms.modelViewMatrix=f.getUniformLocation(t.program,"modelViewMatrix");t.uniforms.projectionMatrix=f.getUniformLocation(t.program,"projectionMatrix");var Va=!1;this.setSize=function(b,c){Ia.width=b;Ia.height=c;this.setViewport(0,0,Ia.width,Ia.height)};this.setViewport=function(b,c,d,e){K=b;Ba=c;Ea=d;wa=e;f.viewport(K,Ba,Ea,wa)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite= +function(b){va=b;f.depthMask(b)};this.setClearColorHex=function(b,c){xa.setHex(b);Ja=c;f.clearColor(xa.r,xa.g,xa.b,Ja)};this.setClearColor=function(b,c){xa.copy(b);Ja=c;f.clearColor(xa.r,xa.g,xa.b,Ja)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.getContext=function(){return f};this.initMaterial=function(b,c,d,e){var g,h,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial? +j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,p,q;m=q=k=0;for(p=c.length;m=0&&f.enableVertexAttribArray(r.position);r.color>=0&&f.enableVertexAttribArray(r.color);r.normal>=0&&f.enableVertexAttribArray(r.normal);r.tangent>=0&&f.enableVertexAttribArray(r.tangent);b.skinning&&r.skinVertexA>=0&&r.skinVertexB>=0&&r.skinIndex>=0&&r.skinWeight>=0&&(f.enableVertexAttribArray(r.skinVertexA),f.enableVertexAttribArray(r.skinVertexB),f.enableVertexAttribArray(r.skinIndex), +f.enableVertexAttribArray(r.skinWeight));if(b.attributes)for(g in b.attributes)r[g]!==void 0&&r[g]>=0&&f.enableVertexAttribArray(r[g]);if(b.morphTargets)for(g=b.numSupportedMorphTargets=0;g=0&&(f.enableVertexAttribArray(r[t]),b.numSupportedMorphTargets++)};this.render=function(b,c,o,t){var G,J,ga,A,Pa,R,B,F,D=b.lights,Oa=b.fog;this.shadowMapEnabled&&C(b,c);L.data.vertices=0;L.data.faces=0;L.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0, +!1,c);c.matrixWorldInverse.flattenToArray(Da);c.projectionMatrix.flattenToArray(Fa);Z.multiply(c.projectionMatrix,c.matrixWorldInverse);q(Z);this.initWebGLObjects(b);T(o);(this.autoClear||t)&&this.clear();Pa=b.__webglObjects.length;for(t=0;t=0;t--)if(G=b.__webglObjects[t],G.render){B=G.object;F=G.buffer;ga=G.opaque;j(B);for(G=0;G0||u.faceVertexUvs.length>0)k.__uvArray=new Float32Array(p*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(p*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray= +new Float32Array(p*4),k.__skinVertexBArray=new Float32Array(p*4),k.__skinIndexArray=new Float32Array(p*4),k.__skinWeightArray=new Float32Array(p*4);k.__faceArray=new Uint16Array(v*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(C*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];u=0;for(t=k.numMorphTargets;u=0;h--)d[h]==e&&d.splice(h,1)}else e instanceof THREE.MarchingCubes&&za(d.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,oa,p));Aa&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglNormalBuffer),f.bufferData(f.ARRAY_BUFFER,Z,p));Ba&&ra.hasTangents&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglTangentBuffer),f.bufferData(f.ARRAY_BUFFER,$,p));qa&&W>0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,ma,p));qa&&Y>0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,pa,p));va&&(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, +m.__webglFaceBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,ha,p),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ca,p));w>0&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,aa,p),f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,ca,p),f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,da,p),f.bindBuffer(f.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER, +ea,p));E&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray,delete m.__tangentArray,delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;ya(k)}else if(g instanceof THREE.Ribbon){h= +g.geometry;if(h.__dirtyVertices||h.__dirtyColors){g=h;j=f.DYNAMIC_DRAW;k=C=v=v=void 0;u=g.vertices;m=g.colors;r=u.length;p=m.length;q=g.__vertexArray;E=g.__colorArray;t=g.__dirtyColors;if(g.__dirtyVertices){for(v=0;v - \ No newline at end of file + diff --git a/examples/webgl_stencil.html b/examples/webgl_stencil.html deleted file mode 100644 index c2bd1a20..00000000 --- a/examples/webgl_stencil.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - three.js webgl - stencil shadow - - - - - - - - - - - - - - diff --git a/examples/webgl_stencilLensFlare.html b/examples/webgl_stencilLensFlare.html deleted file mode 100644 index 0d5d5275..00000000 --- a/examples/webgl_stencilLensFlare.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - three.js - webgl - - - - - - - - - - - - - diff --git a/src/extras/geometries/IcosahedronGeometry.js b/src/extras/geometries/IcosahedronGeometry.js index fb1e836f..d3d3a73c 100644 --- a/src/extras/geometries/IcosahedronGeometry.js +++ b/src/extras/geometries/IcosahedronGeometry.js @@ -84,9 +84,6 @@ THREE.IcosahedronGeometry = function ( subdivisions ) { scope.faces = tempScope.faces; //scope.uvs = tempScope.uvs; - delete tempScope; - delete tempFaces; - this.computeCentroids(); this.computeFaceNormals(); this.computeVertexNormals(); diff --git a/src/extras/geometries/TorusGeometry.js b/src/extras/geometries/TorusGeometry.js index 23621f1f..b9f3b0bf 100644 --- a/src/extras/geometries/TorusGeometry.js +++ b/src/extras/geometries/TorusGeometry.js @@ -54,8 +54,6 @@ THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT ) { } - delete temp_uv; - this.computeCentroids(); this.computeFaceNormals(); this.computeVertexNormals(); diff --git a/src/lights/LensFlare.js b/src/lights/LensFlare.js deleted file mode 100644 index 606ec329..00000000 --- a/src/lights/LensFlare.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @author Mikael Emtinger - */ - -THREE.LensFlare = function ( texture, size, distance, blending ) { - - THREE.Object3D.call( this ); - - this.positionScreen = new THREE.Vector3(); - this.lensFlares = []; - this.customUpdateCallback = undefined; - - if( texture !== undefined ) { - - this.add( texture, size, distance, blending ); - - } - -}; - -THREE.LensFlare.prototype = new THREE.Object3D(); -THREE.LensFlare.prototype.constructor = THREE.LensFlare; -THREE.LensFlare.prototype.supr = THREE.Object3D.prototype; - - -/* - * Add: adds another flare - */ - -THREE.LensFlare.prototype.add = function( texture, size, distance, blending ) { - - if( size === undefined ) size = -1; - if( distance === undefined ) distance = 0; - if( blending === undefined ) blending = THREE.BillboardBlending; - - distance = Math.min( distance, Math.max( 0, distance )); - - this.lensFlares.push( { texture: texture, // THREE.Texture - size: size, // size in pixels (-1 = use texture.width) - distance: distance, // distance (0-1) from light source (0=at light source) - x: 0, y: 0, z: 0, // screen position (-1 => 1) z = 0 is ontop z = 1 is back - scale: 1, // scale - rotation: 1, // rotation - opacity: 1, // opacity - blending: blending } ); // blending - -}; - - -/* - * Update lens flares update positions on all flares based on the screen position - * Set myLensFlare.customUpdateCallback to alter the flares in your project specific way. - */ - -THREE.LensFlare.prototype.updateLensFlares = function() { - - var f, fl = this.lensFlares.length; - var flare; - var vecX = -this.positionScreen.x * 2; - var vecY = -this.positionScreen.y * 2; - - - for( f = 0; f < fl; f++ ) { - - flare = this.lensFlares[ f ]; - - flare.x = this.positionScreen.x + vecX * flare.distance; - flare.y = this.positionScreen.y + vecY * flare.distance; - - flare.wantedRotation = flare.x * Math.PI * 0.25; - flare.rotation += ( flare.wantedRotation - flare.rotation ) * 0.25; - - } - -}; - - - - - - - - - - - - diff --git a/src/materials/ShadowVolumeDynamicMaterial.js b/src/materials/ShadowVolumeDynamicMaterial.js deleted file mode 100644 index a5e24a31..00000000 --- a/src/materials/ShadowVolumeDynamicMaterial.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @author mr.doob / http://mrdoob.com/ - * @author alteredq / http://alteredqualia.com/ - * - * parameters = { - * color: , - * opacity: , - * map: new THREE.Texture( ), - - * lightMap: new THREE.Texture( ), - - * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ), - * combine: THREE.Multiply, - * reflectivity: , - * refractionRatio: , - - * shading: THREE.SmoothShading, - * blending: THREE.NormalBlending, - * depthTest: , - - * wireframe: , - * wireframeLinewidth: , - - * vertexColors: , - * skinning: - * } - */ - -THREE.ShadowVolumeDynamicMaterial = function ( parameters ) { - - THREE.Material.call( this, parameters ); - - parameters = parameters || {}; - - this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff ); - - this.map = parameters.map !== undefined ? parameters.map : null; - - this.lightMap = parameters.lightMap !== undefined ? parameters.lightMap : null; - - this.envMap = parameters.envMap !== undefined ? parameters.envMap : null; - this.combine = parameters.combine !== undefined ? parameters.combine : THREE.MultiplyOperation; - this.reflectivity = parameters.reflectivity !== undefined ? parameters.reflectivity : 1; - this.refractionRatio = parameters.refractionRatio !== undefined ? parameters.refractionRatio : 0.98; - - // this.enableFog = parameters.enableFog ? parameters.enableFog : true; - - this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading; - - this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false; - this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1; - this.wireframeLinecap = parameters.wireframeLinecap !== undefined ? parameters.wireframeLinecap : 'round'; - this.wireframeLinejoin = parameters.wireframeLinejoin !== undefined ? parameters.wireframeLinejoin : 'round'; - - this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : false; - - this.skinning = parameters.skinning !== undefined ? parameters.skinning : false; - this.morphTargets = parameters.morphTargets !== undefined ? parameters.morphTargets : false; - -}; - -THREE.ShadowVolumeDynamicMaterial.prototype = new THREE.Material(); -THREE.ShadowVolumeDynamicMaterial.prototype.constructor = THREE.ShadowVolumeDynamicMaterial; diff --git a/src/objects/ShadowVolume.js b/src/objects/ShadowVolume.js deleted file mode 100644 index ac1ee608..00000000 --- a/src/objects/ShadowVolume.js +++ /dev/null @@ -1,345 +0,0 @@ -/** - * @author mikael emtinger / http://gomo.se/ - */ - -THREE.ShadowVolume = function( meshOrGeometry, isStatic ) { - - if( meshOrGeometry instanceof THREE.Mesh ) { - - THREE.Mesh.call( this, meshOrGeometry.geometry, isStatic ? [ new THREE.ShadowVolumeDynamicMaterial() ] : [ new THREE.ShadowVolumeDynamicMaterial() ] ); - meshOrGeometry.addChild( this ); - - } else { - - THREE.Mesh.call( this, meshOrGeometry, isStatic ? [ new THREE.ShadowVolumeDynamicMaterial() ] : [ new THREE.ShadowVolumeDynamicMaterial() ] ); - - } - - this.calculateShadowVolumeGeometry(); - -}; - -THREE.ShadowVolume.prototype = new THREE.Mesh(); -THREE.ShadowVolume.prototype.constructor = THREE.ShadowVolume; -THREE.ShadowVolume.prototype.supr = THREE.Mesh.prototype; - - -/* - * Calculate Shadow Faces - */ - -THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function() { - - if ( this.geometry.edges && this.geometry.edges.length ) { - - var f, fl, face, faceA, faceB, faceAIndex, faceBIndex, vertexA, vertexB; - var faceACombination, faceBCombination; - var faceAvertexAIndex, faceAvertexBIndex, faceBvertexAIndex, faceBvertexBIndex; - var e, el, edge, temp; - - var newGeometry = new THREE.Geometry(); - var vertices = newGeometry.vertices = this.geometry.vertices; - var faces = newGeometry.faces = this.geometry.faces; - var edges = newGeometry.egdes = this.geometry.edges; - var edgeFaces = newGeometry.edgeFaces = []; - - var vertexOffset = 0; - var vertexOffsetPerFace = []; - - for( f = 0, fl = faces.length; f < fl; f++ ) { - - face = faces[ f ]; - - // calculate faces vertex offset - - vertexOffsetPerFace.push( vertexOffset ); - vertexOffset += face instanceof THREE.Face3 ? 3 : 4; - - // set vertex normals to face normal - - face.vertexNormals[ 0 ] = face.normal; - face.vertexNormals[ 1 ] = face.normal; - face.vertexNormals[ 2 ] = face.normal; - - if( face instanceof THREE.Face4 ) face.vertexNormals[ 3 ] = face.normal; - - } - - - // setup edge faces - - for( e = 0, el = edges.length; e < el; e++ ) { - - edge = edges[ e ]; - - faceA = edge.faces[ 0 ]; - faceB = edge.faces[ 1 ]; - - faceAIndex = edge.faceIndices[ 0 ]; - faceBIndex = edge.faceIndices[ 1 ]; - - vertexA = edge.vertexIndices[ 0 ]; - vertexB = edge.vertexIndices[ 1 ]; - - // find combination and processed vertex index (vertices are split up by renderer) - - if( faceA.a === vertexA ) { faceACombination = "a"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 0; } - else if( faceA.b === vertexA ) { faceACombination = "b"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 1; } - else if( faceA.c === vertexA ) { faceACombination = "c"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 2; } - else if( faceA.d === vertexA ) { faceACombination = "d"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 3; } - - if( faceA.a === vertexB ) { faceACombination += "a"; faceAvertexBIndex = vertexOffsetPerFace[ faceAIndex ] + 0; } - else if( faceA.b === vertexB ) { faceACombination += "b"; faceAvertexBIndex = vertexOffsetPerFace[ faceAIndex ] + 1; } - else if( faceA.c === vertexB ) { faceACombination += "c"; faceAvertexBIndex = vertexOffsetPerFace[ faceAIndex ] + 2; } - else if( faceA.d === vertexB ) { faceACombination += "d"; faceAvertexBIndex = vertexOffsetPerFace[ faceAIndex ] + 3; } - - if( faceB.a === vertexA ) { faceBCombination = "a"; faceBvertexAIndex = vertexOffsetPerFace[ faceBIndex ] + 0; } - else if( faceB.b === vertexA ) { faceBCombination = "b"; faceBvertexAIndex = vertexOffsetPerFace[ faceBIndex ] + 1; } - else if( faceB.c === vertexA ) { faceBCombination = "c"; faceBvertexAIndex = vertexOffsetPerFace[ faceBIndex ] + 2; } - else if( faceB.d === vertexA ) { faceBCombination = "d"; faceBvertexAIndex = vertexOffsetPerFace[ faceBIndex ] + 3; } - - if( faceB.a === vertexB ) { faceBCombination += "a"; faceBvertexBIndex = vertexOffsetPerFace[ faceBIndex ] + 0; } - else if( faceB.b === vertexB ) { faceBCombination += "b"; faceBvertexBIndex = vertexOffsetPerFace[ faceBIndex ] + 1; } - else if( faceB.c === vertexB ) { faceBCombination += "c"; faceBvertexBIndex = vertexOffsetPerFace[ faceBIndex ] + 2; } - else if( faceB.d === vertexB ) { faceBCombination += "d"; faceBvertexBIndex = vertexOffsetPerFace[ faceBIndex ] + 3; } - - if( faceACombination === "ac" || - faceACombination === "ad" || - faceACombination === "ca" || - faceACombination === "da" ) { - - if( faceAvertexAIndex > faceAvertexBIndex ) { - - temp = faceAvertexAIndex; - faceAvertexAIndex = faceAvertexBIndex; - faceAvertexBIndex = temp; - - } - - } else { - - if( faceAvertexAIndex < faceAvertexBIndex ) { - - temp = faceAvertexAIndex; - faceAvertexAIndex = faceAvertexBIndex; - faceAvertexBIndex = temp; - - } - - } - - if( faceBCombination === "ac" || - faceBCombination === "ad" || - faceBCombination === "ca" || - faceBCombination === "da" ) { - - if( faceBvertexAIndex > faceBvertexBIndex ) { - - temp = faceBvertexAIndex; - faceBvertexAIndex = faceBvertexBIndex; - faceBvertexBIndex = temp; - - } - - } else { - - if( faceBvertexAIndex < faceBvertexBIndex ) { - - temp = faceBvertexAIndex; - faceBvertexAIndex = faceBvertexBIndex; - faceBvertexBIndex = temp; - - } - - } - - face = new THREE.Face4( faceAvertexAIndex, faceAvertexBIndex, faceBvertexAIndex, faceBvertexBIndex ); - face.normal.set( 1, 0, 0 ); - edgeFaces.push( face ); - - } - - this.geometry = newGeometry; - - } else { - - this.calculateShadowVolumeGeometryWithoutEdgeInfo( this.geometry ); - - } -} - - -THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo = function( originalGeometry ) { - - // create geometry - - this.geometry = new THREE.Geometry(); - this.geometry.boundingSphere = originalGeometry.boundingSphere; - this.geometry.edgeFaces = []; - - // copy vertices / faces from original mesh - - var vertexTypes = this.geometry.vertexTypes; - var vertices = this.geometry.vertices; - var faces = this.geometry.faces; - var edgeFaces = this.geometry.edgeFaces; - - var originalFaces = originalGeometry.faces; - var originalVertices = originalGeometry.vertices; - var fl = originalFaces.length; - - var originalFace, face, i, f, n, vertex, numVertices; - var indices = [ "a", "b", "c", "d" ]; - - - for( f = 0; f < fl; f++ ) { - - numVertices = vertices.length; - originalFace = originalFaces[ f ]; - - if ( originalFace instanceof THREE.Face4 ) { - - n = 4; - face = new THREE.Face4( numVertices, numVertices + 1, numVertices + 2, numVertices + 3 ); - - } else { - - n = 3; - face = new THREE.Face3( numVertices, numVertices + 1, numVertices + 2 ); - - } - - face.normal.copy( originalFace.normal ); - faces.push( face ); - - - for( i = 0; i < n; i++ ) { - - vertex = originalVertices[ originalFace[ indices[ i ]]]; - vertices.push( new THREE.Vertex( vertex.position.clone())); - - } - - } - - - // calculate edge faces - - var result, faceA, faceB, v, vl; - - for( var fa = 0; fa < originalFaces.length - 1; fa++ ) { - - faceA = faces[ fa ]; - - for( var fb = fa + 1; fb < originalFaces.length; fb++ ) { - - faceB = faces[ fb ]; - result = this.facesShareEdge( vertices, faceA, faceB ); - - if( result !== undefined ) { - - numVertices = vertices.length; - face = new THREE.Face4( result.indices[ 0 ], result.indices[ 3 ], result.indices[ 2 ], result.indices[ 1 ] ); - face.normal.set( 1, 0, 0 ); - edgeFaces.push( face ); - - } - - } - - } - -}; - - -THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB ) { - - var indicesA, - indicesB, - indexA, - indexB, - vertexA, - vertexB, - savedVertexA, - savedVertexB, - savedIndexA, - savedIndexB, - indexLetters, - a, b, - numMatches = 0, - indices = [ "a", "b", "c", "d" ]; - - if( faceA instanceof THREE.Face4 ) indicesA = 4; - else indicesA = 3; - - if( faceB instanceof THREE.Face4 ) indicesB = 4; - else indicesB = 3; - - - for( a = 0; a < indicesA; a++ ) { - - indexA = faceA[ indices[ a ] ]; - vertexA = vertices[ indexA ]; - - for( b = 0; b < indicesB; b++ ) { - - indexB = faceB[ indices[ b ] ]; - vertexB = vertices[ indexB ]; - - if( Math.abs( vertexA.position.x - vertexB.position.x ) < 0.0001 && - Math.abs( vertexA.position.y - vertexB.position.y ) < 0.0001 && - Math.abs( vertexA.position.z - vertexB.position.z ) < 0.0001 ) { - - numMatches++; - - if( numMatches === 1 ) { - - savedVertexA = vertexA; - savedVertexB = vertexB; - savedIndexA = indexA; - savedIndexB = indexB; - indexLetters = indices[ a ]; - - } - - if( numMatches === 2 ) { - - indexLetters += indices[ a ]; - - if( indexLetters === "ad" || indexLetters === "ac" ) { - - return { - - faces : [ faceA, faceB ], - vertices : [ savedVertexA, savedVertexB, vertexB, vertexA ], - indices : [ savedIndexA, savedIndexB, indexB, indexA ], - vertexTypes : [ 1, 2, 2, 1 ], - extrudable : true - - }; - - } else { - - return { - - faces : [ faceA, faceB ], - vertices : [ savedVertexA, vertexA, vertexB, savedVertexB ], - indices : [ savedIndexA, indexA, indexB, savedIndexB ], - vertexTypes : [ 1, 1, 2, 2 ], - extrudable : true - - }; - - } - - } - - } - - } - - } - - return undefined; - -}; diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 6bc28aec..d6f69bb6 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -141,8 +141,8 @@ THREE.CanvasRenderer = function ( parameters ) { if ( !_clearRect.isEmpty() ) { - _clearRect.inflate( 2 ); _clearRect.minSelf( _clipRect ); + _clearRect.inflate( 2 ); if ( _clearOpacity < 1 ) { @@ -886,12 +886,19 @@ THREE.CanvasRenderer = function ( parameters ) { // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 var a, b, c, d, e, f, det, idet, + offsetX = texture.offset.x / texture.repeat.x, + offsetY = texture.offset.y / texture.repeat.y, width = ( texture.image.width - 1 ) * texture.repeat.x, height = ( texture.image.height - 1 ) * texture.repeat.y; - u0 *= width; v0 *= height; - u1 *= width; v1 *= height; - u2 *= width; v2 *= height; + u0 = ( u0 + offsetX ) * width; + v0 = ( v0 + offsetY ) * height; + + u1 = ( u1 + offsetX ) * width; + v1 = ( v1 + offsetY ) * height; + + u2 = ( u2 + offsetX ) * width; + v2 = ( v2 + offsetY ) * height; x1 -= x0; y1 -= y0; x2 -= x0; y2 -= y0; @@ -919,7 +926,7 @@ THREE.CanvasRenderer = function ( parameters ) { } function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) { - + // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 var a, b, c, d, e, f, det, idet, @@ -953,7 +960,7 @@ THREE.CanvasRenderer = function ( parameters ) { _context.clip(); _context.drawImage( image, 0, 0 ); _context.restore(); - + } function getGradientTexture( color1, color2, color3, color4 ) { @@ -1113,7 +1120,7 @@ THREE.CanvasRenderer = function ( parameters ) { } } - + function setFillStyle( style ) { if ( _contextFillStyle != style ) { diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 4edfec86..f01ae179 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -108,21 +108,14 @@ THREE.WebGLRenderer = function ( parameters ) { this.shadowMapEnabled = false; this.shadowMapSoft = true; - var _cameraLight, - _shadowMatrix = []; + var _cameraLight, _shadowMatrix = []; var depthShader = THREE.ShaderLib[ "depthRGBA" ]; var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms ); - var _depthMaterial = new THREE.MeshShaderMaterial( { fragmentShader: depthShader.fragmentShader, - vertexShader: depthShader.vertexShader, - uniforms: depthUniforms } ); + var _depthMaterial = new THREE.MeshShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms } ); - var _depthMaterialMorph = new THREE.MeshShaderMaterial( { fragmentShader: depthShader.fragmentShader, - vertexShader: depthShader.vertexShader, - uniforms: depthUniforms, - morphTargets: true - } ); + var _depthMaterialMorph = new THREE.MeshShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms, morphTargets: true } ); _depthMaterial._shadowPass = true; _depthMaterialMorph._shadowPass = true; @@ -175,135 +168,6 @@ THREE.WebGLRenderer = function ( parameters ) { var _supportsVertexTextures = ( maxVertexTextures() > 0 ); - // prepare stencil shadow polygon - - if ( _stencil ) { - - var _stencilShadow = {}; - - _stencilShadow.vertices = new Float32Array( 12 ); - _stencilShadow.faces = new Uint16Array( 6 ); - _stencilShadow.darkness = 0.5; - - _stencilShadow.vertices[ 0 * 3 + 0 ] = -20; _stencilShadow.vertices[ 0 * 3 + 1 ] = -20; _stencilShadow.vertices[ 0 * 3 + 2 ] = -1; - _stencilShadow.vertices[ 1 * 3 + 0 ] = 20; _stencilShadow.vertices[ 1 * 3 + 1 ] = -20; _stencilShadow.vertices[ 1 * 3 + 2 ] = -1; - _stencilShadow.vertices[ 2 * 3 + 0 ] = 20; _stencilShadow.vertices[ 2 * 3 + 1 ] = 20; _stencilShadow.vertices[ 2 * 3 + 2 ] = -1; - _stencilShadow.vertices[ 3 * 3 + 0 ] = -20; _stencilShadow.vertices[ 3 * 3 + 1 ] = 20; _stencilShadow.vertices[ 3 * 3 + 2 ] = -1; - - _stencilShadow.faces[ 0 ] = 0; _stencilShadow.faces[ 1 ] = 1; _stencilShadow.faces[ 2 ] = 2; - _stencilShadow.faces[ 3 ] = 0; _stencilShadow.faces[ 4 ] = 2; _stencilShadow.faces[ 5 ] = 3; - - _stencilShadow.vertexBuffer = _gl.createBuffer(); - _stencilShadow.elementBuffer = _gl.createBuffer(); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, _stencilShadow.vertexBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, _stencilShadow.vertices, _gl.STATIC_DRAW ); - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _stencilShadow.elementBuffer ); - _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, _stencilShadow.faces, _gl.STATIC_DRAW ); - - _stencilShadow.program = _gl.createProgram(); - - _gl.attachShader( _stencilShadow.program, getShader( "fragment", THREE.ShaderLib.shadowPost.fragmentShader )); - _gl.attachShader( _stencilShadow.program, getShader( "vertex", THREE.ShaderLib.shadowPost.vertexShader )); - - _gl.linkProgram( _stencilShadow.program ); - - _stencilShadow.vertexLocation = _gl.getAttribLocation ( _stencilShadow.program, "position" ); - _stencilShadow.projectionLocation = _gl.getUniformLocation( _stencilShadow.program, "projectionMatrix" ); - _stencilShadow.darknessLocation = _gl.getUniformLocation( _stencilShadow.program, "darkness" ); - - } - - - // prepare lens flare - - var _lensFlare = {}; - var i; - - _lensFlare.vertices = new Float32Array( 8 + 8 ); - _lensFlare.faces = new Uint16Array( 6 ); - - i = 0; - _lensFlare.vertices[ i++ ] = -1; _lensFlare.vertices[ i++ ] = -1; // vertex - _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 0; // uv... etc. - - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = -1; - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 0; - - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; - - _lensFlare.vertices[ i++ ] = -1; _lensFlare.vertices[ i++ ] = 1; - _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 1; - - i = 0; - _lensFlare.faces[ i++ ] = 0; _lensFlare.faces[ i++ ] = 1; _lensFlare.faces[ i++ ] = 2; - _lensFlare.faces[ i++ ] = 0; _lensFlare.faces[ i++ ] = 2; _lensFlare.faces[ i++ ] = 3; - - _lensFlare.vertexBuffer = _gl.createBuffer(); - _lensFlare.elementBuffer = _gl.createBuffer(); - _lensFlare.tempTexture = _gl.createTexture(); - _lensFlare.occlusionTexture = _gl.createTexture(); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, _lensFlare.vertexBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, _lensFlare.vertices, _gl.STATIC_DRAW ); - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _lensFlare.elementBuffer ); - _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, _lensFlare.faces, _gl.STATIC_DRAW ); - - _gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.tempTexture ); - _gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGB, 16, 16, 0, _gl.RGB, _gl.UNSIGNED_BYTE, null ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, _gl.NEAREST ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.NEAREST ); - - _gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.occlusionTexture ); - _gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, 16, 16, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, null ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, _gl.NEAREST ); - _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.NEAREST ); - - if( _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS ) <= 0 ) { - - _lensFlare.hasVertexTexture = false; - - _lensFlare.program = _gl.createProgram(); - _gl.attachShader( _lensFlare.program, getShader( "fragment", THREE.ShaderLib.lensFlare.fragmentShader )); - _gl.attachShader( _lensFlare.program, getShader( "vertex", THREE.ShaderLib.lensFlare.vertexShader )); - _gl.linkProgram( _lensFlare.program ); - - - } else { - - _lensFlare.hasVertexTexture = true; - - _lensFlare.program = _gl.createProgram(); - _gl.attachShader( _lensFlare.program, getShader( "fragment", THREE.ShaderLib.lensFlareVertexTexture.fragmentShader )); - _gl.attachShader( _lensFlare.program, getShader( "vertex", THREE.ShaderLib.lensFlareVertexTexture.vertexShader )); - _gl.linkProgram( _lensFlare.program ); - - } - - _lensFlare.attributes = {}; - _lensFlare.uniforms = {}; - _lensFlare.attributes.vertex = _gl.getAttribLocation ( _lensFlare.program, "position" ); - _lensFlare.attributes.uv = _gl.getAttribLocation ( _lensFlare.program, "UV" ); - _lensFlare.uniforms.renderType = _gl.getUniformLocation( _lensFlare.program, "renderType" ); - _lensFlare.uniforms.map = _gl.getUniformLocation( _lensFlare.program, "map" ); - _lensFlare.uniforms.occlusionMap = _gl.getUniformLocation( _lensFlare.program, "occlusionMap" ); - _lensFlare.uniforms.opacity = _gl.getUniformLocation( _lensFlare.program, "opacity" ); - _lensFlare.uniforms.scale = _gl.getUniformLocation( _lensFlare.program, "scale" ); - _lensFlare.uniforms.rotation = _gl.getUniformLocation( _lensFlare.program, "rotation" ); - _lensFlare.uniforms.screenPosition = _gl.getUniformLocation( _lensFlare.program, "screenPosition" ); - - //_gl.enableVertexAttribArray( _lensFlare.attributes.vertex ); - //_gl.enableVertexAttribArray( _lensFlare.attributes.uv ); - - var _lensFlareAttributesEnabled = false; - // prepare sprites var _sprite = {}; @@ -433,12 +297,6 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.setStencilShadowDarkness = function( value ) { - - _stencilShadow.darkness = value; - - }; - this.getContext = function() { return _gl; @@ -979,8 +837,6 @@ THREE.WebGLRenderer = function ( parameters ) { obj_skinIndices = geometry.skinIndices, obj_skinWeights = geometry.skinWeights, - obj_edgeFaces = object instanceof THREE.ShadowVolume ? geometry.edgeFaces : undefined, - morphTargets = geometry.morphTargets; if ( customAttributes ) { @@ -1962,24 +1818,6 @@ THREE.WebGLRenderer = function ( parameters ) { } - if ( obj_edgeFaces ) { - - for ( f = 0, fl = obj_edgeFaces.length; f < fl; f ++ ) { - - faceArray[ offset_face ] = obj_edgeFaces[ f ].a; - faceArray[ offset_face + 1 ] = obj_edgeFaces[ f ].b; - faceArray[ offset_face + 2 ] = obj_edgeFaces[ f ].c; - - faceArray[ offset_face + 3 ] = obj_edgeFaces[ f ].a; - faceArray[ offset_face + 4 ] = obj_edgeFaces[ f ].c; - faceArray[ offset_face + 5 ] = obj_edgeFaces[ f ].d; - - offset_face += 6; - - } - - } - if ( dirtyVertices ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer ); @@ -2607,10 +2445,6 @@ THREE.WebGLRenderer = function ( parameters ) { shaderID = 'depth'; - } else if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) { - - shaderID = 'shadowVolumeDynamic'; - } else if ( material instanceof THREE.MeshNormalMaterial ) { shaderID = 'normal'; @@ -2871,21 +2705,6 @@ THREE.WebGLRenderer = function ( parameters ) { } - if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) { - - var dirLight = m_uniforms.directionalLightDirection.value; - - dirLight[ 0 ] = -lights[ 1 ].position.x; - dirLight[ 1 ] = -lights[ 1 ].position.y; - dirLight[ 2 ] = -lights[ 1 ].position.z; - - _gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight ); - _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); - _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); - - } - - if ( material.skinning ) { loadUniformsSkinning( p_uniforms, object ); @@ -3927,24 +3746,6 @@ THREE.WebGLRenderer = function ( parameters ) { } - // render stencil shadows - - if ( _stencil && scene.__webglShadowVolumes.length && scene.lights.length ) { - - renderStencilShadows( scene ); - - } - - - // render lens flares - - if ( scene.__webglLensFlares.length ) { - - renderLensFlares( scene, camera ); - - } - - // Generate mipmap if we're using any kind of mipmap filtering if ( renderTarget && renderTarget.minFilter !== THREE.NearestFilter && renderTarget.minFilter !== THREE.LinearFilter ) { @@ -3957,147 +3758,6 @@ THREE.WebGLRenderer = function ( parameters ) { }; - - - /* - * Stencil Shadows - * method: we're rendering the world in light, then the shadow - * volumes into the stencil and last a big darkening - * quad over the whole thing. This is not how "you're - * supposed to" do stencil shadows but is much faster - * - */ - - function renderStencilShadows( scene ) { - - // setup stencil - - _gl.enable( _gl.POLYGON_OFFSET_FILL ); - _gl.polygonOffset( 0.1, 1.0 ); - _gl.enable( _gl.STENCIL_TEST ); - _gl.enable( _gl.DEPTH_TEST ); - _gl.depthMask( false ); - _gl.colorMask( false, false, false, false ); - - _gl.stencilFunc( _gl.ALWAYS, 1, 0xFF ); - _gl.stencilOpSeparate( _gl.BACK, _gl.KEEP, _gl.INCR, _gl.KEEP ); - _gl.stencilOpSeparate( _gl.FRONT, _gl.KEEP, _gl.DECR, _gl.KEEP ); - - - // loop through all directional lights - - var l, ll = scene.lights.length; - var p; - var light, lights = scene.lights; - var dirLight = []; - var object, geometryGroup, material; - var program; - var p_uniforms; - var m_uniforms; - var attributes; - var o, ol = scene.__webglShadowVolumes.length; - - for ( l = 0; l < ll; l++ ) { - - light = scene.lights[ l ]; - - if ( light instanceof THREE.DirectionalLight && light.castShadow ) { - - dirLight[ 0 ] = -light.position.x; - dirLight[ 1 ] = -light.position.y; - dirLight[ 2 ] = -light.position.z; - - // render all volumes - - for ( o = 0; o < ol; o++ ) { - - object = scene.__webglShadowVolumes[ o ].object; - geometryGroup = scene.__webglShadowVolumes[ o ].buffer; - material = object.materials[ 0 ]; - - if ( !material.program ) _this.initMaterial( material, lights, undefined, object ); - - program = material.program, - p_uniforms = program.uniforms, - m_uniforms = material.uniforms, - attributes = program.attributes; - - if ( _currentProgram !== program ) { - - _gl.useProgram( program ); - _currentProgram = program; - - _gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray ); - _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); - _gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight ); - - } - - - object.matrixWorld.flattenToArray( object._objectMatrixArray ); - _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); - - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer ); - _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 ); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglNormalBuffer ); - _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglFaceBuffer ); - - _gl.cullFace( _gl.FRONT ); - _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webglFaceCount, _gl.UNSIGNED_SHORT, 0 ); - - _gl.cullFace( _gl.BACK ); - _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webglFaceCount, _gl.UNSIGNED_SHORT, 0 ); - - } - - } - - } - - - // setup color+stencil - - _gl.disable( _gl.POLYGON_OFFSET_FILL ); - _gl.colorMask( true, true, true, true ); - _gl.stencilFunc( _gl.NOTEQUAL, 0, 0xFF ); - _gl.stencilOp( _gl.KEEP, _gl.KEEP, _gl.KEEP ); - _gl.disable( _gl.DEPTH_TEST ); - - - // draw darkening polygon - - _oldBlending = -1; - _oldDepth = -1; - _currentProgram = _stencilShadow.program; - - _gl.useProgram( _stencilShadow.program ); - _gl.uniformMatrix4fv( _stencilShadow.projectionLocation, false, _projectionMatrixArray ); - _gl.uniform1f( _stencilShadow.darknessLocation, _stencilShadow.darkness ); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, _stencilShadow.vertexBuffer ); - _gl.vertexAttribPointer( _stencilShadow.vertexLocation, 3, _gl.FLOAT, false, 0, 0 ); - _gl.enableVertexAttribArray( _stencilShadow.vertexLocation ); - - _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); - _gl.blendEquation( _gl.FUNC_ADD ); - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _stencilShadow.elementBuffer ); - _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); - - - // disable stencil - - _gl.disable( _gl.STENCIL_TEST ); - _gl.enable( _gl.DEPTH_TEST ); - _gl.depthMask( _currentDepthMask ); - - } - - /* * Render sprites * @@ -4249,202 +3909,6 @@ THREE.WebGLRenderer = function ( parameters ) { } - - - /* - * Render lens flares - * Method: renders 16x16 0xff00ff-colored points scattered over the light source area, - * reads these back and calculates occlusion. - * Then LensFlare.updateLensFlares() is called to re-position and - * update transparency of flares. Then they are rendered. - * - */ - - function renderLensFlares( scene, camera ) { - - var object, objectZ, geometryGroup, material; - var o, ol = scene.__webglLensFlares.length; - var f, fl, flare; - var tempPosition = new THREE.Vector3(); - var invAspect = _viewportHeight / _viewportWidth; - var halfViewportWidth = _viewportWidth * 0.5; - var halfViewportHeight = _viewportHeight * 0.5; - var size = 16 / _viewportHeight; - var scale = [ size * invAspect, size ]; - var screenPosition = [ 1, 1, 0 ]; - var screenPositionPixels = [ 1, 1 ]; - var sampleX, sampleY, readBackPixels = _lensFlare.readBackPixels; - var sampleMidX = 7 * 4; - var sampleMidY = 7 * 16 * 4; - var sampleIndex, visibility; - var uniforms = _lensFlare.uniforms; - var attributes = _lensFlare.attributes; - - - // set lensflare program and reset blending - - _gl.useProgram( _lensFlare.program ); - _currentProgram = _lensFlare.program; - _oldBlending = -1; - _oldDepth = -1; - - - if ( ! _lensFlareAttributesEnabled ) { - - _gl.enableVertexAttribArray( _lensFlare.attributes.vertex ); - _gl.enableVertexAttribArray( _lensFlare.attributes.uv ); - - _lensFlareAttributesEnabled = true; - - } - - // loop through all lens flares to update their occlusion and positions - // setup gl and common used attribs/unforms - - _gl.uniform1i( uniforms.occlusionMap, 0 ); - _gl.uniform1i( uniforms.map, 1 ); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, _lensFlare.vertexBuffer ); - _gl.vertexAttribPointer( attributes.vertex, 2, _gl.FLOAT, false, 2 * 8, 0 ); - _gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 2 * 8, 8 ); - - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _lensFlare.elementBuffer ); - - _gl.disable( _gl.CULL_FACE ); - _gl.depthMask( false ); - - _gl.activeTexture( _gl.TEXTURE0 ); - _gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.occlusionTexture ); - - _gl.activeTexture( _gl.TEXTURE1 ); - - for ( o = 0; o < ol; o ++ ) { - - // calc object screen position - - object = scene.__webglLensFlares[ o ].object; - - tempPosition.set( object.matrixWorld.n14, object.matrixWorld.n24, object.matrixWorld.n34 ); - - camera.matrixWorldInverse.multiplyVector3( tempPosition ); - objectZ = tempPosition.z; - camera.projectionMatrix.multiplyVector3( tempPosition ); - - - // setup arrays for gl programs - - screenPosition[ 0 ] = tempPosition.x; - screenPosition[ 1 ] = tempPosition.y; - screenPosition[ 2 ] = tempPosition.z; - - screenPositionPixels[ 0 ] = screenPosition[ 0 ] * halfViewportWidth + halfViewportWidth; - screenPositionPixels[ 1 ] = screenPosition[ 1 ] * halfViewportHeight + halfViewportHeight; - - - // screen cull - - if ( _lensFlare.hasVertexTexture || ( screenPositionPixels[ 0 ] > 0 && - screenPositionPixels[ 0 ] < _viewportWidth && - screenPositionPixels[ 1 ] > 0 && - screenPositionPixels[ 1 ] < _viewportHeight )) { - - - // save current RGB to temp texture - - _gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.tempTexture ); - _gl.copyTexImage2D( _gl.TEXTURE_2D, 0, _gl.RGB, screenPositionPixels[ 0 ] - 8, screenPositionPixels[ 1 ] - 8, 16, 16, 0 ); - - - // render pink quad - - _gl.uniform1i( uniforms.renderType, 0 ); - _gl.uniform2fv( uniforms.scale, scale ); - _gl.uniform3fv( uniforms.screenPosition, screenPosition ); - - _gl.disable( _gl.BLEND ); - _gl.enable( _gl.DEPTH_TEST ); - - _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); - - - // copy result to occlusionMap - - _gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.occlusionTexture ); - _gl.copyTexImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, screenPositionPixels[ 0 ] - 8, screenPositionPixels[ 1 ] - 8, 16, 16, 0 ); - - - // restore graphics - - _gl.uniform1i( uniforms.renderType, 1 ); - _gl.disable( _gl.DEPTH_TEST ); - _gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.tempTexture ); - _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); - - - // update object positions - - object.positionScreen.x = screenPosition[ 0 ]; - object.positionScreen.y = screenPosition[ 1 ]; - object.positionScreen.z = screenPosition[ 2 ]; - - if ( object.customUpdateCallback ) { - - object.customUpdateCallback( object ); - - } else { - - object.updateLensFlares(); - - } - - - // render flares - - _gl.uniform1i( uniforms.renderType, 2 ); - _gl.enable( _gl.BLEND ); - - for ( f = 0, fl = object.lensFlares.length; f < fl; f ++ ) { - - flare = object.lensFlares[ f ]; - - if ( flare.opacity > 0.001 && flare.scale > 0.001 ) { - - screenPosition[ 0 ] = flare.x; - screenPosition[ 1 ] = flare.y; - screenPosition[ 2 ] = flare.z; - - size = flare.size * flare.scale / _viewportHeight; - scale[ 0 ] = size * invAspect; - scale[ 1 ] = size; - - _gl.uniform3fv( uniforms.screenPosition, screenPosition ); - _gl.uniform2fv( uniforms.scale, scale ); - _gl.uniform1f( uniforms.rotation, flare.rotation ); - _gl.uniform1f( uniforms.opacity, flare.opacity ); - - setBlending( flare.blending ); - setTexture( flare.texture, 1 ); - - _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); - - } - - } - - } - - } - - // restore gl - - _gl.enable( _gl.CULL_FACE ); - _gl.enable( _gl.DEPTH_TEST ); - _gl.depthMask( _currentDepthMask ); - - }; - - function setupMatrices( object, camera, computeNormalMatrix ) { object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray ); @@ -4455,7 +3919,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - }; + } this.initWebGLObjects = function ( scene ) { @@ -4463,8 +3927,6 @@ THREE.WebGLRenderer = function ( parameters ) { scene.__webglObjects = []; scene.__webglObjectsImmediate = []; - scene.__webglShadowVolumes = []; - scene.__webglLensFlares = []; scene.__webglSprites = []; } @@ -4491,26 +3953,6 @@ THREE.WebGLRenderer = function ( parameters ) { } - for ( var o = 0, ol = scene.__webglShadowVolumes.length; o < ol; o ++ ) { - - updateObject( scene.__webglShadowVolumes[ o ].object, scene ); - - } - - for ( var o = 0, ol = scene.__webglLensFlares.length; o < ol; o ++ ) { - - updateObject( scene.__webglLensFlares[ o ].object, scene ); - - } - - /* - for ( var o = 0, ol = scene.__webglSprites.length; o < ol; o ++ ) { - - updateObject( scene.__webglSprites[ o ].object, scene ); - - } - */ - }; function addObject( object, scene ) { @@ -4562,24 +4004,10 @@ THREE.WebGLRenderer = function ( parameters ) { } - // create separate wrapper per each use of VBO - - if ( object instanceof THREE.ShadowVolume ) { - - addBuffer( scene.__webglShadowVolumes, geometryGroup, object ); - - } else { - - addBuffer( scene.__webglObjects, geometryGroup, object ); - - } + addBuffer( scene.__webglObjects, geometryGroup, object ); } - } else if ( object instanceof THREE.LensFlare ) { - - addBuffer( scene.__webglLensFlares, undefined, object ); - } else if ( object instanceof THREE.Ribbon ) { geometry = object.geometry; @@ -4824,13 +4252,7 @@ THREE.WebGLRenderer = function ( parameters ) { function removeObject( object, scene ) { - // must check as shadow volume before mesh (as they are also meshes) - - if ( object instanceof THREE.ShadowVolume ) { - - removeInstances( scene.__webglShadowVolumes, object ); - - } else if ( object instanceof THREE.Mesh || + if ( object instanceof THREE.Mesh || object instanceof THREE.ParticleSystem || object instanceof THREE.Ribbon || object instanceof THREE.Line ) { @@ -4841,10 +4263,6 @@ THREE.WebGLRenderer = function ( parameters ) { removeInstancesDirect( scene.__webglSprites, object ); - } else if ( object instanceof THREE.LensFlare ) { - - removeInstances( scene.__webglLensFlares, object ); - } else if ( object instanceof THREE.MarchingCubes ) { removeInstances( scene.__webglObjectsImmediate, object ); @@ -5839,7 +5257,7 @@ THREE.WebGLRenderer = function ( parameters ) { // use vertexColor type from the first material in unrolled materials - for ( i = 0; i < ml; i++ ) { + for ( i = 0; i < ml; i ++ ) { m = materials[ i ]; @@ -5861,7 +5279,7 @@ THREE.WebGLRenderer = function ( parameters ) { // only MeshBasicMaterial and MeshDepthMaterial don't need normals - for ( i = 0; i < ml; i++ ) { + for ( i = 0; i < ml; i ++ ) { m = materials[ i ]; @@ -5960,8 +5378,7 @@ THREE.WebGLRenderer = function ( parameters ) { function allocateShadows( lights ) { - var l, ll, light, - maxShadows = 0; + var l, ll, light, maxShadows = 0; for ( l = 0, ll = lights.length; l < ll; l++ ) { diff --git a/utils/build.py b/utils/build.py index c9fd299c..a6cd5cd3 100644 --- a/utils/build.py +++ b/utils/build.py @@ -36,7 +36,6 @@ COMMON_FILES = [ 'lights/DirectionalLight.js', 'lights/PointLight.js', 'lights/SpotLight.js', -'lights/LensFlare.js', 'materials/Material.js', 'materials/Mappings.js', 'materials/LineBasicMaterial.js', @@ -47,7 +46,6 @@ COMMON_FILES = [ 'materials/MeshNormalMaterial.js', 'materials/MeshFaceMaterial.js', 'materials/MeshShaderMaterial.js', -'materials/ShadowVolumeDynamicMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCanvasMaterial.js', 'materials/ParticleDOMMaterial.js', @@ -61,7 +59,6 @@ COMMON_FILES = [ 'objects/SkinnedMesh.js', 'objects/Ribbon.js', 'objects/LOD.js', -'objects/ShadowVolume.js', 'objects/Sprite.js', 'scenes/Scene.js', 'scenes/Fog.js', @@ -269,7 +266,6 @@ WEBGL_FILES = [ 'lights/DirectionalLight.js', 'lights/PointLight.js', 'lights/SpotLight.js', -'lights/LensFlare.js', 'materials/Material.js', 'materials/Mappings.js', 'materials/LineBasicMaterial.js', @@ -281,7 +277,6 @@ WEBGL_FILES = [ 'materials/MeshFaceMaterial.js', 'materials/MeshShaderMaterial.js', 'materials/ParticleBasicMaterial.js', -'materials/ShadowVolumeDynamicMaterial.js', 'materials/Texture.js', 'objects/Particle.js', 'objects/ParticleSystem.js', @@ -291,7 +286,6 @@ WEBGL_FILES = [ 'objects/SkinnedMesh.js', 'objects/Ribbon.js', 'objects/LOD.js', -'objects/ShadowVolume.js', 'objects/Sprite.js', 'scenes/Scene.js', 'scenes/Fog.js', diff --git a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py deleted file mode 100644 index 769e2d2d..00000000 --- a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py +++ /dev/null @@ -1,359 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# ################################################################ -# Init -# ################################################################ - -# To support reload properly, try to access a package var, -# if it's there, reload everything - -if "bpy" in locals(): - import imp - if "export_threejs" in locals(): - imp.reload(export_threejs) - if "import_threejs" in locals(): - imp.reload(import_threejs) - -import bpy -from bpy.props import * -from io_utils import ExportHelper, ImportHelper - -# ################################################################ -# Custom properties -# ################################################################ - -bpy.types.Object.THREE_castsShadow = bpy.props.BoolProperty() -bpy.types.Object.THREE_meshCollider = bpy.props.BoolProperty() -bpy.types.Object.THREE_exportGeometry = bpy.props.BoolProperty(default = True) - -THREE_trigger_types = [("None", "None", "None"), ("Small", "Small", "Small"), ("Large", "Large", "Large")] -bpy.types.Object.THREE_triggerType = EnumProperty(name = "Trigger type", description = "Trigger type", items = THREE_trigger_types, default = "None") - -bpy.types.Material.THREE_useVertexColors = bpy.props.BoolProperty() - -THREE_material_types = [("Basic", "Basic", "Basic"), ("Phong", "Phong", "Phong"), ("Lambert", "Lambert", "Lambert")] -bpy.types.Material.THREE_materialType = EnumProperty(name = "Material type", description = "Material type", items = THREE_material_types, default = "Lambert") - -class OBJECT_PT_hello( bpy.types.Panel ): - - bl_label = "THREE" - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "object" - - def draw(self, context): - layout = self.layout - obj = context.object - - row = layout.row() - row.label(text="Selected object: " + obj.name ) - - row = layout.row() - row.prop( obj, "THREE_exportGeometry", text="Export geometry" ) - - row = layout.row() - row.prop( obj, "THREE_castsShadow", text="Casts shadow" ) - - row = layout.row() - row.prop( obj, "THREE_meshCollider", text="Mesh collider" ) - - row = layout.row() - row.prop( obj, "THREE_triggerType", text="Trigger type" ) - - -class MATERIAL_PT_hello( bpy.types.Panel ): - - bl_label = "THREE" - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "material" - - def draw(self, context): - layout = self.layout - mat = context.material - - row = layout.row() - row.label(text="Selected material: " + mat.name ) - - row = layout.row() - row.prop( mat, "THREE_materialType", text="Material type" ) - - row = layout.row() - row.prop( mat, "THREE_useVertexColors", text="Use vertex colors" ) - - -# ################################################################ -# Importer -# ################################################################ - -class ImportTHREEJS(bpy.types.Operator, ImportHelper): - '''Load a Three.js ASCII JSON model''' - - bl_idname = "import.threejs" - bl_label = "Import Three.js" - - filename_ext = ".js" - filter_glob = StringProperty(default="*.js", options={'HIDDEN'}) - - option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True) - recalculate_normals = BoolProperty(name="Recalculate normals", description="Recalculate vertex normals", default=True) - - def execute(self, context): - import io_mesh_threejs.import_threejs - return io_mesh_threejs.import_threejs.load(self, context, **self.properties) - - - def draw(self, context): - layout = self.layout - - row = layout.row() - row.prop(self.properties, "option_flip_yz") - - row = layout.row() - row.prop(self.properties, "recalculate_normals") - - -# ################################################################ -# Exporter - settings -# ################################################################ - -SETTINGS_FILE_EXPORT = "threejs_settings_export.js" - -import os -import json - -def file_exists(filename): - """Return true if file exists and accessible for reading. - - Should be safer than just testing for existence due to links and - permissions magic on Unix filesystems. - - @rtype: boolean - """ - - try: - f = open(filename, 'r') - f.close() - return True - except IOError: - return False - -def get_settings_fullpath(): - return os.path.join(bpy.app.tempdir, SETTINGS_FILE_EXPORT) - -def save_settings_export(properties): - - settings = { - "option_export_scene" : properties.option_export_scene, - "option_embed_meshes" : properties.option_embed_meshes, - - "option_lights" : properties.option_lights, - "option_cameras" : properties.option_cameras, - - "option_flip_yz" : properties.option_flip_yz, - - "option_materials" : properties.option_materials, - "option_normals" : properties.option_normals, - "option_colors" : properties.option_colors, - "option_uv_coords" : properties.option_uv_coords, - "option_edges" : properties.option_edges, - "option_faces" : properties.option_faces, - "option_vertices" : properties.option_vertices, - - "option_vertices_truncate" : properties.option_vertices_truncate, - "option_scale" : properties.option_scale, - - "align_model" : properties.align_model - } - - fname = get_settings_fullpath() - f = open(fname, "w") - json.dump(settings, f) - -def restore_settings_export(properties): - - settings = {} - - fname = get_settings_fullpath() - if file_exists(fname): - f = open(fname, "r") - settings = json.load(f) - - properties.option_vertices = settings.get("option_vertices", True) - properties.option_vertices_truncate = settings.get("option_vertices_truncate", False) - properties.option_faces = settings.get("option_faces", True) - properties.option_normals = settings.get("option_normals", True) - properties.option_edges = settings.get("option_edges", False) - - properties.option_colors = settings.get("option_colors", True) - properties.option_uv_coords = settings.get("option_uv_coords", True) - properties.option_materials = settings.get("option_materials", True) - - properties.align_model = settings.get("align_model", "None") - - properties.option_scale = settings.get("option_scale", 1.0) - properties.option_flip_yz = settings.get("option_flip_yz", True) - - properties.option_export_scene = settings.get("option_export_scene", False) - properties.option_embed_meshes = settings.get("option_embed_meshes", True) - - properties.option_lights = settings.get("option_lights", False) - properties.option_cameras = settings.get("option_cameras", False) - -# ################################################################ -# Exporter -# ################################################################ - -class ExportTHREEJS(bpy.types.Operator, ExportHelper): - '''Export selected object / scene for Three.js (ASCII JSON format).''' - - bl_idname = "export.threejs" - bl_label = "Export Three.js" - - filename_ext = ".js" - - option_vertices = BoolProperty(name = "Vertices", description = "Export vertices", default = True) - option_vertices_deltas = BoolProperty(name = "Deltas", description = "Delta vertices", default = False) - option_vertices_truncate = BoolProperty(name = "Truncate", description = "Truncate vertices", default = False) - - option_faces = BoolProperty(name = "Faces", description = "Export faces", default = True) - option_faces_deltas = BoolProperty(name = "Deltas", description = "Delta faces", default = False) - - option_normals = BoolProperty(name = "Normals", description = "Export normals", default = True) - option_edges = BoolProperty(name = "Edges", description = "Export edges", default = False) - - option_colors = BoolProperty(name = "Colors", description = "Export vertex colors", default = True) - option_uv_coords = BoolProperty(name = "UVs", description = "Export texture coordinates", default = True) - option_materials = BoolProperty(name = "Materials", description = "Export materials", default = True) - - align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")] - align_model = EnumProperty(name = "Align model", description = "Align model", items = align_types, default = "None") - - option_scale = FloatProperty(name = "Scale", description = "Scale vertices", min = 0.01, max = 1000.0, soft_min = 0.01, soft_max = 1000.0, default = 1.0) - option_flip_yz = BoolProperty(name = "Flip YZ", description = "Flip YZ", default = True) - - option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False) - option_embed_meshes = BoolProperty(name = "Embed", description = "Embed meshes", default = True) - - option_lights = BoolProperty(name = "Lights", description = "Export default scene lights", default = False) - option_cameras = BoolProperty(name = "Cameras", description = "Export default scene cameras", default = False) - - def invoke(self, context, event): - restore_settings_export(self.properties) - return ExportHelper.invoke(self, context, event) - - @classmethod - def poll(cls, context): - return context.active_object != None - - def execute(self, context): - print("Selected: " + context.active_object.name) - - if not self.properties.filepath: - raise Exception("filename not set") - - save_settings_export(self.properties) - - filepath = self.filepath - import io_mesh_threejs.export_threejs - return io_mesh_threejs.export_threejs.save(self, context, **self.properties) - - def draw(self, context): - layout = self.layout - - row = layout.row() - row.label(text="Geometry:") - - row = layout.row() - row.prop(self.properties, "option_vertices") - row = layout.row() - row.enabled = self.properties.option_vertices - # row.prop(self.properties, "option_vertices_deltas") - row.prop(self.properties, "option_vertices_truncate") - layout.separator() - - row = layout.row() - row.prop(self.properties, "option_faces") - row = layout.row() - row.enabled = self.properties.option_faces - # row.prop(self.properties, "option_faces_deltas") - layout.separator() - - row = layout.row() - row.prop(self.properties, "option_normals") - layout.separator() - - row = layout.row() - row.prop(self.properties, "option_edges") - layout.separator() - - row = layout.row() - row.label(text="Materials:") - - row = layout.row() - row.prop(self.properties, "option_uv_coords") - row.prop(self.properties, "option_colors") - row = layout.row() - row.prop(self.properties, "option_materials") - layout.separator() - - row = layout.row() - row.label(text="Settings:") - - row = layout.row() - row.prop(self.properties, "align_model") - row = layout.row() - row.prop(self.properties, "option_flip_yz") - row.prop(self.properties, "option_scale") - layout.separator() - - row = layout.row() - row.label(text="Beta:") - - row = layout.row() - row.prop(self.properties, "option_export_scene") - row.prop(self.properties, "option_lights") - row.prop(self.properties, "option_cameras") - - row = layout.row() - row.prop(self.properties, "option_embed_meshes") - layout.separator() - - -# ################################################################ -# Common -# ################################################################ - -def menu_func_export(self, context): - default_path = bpy.data.filepath.replace(".blend", ".js") - self.layout.operator(ExportTHREEJS.bl_idname, text="Three.js (.js)").filepath = default_path - -def menu_func_import(self, context): - self.layout.operator(ImportTHREEJS.bl_idname, text="Three.js (.js)") - -def register(): - bpy.types.INFO_MT_file_export.append(menu_func_export) - bpy.types.INFO_MT_file_import.append(menu_func_import) - -def unregister(): - bpy.types.INFO_MT_file_export.remove(menu_func_export) - bpy.types.INFO_MT_file_import.remove(menu_func_import) - -if __name__ == "__main__": - register() diff --git a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py deleted file mode 100644 index 02b21530..00000000 --- a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py +++ /dev/null @@ -1,1623 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# Based on export_obj.py and export_ply.py -# Contributors: Mr.doob, Kikko, alteredq - -""" -Blender exporter for Three.js (ASCII JSON format). - -TODO - - export scene - - copy used images to folder where exported file goes - - binary format -""" - -import bpy -import mathutils - -import os -import os.path -import math -import operator -import random - -# ##################################################### -# Configuration -# ##################################################### - -DEFAULTS = { -"bgcolor" : [0, 0, 0], -"bgalpha" : 1.0, - -"position" : [0, 0, 0], -"rotation" : [-math.pi/2, 0, 0], -"scale" : [1, 1, 1], - -"camera" : - { - "name" : "default_camera", - "type" : "perspective", - "near" : 1, - "far" : 10000, - "fov" : 60, - "aspect": 1.333, - "position" : [0, 0, 10], - "target" : [0, 0, 0] - }, - -"light" : - { - "name" : "default_light", - "type" : "directional", - "direction" : [0, 1, 1], - "color" : [1, 1, 1], - "intensity" : 0.8 - } -} - -# default colors for debugging (each material gets one distinct color): -# white, red, green, blue, yellow, cyan, magenta -COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee] - - -# ##################################################### -# Templates - scene -# ##################################################### - -TEMPLATE_SCENE_ASCII = """\ -/* Converted from: %(fname)s - * - * File generated with Blender 2.56 Exporter - * https://github.com/alteredq/three.js/tree/master/utils/exporters/blender/ - * - * objects: %(nobjects)s - * geometries: %(ngeometries)s - * materials: %(nmaterials)s - * textures: %(ntextures)s - */ - -var scene = { - -"type" : "scene", -"urlBaseType" : "relativeToScene", - -%(sections)s - -"transform" : -{ - "position" : %(position)s, - "rotation" : %(rotation)s, - "scale" : %(scale)s -}, - -"defaults" : -{ - "bgcolor" : %(bgcolor)s, - "bgalpha" : %(bgalpha)f, - "camera" : %(defcamera)s -} - -} - -postMessage( scene ); -close(); -""" - -TEMPLATE_SECTION = """ -"%s" : -{ -%s -}, -""" - -TEMPLATE_OBJECT = """\ - %(object_id)s : { - "geometry" : %(geometry_id)s, - "groups" : [ %(group_id)s ], - "materials" : [ %(material_id)s ], - "position" : %(position)s, - "rotation" : %(rotation)s, - "quaternion": %(quaternion)s, - "scale" : %(scale)s, - "visible" : %(visible)s, - "castsShadow" : %(castsShadow)s, - "meshCollider" : %(meshCollider)s, - "trigger" : %(trigger)s - }""" - -TEMPLATE_EMPTY = """\ - %(object_id)s : { - "groups" : [ %(group_id)s ], - "position" : %(position)s, - "rotation" : %(rotation)s, - "quaternion": %(quaternion)s, - "scale" : %(scale)s, - "trigger" : %(trigger)s - }""" - -TEMPLATE_GEOMETRY_LINK = """\ - %(geometry_id)s : { - "type" : "ascii_mesh", - "url" : %(model_file)s - }""" - -TEMPLATE_GEOMETRY_EMBED = """\ - %(geometry_id)s : { - "type" : "embedded_mesh", - "id" : %(embed_id)s - }""" - -TEMPLATE_TEXTURE = """\ - %(texture_id)s : { - "url": %(texture_file)s - }""" - -TEMPLATE_MATERIAL_SCENE = """\ - %(material_id)s : { - "type": %(type)s, - "parameters": { %(parameters)s } - }""" - -TEMPLATE_CAMERA_PERSPECTIVE = """\ - %(camera_id)s : { - "type" : "perspective", - "fov" : %(fov)f, - "aspect": %(aspect)f, - "near" : %(near)f, - "far" : %(far)f, - "position": %(position)s, - "target" : %(target)s - }""" - -TEMPLATE_CAMERA_ORTHO = """\ - %(camera_id)s: { - "type" : "ortho", - "left" : %(left)f, - "right" : %(right)f, - "top" : %(top)f, - "bottom": %(bottom)f, - "near" : %(near)f, - "far" : %(far)f, - "position": %(position)s, - "target" : %(target)s - }""" - -TEMPLATE_LIGHT_DIRECTIONAL = """\ - %(light_id)s: { - "type" : "directional", - "direction" : %(direction)s, - "color" : %(color)d, - "intensity" : %(intensity).2f - }""" - -TEMPLATE_LIGHT_POINT = """\ - %(light_id)s: { - "type" : "point", - "position" : %(position)s, - "color" : %(color)d, - "intensity" : %(intensity).3f - }""" - -TEMPLATE_VEC4 = '[ %f, %f, %f, %f ]' -TEMPLATE_VEC3 = '[ %f, %f, %f ]' -TEMPLATE_VEC2 = '[ %f, %f ]' -TEMPLATE_STRING = '"%s"' -TEMPLATE_HEX = "0x%06x" - -# ##################################################### -# Templates - model -# ##################################################### - -TEMPLATE_FILE_ASCII = """\ -/* - * File generated with Blender 2.56 Exporter - * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/ - * - * vertices: %(nvertex)d - * faces: %(nface)d - * normals: %(nnormal)d - * uvs: %(nuv)d - * colors: %(ncolor)d - * materials: %(nmaterial)d - * edges: %(nedges)d - * - */ - -var model = { - -%(model)s - -}; - -postMessage( model ); -close(); -""" - -TEMPLATE_MODEL_ASCII = """\ - "version" : 2, - - "scale" : %(scale)f, - - "materials": [%(materials)s], - - "vertices": [%(vertices)s], - - "morphTargets": [], - - "normals": [%(normals)s], - - "colors": [%(colors)s], - - "uvs": [[%(uvs)s]], - - "faces": [%(faces)s], - - "edges" : [%(edges)s] -""" - -TEMPLATE_VERTEX = "%f,%f,%f" -TEMPLATE_VERTEX_TRUNCATE = "%d,%d,%d" - -TEMPLATE_N = "%f,%f,%f" -TEMPLATE_UV = "%f,%f" -#TEMPLATE_C = "0x%06x" -TEMPLATE_C = "%d" -TEMPLATE_EDGE = "%d,%d" - -# ##################################################### -# Utils -# ##################################################### - -def veckey3(x,y,z): - return round(x, 6), round(y, 6), round(z, 6) - -def veckey3d(v): - return veckey3(v.x, v.y, v.z) - -def veckey2d(v): - return round(v[0], 6), round(v[1], 6) - -def get_normal_indices(v, normals, mesh): - n = [] - mv = mesh.vertices - - for i in v: - normal = mv[i].normal - key = veckey3d(normal) - - n.append( normals[key] ) - - return n - -def get_uv_indices(face_index, uvs, mesh): - uv = [] - uv_layer = mesh.uv_textures.active.data - for i in uv_layer[face_index].uv: - uv.append( uvs[veckey2d(i)] ) - return uv - -def get_color_indices(face_index, colors, mesh): - c = [] - color_layer = mesh.vertex_colors.active.data - face_colors = color_layer[face_index] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - for i in face_colors: - c.append( colors[hexcolor(i)] ) - return c - -def rgb2int(rgb): - color = (int(rgb[0]*255) << 16) + (int(rgb[1]*255) << 8) + int(rgb[2]*255); - return color - -# ##################################################### -# Utils - files -# ##################################################### - -def write_file(fname, content): - out = open(fname, "w") - out.write(content) - out.close() - -def ensure_folder_exist(foldername): - """Create folder (with whole path) if it doesn't exist yet.""" - - if not os.access(foldername, os.R_OK|os.W_OK|os.X_OK): - os.makedirs(foldername) - -def ensure_extension(filepath, extension): - if not filepath.lower().endswith(extension): - filepath += extension - return filepath - -def generate_mesh_filename(meshname, filepath): - normpath = os.path.normpath(filepath) - path, ext = os.path.splitext(normpath) - return "%s.%s%s" % (path, meshname, ext) - - -# ##################################################### -# Utils - alignment -# ##################################################### - -def bbox(vertices): - """Compute bounding box of vertex array. - """ - - if len(vertices)>0: - minx = maxx = vertices[0].co.x - miny = maxy = vertices[0].co.y - minz = maxz = vertices[0].co.z - - for v in vertices[1:]: - if v.co.x < minx: - minx = v.co.x - elif v.co.x > maxx: - maxx = v.co.x - - if v.co.y < miny: - miny = v.co.y - elif v.co.y > maxy: - maxy = v.co.y - - if v.co.z < minz: - minz = v.co.z - elif v.co.z > maxz: - maxz = v.co.z - - return { 'x':[minx,maxx], 'y':[miny,maxy], 'z':[minz,maxz] } - - else: - return { 'x':[0,0], 'y':[0,0], 'z':[0,0] } - -def translate(vertices, t): - """Translate array of vertices by vector t. - """ - - for i in range(len(vertices)): - vertices[i].co.x += t[0] - vertices[i].co.y += t[1] - vertices[i].co.z += t[2] - -def center(vertices): - """Center model (middle of bounding box). - """ - - bb = bbox(vertices) - - cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0 - cy = bb['y'][0] + (bb['y'][1] - bb['y'][0])/2.0 - cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0 - - translate(vertices, [-cx,-cy,-cz]) - -def top(vertices): - """Align top of the model with the floor (Y-axis) and center it around X and Z. - """ - - bb = bbox(vertices) - - cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0 - cy = bb['y'][1] - cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0 - - translate(vertices, [-cx,-cy,-cz]) - -def bottom(vertices): - """Align bottom of the model with the floor (Y-axis) and center it around X and Z. - """ - - bb = bbox(vertices) - - cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0 - cy = bb['y'][0] - cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0 - - translate(vertices, [-cx,-cy,-cz]) - -# ##################################################### -# Elements rendering -# ##################################################### - -def hexcolor(c): - return ( int(c[0] * 255) << 16 ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255) - -def generate_vertices(vertices, option_vertices_truncate, option_vertices): - if not option_vertices: - return "" - - return ",".join(generate_vertex(v, option_vertices_truncate) for v in vertices) - -def generate_vertex(v, option_vertices_truncate): - if not option_vertices_truncate: - return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z) - else: - return TEMPLATE_VERTEX_TRUNCATE % (v.co.x, v.co.y, v.co.z) - -def generate_normal(n): - return TEMPLATE_N % (n[0], n[1], n[2]) - -def generate_vertex_color(c): - return TEMPLATE_C % c - -def generate_uv(uv): - return TEMPLATE_UV % (uv[0], 1.0 - uv[1]) - -def generate_edge(e): - return TEMPLATE_EDGE % (e.vertices[0], e.vertices[1]) - -# ##################################################### -# Model exporter - faces -# ##################################################### - -def setBit(value, position, on): - if on: - mask = 1 << position - return (value | mask) - else: - mask = ~(1 << position) - return (value & mask) - -def generate_faces(normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz, option_faces): - if not option_faces: - return "" - - return ",".join(generate_face(f, i, normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz) for i, f in enumerate(mesh.faces)) - -def generate_face(f, faceIndex, normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz): - isTriangle = ( len(f.vertices) == 3 ) - - if isTriangle: - nVertices = 3 - else: - nVertices = 4 - - hasMaterial = option_materials - - hasFaceUvs = False # not supported in Blender - hasFaceVertexUvs = option_uv_coords - - hasFaceNormals = False # don't export any face normals (as they are computed in engine) - hasFaceVertexNormals = option_normals - - hasFaceColors = False # not supported in Blender - hasFaceVertexColors = option_colors - - faceType = 0 - faceType = setBit(faceType, 0, not isTriangle) - faceType = setBit(faceType, 1, hasMaterial) - faceType = setBit(faceType, 2, hasFaceUvs) - faceType = setBit(faceType, 3, hasFaceVertexUvs) - faceType = setBit(faceType, 4, hasFaceNormals) - faceType = setBit(faceType, 5, hasFaceVertexNormals) - faceType = setBit(faceType, 6, hasFaceColors) - faceType = setBit(faceType, 7, hasFaceVertexColors) - - faceData = [] - - # order is important, must match order in JSONLoader - - # face type - # vertex indices - # material index - # face uvs index - # face vertex uvs indices - # face color index - # face vertex colors indices - - faceData.append(faceType) - - # must clamp in case on polygons bigger than quads - - for i in range(nVertices): - index = f.vertices[i] - faceData.append(index) - - if hasMaterial: - faceData.append( f.material_index ) - - if hasFaceVertexUvs: - uv = get_uv_indices(faceIndex, uvs, mesh) - for i in range(nVertices): - index = uv[i] - faceData.append(index) - - if hasFaceVertexNormals: - n = get_normal_indices(f.vertices, normals, mesh) - for i in range(nVertices): - index = n[i] - faceData.append(index) - - if hasFaceVertexColors: - c = get_color_indices(faceIndex, colors, mesh) - for i in range(nVertices): - index = c[i] - faceData.append(index) - - return ",".join( map(str, faceData) ) - - -# ##################################################### -# Model exporter - normals -# ##################################################### - -def extract_vertex_normals(mesh, option_normals): - if not option_normals: - return {}, 0 - - count = 0 - normals = {} - - for f in mesh.faces: - for v in f.vertices: - - normal = mesh.vertices[v].normal - key = veckey3d(normal) - - if key not in normals: - normals[key] = count - count += 1 - - return normals, count - -def generate_normals(normals, option_normals): - if not option_normals: - return "" - - chunks = [] - for key, index in sorted(normals.items(), key = operator.itemgetter(1)): - chunks.append(key) - - return ",".join(generate_normal(n) for n in chunks) - -# ##################################################### -# Model exporter - vertex colors -# ##################################################### - -def extract_vertex_colors(mesh, option_colors): - - if not option_colors: - return {}, 0 - - count = 0 - colors = {} - - color_layer = mesh.vertex_colors.active.data - - for face_index, face in enumerate(mesh.faces): - - face_colors = color_layer[face_index] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - - for c in face_colors: - key = hexcolor(c) - if key not in colors: - colors[key] = count - count += 1 - - return colors, count - -def generate_vertex_colors(colors, option_colors): - if not option_colors: - return "" - - chunks = [] - for key, index in sorted(colors.items(), key=operator.itemgetter(1)): - chunks.append(key) - - return ",".join(generate_vertex_color(c) for c in chunks) - -# ##################################################### -# Model exporter - UVs -# ##################################################### - -def extract_uvs(mesh, option_uv_coords): - - if not option_uv_coords: - return {}, 0 - - count = 0 - uvs = {} - - uv_layer = mesh.uv_textures.active.data - - for face_index, face in enumerate(mesh.faces): - - for uv_index, uv in enumerate(uv_layer[face_index].uv): - - key = veckey2d(uv) - if key not in uvs: - uvs[key] = count - count += 1 - - return uvs, count - -def generate_uvs(uvs, option_uv_coords): - if not option_uv_coords: - return "" - - chunks = [] - for key, index in sorted(uvs.items(), key=operator.itemgetter(1)): - chunks.append(key) - - return ",".join(generate_uv(n) for n in chunks) - -# ##################################################### -# Model exporter - materials -# ##################################################### - -def generate_color(i): - """Generate hex color corresponding to integer. - - Colors should have well defined ordering. - First N colors are hardcoded, then colors are random - (must seed random number generator with deterministic value - before getting colors). - """ - - if i < len(COLORS): - #return "0x%06x" % COLORS[i] - return COLORS[i] - else: - #return "0x%06x" % int(0xffffff * random.random()) - return int(0xffffff * random.random()) - -def generate_mtl(materials): - """Generate dummy materials. - """ - - mtl = {} - for m in materials: - index = materials[m] - mtl[m] = { - "DbgName": m, - "DbgIndex": index, - "DbgColor": generate_color(index), - "vertexColors" : False - } - return mtl - -def value2string(v): - if type(v) == str and v[0:2] != "0x": - return '"%s"' % v - elif type(v) == bool: - return str(v).lower() - return str(v) - -def generate_materials(mtl, materials, draw_type): - """Generate JS array of materials objects - """ - - mtl_array = [] - for m in mtl: - index = materials[m] - - # add debug information - # materials should be sorted according to how - # they appeared in OBJ file (for the first time) - # this index is identifier used in face definitions - mtl[m]['DbgName'] = m - mtl[m]['DbgIndex'] = index - mtl[m]['DbgColor'] = generate_color(index) - - if draw_type in [ "BOUNDS", "WIRE" ]: - mtl[m]['wireframe'] = True - mtl[m]['DbgColor'] = 0xff0000 - - mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())]) - mtl_string = "\t{\n%s\n\t}" % mtl_raw - mtl_array.append([index, mtl_string]) - - return ",\n\n".join([m for i,m in sorted(mtl_array)]), len(mtl_array) - -def extract_materials(mesh, scene, option_colors): - world = scene.world - - materials = {} - for m in mesh.materials: - if m: - materials[m.name] = {} - material = materials[m.name] - - material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0], - m.diffuse_intensity * m.diffuse_color[1], - m.diffuse_intensity * m.diffuse_color[2]] - - material['colorSpecular'] = [m.specular_intensity * m.specular_color[0], - m.specular_intensity * m.specular_color[1], - m.specular_intensity * m.specular_color[2]] - - world_ambient_color = [0, 0, 0] - if world: - world_ambient_color = world.ambient_color - - material['colorAmbient'] = [m.ambient * world_ambient_color[0], - m.ambient * world_ambient_color[1], - m.ambient * world_ambient_color[2]] - - material['transparency'] = m.alpha - - # not sure about mapping values to Blinn-Phong shader - # Blender uses INT from [1,511] with default 0 - # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness - - material["specularCoef"] = m.specular_hardness - - if m.active_texture and m.active_texture.type == 'IMAGE' and m.active_texture.image: - fn = bpy.path.abspath(m.active_texture.image.filepath) - fn = os.path.normpath(fn) - fn_strip = os.path.basename(fn) - material['mapDiffuse'] = fn_strip - - material["vertexColors"] = m.THREE_useVertexColors and option_colors - - # can't really use this reliably to tell apart Phong from Lambert - # as Blender defaults to non-zero specular color - #if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0): - # material['shading'] = "Phong" - #else: - # material['shading'] = "Lambert" - - material['shading'] = m.THREE_materialType - - return materials - -def generate_materials_string(mesh, scene, option_colors, draw_type): - - random.seed(42) # to get well defined color order for debug materials - - materials = {} - if mesh.materials: - for i, m in enumerate(mesh.materials): - if m: - materials[m.name] = i - else: - materials["undefined_dummy_%0d" % i] = i - - - if not materials: - materials = { 'default':0 } - - # default dummy materials - - mtl = generate_mtl(materials) - - # extract real materials from the mesh - - mtl.update(extract_materials(mesh, scene, option_colors)) - - return generate_materials(mtl, materials, draw_type) - -# ##################################################### -# ASCII model generator -# ##################################################### - -def generate_ascii_model(mesh, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - draw_type): - - vertices = mesh.vertices[:] - - if align_model == 1: - center(vertices) - elif align_model == 2: - bottom(vertices) - elif align_model == 3: - top(vertices) - - normals, nnormal = extract_vertex_normals(mesh, option_normals) - colors, ncolor = extract_vertex_colors(mesh, option_colors) - uvs, nuv = extract_uvs(mesh, option_uv_coords) - - materials_string = "" - nmaterial = 0 - - edges_string = "" - nedges = 0 - - if option_materials: - materials_string, nmaterial = generate_materials_string(mesh, scene, option_colors, draw_type) - - if option_edges: - nedges = len(mesh.edges) - edges_string = ",".join(generate_edge(e) for e in mesh.edges) - - model_string = TEMPLATE_MODEL_ASCII % { - "scale" : option_scale, - - "uvs" : generate_uvs(uvs, option_uv_coords), - "normals" : generate_normals(normals, option_normals), - "colors" : generate_vertex_colors(colors, option_colors), - - "materials" : materials_string, - - "vertices" : generate_vertices(vertices, option_vertices_truncate, option_vertices), - - "faces" : generate_faces(normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz, option_faces), - - "edges" : edges_string - } - - text = TEMPLATE_FILE_ASCII % { - "nvertex" : len(mesh.vertices), - "nface" : len(mesh.faces), - "nuv" : nuv, - "nnormal" : nnormal, - "ncolor" : ncolor, - "nmaterial" : nmaterial, - "nedges" : nedges, - - "model" : model_string - } - - - return text, model_string - - -# ##################################################### -# Model exporter - export single mesh -# ##################################################### - -def generate_mesh_string(obj, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - export_single_model): - - # collapse modifiers into mesh - - mesh = obj.create_mesh(scene, True, 'RENDER') - - if not mesh: - raise Exception("Error, could not get mesh data from object [%s]" % obj.name) - - # that's what Blender's native export_obj.py does - # to flip YZ - - if export_single_model: - X_ROT = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X') - mesh.transform(X_ROT * obj.matrix_world) - - mesh.calc_normals() - - mesh.transform(mathutils.Matrix.Scale(option_scale, 4)) - - faceUV = (len(mesh.uv_textures) > 0) - vertexUV = (len(mesh.sticky) > 0) - vertexColors = len(mesh.vertex_colors) > 0 - - if not vertexColors: - option_colors = False - - if (not faceUV) and (not vertexUV): - option_uv_coords = False - - if faceUV: - active_uv_layer = mesh.uv_textures.active - if not active_uv_layer: - option_uv_coords = False - - if vertexColors: - active_col_layer = mesh.vertex_colors.active - if not active_col_layer: - option_colors = False - - text, model_string = generate_ascii_model(mesh, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - obj.draw_type) - # remove temp mesh - - bpy.data.meshes.remove(mesh) - - return text, model_string - -def export_mesh(obj, scene, filepath, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - export_single_model): - - """Export single mesh""" - - text, model_string = generate_mesh_string(obj, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - export_single_model) - - write_file(filepath, text) - - print("writing", filepath, "done") - - -# ##################################################### -# Scene exporter - render elements -# ##################################################### - -def generate_vec4(vec): - return TEMPLATE_VEC4 % (vec[0], vec[1], vec[2], vec[3]) - -def generate_vec3(vec): - return TEMPLATE_VEC3 % (vec[0], vec[1], vec[2]) - -def generate_vec2(vec): - return TEMPLATE_VEC2 % (vec[0], vec[1]) - -def generate_hex(number): - return TEMPLATE_HEX % number - -def generate_string(s): - return TEMPLATE_STRING % s - -def generate_string_list(src_list): - return ", ".join(generate_string(item) for item in src_list) - -def generate_section(label, content): - return TEMPLATE_SECTION % (label, content) - -def get_mesh_filename(mesh): - object_id = mesh["data"]["name"] - filename = "%s.js" % sanitize(object_id) - return filename - -def generate_material_id_list(materials): - chunks = [] - for material in materials: - chunks.append(material.name) - - return chunks - -def generate_group_id_list(obj): - chunks = [] - - for group in bpy.data.groups: - if obj.name in group.objects: - chunks.append(group.name) - - return chunks - -def generate_bool_property(property): - if property: - return "true" - return "false" - -# ##################################################### -# Scene exporter - objects -# ##################################################### - -def generate_objects(data): - chunks = [] - - for obj in data["objects"]: - - if obj.type == "MESH" and obj.THREE_exportGeometry: - object_id = obj.name - - if len(obj.modifiers) > 0: - geo_name = obj.name - else: - geo_name = obj.data.name - - geometry_id = "geo_%s" % geo_name - - material_ids = generate_material_id_list(obj.material_slots) - group_ids = generate_group_id_list(obj) - - position, quaternion, scale = obj.matrix_world.decompose() - rotation = quaternion.to_euler("XYZ") - - material_string = "" - if len(material_ids) > 0: - material_string = generate_string_list(material_ids) - - group_string = "" - if len(group_ids) > 0: - group_string = generate_string_list(group_ids) - - castsShadow = obj.THREE_castsShadow - meshCollider = obj.THREE_meshCollider - triggerType = obj.THREE_triggerType - - visible = True - #if obj.draw_type in ["BOUNDS", "WIRE"] and (meshCollider or castsShadow): - if meshCollider or castsShadow: - visible = False - - geometry_string = generate_string(geometry_id) - - object_string = TEMPLATE_OBJECT % { - "object_id" : generate_string(object_id), - "geometry_id" : geometry_string, - "group_id" : group_string, - "material_id" : material_string, - - "position" : generate_vec3(position), - "rotation" : generate_vec3(rotation), - "quaternion" : generate_vec4(quaternion), - "scale" : generate_vec3(scale), - - "castsShadow" : generate_bool_property(castsShadow), - "meshCollider" : generate_bool_property(meshCollider), - "trigger" : generate_string(triggerType), - "visible" : generate_bool_property(visible) - } - chunks.append(object_string) - - elif obj.type == "EMPTY" or (obj.type == "MESH" and not obj.THREE_exportGeometry): - - object_id = obj.name - group_ids = generate_group_id_list(obj) - - position, quaternion, scale = obj.matrix_world.decompose() - rotation = quaternion.to_euler("XYZ") - - group_string = "" - if len(group_ids) > 0: - group_string = generate_string_list(group_ids) - - triggerType = obj.THREE_triggerType - - object_string = TEMPLATE_EMPTY % { - "object_id" : generate_string(object_id), - "group_id" : group_string, - - "position" : generate_vec3(position), - "rotation" : generate_vec3(rotation), - "quaternion" : generate_vec4(quaternion), - "scale" : generate_vec3(scale), - - "trigger" : generate_string(triggerType), - } - chunks.append(object_string) - - return ",\n\n".join(chunks), len(chunks) - -# ##################################################### -# Scene exporter - geometries -# ##################################################### - -def generate_geometries(data): - chunks = [] - - geo_set = set() - - for obj in data["objects"]: - if obj.type == "MESH" and obj.THREE_exportGeometry: - - if len(obj.modifiers) > 0: - name = obj.name - else: - name = obj.data.name - - if name not in geo_set: - - geometry_id = "geo_%s" % name - - if data["embed_meshes"]: - - embed_id = "emb_%s" % name - - geometry_string = TEMPLATE_GEOMETRY_EMBED % { - "geometry_id" : generate_string(geometry_id), - "embed_id" : generate_string(embed_id) - } - - else: - - model_filename = os.path.basename(generate_mesh_filename(name, data["filepath"])) - - geometry_string = TEMPLATE_GEOMETRY_LINK % { - "geometry_id" : generate_string(geometry_id), - "model_file" : generate_string(model_filename) - } - - chunks.append(geometry_string) - - geo_set.add(name) - - return ",\n\n".join(chunks), len(chunks) - -# ##################################################### -# Scene exporter - textures -# ##################################################### - -def generate_textures_scene(data): - chunks = [] - - # TODO: extract just textures actually used by some objects in the scene - - for img in bpy.data.images: - - texture_id = img.name - texture_file = extract_texture_filename(img) - - texture_string = TEMPLATE_TEXTURE % { - "texture_id" : generate_string(texture_id), - "texture_file" : generate_string(texture_file) - } - chunks.append(texture_string) - - return ",\n\n".join(chunks), len(chunks) - -def extract_texture_filename(image): - fn = bpy.path.abspath(image.filepath) - fn = os.path.normpath(fn) - fn_strip = os.path.basename(fn) - return fn_strip - -# ##################################################### -# Scene exporter - materials -# ##################################################### - -def extract_material_data(m, option_colors): - world = bpy.context.scene.world - - material = { 'name': m.name } - - material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0], - m.diffuse_intensity * m.diffuse_color[1], - m.diffuse_intensity * m.diffuse_color[2]] - - material['colorSpecular'] = [m.specular_intensity * m.specular_color[0], - m.specular_intensity * m.specular_color[1], - m.specular_intensity * m.specular_color[2]] - - world_ambient_color = [0, 0, 0] - if world: - world_ambient_color = world.ambient_color - - material['colorAmbient'] = [m.ambient * world_ambient_color[0], - m.ambient * world_ambient_color[1], - m.ambient * world_ambient_color[2]] - - material['transparency'] = m.alpha - - # not sure about mapping values to Blinn-Phong shader - # Blender uses INT from [1,511] with default 0 - # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness - - material["specularCoef"] = m.specular_hardness - - material['mapDiffuse'] = "" - material['mapLight'] = "" - material['mapNormal'] = "" - - material["vertexColors"] = m.THREE_useVertexColors and option_colors - - # just take first textures of each, for the moment three.js materials can't handle more - - for i in range(len(m.texture_slots)): - ts = m.texture_slots[i] - if ts: - t = ts.texture - if ts.use and t.type == 'IMAGE': - name = t.image.name - - if t.use_normal_map: - material['mapNormal'] = name - else: - if not material['mapDiffuse']: - material['mapDiffuse'] = name - else: - material['mapLight'] = name - - if material['mapDiffuse'] and material['mapNormal'] and material['mapLight']: - break - - #if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0): - # material['shading'] = "Phong" - #else: - # material['shading'] = "Lambert" - - material['shading'] = m.THREE_materialType - - return material - -def generate_material_string(material): - type_map = { - "Lambert" : "MeshLambertMaterial", - "Phong" : "MeshPhongMaterial" - } - - material_id = material["name"] - shading = material.get("shading", "Lambert") - material_type = type_map.get(shading, "MeshBasicMaterial") - - parameters = '"color": %d' % rgb2int(material["colorDiffuse"]) - parameters += ', "opacity": %.2g' % material["transparency"] - - if shading == "Phong": - parameters += ', "ambient": %d' % rgb2int(material["colorAmbient"]) - parameters += ', "specular": %d' % rgb2int(material["colorSpecular"]) - parameters += ', "shininess": %.1g' % material["specularCoef"] - - colorMap = material['mapDiffuse'] - lightMap = material['mapLight'] - normalMap = material['mapNormal'] - - if colorMap: - parameters += ', "map": %s' % generate_string(colorMap) - if lightMap: - parameters += ', "lightMap": %s' % generate_string(lightMap) - if normalMap: - parameters += ', "normalMap": %s' % generate_string(normalMap) - - if material['vertexColors']: - parameters += ', "vertexColors": "vertex"' - - material_string = TEMPLATE_MATERIAL_SCENE % { - "material_id" : generate_string(material_id), - "type" : generate_string(material_type), - "parameters" : parameters - } - - return material_string - -def generate_materials_scene(data): - chunks = [] - - # TODO: extract just materials actually used by some objects in the scene - - for m in bpy.data.materials: - material = extract_material_data(m, data["use_colors"]) - material_string = generate_material_string(material) - chunks.append(material_string) - - return ",\n\n".join(chunks), len(chunks) - -# ##################################################### -# Scene exporter - cameras -# ##################################################### - -def generate_cameras(data): - if data["use_cameras"]: - - cameras = data.get("cameras", []) - - if not cameras: - cameras.append(DEFAULTS["camera"]) - - chunks = [] - - for camera in cameras: - - if camera["type"] == "perspective": - - camera_string = TEMPLATE_CAMERA_PERSPECTIVE % { - "camera_id" : generate_string(camera["name"]), - "fov" : camera["fov"], - "aspect" : camera["aspect"], - "near" : camera["near"], - "far" : camera["far"], - "position" : generate_vec3(camera["position"]), - "target" : generate_vec3(camera["target"]) - } - - elif camera["type"] == "ortho": - - camera_string = TEMPLATE_CAMERA_ORTHO % { - "camera_id" : generate_string(camera["name"]), - "left" : camera["left"], - "right" : camera["right"], - "top" : camera["top"], - "bottom" : camera["bottom"], - "near" : camera["near"], - "far" : camera["far"], - "position" : generate_vec3(camera["position"]), - "target" : generate_vec3(camera["target"]) - } - - chunks.append(camera_string) - - return ",\n\n".join(chunks) - - return "" - -# ##################################################### -# Scene exporter - lights -# ##################################################### - -def generate_lights(data): - - if data["use_lights"]: - - lights = data.get("lights", []) - if not lights: - lights.append(DEFAULTS["light"]) - - chunks = [] - for light in lights: - - if light["type"] == "directional": - light_string = TEMPLATE_LIGHT_DIRECTIONAL % { - "light_id" : generate_string(light["name"]), - "direction" : generate_vec3(light["direction"]), - #"color" : generate_hex(rgb2int(light["color"])), - "color" : rgb2int(light["color"]), - "intensity" : light["intensity"] - } - - elif light["type"] == "point": - light_string = TEMPLATE_LIGHT_POINT % { - "light_id" : generate_string(light["name"]), - "position" : generate_vec3(light["position"]), - #"color" : generate_hex(rgb2int(light["color"])), - "color" : rgb2int(light["color"]), - "intensity" : light["intensity"] - } - - chunks.append(light_string) - - return ",\n\n".join(chunks) - - return "" - -# ##################################################### -# Scene exporter - embedded meshes -# ##################################################### - -def generate_embeds(data): - - if data["embed_meshes"]: - - chunks = [] - - for e in data["embeds"]: - - embed = '"emb_%s": {%s}' % (e, data["embeds"][e]) - chunks.append(embed) - - return ",\n\n".join(chunks) - - return "" - -# ##################################################### -# Scene exporter - generate ASCII scene -# ##################################################### - -def generate_ascii_scene(data): - - objects, nobjects = generate_objects(data) - geometries, ngeometries = generate_geometries(data) - textures, ntextures = generate_textures_scene(data) - materials, nmaterials = generate_materials_scene(data) - - cameras = generate_cameras(data) - lights = generate_lights(data) - - embeds = generate_embeds(data) - - sections = [ - ["objects", objects], - ["geometries", geometries], - ["textures", textures], - ["materials", materials], - ["cameras", cameras], - ["lights", lights], - ["embeds", embeds] - ] - - chunks = [] - for label, content in sections: - if content: - chunks.append(generate_section(label, content)) - - sections_string = "\n".join(chunks) - - default_camera = "" - if data["use_cameras"]: - default_camera = generate_string("default_camera") - - parameters = { - "fname" : data["source_file"], - - "sections" : sections_string, - - "bgcolor" : generate_vec3(DEFAULTS["bgcolor"]), - "bgalpha" : DEFAULTS["bgalpha"], - "defcamera" : generate_string(default_camera), - - "nobjects" : nobjects, - "ngeometries" : ngeometries, - "ntextures" : ntextures, - "nmaterials" : nmaterials, - - "position" : generate_vec3(DEFAULTS["position"]), - "rotation" : generate_vec3(DEFAULTS["rotation"]), - "scale" : generate_vec3(DEFAULTS["scale"]) - } - - text = TEMPLATE_SCENE_ASCII % parameters - - return text - -def export_scene(scene, filepath, flipyz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds): - - source_file = os.path.basename(bpy.data.filepath) - - scene_text = "" - data = { - "scene" : scene, - "objects" : scene.objects, - "embeds" : embeds, - "source_file" : source_file, - "filepath" : filepath, - "flipyz" : flipyz, - "use_colors" : option_colors, - "use_lights" : option_lights, - "use_cameras" : option_cameras, - "embed_meshes": option_embed_meshes - } - scene_text += generate_ascii_scene(data) - - write_file(filepath, scene_text) - -# ##################################################### -# Main -# ##################################################### - -def save(operator, context, filepath = "", - option_flip_yz = True, - option_vertices = True, - option_vertices_truncate = False, - option_faces = True, - option_normals = True, - option_edges = False, - option_uv_coords = True, - option_materials = True, - option_colors = True, - align_model = 0, - option_export_scene = False, - option_lights = False, - option_cameras = False, - option_scale = 1.0, - option_embed_meshes = True): - - filepath = ensure_extension(filepath, '.js') - - scene = context.scene - - if scene.objects.active: - bpy.ops.object.mode_set(mode='OBJECT') - - if option_export_scene: - - geo_set = set() - embeds = {} - - for obj in scene.objects: - if obj.type == "MESH" and obj.THREE_exportGeometry: - - # create extra copy of geometry with applied modifiers - # (if they exist) - - if len(obj.modifiers) > 0: - name = obj.name - - # otherwise can share geometry - - else: - name = obj.data.name - - if name not in geo_set: - - if option_embed_meshes: - - text, model_string = generate_mesh_string(obj, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - False, - option_flip_yz, - option_scale, - False) - - embeds[name] = model_string - - else: - - fname = generate_mesh_filename(name, filepath) - export_mesh(obj, scene, fname, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - False, - option_flip_yz, - option_scale, - False) - - geo_set.add(name) - - export_scene(scene, filepath, option_flip_yz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds) - - else: - - obj = context.object - if not obj: - raise Exception("Error, Select 1 active object or select 'export scene'") - - export_mesh(obj, scene, filepath, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - option_flip_yz, - option_scale, - True) - - - return {'FINISHED'} diff --git a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py deleted file mode 100644 index 79708689..00000000 --- a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py +++ /dev/null @@ -1,635 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# Based on import_obj.py -# Contributors: alteredq - - -""" -Blender importer for Three.js (ASCII JSON format). - -""" - -import os -import time -import json -import bpy -import mathutils -from mathutils.geometry import tesselate_polygon -from io_utils import load_image, unpack_list, unpack_face_list - -# ##################################################### -# Generators -# ##################################################### -def setColor(c, t): - c.r = t[0] - c.g = t[1] - c.b = t[2] - -def create_texture(filename, modelpath): - name = filename - texture = bpy.data.textures.new(name, type='IMAGE') - - image = load_image(filename, modelpath) - has_data = False - - if image: - texture.image = image - has_data = image.has_data - - return texture - -def create_materials(data, modelpath): - materials = [] - materials_data = data.get("materials", []) - - for i, m in enumerate(materials_data): - - name = m.get("DbgName", "material_%d" % i) - - colorAmbient = m.get("colorAmbient", None) - colorDiffuse = m.get("colorDiffuse", None) - colorSpecular = m.get("colorSpecular", None) - alpha = m.get("transparency", 1.0) - specular_hardness = m.get("specularCoef", 0) - - mapDiffuse = m.get("mapDiffuse", None) - mapLightmap = m.get("mapLightmap", None) - - vertexColorsType = m.get("vertexColors", False) - - useVertexColors = False - if vertexColorsType: - useVertexColors = True - - material = bpy.data.materials.new(name) - - material.THREE_useVertexColors = useVertexColors - - if colorDiffuse: - setColor(material.diffuse_color, colorDiffuse) - material.diffuse_intensity = 1.0 - - if colorSpecular: - setColor(material.specular_color, colorSpecular) - material.specular_intensity = 1.0 - - if alpha < 1.0: - material.alpha = alpha - material.use_transparency = True - - if specular_hardness: - material.specular_hardness = specular_hardness - - if mapDiffuse: - texture = create_texture(mapDiffuse, modelpath) - mtex = material.texture_slots.add() - mtex.texture = texture - mtex.texture_coords = 'UV' - mtex.use = True - mtex.use_map_color_diffuse = True - - material.active_texture = texture - - materials.append(material) - - return materials - -def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate_normals): - - faces = face_data["faces"] - vertexNormals = face_data["vertexNormals"] - vertexColors = face_data["vertexColors"] - vertexUVs = face_data["vertexUVs"] - faceMaterials = face_data["materials"] - faceColors = face_data["faceColors"] - - edges = [] - - # Create a new mesh - - me = bpy.data.meshes.new(name) - me.from_pydata(vertices, edges, faces) - - # Handle normals - - if not recalculate_normals: - me.update(calc_edges = True) - - if face_data["hasVertexNormals"]: - - print("setting vertex normals") - - for fi in range(len(faces)): - - if vertexNormals[fi]: - - #print("setting face %i with %i vertices" % (fi, len(normals[fi]))) - - # if me.update() is called after setting vertex normals - # setting face.use_smooth overrides these normals - # - this fixes weird shading artefacts (seems to come from sharing - # of vertices between faces, didn't find a way how to set vertex normals - # per face use of vertex as opposed to per vertex), - # - probably this just overrides all custom vertex normals - # - to preserve vertex normals from the original data - # call me.update() before setting them - - me.faces[fi].use_smooth = True - - if not recalculate_normals: - for j in range(len(vertexNormals[fi])): - - vertexNormal = vertexNormals[fi][j] - - x = vertexNormal[0] - y = vertexNormal[1] - z = vertexNormal[2] - - if flipYZ: - tmp = y - y = -z - z = tmp - - # flip normals (this make them look consistent with the original before export) - - #x = -x - #y = -y - #z = -z - - vi = me.faces[fi].vertices[j] - - me.vertices[vi].normal.x = x - me.vertices[vi].normal.y = y - me.vertices[vi].normal.z = z - - if recalculate_normals: - me.update(calc_edges = True) - - # Handle colors - - if face_data["hasVertexColors"]: - - print("setting vertex colors") - - me.vertex_colors.new("vertex_color_layer_0") - - for fi in range(len(faces)): - - if vertexColors[fi]: - - face_colors = me.vertex_colors[0].data[fi] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - - for vi in range(len(vertexColors[fi])): - - r = vertexColors[fi][vi][0] - g = vertexColors[fi][vi][1] - b = vertexColors[fi][vi][2] - - face_colors[vi].r = r - face_colors[vi].g = g - face_colors[vi].b = b - - elif face_data["hasFaceColors"]: - - print("setting vertex colors from face colors") - - me.vertex_colors.new("vertex_color_layer_0") - - for fi in range(len(faces)): - - if faceColors[fi]: - - r = faceColors[fi][0] - g = faceColors[fi][1] - b = faceColors[fi][2] - - face_colors = me.vertex_colors[0].data[fi] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - - for vi in range(len(faces[fi])): - - face_colors[vi].r = r - face_colors[vi].g = g - face_colors[vi].b = b - - # Handle uvs - - if face_data["hasVertexUVs"]: - - print("setting vertex uvs") - - for li, layer in enumerate(vertexUVs): - - me.uv_textures.new("uv_layer_%d" % li) - - for fi in range(len(faces)): - - if layer[fi]: - - uv_face = me.uv_textures[li].data[fi] - face_uvs = uv_face.uv1, uv_face.uv2, uv_face.uv3, uv_face.uv4 - - for vi in range(len(layer[fi])): - - u = layer[fi][vi][0] - v = layer[fi][vi][1] - - face_uvs[vi].x = u - face_uvs[vi].y = 1.0 - v - - active_texture = materials[faceMaterials[fi]].active_texture - - if active_texture: - uv_face.use_image = True - uv_face.image = active_texture.image - - - # Handle materials # 1 - - if face_data["hasMaterials"]: - - - print("setting materials (mesh)") - - for m in materials: - - me.materials.append(m) - - print("setting materials (faces)") - - for fi in range(len(faces)): - - if faceMaterials[fi] >= 0: - - me.faces[fi].material_index = faceMaterials[fi] - - # Create a new object - - ob = bpy.data.objects.new(name, me) - ob.data = me # link the mesh data to the object - - - scene = bpy.context.scene # get the current scene - scene.objects.link(ob) # link the object into the scene - - ob.location = scene.cursor_location # position object at 3d-cursor - - -# ##################################################### -# Faces -# ##################################################### - -def extract_faces(data): - - result = { - "faces" : [], - "materials" : [], - "faceUVs" : [], - "vertexUVs" : [], - "faceNormals" : [], - "vertexNormals" : [], - "faceColors" : [], - "vertexColors" : [], - - "hasVertexNormals" : False, - "hasVertexUVs" : False, - "hasVertexColors" : False, - "hasFaceColors" : False, - "hasMaterials" : False - } - - faces = data.get("faces", []) - normals = data.get("normals", []) - colors = data.get("colors", []) - - offset = 0 - zLength = len(faces) - - # disregard empty arrays - - nUvLayers = 0 - - for layer in data["uvs"]: - - if len(layer) > 0: - nUvLayers += 1 - result["faceUVs"].append([]) - result["vertexUVs"].append([]) - - - while ( offset < zLength ): - - type = faces[ offset ] - offset += 1 - - isQuad = isBitSet( type, 0 ) - hasMaterial = isBitSet( type, 1 ) - hasFaceUv = isBitSet( type, 2 ) - hasFaceVertexUv = isBitSet( type, 3 ) - hasFaceNormal = isBitSet( type, 4 ) - hasFaceVertexNormal = isBitSet( type, 5 ) - hasFaceColor = isBitSet( type, 6 ) - hasFaceVertexColor = isBitSet( type, 7 ) - - #print("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor) - - result["hasVertexUVs"] = result["hasVertexUVs"] or hasFaceVertexUv - result["hasVertexNormals"] = result["hasVertexNormals"] or hasFaceVertexNormal - result["hasVertexColors"] = result["hasVertexColors"] or hasFaceVertexColor - result["hasFaceColors"] = result["hasFaceColors"] or hasFaceColor - result["hasMaterials"] = result["hasMaterials"] or hasMaterial - - # vertices - - if isQuad: - - a = faces[ offset ] - offset += 1 - - b = faces[ offset ] - offset += 1 - - c = faces[ offset ] - offset += 1 - - d = faces[ offset ] - offset += 1 - - face = [a, b, c, d] - - nVertices = 4 - - else: - - a = faces[ offset ] - offset += 1 - - b = faces[ offset ] - offset += 1 - - c = faces[ offset ] - offset += 1 - - face = [a, b, c] - - nVertices = 3 - - result["faces"].append(face) - - # material - - if hasMaterial: - - materialIndex = faces[ offset ] - offset += 1 - - else: - - materialIndex = -1 - - result["materials"].append(materialIndex) - - # uvs - - for i in range(nUvLayers): - - faceUv = None - - if hasFaceUv: - - uvLayer = data["uvs"][ i ] - - uvIndex = faces[ offset ] - offset += 1 - - u = uvLayer[ uvIndex * 2 ] - v = uvLayer[ uvIndex * 2 + 1 ] - - faceUv = [u, v] - - result["faceUVs"][i].append(faceUv) - - - if hasFaceVertexUv: - - uvLayer = data["uvs"][ i ] - - vertexUvs = [] - - for j in range(nVertices): - - uvIndex = faces[ offset ] - offset += 1 - - u = uvLayer[ uvIndex * 2 ] - v = uvLayer[ uvIndex * 2 + 1 ] - - vertexUvs.append([u, v]) - - result["vertexUVs"][i].append(vertexUvs) - - - if hasFaceNormal: - - normalIndex = faces[ offset ] * 3 - offset += 1 - - x = normals[ normalIndex ] - y = normals[ normalIndex + 1 ] - z = normals[ normalIndex + 2 ] - - faceNormal = [x, y, z] - - else: - - faceNormal = None - - result["faceNormals"].append(faceNormal) - - - if hasFaceVertexNormal: - - vertexNormals = [] - - for j in range(nVertices): - - normalIndex = faces[ offset ] * 3 - offset += 1 - - x = normals[ normalIndex ] - y = normals[ normalIndex + 1 ] - z = normals[ normalIndex + 2 ] - - vertexNormals.append( [x, y, z] ) - - - else: - - vertexNormals = None - - result["vertexNormals"].append(vertexNormals) - - - if hasFaceColor: - - colorIndex = faces[ offset ] - offset += 1 - - faceColor = hexToTuple( colors[ colorIndex ] ) - - else: - - faceColor = None - - result["faceColors"].append(faceColor) - - - if hasFaceVertexColor: - - vertexColors = [] - - for j in range(nVertices): - - colorIndex = faces[ offset ] - offset += 1 - - color = hexToTuple( colors[ colorIndex ] ) - vertexColors.append( color ) - - else: - - vertexColors = None - - result["vertexColors"].append(vertexColors) - - - return result - -# ##################################################### -# Utils -# ##################################################### - -def hexToTuple( hexColor ): - r = (( hexColor >> 16 ) & 0xff) / 255.0 - g = (( hexColor >> 8 ) & 0xff) / 255.0 - b = ( hexColor & 0xff) / 255.0 - return (r, g, b) - -def isBitSet(value, position): - return value & ( 1 << position ) - -def splitArray(data, chunkSize): - result = [] - chunk = [] - for i in range(len(data)): - if i > 0 and i % chunkSize == 0: - result.append(chunk) - chunk = [] - chunk.append(data[i]) - result.append(chunk) - return result - - -def extract_json_string(text): - marker_begin = "var model =" - marker_end = "postMessage" - - start = text.find(marker_begin) + len(marker_begin) - end = text.find(marker_end) - end = text.rfind("}", start, end) - return text[start:end+1].strip() - -def get_name(filepath): - return os.path.splitext(os.path.basename(filepath))[0] - -def get_path(filepath): - return os.path.dirname(filepath) - -# ##################################################### -# Parser -# ##################################################### - -def load(operator, context, filepath, option_flip_yz = True, recalculate_normals = True): - - print('\nimporting %r' % filepath) - - time_main = time.time() - - print("\tparsing JSON file...") - - time_sub = time.time() - - file = open(filepath, 'rU') - rawcontent = file.read() - file.close() - - json_string = extract_json_string(rawcontent) - data = json.loads( json_string ) - - time_new = time.time() - - print('parsing %.4f sec' % (time_new - time_sub)) - - time_sub = time_new - - # flip YZ - - vertices = splitArray(data["vertices"], 3) - - if option_flip_yz: - vertices[:] = [(v[0], -v[2], v[1]) for v in vertices] - - # extract faces - - face_data = extract_faces(data) - - # deselect all - - bpy.ops.object.select_all(action='DESELECT') - - nfaces = len(face_data["faces"]) - nvertices = len(vertices) - nnormals = len(data.get("normals", [])) / 3 - ncolors = len(data.get("colors", [])) / 3 - nuvs = len(data.get("uvs", [])) / 2 - nmaterials = len(data.get("materials", [])) - - print('\tbuilding geometry...\n\tfaces:%i, vertices:%i, vertex normals: %i, vertex uvs: %i, vertex colors: %i, materials: %i ...' % ( - nfaces, nvertices, nnormals, nuvs, ncolors, nmaterials )) - - # Create materials - - materials = create_materials(data, get_path(filepath)) - - # Create new obj - - create_mesh_object(get_name(filepath), vertices, materials, face_data, option_flip_yz, recalculate_normals) - - scene = bpy.context.scene - scene.update() - - time_new = time.time() - - print('finished importing: %r in %.4f sec.' % (filepath, (time_new - time_main))) - return {'FINISHED'} - - -if __name__ == "__main__": - register() diff --git a/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/__init__.py b/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/__init__.py deleted file mode 100644 index de10b4ee..00000000 --- a/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/__init__.py +++ /dev/null @@ -1,388 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# ################################################################ -# Init -# ################################################################ - -# To support reload properly, try to access a package var, -# if it's there, reload everything - -bl_info = { - "name": "three.js format", - "author": "mrdoob, kikko, alteredq, remoe, pxf", - "version": (1, 0, 1), - "blender": (2, 5, 7), - "api": 35622, - "location": "File > Import-Export", - "description": "Import-Export three.js meshes", - "warning": "", - "wiki_url": "https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender", - "tracker_url": "https://github.com/mrdoob/three.js/issues", - "category": "Import-Export"} - -if "bpy" in locals(): - import imp - if "export_threejs" in locals(): - imp.reload(export_threejs) - if "import_threejs" in locals(): - imp.reload(import_threejs) - -import bpy -from bpy.props import * -from io_utils import ExportHelper, ImportHelper - -# ################################################################ -# Custom properties -# ################################################################ - -bpy.types.Object.THREE_castsShadow = bpy.props.BoolProperty() -bpy.types.Object.THREE_meshCollider = bpy.props.BoolProperty() -bpy.types.Object.THREE_exportGeometry = bpy.props.BoolProperty(default = True) - -THREE_trigger_types = [("None", "None", "None"), ("Small", "Small", "Small"), ("Large", "Large", "Large")] -bpy.types.Object.THREE_triggerType = EnumProperty(name = "Trigger type", description = "Trigger type", items = THREE_trigger_types, default = "None") - -bpy.types.Material.THREE_useVertexColors = bpy.props.BoolProperty() - -THREE_material_types = [("Basic", "Basic", "Basic"), ("Phong", "Phong", "Phong"), ("Lambert", "Lambert", "Lambert")] -bpy.types.Material.THREE_materialType = EnumProperty(name = "Material type", description = "Material type", items = THREE_material_types, default = "Lambert") - -class OBJECT_PT_hello( bpy.types.Panel ): - - bl_label = "THREE" - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "object" - - def draw(self, context): - layout = self.layout - obj = context.object - - row = layout.row() - row.label(text="Selected object: " + obj.name ) - - row = layout.row() - row.prop( obj, "THREE_exportGeometry", text="Export geometry" ) - - row = layout.row() - row.prop( obj, "THREE_castsShadow", text="Casts shadow" ) - - row = layout.row() - row.prop( obj, "THREE_meshCollider", text="Mesh collider" ) - - row = layout.row() - row.prop( obj, "THREE_triggerType", text="Trigger type" ) - - -class MATERIAL_PT_hello( bpy.types.Panel ): - - bl_label = "THREE" - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "material" - - def draw(self, context): - layout = self.layout - mat = context.material - - row = layout.row() - row.label(text="Selected material: " + mat.name ) - - row = layout.row() - row.prop( mat, "THREE_materialType", text="Material type" ) - - row = layout.row() - row.prop( mat, "THREE_useVertexColors", text="Use vertex colors" ) - - -# ################################################################ -# Importer -# ################################################################ - -class ImportTHREEJS(bpy.types.Operator, ImportHelper): - '''Load a Three.js ASCII JSON model''' - - bl_idname = "import.threejs" - bl_label = "Import Three.js" - - filename_ext = ".js" - filter_glob = StringProperty(default="*.js", options={'HIDDEN'}) - - option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True) - recalculate_normals = BoolProperty(name="Recalculate normals", description="Recalculate vertex normals", default=True) - - def execute(self, context): - import io_mesh_threejs.import_threejs - return io_mesh_threejs.import_threejs.load(self, context, **self.properties) - - - def draw(self, context): - layout = self.layout - - row = layout.row() - row.prop(self.properties, "option_flip_yz") - - row = layout.row() - row.prop(self.properties, "recalculate_normals") - - -# ################################################################ -# Exporter - settings -# ################################################################ - -SETTINGS_FILE_EXPORT = "threejs_settings_export.js" - -import os -import json - -def file_exists(filename): - """Return true if file exists and accessible for reading. - - Should be safer than just testing for existence due to links and - permissions magic on Unix filesystems. - - @rtype: boolean - """ - - try: - f = open(filename, 'r') - f.close() - return True - except IOError: - return False - -def get_settings_fullpath(): - return os.path.join(bpy.app.tempdir, SETTINGS_FILE_EXPORT) - -def save_settings_export(properties): - - settings = { - "option_export_scene" : properties.option_export_scene, - "option_embed_meshes" : properties.option_embed_meshes, - "option_url_base_html" : properties.option_url_base_html, - "option_copy_textures" : properties.option_copy_textures, - - "option_lights" : properties.option_lights, - "option_cameras" : properties.option_cameras, - - "option_flip_yz" : properties.option_flip_yz, - - "option_materials" : properties.option_materials, - "option_normals" : properties.option_normals, - "option_colors" : properties.option_colors, - "option_uv_coords" : properties.option_uv_coords, - "option_edges" : properties.option_edges, - "option_faces" : properties.option_faces, - "option_vertices" : properties.option_vertices, - - "option_vertices_truncate" : properties.option_vertices_truncate, - "option_scale" : properties.option_scale, - - "align_model" : properties.align_model - } - - fname = get_settings_fullpath() - f = open(fname, "w") - json.dump(settings, f) - -def restore_settings_export(properties): - - settings = {} - - fname = get_settings_fullpath() - if file_exists(fname): - f = open(fname, "r") - settings = json.load(f) - - properties.option_vertices = settings.get("option_vertices", True) - properties.option_vertices_truncate = settings.get("option_vertices_truncate", False) - properties.option_faces = settings.get("option_faces", True) - properties.option_normals = settings.get("option_normals", True) - properties.option_edges = settings.get("option_edges", False) - - properties.option_colors = settings.get("option_colors", True) - properties.option_uv_coords = settings.get("option_uv_coords", True) - properties.option_materials = settings.get("option_materials", True) - - properties.align_model = settings.get("align_model", "None") - - properties.option_scale = settings.get("option_scale", 1.0) - properties.option_flip_yz = settings.get("option_flip_yz", True) - - properties.option_export_scene = settings.get("option_export_scene", False) - properties.option_embed_meshes = settings.get("option_embed_meshes", True) - properties.option_url_base_html = settings.get("option_url_base_html", False) - properties.option_copy_textures = settings.get("option_copy_textures", False) - - properties.option_lights = settings.get("option_lights", False) - properties.option_cameras = settings.get("option_cameras", False) - -# ################################################################ -# Exporter -# ################################################################ - -class ExportTHREEJS(bpy.types.Operator, ExportHelper): - '''Export selected object / scene for Three.js (ASCII JSON format).''' - - bl_idname = "export.threejs" - bl_label = "Export Three.js" - - filename_ext = ".js" - - option_vertices = BoolProperty(name = "Vertices", description = "Export vertices", default = True) - option_vertices_deltas = BoolProperty(name = "Deltas", description = "Delta vertices", default = False) - option_vertices_truncate = BoolProperty(name = "Truncate", description = "Truncate vertices", default = False) - - option_faces = BoolProperty(name = "Faces", description = "Export faces", default = True) - option_faces_deltas = BoolProperty(name = "Deltas", description = "Delta faces", default = False) - - option_normals = BoolProperty(name = "Normals", description = "Export normals", default = True) - option_edges = BoolProperty(name = "Edges", description = "Export edges", default = False) - - option_colors = BoolProperty(name = "Colors", description = "Export vertex colors", default = True) - option_uv_coords = BoolProperty(name = "UVs", description = "Export texture coordinates", default = True) - option_materials = BoolProperty(name = "Materials", description = "Export materials", default = True) - - align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")] - align_model = EnumProperty(name = "Align model", description = "Align model", items = align_types, default = "None") - - option_scale = FloatProperty(name = "Scale", description = "Scale vertices", min = 0.01, max = 1000.0, soft_min = 0.01, soft_max = 1000.0, default = 1.0) - option_flip_yz = BoolProperty(name = "Flip YZ", description = "Flip YZ", default = True) - - option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False) - option_embed_meshes = BoolProperty(name = "Embed", description = "Embed meshes", default = True) - option_copy_textures = BoolProperty(name = "Copy textures", description = "Copy textures", default = False) - option_url_base_html = BoolProperty(name = "HTML as url base", description = "Use HTML as url base ", default = False) - - option_lights = BoolProperty(name = "Lights", description = "Export default scene lights", default = False) - option_cameras = BoolProperty(name = "Cameras", description = "Export default scene cameras", default = False) - - def invoke(self, context, event): - restore_settings_export(self.properties) - return ExportHelper.invoke(self, context, event) - - @classmethod - def poll(cls, context): - return context.active_object != None - - def execute(self, context): - print("Selected: " + context.active_object.name) - - if not self.properties.filepath: - raise Exception("filename not set") - - save_settings_export(self.properties) - - filepath = self.filepath - - import io_mesh_threejs.export_threejs - return io_mesh_threejs.export_threejs.save(self, context, **self.properties) - - def draw(self, context): - layout = self.layout - - row = layout.row() - row.label(text="Geometry:") - - row = layout.row() - row.prop(self.properties, "option_vertices") - # row = layout.row() - # row.enabled = self.properties.option_vertices - # row.prop(self.properties, "option_vertices_deltas") - row.prop(self.properties, "option_vertices_truncate") - layout.separator() - - row = layout.row() - row.prop(self.properties, "option_faces") - row = layout.row() - row.enabled = self.properties.option_faces - # row.prop(self.properties, "option_faces_deltas") - layout.separator() - - row = layout.row() - row.prop(self.properties, "option_normals") - layout.separator() - - row = layout.row() - row.prop(self.properties, "option_edges") - layout.separator() - - row = layout.row() - row.label(text="Materials:") - - row = layout.row() - row.prop(self.properties, "option_uv_coords") - row.prop(self.properties, "option_colors") - row = layout.row() - row.prop(self.properties, "option_materials") - layout.separator() - - row = layout.row() - row.label(text="Settings:") - - row = layout.row() - row.prop(self.properties, "align_model") - row = layout.row() - row.prop(self.properties, "option_flip_yz") - row.prop(self.properties, "option_scale") - layout.separator() - - row = layout.row() - row.label(text="Beta:") - - row = layout.row() - row.prop(self.properties, "option_export_scene") - - row = layout.row() - row.prop(self.properties, "option_lights") - row.prop(self.properties, "option_cameras") - - row = layout.row() - row.prop(self.properties, "option_embed_meshes") - row.prop(self.properties, "option_copy_textures") - - row = layout.row() - row.prop(self.properties, "option_url_base_html") - - layout.separator() - - -# ################################################################ -# Common -# ################################################################ - -def menu_func_export(self, context): - default_path = bpy.data.filepath.replace(".blend", ".js") - self.layout.operator(ExportTHREEJS.bl_idname, text="Three.js (.js)").filepath = default_path - -def menu_func_import(self, context): - self.layout.operator(ImportTHREEJS.bl_idname, text="Three.js (.js)") - -def register(): - bpy.utils.register_module(__name__) - bpy.types.INFO_MT_file_export.append(menu_func_export) - bpy.types.INFO_MT_file_import.append(menu_func_import) - -def unregister(): - bpy.utils.unregister_module(__name__) - bpy.types.INFO_MT_file_export.remove(menu_func_export) - bpy.types.INFO_MT_file_import.remove(menu_func_import) - -if __name__ == "__main__": - register() diff --git a/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/export_threejs.py b/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/export_threejs.py deleted file mode 100644 index b456e926..00000000 --- a/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/export_threejs.py +++ /dev/null @@ -1,1781 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -""" -Blender exporter for Three.js (ASCII JSON format). - -TODO - - binary format -""" - -import bpy -import mathutils - -import shutil -import os -import os.path -import math -import operator -import random - -# ##################################################### -# Configuration -# ##################################################### - -DEFAULTS = { -"bgcolor" : [0, 0, 0], -"bgalpha" : 1.0, - -"position" : [0, 0, 0], -"rotation" : [-math.pi/2, 0, 0], -"scale" : [1, 1, 1], - -"camera" : - { - "name" : "default_camera", - "type" : "perspective", - "near" : 1, - "far" : 10000, - "fov" : 60, - "aspect": 1.333, - "position" : [0, 0, 10], - "target" : [0, 0, 0] - }, - -"light" : - { - "name" : "default_light", - "type" : "directional", - "direction" : [0, 1, 1], - "color" : [1, 1, 1], - "intensity" : 0.8 - } -} - -# default colors for debugging (each material gets one distinct color): -# white, red, green, blue, yellow, cyan, magenta -COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee] - - -# ##################################################### -# Templates - scene -# ##################################################### - -TEMPLATE_SCENE_ASCII = """\ -/* Converted from: %(fname)s - * - * File generated with Blender 2.57 Exporter - * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/ - * - * objects: %(nobjects)s - * geometries: %(ngeometries)s - * materials: %(nmaterials)s - * textures: %(ntextures)s - */ - -var scene = { - -"type" : "scene", -"urlBaseType" : %(basetype)s, - -%(sections)s - -"transform" : -{ - "position" : %(position)s, - "rotation" : %(rotation)s, - "scale" : %(scale)s -}, - -"defaults" : -{ - "bgcolor" : %(bgcolor)s, - "bgalpha" : %(bgalpha)f, - "camera" : %(defcamera)s -} - -} - -postMessage( scene ); -close(); -""" - -TEMPLATE_SECTION = """ -"%s" : -{ -%s -}, -""" - -TEMPLATE_OBJECT = """\ - %(object_id)s : { - "geometry" : %(geometry_id)s, - "groups" : [ %(group_id)s ], - "materials" : [ %(material_id)s ], - "position" : %(position)s, - "rotation" : %(rotation)s, - "quaternion": %(quaternion)s, - "scale" : %(scale)s, - "visible" : %(visible)s, - "castsShadow" : %(castsShadow)s, - "meshCollider" : %(meshCollider)s, - "trigger" : %(trigger)s - }""" - -TEMPLATE_EMPTY = """\ - %(object_id)s : { - "groups" : [ %(group_id)s ], - "position" : %(position)s, - "rotation" : %(rotation)s, - "quaternion": %(quaternion)s, - "scale" : %(scale)s, - "trigger" : %(trigger)s - }""" - -TEMPLATE_GEOMETRY_LINK = """\ - %(geometry_id)s : { - "type" : "ascii_mesh", - "url" : %(model_file)s - }""" - -TEMPLATE_GEOMETRY_EMBED = """\ - %(geometry_id)s : { - "type" : "embedded_mesh", - "id" : %(embed_id)s - }""" - -TEMPLATE_TEXTURE = """\ - %(texture_id)s : { - "url": %(texture_file)s%(extras)s - }""" - -TEMPLATE_MATERIAL_SCENE = """\ - %(material_id)s : { - "type": %(type)s, - "parameters": { %(parameters)s } - }""" - -TEMPLATE_CAMERA_PERSPECTIVE = """\ - %(camera_id)s : { - "type" : "perspective", - "fov" : %(fov)f, - "aspect": %(aspect)f, - "near" : %(near)f, - "far" : %(far)f, - "position": %(position)s, - "target" : %(target)s - }""" - -TEMPLATE_CAMERA_ORTHO = """\ - %(camera_id)s: { - "type" : "ortho", - "left" : %(left)f, - "right" : %(right)f, - "top" : %(top)f, - "bottom": %(bottom)f, - "near" : %(near)f, - "far" : %(far)f, - "position": %(position)s, - "target" : %(target)s - }""" - -TEMPLATE_LIGHT_DIRECTIONAL = """\ - %(light_id)s: { - "type" : "directional", - "direction" : %(direction)s, - "color" : %(color)d, - "intensity" : %(intensity).2f - }""" - -TEMPLATE_LIGHT_POINT = """\ - %(light_id)s: { - "type" : "point", - "position" : %(position)s, - "color" : %(color)d, - "intensity" : %(intensity).3f - }""" - -TEMPLATE_VEC4 = '[ %f, %f, %f, %f ]' -TEMPLATE_VEC3 = '[ %f, %f, %f ]' -TEMPLATE_VEC2 = '[ %f, %f ]' -TEMPLATE_STRING = '"%s"' -TEMPLATE_HEX = "0x%06x" - -# ##################################################### -# Templates - model -# ##################################################### - -TEMPLATE_FILE_ASCII = """\ -/* - * File generated with Blender 2.57 Exporter - * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/ - * - * vertices: %(nvertex)d - * faces: %(nface)d - * normals: %(nnormal)d - * uvs: %(nuv)d - * colors: %(ncolor)d - * materials: %(nmaterial)d - * edges: %(nedges)d - * - */ - -var model = { - -%(model)s - -}; - -postMessage( model ); -close(); -""" - -TEMPLATE_MODEL_ASCII = """\ - "version" : 2, - - "scale" : %(scale)f, - - "materials": [%(materials)s], - - "vertices": [%(vertices)s], - - "morphTargets": [], - - "normals": [%(normals)s], - - "colors": [%(colors)s], - - "uvs": [[%(uvs)s]], - - "faces": [%(faces)s], - - "edges" : [%(edges)s] -""" - -TEMPLATE_VERTEX = "%f,%f,%f" -TEMPLATE_VERTEX_TRUNCATE = "%d,%d,%d" - -TEMPLATE_N = "%f,%f,%f" -TEMPLATE_UV = "%f,%f" -#TEMPLATE_C = "0x%06x" -TEMPLATE_C = "%d" -TEMPLATE_EDGE = "%d,%d" - -# ##################################################### -# Utils -# ##################################################### - -def veckey3(x,y,z): - return round(x, 6), round(y, 6), round(z, 6) - -def veckey3d(v): - return veckey3(v.x, v.y, v.z) - -def veckey2d(v): - return round(v[0], 6), round(v[1], 6) - -def get_normal_indices(v, normals, mesh): - n = [] - mv = mesh.vertices - - for i in v: - normal = mv[i].normal - key = veckey3d(normal) - - n.append( normals[key] ) - - return n - -def get_uv_indices(face_index, uvs, mesh): - uv = [] - uv_layer = mesh.uv_textures.active.data - for i in uv_layer[face_index].uv: - uv.append( uvs[veckey2d(i)] ) - return uv - -def get_color_indices(face_index, colors, mesh): - c = [] - color_layer = mesh.vertex_colors.active.data - face_colors = color_layer[face_index] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - for i in face_colors: - c.append( colors[hexcolor(i)] ) - return c - -def rgb2int(rgb): - color = (int(rgb[0]*255) << 16) + (int(rgb[1]*255) << 8) + int(rgb[2]*255); - return color - -# ##################################################### -# Utils - files -# ##################################################### - -def write_file(fname, content): - out = open(fname, "w") - out.write(content) - out.close() - -def ensure_folder_exist(foldername): - """Create folder (with whole path) if it doesn't exist yet.""" - - if not os.access(foldername, os.R_OK|os.W_OK|os.X_OK): - os.makedirs(foldername) - -def ensure_extension(filepath, extension): - if not filepath.lower().endswith(extension): - filepath += extension - return filepath - -def generate_mesh_filename(meshname, filepath): - normpath = os.path.normpath(filepath) - path, ext = os.path.splitext(normpath) - return "%s.%s%s" % (path, meshname, ext) - - -# ##################################################### -# Utils - alignment -# ##################################################### - -def bbox(vertices): - """Compute bounding box of vertex array. - """ - - if len(vertices)>0: - minx = maxx = vertices[0].co.x - miny = maxy = vertices[0].co.y - minz = maxz = vertices[0].co.z - - for v in vertices[1:]: - if v.co.x < minx: - minx = v.co.x - elif v.co.x > maxx: - maxx = v.co.x - - if v.co.y < miny: - miny = v.co.y - elif v.co.y > maxy: - maxy = v.co.y - - if v.co.z < minz: - minz = v.co.z - elif v.co.z > maxz: - maxz = v.co.z - - return { 'x':[minx,maxx], 'y':[miny,maxy], 'z':[minz,maxz] } - - else: - return { 'x':[0,0], 'y':[0,0], 'z':[0,0] } - -def translate(vertices, t): - """Translate array of vertices by vector t. - """ - - for i in range(len(vertices)): - vertices[i].co.x += t[0] - vertices[i].co.y += t[1] - vertices[i].co.z += t[2] - -def center(vertices): - """Center model (middle of bounding box). - """ - - bb = bbox(vertices) - - cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0 - cy = bb['y'][0] + (bb['y'][1] - bb['y'][0])/2.0 - cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0 - - translate(vertices, [-cx,-cy,-cz]) - -def top(vertices): - """Align top of the model with the floor (Y-axis) and center it around X and Z. - """ - - bb = bbox(vertices) - - cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0 - cy = bb['y'][1] - cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0 - - translate(vertices, [-cx,-cy,-cz]) - -def bottom(vertices): - """Align bottom of the model with the floor (Y-axis) and center it around X and Z. - """ - - bb = bbox(vertices) - - cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0 - cy = bb['y'][0] - cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0 - - translate(vertices, [-cx,-cy,-cz]) - -# ##################################################### -# Elements rendering -# ##################################################### - -def hexcolor(c): - return ( int(c[0] * 255) << 16 ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255) - -def generate_vertices(vertices, option_vertices_truncate, option_vertices): - if not option_vertices: - return "" - - return ",".join(generate_vertex(v, option_vertices_truncate) for v in vertices) - -def generate_vertex(v, option_vertices_truncate): - if not option_vertices_truncate: - return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z) - else: - return TEMPLATE_VERTEX_TRUNCATE % (v.co.x, v.co.y, v.co.z) - -def generate_normal(n): - return TEMPLATE_N % (n[0], n[1], n[2]) - -def generate_vertex_color(c): - return TEMPLATE_C % c - -def generate_uv(uv): - return TEMPLATE_UV % (uv[0], 1.0 - uv[1]) - -def generate_edge(e): - return TEMPLATE_EDGE % (e.vertices[0], e.vertices[1]) - -# ##################################################### -# Model exporter - faces -# ##################################################### - -def setBit(value, position, on): - if on: - mask = 1 << position - return (value | mask) - else: - mask = ~(1 << position) - return (value & mask) - -def generate_faces(normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz, option_faces): - if not option_faces: - return "" - - return ",".join(generate_face(f, i, normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz) for i, f in enumerate(mesh.faces)) - -def generate_face(f, faceIndex, normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz): - isTriangle = ( len(f.vertices) == 3 ) - - if isTriangle: - nVertices = 3 - else: - nVertices = 4 - - hasMaterial = option_materials - - hasFaceUvs = False # not supported in Blender - hasFaceVertexUvs = option_uv_coords - - hasFaceNormals = False # don't export any face normals (as they are computed in engine) - hasFaceVertexNormals = option_normals - - hasFaceColors = False # not supported in Blender - hasFaceVertexColors = option_colors - - faceType = 0 - faceType = setBit(faceType, 0, not isTriangle) - faceType = setBit(faceType, 1, hasMaterial) - faceType = setBit(faceType, 2, hasFaceUvs) - faceType = setBit(faceType, 3, hasFaceVertexUvs) - faceType = setBit(faceType, 4, hasFaceNormals) - faceType = setBit(faceType, 5, hasFaceVertexNormals) - faceType = setBit(faceType, 6, hasFaceColors) - faceType = setBit(faceType, 7, hasFaceVertexColors) - - faceData = [] - - # order is important, must match order in JSONLoader - - # face type - # vertex indices - # material index - # face uvs index - # face vertex uvs indices - # face color index - # face vertex colors indices - - faceData.append(faceType) - - # must clamp in case on polygons bigger than quads - - for i in range(nVertices): - index = f.vertices[i] - faceData.append(index) - - if hasMaterial: - faceData.append( f.material_index ) - - if hasFaceVertexUvs: - uv = get_uv_indices(faceIndex, uvs, mesh) - for i in range(nVertices): - index = uv[i] - faceData.append(index) - - if hasFaceVertexNormals: - n = get_normal_indices(f.vertices, normals, mesh) - for i in range(nVertices): - index = n[i] - faceData.append(index) - - if hasFaceVertexColors: - c = get_color_indices(faceIndex, colors, mesh) - for i in range(nVertices): - index = c[i] - faceData.append(index) - - return ",".join( map(str, faceData) ) - - -# ##################################################### -# Model exporter - normals -# ##################################################### - -def extract_vertex_normals(mesh, option_normals): - if not option_normals: - return {}, 0 - - count = 0 - normals = {} - - for f in mesh.faces: - for v in f.vertices: - - normal = mesh.vertices[v].normal - key = veckey3d(normal) - - if key not in normals: - normals[key] = count - count += 1 - - return normals, count - -def generate_normals(normals, option_normals): - if not option_normals: - return "" - - chunks = [] - for key, index in sorted(normals.items(), key = operator.itemgetter(1)): - chunks.append(key) - - return ",".join(generate_normal(n) for n in chunks) - -# ##################################################### -# Model exporter - vertex colors -# ##################################################### - -def extract_vertex_colors(mesh, option_colors): - - if not option_colors: - return {}, 0 - - count = 0 - colors = {} - - color_layer = mesh.vertex_colors.active.data - - for face_index, face in enumerate(mesh.faces): - - face_colors = color_layer[face_index] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - - for c in face_colors: - key = hexcolor(c) - if key not in colors: - colors[key] = count - count += 1 - - return colors, count - -def generate_vertex_colors(colors, option_colors): - if not option_colors: - return "" - - chunks = [] - for key, index in sorted(colors.items(), key=operator.itemgetter(1)): - chunks.append(key) - - return ",".join(generate_vertex_color(c) for c in chunks) - -# ##################################################### -# Model exporter - UVs -# ##################################################### - -def extract_uvs(mesh, option_uv_coords): - - if not option_uv_coords: - return {}, 0 - - count = 0 - uvs = {} - - uv_layer = mesh.uv_textures.active.data - - for face_index, face in enumerate(mesh.faces): - - for uv_index, uv in enumerate(uv_layer[face_index].uv): - - key = veckey2d(uv) - if key not in uvs: - uvs[key] = count - count += 1 - - return uvs, count - -def generate_uvs(uvs, option_uv_coords): - if not option_uv_coords: - return "" - - chunks = [] - for key, index in sorted(uvs.items(), key=operator.itemgetter(1)): - chunks.append(key) - - return ",".join(generate_uv(n) for n in chunks) - -# ##################################################### -# Model exporter - materials -# ##################################################### - -def generate_color(i): - """Generate hex color corresponding to integer. - - Colors should have well defined ordering. - First N colors are hardcoded, then colors are random - (must seed random number generator with deterministic value - before getting colors). - """ - - if i < len(COLORS): - #return "0x%06x" % COLORS[i] - return COLORS[i] - else: - #return "0x%06x" % int(0xffffff * random.random()) - return int(0xffffff * random.random()) - -def generate_mtl(materials): - """Generate dummy materials. - """ - - mtl = {} - for m in materials: - index = materials[m] - mtl[m] = { - "DbgName": m, - "DbgIndex": index, - "DbgColor": generate_color(index), - "vertexColors" : False - } - return mtl - -def value2string(v): - if type(v) == str and v[0:2] != "0x": - return '"%s"' % v - elif type(v) == bool: - return str(v).lower() - elif type(v) == list: - return "[%s]" % (", ".join(value2string(x) for x in v)) - return str(v) - -def generate_materials(mtl, materials, draw_type): - """Generate JS array of materials objects - """ - - mtl_array = [] - for m in mtl: - index = materials[m] - - # add debug information - # materials should be sorted according to how - # they appeared in OBJ file (for the first time) - # this index is identifier used in face definitions - mtl[m]['DbgName'] = m - mtl[m]['DbgIndex'] = index - mtl[m]['DbgColor'] = generate_color(index) - - if draw_type in [ "BOUNDS", "WIRE" ]: - mtl[m]['wireframe'] = True - mtl[m]['DbgColor'] = 0xff0000 - - mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())]) - mtl_string = "\t{\n%s\n\t}" % mtl_raw - mtl_array.append([index, mtl_string]) - - return ",\n\n".join([m for i,m in sorted(mtl_array)]), len(mtl_array) - -def extract_materials(mesh, scene, option_colors, option_copy_textures, filepath): - world = scene.world - - materials = {} - for m in mesh.materials: - if m: - materials[m.name] = {} - material = materials[m.name] - - material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0], - m.diffuse_intensity * m.diffuse_color[1], - m.diffuse_intensity * m.diffuse_color[2]] - - material['colorSpecular'] = [m.specular_intensity * m.specular_color[0], - m.specular_intensity * m.specular_color[1], - m.specular_intensity * m.specular_color[2]] - - world_ambient_color = [0, 0, 0] - if world: - world_ambient_color = world.ambient_color - - material['colorAmbient'] = [m.ambient * world_ambient_color[0], - m.ambient * world_ambient_color[1], - m.ambient * world_ambient_color[2]] - - material['transparency'] = m.alpha - - # not sure about mapping values to Blinn-Phong shader - # Blender uses INT from [1, 511] with default 0 - # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness - - material["specularCoef"] = m.specular_hardness - - textures = guess_material_textures(m) - - handle_texture('diffuse', textures, material, filepath, option_copy_textures) - handle_texture('light', textures, material, filepath, option_copy_textures) - handle_texture('normal', textures, material, filepath, option_copy_textures) - - material["vertexColors"] = m.THREE_useVertexColors and option_colors - - # can't really use this reliably to tell apart Phong from Lambert - # as Blender defaults to non-zero specular color - #if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0): - # material['shading'] = "Phong" - #else: - # material['shading'] = "Lambert" - - material['shading'] = m.THREE_materialType - - return materials - -def generate_materials_string(mesh, scene, option_colors, draw_type, option_copy_textures, filepath): - - random.seed(42) # to get well defined color order for debug materials - - materials = {} - if mesh.materials: - for i, m in enumerate(mesh.materials): - if m: - materials[m.name] = i - else: - materials["undefined_dummy_%0d" % i] = i - - - if not materials: - materials = { 'default':0 } - - # default dummy materials - - mtl = generate_mtl(materials) - - # extract real materials from the mesh - - mtl.update(extract_materials(mesh, scene, option_colors, option_copy_textures, filepath)) - - return generate_materials(mtl, materials, draw_type) - -def handle_texture(id, textures, material, filepath, option_copy_textures): - - if textures[id]: - texName = 'map%s' % id.capitalize() - repeatName = 'map%sRepeat' % id.capitalize() - wrapName = 'map%sWrap' % id.capitalize() - - slot = textures[id]['slot'] - texture = textures[id]['texture'] - image = texture.image - fname = extract_texture_filename(image) - material[texName] = fname - - if option_copy_textures: - save_image(image, fname, filepath) - - if texture.repeat_x != 1 or texture.repeat_y != 1: - material[repeatName] = [texture.repeat_x, texture.repeat_y] - - if texture.extension == "REPEAT": - wrap_x = "repeat" - wrap_y = "repeat" - - if texture.use_mirror_x: - wrap_x = "mirror" - if texture.use_mirror_y: - wrap_y = "mirror" - - material[wrapName] = [wrap_x, wrap_y] - - if slot.use_map_normal: - if slot.normal_factor != 1.0: - material['mapNormalFactor'] = slot.normal_factor - - -# ##################################################### -# ASCII model generator -# ##################################################### - -def generate_ascii_model(mesh, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - draw_type, - option_copy_textures, - filepath): - - vertices = mesh.vertices[:] - - if align_model == 1: - center(vertices) - elif align_model == 2: - bottom(vertices) - elif align_model == 3: - top(vertices) - - normals, nnormal = extract_vertex_normals(mesh, option_normals) - colors, ncolor = extract_vertex_colors(mesh, option_colors) - uvs, nuv = extract_uvs(mesh, option_uv_coords) - - materials_string = "" - nmaterial = 0 - - edges_string = "" - nedges = 0 - - if option_materials: - materials_string, nmaterial = generate_materials_string(mesh, scene, option_colors, draw_type, option_copy_textures, filepath) - - if option_edges: - nedges = len(mesh.edges) - edges_string = ",".join(generate_edge(e) for e in mesh.edges) - - model_string = TEMPLATE_MODEL_ASCII % { - "scale" : option_scale, - - "uvs" : generate_uvs(uvs, option_uv_coords), - "normals" : generate_normals(normals, option_normals), - "colors" : generate_vertex_colors(colors, option_colors), - - "materials" : materials_string, - - "vertices" : generate_vertices(vertices, option_vertices_truncate, option_vertices), - - "faces" : generate_faces(normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz, option_faces), - - "edges" : edges_string - } - - text = TEMPLATE_FILE_ASCII % { - "nvertex" : len(mesh.vertices), - "nface" : len(mesh.faces), - "nuv" : nuv, - "nnormal" : nnormal, - "ncolor" : ncolor, - "nmaterial" : nmaterial, - "nedges" : nedges, - - "model" : model_string - } - - - return text, model_string - - -# ##################################################### -# Model exporter - export single mesh -# ##################################################### - -def generate_mesh_string(obj, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - export_single_model, - option_copy_textures, - filepath): - - # collapse modifiers into mesh - - mesh = obj.to_mesh(scene, True, 'RENDER') - - if not mesh: - raise Exception("Error, could not get mesh data from object [%s]" % obj.name) - - # that's what Blender's native export_obj.py does - # to flip YZ - - if export_single_model: - X_ROT = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X') - mesh.transform(X_ROT * obj.matrix_world) - - mesh.calc_normals() - - mesh.transform(mathutils.Matrix.Scale(option_scale, 4)) - - faceUV = (len(mesh.uv_textures) > 0) - vertexUV = (len(mesh.sticky) > 0) - vertexColors = len(mesh.vertex_colors) > 0 - - if not vertexColors: - option_colors = False - - if (not faceUV) and (not vertexUV): - option_uv_coords = False - - if faceUV: - active_uv_layer = mesh.uv_textures.active - if not active_uv_layer: - option_uv_coords = False - - if vertexColors: - active_col_layer = mesh.vertex_colors.active - if not active_col_layer: - option_colors = False - - option_copy_textures_model = False - if export_single_model and option_copy_textures: - option_copy_textures_model = True - - text, model_string = generate_ascii_model(mesh, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - obj.draw_type, - option_copy_textures_model, - filepath) - # remove temp mesh - - bpy.data.meshes.remove(mesh) - - return text, model_string - -def export_mesh(obj, scene, filepath, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - export_single_model, - option_copy_textures): - - """Export single mesh""" - - text, model_string = generate_mesh_string(obj, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - flipyz, - option_scale, - export_single_model, - option_copy_textures, - filepath) - - write_file(filepath, text) - - print("writing", filepath, "done") - - -# ##################################################### -# Scene exporter - render elements -# ##################################################### - -def generate_vec4(vec): - return TEMPLATE_VEC4 % (vec[0], vec[1], vec[2], vec[3]) - -def generate_vec3(vec): - return TEMPLATE_VEC3 % (vec[0], vec[1], vec[2]) - -def generate_vec2(vec): - return TEMPLATE_VEC2 % (vec[0], vec[1]) - -def generate_hex(number): - return TEMPLATE_HEX % number - -def generate_string(s): - return TEMPLATE_STRING % s - -def generate_string_list(src_list): - return ", ".join(generate_string(item) for item in src_list) - -def generate_section(label, content): - return TEMPLATE_SECTION % (label, content) - -def get_mesh_filename(mesh): - object_id = mesh["data"]["name"] - filename = "%s.js" % sanitize(object_id) - return filename - -def generate_material_id_list(materials): - chunks = [] - for material in materials: - chunks.append(material.name) - - return chunks - -def generate_group_id_list(obj): - chunks = [] - - for group in bpy.data.groups: - if obj.name in group.objects: - chunks.append(group.name) - - return chunks - -def generate_bool_property(property): - if property: - return "true" - return "false" - -# ##################################################### -# Scene exporter - objects -# ##################################################### - -def generate_objects(data): - chunks = [] - - for obj in data["objects"]: - - if obj.type == "MESH" and obj.THREE_exportGeometry: - object_id = obj.name - - if len(obj.modifiers) > 0: - geo_name = obj.name - else: - geo_name = obj.data.name - - geometry_id = "geo_%s" % geo_name - - material_ids = generate_material_id_list(obj.material_slots) - group_ids = generate_group_id_list(obj) - - position, quaternion, scale = obj.matrix_world.decompose() - rotation = quaternion.to_euler("XYZ") - - material_string = "" - if len(material_ids) > 0: - material_string = generate_string_list(material_ids) - - group_string = "" - if len(group_ids) > 0: - group_string = generate_string_list(group_ids) - - castsShadow = obj.THREE_castsShadow - meshCollider = obj.THREE_meshCollider - triggerType = obj.THREE_triggerType - - visible = True - #if obj.draw_type in ["BOUNDS", "WIRE"] and (meshCollider or castsShadow): - if meshCollider or castsShadow: - visible = False - - geometry_string = generate_string(geometry_id) - - object_string = TEMPLATE_OBJECT % { - "object_id" : generate_string(object_id), - "geometry_id" : geometry_string, - "group_id" : group_string, - "material_id" : material_string, - - "position" : generate_vec3(position), - "rotation" : generate_vec3(rotation), - "quaternion" : generate_vec4(quaternion), - "scale" : generate_vec3(scale), - - "castsShadow" : generate_bool_property(castsShadow), - "meshCollider" : generate_bool_property(meshCollider), - "trigger" : generate_string(triggerType), - "visible" : generate_bool_property(visible) - } - chunks.append(object_string) - - elif obj.type == "EMPTY" or (obj.type == "MESH" and not obj.THREE_exportGeometry): - - object_id = obj.name - group_ids = generate_group_id_list(obj) - - position, quaternion, scale = obj.matrix_world.decompose() - rotation = quaternion.to_euler("XYZ") - - group_string = "" - if len(group_ids) > 0: - group_string = generate_string_list(group_ids) - - triggerType = obj.THREE_triggerType - - object_string = TEMPLATE_EMPTY % { - "object_id" : generate_string(object_id), - "group_id" : group_string, - - "position" : generate_vec3(position), - "rotation" : generate_vec3(rotation), - "quaternion" : generate_vec4(quaternion), - "scale" : generate_vec3(scale), - - "trigger" : generate_string(triggerType), - } - chunks.append(object_string) - - return ",\n\n".join(chunks), len(chunks) - -# ##################################################### -# Scene exporter - geometries -# ##################################################### - -def generate_geometries(data): - chunks = [] - - geo_set = set() - - for obj in data["objects"]: - if obj.type == "MESH" and obj.THREE_exportGeometry: - - if len(obj.modifiers) > 0: - name = obj.name - else: - name = obj.data.name - - if name not in geo_set: - - geometry_id = "geo_%s" % name - - if data["embed_meshes"]: - - embed_id = "emb_%s" % name - - geometry_string = TEMPLATE_GEOMETRY_EMBED % { - "geometry_id" : generate_string(geometry_id), - "embed_id" : generate_string(embed_id) - } - - else: - - model_filename = os.path.basename(generate_mesh_filename(name, data["filepath"])) - - geometry_string = TEMPLATE_GEOMETRY_LINK % { - "geometry_id" : generate_string(geometry_id), - "model_file" : generate_string(model_filename) - } - - chunks.append(geometry_string) - - geo_set.add(name) - - return ",\n\n".join(chunks), len(chunks) - -# ##################################################### -# Scene exporter - textures -# ##################################################### - -def generate_textures_scene(data): - chunks = [] - - # TODO: extract just textures actually used by some objects in the scene - - for texture in bpy.data.textures: - - if texture.type == 'IMAGE' and texture.image: - - img = texture.image - - texture_id = img.name - texture_file = extract_texture_filename(img) - - if data["copy_textures"]: - save_image(img, texture_file, data["filepath"]) - - extras = "" - - if texture.repeat_x != 1 or texture.repeat_y != 1: - extras += ',\n "repeat": [%f, %f]' % (texture.repeat_x, texture.repeat_y) - - if texture.extension == "REPEAT": - wrap_x = "repeat" - wrap_y = "repeat" - - if texture.use_mirror_x: - wrap_x = "mirror" - if texture.use_mirror_y: - wrap_y = "mirror" - - extras += ',\n "wrap": ["%s", "%s"]' % (wrap_x, wrap_y) - - texture_string = TEMPLATE_TEXTURE % { - "texture_id" : generate_string(texture_id), - "texture_file" : generate_string(texture_file), - "extras" : extras - } - chunks.append(texture_string) - - return ",\n\n".join(chunks), len(chunks) - -def extract_texture_filename(image): - fn = bpy.path.abspath(image.filepath) - fn = os.path.normpath(fn) - fn_strip = os.path.basename(fn) - return fn_strip - -def save_image(img, name, fpath): - dst_dir = os.path.dirname(fpath) - dst_path = os.path.join(dst_dir, name) - - ensure_folder_exist(dst_dir) - - if img.packed_file: - img.save_render(dst_path) - - else: - src_path = bpy.path.abspath(img.filepath) - shutil.copy(src_path, dst_dir) - -# ##################################################### -# Scene exporter - materials -# ##################################################### - -def extract_material_data(m, option_colors): - world = bpy.context.scene.world - - material = { 'name': m.name } - - material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0], - m.diffuse_intensity * m.diffuse_color[1], - m.diffuse_intensity * m.diffuse_color[2]] - - material['colorSpecular'] = [m.specular_intensity * m.specular_color[0], - m.specular_intensity * m.specular_color[1], - m.specular_intensity * m.specular_color[2]] - - world_ambient_color = [0, 0, 0] - if world: - world_ambient_color = world.ambient_color - - material['colorAmbient'] = [m.ambient * world_ambient_color[0], - m.ambient * world_ambient_color[1], - m.ambient * world_ambient_color[2]] - - material['transparency'] = m.alpha - - # not sure about mapping values to Blinn-Phong shader - # Blender uses INT from [1,511] with default 0 - # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness - - material["specularCoef"] = m.specular_hardness - - material["vertexColors"] = m.THREE_useVertexColors and option_colors - - material['mapDiffuse'] = "" - material['mapLight'] = "" - material['mapNormal'] = "" - material['mapNormalFactor'] = 1.0 - - textures = guess_material_textures(m) - - if textures['diffuse']: - material['mapDiffuse'] = textures['diffuse']['texture'].image.name - - if textures['light']: - material['mapLight'] = textures['light']['texture'].image.name - - if textures['normal']: - material['mapNormal'] = textures['normal']['texture'].image.name - if textures['normal']['slot'].use_map_normal: - material['mapNormalFactor'] = textures['normal']['slot'].normal_factor - - material['shading'] = m.THREE_materialType - - return material - -def guess_material_textures(material): - textures = { - 'diffuse' : None, - 'light' : None, - 'normal' : None - } - - # just take first textures of each, for the moment three.js materials can't handle more - # assume diffuse comes before lightmap, normalmap has checked flag - - for i in range(len(material.texture_slots)): - slot = material.texture_slots[i] - if slot: - texture = slot.texture - if slot.use and texture.type == 'IMAGE': - - if texture.use_normal_map: - textures['normal'] = { "texture": texture, "slot": slot } - - else: - if not textures['diffuse']: - textures['diffuse'] = { "texture": texture, "slot": slot } - - else: - textures['light'] = { "texture": texture, "slot": slot } - - if textures['diffuse'] and textures['normal'] and textures['light']: - break - - return textures - -def generate_material_string(material): - type_map = { - "Lambert" : "MeshLambertMaterial", - "Phong" : "MeshPhongMaterial" - } - - material_id = material["name"] - shading = material.get("shading", "Lambert") - material_type = type_map.get(shading, "MeshBasicMaterial") - - parameters = '"color": %d' % rgb2int(material["colorDiffuse"]) - parameters += ', "opacity": %.2g' % material["transparency"] - - if shading == "Phong": - parameters += ', "ambient": %d' % rgb2int(material["colorAmbient"]) - parameters += ', "specular": %d' % rgb2int(material["colorSpecular"]) - parameters += ', "shininess": %.1g' % material["specularCoef"] - - colorMap = material['mapDiffuse'] - lightMap = material['mapLight'] - normalMap = material['mapNormal'] - normalMapFactor = material['mapNormalFactor'] - - if colorMap: - parameters += ', "map": %s' % generate_string(colorMap) - if lightMap: - parameters += ', "lightMap": %s' % generate_string(lightMap) - if normalMap: - parameters += ', "normalMap": %s' % generate_string(normalMap) - if normalMapFactor != 1.0: - parameters += ', "normalMapFactor": %f' % normalMapFactor - - if material['vertexColors']: - parameters += ', "vertexColors": "vertex"' - - material_string = TEMPLATE_MATERIAL_SCENE % { - "material_id" : generate_string(material_id), - "type" : generate_string(material_type), - "parameters" : parameters - } - - return material_string - -def generate_materials_scene(data): - chunks = [] - - # TODO: extract just materials actually used by some objects in the scene - - for m in bpy.data.materials: - material = extract_material_data(m, data["use_colors"]) - material_string = generate_material_string(material) - chunks.append(material_string) - - return ",\n\n".join(chunks), len(chunks) - -# ##################################################### -# Scene exporter - cameras -# ##################################################### - -def generate_cameras(data): - if data["use_cameras"]: - - cams = bpy.data.objects - cams = [ob for ob in cams if (ob.type == 'CAMERA' and ob.select)] - - chunks = [] - - if not cams: - camera = DEFAULTS["camera"] - - if camera["type"] == "perspective": - - camera_string = TEMPLATE_CAMERA_PERSPECTIVE % { - "camera_id" : generate_string(camera["name"]), - "fov" : camera["fov"], - "aspect" : camera["aspect"], - "near" : camera["near"], - "far" : camera["far"], - "position" : generate_vec3(camera["position"]), - "target" : generate_vec3(camera["target"]) - } - - elif camera["type"] == "ortho": - - camera_string = TEMPLATE_CAMERA_ORTHO % { - "camera_id" : generate_string(camera["name"]), - "left" : camera["left"], - "right" : camera["right"], - "top" : camera["top"], - "bottom" : camera["bottom"], - "near" : camera["near"], - "far" : camera["far"], - "position" : generate_vec3(camera["position"]), - "target" : generate_vec3(camera["target"]) - } - - chunks.append(camera_string) - - else: - - for cameraobj in cams: - camera = bpy.data.cameras[cameraobj.name] - - # TODO: - # Support more than perspective camera - # Calculate a target/lookat - # Get correct aspect ratio - if camera.id_data.type == "PERSP": - - camera_string = TEMPLATE_CAMERA_PERSPECTIVE % { - "camera_id" : generate_string(camera.name), - "fov" : (camera.angle / 3.14) * 180.0, - "aspect" : 1.333, - "near" : camera.clip_start, - "far" : camera.clip_end, - "position" : generate_vec3([cameraobj.location[0], -cameraobj.location[1], cameraobj.location[2]]), - "target" : generate_vec3([0, 0, 0]) - } - - chunks.append(camera_string) - - return ",\n\n".join(chunks) - - return "" - -# ##################################################### -# Scene exporter - lights -# ##################################################### - -def generate_lights(data): - - if data["use_lights"]: - - lights = data.get("lights", []) - if not lights: - lights.append(DEFAULTS["light"]) - - chunks = [] - for light in lights: - - if light["type"] == "directional": - light_string = TEMPLATE_LIGHT_DIRECTIONAL % { - "light_id" : generate_string(light["name"]), - "direction" : generate_vec3(light["direction"]), - #"color" : generate_hex(rgb2int(light["color"])), - "color" : rgb2int(light["color"]), - "intensity" : light["intensity"] - } - - elif light["type"] == "point": - light_string = TEMPLATE_LIGHT_POINT % { - "light_id" : generate_string(light["name"]), - "position" : generate_vec3(light["position"]), - #"color" : generate_hex(rgb2int(light["color"])), - "color" : rgb2int(light["color"]), - "intensity" : light["intensity"] - } - - chunks.append(light_string) - - return ",\n\n".join(chunks) - - return "" - -# ##################################################### -# Scene exporter - embedded meshes -# ##################################################### - -def generate_embeds(data): - - if data["embed_meshes"]: - - chunks = [] - - for e in data["embeds"]: - - embed = '"emb_%s": {%s}' % (e, data["embeds"][e]) - chunks.append(embed) - - return ",\n\n".join(chunks) - - return "" - -# ##################################################### -# Scene exporter - generate ASCII scene -# ##################################################### - -def generate_ascii_scene(data): - - objects, nobjects = generate_objects(data) - geometries, ngeometries = generate_geometries(data) - textures, ntextures = generate_textures_scene(data) - materials, nmaterials = generate_materials_scene(data) - - cameras = generate_cameras(data) - lights = generate_lights(data) - - embeds = generate_embeds(data) - - basetype = "relativeTo" - - if data["base_html"]: - basetype += "HTML" - else: - basetype += "Scene" - - sections = [ - ["objects", objects], - ["geometries", geometries], - ["textures", textures], - ["materials", materials], - ["cameras", cameras], - ["lights", lights], - ["embeds", embeds] - ] - - chunks = [] - for label, content in sections: - if content: - chunks.append(generate_section(label, content)) - - sections_string = "\n".join(chunks) - - default_camera = "" - if data["use_cameras"]: - cams = [ob for ob in bpy.data.objects if (ob.type == 'CAMERA' and ob.select)] - if not cams: - default_camera = "default_camera" - else: - default_camera = cams[0].name - - parameters = { - "fname" : data["source_file"], - - "sections" : sections_string, - - "bgcolor" : generate_vec3(DEFAULTS["bgcolor"]), - "bgalpha" : DEFAULTS["bgalpha"], - "defcamera" : generate_string(default_camera), - - "nobjects" : nobjects, - "ngeometries" : ngeometries, - "ntextures" : ntextures, - "basetype" : generate_string(basetype), - "nmaterials" : nmaterials, - - "position" : generate_vec3(DEFAULTS["position"]), - "rotation" : generate_vec3(DEFAULTS["rotation"]), - "scale" : generate_vec3(DEFAULTS["scale"]) - } - - text = TEMPLATE_SCENE_ASCII % parameters - - return text - -def export_scene(scene, filepath, flipyz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds, option_url_base_html, option_copy_textures): - - source_file = os.path.basename(bpy.data.filepath) - - scene_text = "" - data = { - "scene" : scene, - "objects" : scene.objects, - "embeds" : embeds, - "source_file" : source_file, - "filepath" : filepath, - "flipyz" : flipyz, - "use_colors" : option_colors, - "use_lights" : option_lights, - "use_cameras" : option_cameras, - "embed_meshes" : option_embed_meshes, - "base_html" : option_url_base_html, - "copy_textures": option_copy_textures - } - scene_text += generate_ascii_scene(data) - - write_file(filepath, scene_text) - -# ##################################################### -# Main -# ##################################################### - -def save(operator, context, filepath = "", - option_flip_yz = True, - option_vertices = True, - option_vertices_truncate = False, - option_faces = True, - option_normals = True, - option_edges = False, - option_uv_coords = True, - option_materials = True, - option_colors = True, - align_model = 0, - option_export_scene = False, - option_lights = False, - option_cameras = False, - option_scale = 1.0, - option_embed_meshes = True, - option_url_base_html = False, - option_copy_textures = False): - - #print("URL TYPE", option_url_base_html) - - filepath = ensure_extension(filepath, '.js') - - scene = context.scene - - if scene.objects.active: - bpy.ops.object.mode_set(mode='OBJECT') - - if option_export_scene: - - geo_set = set() - embeds = {} - - for obj in scene.objects: - if obj.type == "MESH" and obj.THREE_exportGeometry: - - # create extra copy of geometry with applied modifiers - # (if they exist) - - if len(obj.modifiers) > 0: - name = obj.name - - # otherwise can share geometry - - else: - name = obj.data.name - - if name not in geo_set: - - if option_embed_meshes: - - text, model_string = generate_mesh_string(obj, scene, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - False, # align_model - option_flip_yz, - option_scale, - False, # export_single_model - False, # option_copy_textures - filepath) - - embeds[name] = model_string - - else: - - fname = generate_mesh_filename(name, filepath) - export_mesh(obj, scene, - fname, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - False, # align_model - option_flip_yz, - option_scale, - False, # export_single_model - option_copy_textures) - - geo_set.add(name) - - export_scene(scene, filepath, - option_flip_yz, - option_colors, - option_lights, - option_cameras, - option_embed_meshes, - embeds, - option_url_base_html, - option_copy_textures) - - else: - - obj = context.object - if not obj: - raise Exception("Error, Select 1 active object or select 'export scene'") - - export_mesh(obj, scene, filepath, - option_vertices, - option_vertices_truncate, - option_faces, - option_normals, - option_edges, - option_uv_coords, - option_materials, - option_colors, - align_model, - option_flip_yz, - option_scale, - True, # export_single_model - option_copy_textures) - - return {'FINISHED'} diff --git a/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/import_threejs.py b/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/import_threejs.py deleted file mode 100644 index 0cd893a1..00000000 --- a/utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/import_threejs.py +++ /dev/null @@ -1,631 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -""" -Blender importer for Three.js (ASCII JSON format). - -""" - -import os -import time -import json -import bpy -import mathutils -from mathutils.geometry import tesselate_polygon -from io_utils import load_image, unpack_list, unpack_face_list - -# ##################################################### -# Generators -# ##################################################### -def setColor(c, t): - c.r = t[0] - c.g = t[1] - c.b = t[2] - -def create_texture(filename, modelpath): - name = filename - texture = bpy.data.textures.new(name, type='IMAGE') - - image = load_image(filename, modelpath) - has_data = False - - if image: - texture.image = image - has_data = image.has_data - - return texture - -def create_materials(data, modelpath): - materials = [] - materials_data = data.get("materials", []) - - for i, m in enumerate(materials_data): - - name = m.get("DbgName", "material_%d" % i) - - colorAmbient = m.get("colorAmbient", None) - colorDiffuse = m.get("colorDiffuse", None) - colorSpecular = m.get("colorSpecular", None) - alpha = m.get("transparency", 1.0) - specular_hardness = m.get("specularCoef", 0) - - mapDiffuse = m.get("mapDiffuse", None) - mapLightmap = m.get("mapLightmap", None) - - vertexColorsType = m.get("vertexColors", False) - - useVertexColors = False - if vertexColorsType: - useVertexColors = True - - material = bpy.data.materials.new(name) - - material.THREE_useVertexColors = useVertexColors - - if colorDiffuse: - setColor(material.diffuse_color, colorDiffuse) - material.diffuse_intensity = 1.0 - - if colorSpecular: - setColor(material.specular_color, colorSpecular) - material.specular_intensity = 1.0 - - if alpha < 1.0: - material.alpha = alpha - material.use_transparency = True - - if specular_hardness: - material.specular_hardness = specular_hardness - - if mapDiffuse: - texture = create_texture(mapDiffuse, modelpath) - mtex = material.texture_slots.add() - mtex.texture = texture - mtex.texture_coords = 'UV' - mtex.use = True - mtex.use_map_color_diffuse = True - - material.active_texture = texture - - materials.append(material) - - return materials - -def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate_normals): - - faces = face_data["faces"] - vertexNormals = face_data["vertexNormals"] - vertexColors = face_data["vertexColors"] - vertexUVs = face_data["vertexUVs"] - faceMaterials = face_data["materials"] - faceColors = face_data["faceColors"] - - edges = [] - - # Create a new mesh - - me = bpy.data.meshes.new(name) - me.from_pydata(vertices, edges, faces) - - # Handle normals - - if not recalculate_normals: - me.update(calc_edges = True) - - if face_data["hasVertexNormals"]: - - print("setting vertex normals") - - for fi in range(len(faces)): - - if vertexNormals[fi]: - - #print("setting face %i with %i vertices" % (fi, len(normals[fi]))) - - # if me.update() is called after setting vertex normals - # setting face.use_smooth overrides these normals - # - this fixes weird shading artefacts (seems to come from sharing - # of vertices between faces, didn't find a way how to set vertex normals - # per face use of vertex as opposed to per vertex), - # - probably this just overrides all custom vertex normals - # - to preserve vertex normals from the original data - # call me.update() before setting them - - me.faces[fi].use_smooth = True - - if not recalculate_normals: - for j in range(len(vertexNormals[fi])): - - vertexNormal = vertexNormals[fi][j] - - x = vertexNormal[0] - y = vertexNormal[1] - z = vertexNormal[2] - - if flipYZ: - tmp = y - y = -z - z = tmp - - # flip normals (this make them look consistent with the original before export) - - #x = -x - #y = -y - #z = -z - - vi = me.faces[fi].vertices[j] - - me.vertices[vi].normal.x = x - me.vertices[vi].normal.y = y - me.vertices[vi].normal.z = z - - if recalculate_normals: - me.update(calc_edges = True) - - # Handle colors - - if face_data["hasVertexColors"]: - - print("setting vertex colors") - - me.vertex_colors.new("vertex_color_layer_0") - - for fi in range(len(faces)): - - if vertexColors[fi]: - - face_colors = me.vertex_colors[0].data[fi] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - - for vi in range(len(vertexColors[fi])): - - r = vertexColors[fi][vi][0] - g = vertexColors[fi][vi][1] - b = vertexColors[fi][vi][2] - - face_colors[vi].r = r - face_colors[vi].g = g - face_colors[vi].b = b - - elif face_data["hasFaceColors"]: - - print("setting vertex colors from face colors") - - me.vertex_colors.new("vertex_color_layer_0") - - for fi in range(len(faces)): - - if faceColors[fi]: - - r = faceColors[fi][0] - g = faceColors[fi][1] - b = faceColors[fi][2] - - face_colors = me.vertex_colors[0].data[fi] - face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4 - - for vi in range(len(faces[fi])): - - face_colors[vi].r = r - face_colors[vi].g = g - face_colors[vi].b = b - - # Handle uvs - - if face_data["hasVertexUVs"]: - - print("setting vertex uvs") - - for li, layer in enumerate(vertexUVs): - - me.uv_textures.new("uv_layer_%d" % li) - - for fi in range(len(faces)): - - if layer[fi]: - - uv_face = me.uv_textures[li].data[fi] - face_uvs = uv_face.uv1, uv_face.uv2, uv_face.uv3, uv_face.uv4 - - for vi in range(len(layer[fi])): - - u = layer[fi][vi][0] - v = layer[fi][vi][1] - - face_uvs[vi].x = u - face_uvs[vi].y = 1.0 - v - - active_texture = materials[faceMaterials[fi]].active_texture - - if active_texture: - uv_face.use_image = True - uv_face.image = active_texture.image - - - # Handle materials # 1 - - if face_data["hasMaterials"]: - - - print("setting materials (mesh)") - - for m in materials: - - me.materials.append(m) - - print("setting materials (faces)") - - for fi in range(len(faces)): - - if faceMaterials[fi] >= 0: - - me.faces[fi].material_index = faceMaterials[fi] - - # Create a new object - - ob = bpy.data.objects.new(name, me) - ob.data = me # link the mesh data to the object - - - scene = bpy.context.scene # get the current scene - scene.objects.link(ob) # link the object into the scene - - ob.location = scene.cursor_location # position object at 3d-cursor - - -# ##################################################### -# Faces -# ##################################################### - -def extract_faces(data): - - result = { - "faces" : [], - "materials" : [], - "faceUVs" : [], - "vertexUVs" : [], - "faceNormals" : [], - "vertexNormals" : [], - "faceColors" : [], - "vertexColors" : [], - - "hasVertexNormals" : False, - "hasVertexUVs" : False, - "hasVertexColors" : False, - "hasFaceColors" : False, - "hasMaterials" : False - } - - faces = data.get("faces", []) - normals = data.get("normals", []) - colors = data.get("colors", []) - - offset = 0 - zLength = len(faces) - - # disregard empty arrays - - nUvLayers = 0 - - for layer in data["uvs"]: - - if len(layer) > 0: - nUvLayers += 1 - result["faceUVs"].append([]) - result["vertexUVs"].append([]) - - - while ( offset < zLength ): - - type = faces[ offset ] - offset += 1 - - isQuad = isBitSet( type, 0 ) - hasMaterial = isBitSet( type, 1 ) - hasFaceUv = isBitSet( type, 2 ) - hasFaceVertexUv = isBitSet( type, 3 ) - hasFaceNormal = isBitSet( type, 4 ) - hasFaceVertexNormal = isBitSet( type, 5 ) - hasFaceColor = isBitSet( type, 6 ) - hasFaceVertexColor = isBitSet( type, 7 ) - - #print("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor) - - result["hasVertexUVs"] = result["hasVertexUVs"] or hasFaceVertexUv - result["hasVertexNormals"] = result["hasVertexNormals"] or hasFaceVertexNormal - result["hasVertexColors"] = result["hasVertexColors"] or hasFaceVertexColor - result["hasFaceColors"] = result["hasFaceColors"] or hasFaceColor - result["hasMaterials"] = result["hasMaterials"] or hasMaterial - - # vertices - - if isQuad: - - a = faces[ offset ] - offset += 1 - - b = faces[ offset ] - offset += 1 - - c = faces[ offset ] - offset += 1 - - d = faces[ offset ] - offset += 1 - - face = [a, b, c, d] - - nVertices = 4 - - else: - - a = faces[ offset ] - offset += 1 - - b = faces[ offset ] - offset += 1 - - c = faces[ offset ] - offset += 1 - - face = [a, b, c] - - nVertices = 3 - - result["faces"].append(face) - - # material - - if hasMaterial: - - materialIndex = faces[ offset ] - offset += 1 - - else: - - materialIndex = -1 - - result["materials"].append(materialIndex) - - # uvs - - for i in range(nUvLayers): - - faceUv = None - - if hasFaceUv: - - uvLayer = data["uvs"][ i ] - - uvIndex = faces[ offset ] - offset += 1 - - u = uvLayer[ uvIndex * 2 ] - v = uvLayer[ uvIndex * 2 + 1 ] - - faceUv = [u, v] - - result["faceUVs"][i].append(faceUv) - - - if hasFaceVertexUv: - - uvLayer = data["uvs"][ i ] - - vertexUvs = [] - - for j in range(nVertices): - - uvIndex = faces[ offset ] - offset += 1 - - u = uvLayer[ uvIndex * 2 ] - v = uvLayer[ uvIndex * 2 + 1 ] - - vertexUvs.append([u, v]) - - result["vertexUVs"][i].append(vertexUvs) - - - if hasFaceNormal: - - normalIndex = faces[ offset ] * 3 - offset += 1 - - x = normals[ normalIndex ] - y = normals[ normalIndex + 1 ] - z = normals[ normalIndex + 2 ] - - faceNormal = [x, y, z] - - else: - - faceNormal = None - - result["faceNormals"].append(faceNormal) - - - if hasFaceVertexNormal: - - vertexNormals = [] - - for j in range(nVertices): - - normalIndex = faces[ offset ] * 3 - offset += 1 - - x = normals[ normalIndex ] - y = normals[ normalIndex + 1 ] - z = normals[ normalIndex + 2 ] - - vertexNormals.append( [x, y, z] ) - - - else: - - vertexNormals = None - - result["vertexNormals"].append(vertexNormals) - - - if hasFaceColor: - - colorIndex = faces[ offset ] - offset += 1 - - faceColor = hexToTuple( colors[ colorIndex ] ) - - else: - - faceColor = None - - result["faceColors"].append(faceColor) - - - if hasFaceVertexColor: - - vertexColors = [] - - for j in range(nVertices): - - colorIndex = faces[ offset ] - offset += 1 - - color = hexToTuple( colors[ colorIndex ] ) - vertexColors.append( color ) - - else: - - vertexColors = None - - result["vertexColors"].append(vertexColors) - - - return result - -# ##################################################### -# Utils -# ##################################################### - -def hexToTuple( hexColor ): - r = (( hexColor >> 16 ) & 0xff) / 255.0 - g = (( hexColor >> 8 ) & 0xff) / 255.0 - b = ( hexColor & 0xff) / 255.0 - return (r, g, b) - -def isBitSet(value, position): - return value & ( 1 << position ) - -def splitArray(data, chunkSize): - result = [] - chunk = [] - for i in range(len(data)): - if i > 0 and i % chunkSize == 0: - result.append(chunk) - chunk = [] - chunk.append(data[i]) - result.append(chunk) - return result - - -def extract_json_string(text): - marker_begin = "var model =" - marker_end = "postMessage" - - start = text.find(marker_begin) + len(marker_begin) - end = text.find(marker_end) - end = text.rfind("}", start, end) - return text[start:end+1].strip() - -def get_name(filepath): - return os.path.splitext(os.path.basename(filepath))[0] - -def get_path(filepath): - return os.path.dirname(filepath) - -# ##################################################### -# Parser -# ##################################################### - -def load(operator, context, filepath, option_flip_yz = True, recalculate_normals = True): - - print('\nimporting %r' % filepath) - - time_main = time.time() - - print("\tparsing JSON file...") - - time_sub = time.time() - - file = open(filepath, 'rU') - rawcontent = file.read() - file.close() - - json_string = extract_json_string(rawcontent) - data = json.loads( json_string ) - - time_new = time.time() - - print('parsing %.4f sec' % (time_new - time_sub)) - - time_sub = time_new - - # flip YZ - - vertices = splitArray(data["vertices"], 3) - - if option_flip_yz: - vertices[:] = [(v[0], -v[2], v[1]) for v in vertices] - - # extract faces - - face_data = extract_faces(data) - - # deselect all - - bpy.ops.object.select_all(action='DESELECT') - - nfaces = len(face_data["faces"]) - nvertices = len(vertices) - nnormals = len(data.get("normals", [])) / 3 - ncolors = len(data.get("colors", [])) / 3 - nuvs = len(data.get("uvs", [])) / 2 - nmaterials = len(data.get("materials", [])) - - print('\tbuilding geometry...\n\tfaces:%i, vertices:%i, vertex normals: %i, vertex uvs: %i, vertex colors: %i, materials: %i ...' % ( - nfaces, nvertices, nnormals, nuvs, ncolors, nmaterials )) - - # Create materials - - materials = create_materials(data, get_path(filepath)) - - # Create new obj - - create_mesh_object(get_name(filepath), vertices, materials, face_data, option_flip_yz, recalculate_normals) - - scene = bpy.context.scene - scene.update() - - time_new = time.time() - - print('finished importing: %r in %.4f sec.' % (filepath, (time_new - time_main))) - return {'FINISHED'} - - -if __name__ == "__main__": - register() diff --git a/utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/__init__.py b/utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/__init__.py similarity index 100% rename from utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/__init__.py rename to utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/__init__.py diff --git a/utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/export_threejs.py b/utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/export_threejs.py similarity index 100% rename from utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/export_threejs.py rename to utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/export_threejs.py diff --git a/utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/import_threejs.py b/utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/import_threejs.py similarity index 100% rename from utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/import_threejs.py rename to utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/import_threejs.py