Explorar o código

REVISION++

* Added support to texture.offset in CanvasRenderer
* Removed ShadowVolume, ShadowVolumeDynamicMaterial and LensFlare classes.
* Removed Stencil Shadows and LensFlare code out of WebGLRenderer
* Added 2.59 folder to Blender, and removed old ones.
Mr.doob %!s(int64=14) %!d(string=hai) anos
pai
achega
714e9ec302
Modificáronse 29 ficheiros con 674 adicións e 7586 borrados
  1. 23 3
      README.md
  2. 1 1
      REVISION
  3. 346 378
      build/Three.js
  4. 56 56
      build/custom/ThreeCanvas.js
  5. 1 1
      build/custom/ThreeDOM.js
  6. 5 5
      build/custom/ThreeExtras.js
  7. 1 1
      build/custom/ThreeSVG.js
  8. 216 248
      build/custom/ThreeWebGL.js
  9. 0 1
      examples/textures/metal.txt
  10. 2 2
      examples/webgl_custom_attributes.html
  11. 0 178
      examples/webgl_stencil.html
  12. 0 190
      examples/webgl_stencilLensFlare.html
  13. 0 3
      src/extras/geometries/IcosahedronGeometry.js
  14. 0 2
      src/extras/geometries/TorusGeometry.js
  15. 0 87
      src/lights/LensFlare.js
  16. 0 63
      src/materials/ShadowVolumeDynamicMaterial.js
  17. 0 345
      src/objects/ShadowVolume.js
  18. 14 7
      src/renderers/CanvasRenderer.js
  19. 9 592
      src/renderers/WebGLRenderer.js
  20. 0 6
      utils/build.py
  21. 0 359
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
  22. 0 1623
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
  23. 0 635
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py
  24. 0 388
      utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/__init__.py
  25. 0 1781
      utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/export_threejs.py
  26. 0 631
      utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/import_threejs.py
  27. 0 0
      utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/__init__.py
  28. 0 0
      utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/export_threejs.py
  29. 0 0
      utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/import_threejs.py

+ 23 - 3
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))

+ 1 - 1
REVISION

@@ -1 +1 @@
-42
+43

+ 346 - 378
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;c<e;c++)f=f.concat(this.intersectObject(b[c]));f.sort(function(b,e){return b.distance-e.distance});return f},intersectObject:function(b){function c(b,e,c){var f,c=c.matrixWorld.getPosition();f=c.clone().subSelf(b).dot(e);b=b.clone().addSelf(e.clone().multiplyScalar(f));return c.distanceTo(b)}function e(b,e,c,f){var f=f.clone().subSelf(e),
-c=c.clone().subSelf(e),g=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(g),h=c.dot(c),c=c.dot(g),g=1/(b*h-e*e),h=(h*f-e*c)*g,b=(b*c-e*f)*g;return h>0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,j,h,m,
-n,p,o,t,v,u,y=b.geometry,z=y.vertices,x=[],f=0;for(g=y.faces.length;f<g;f++)if(j=y.faces[f],v=this.origin.clone(),u=this.direction.clone(),p=b.matrixWorld,h=p.multiplyVector3(z[j.a].position.clone()),m=p.multiplyVector3(z[j.b].position.clone()),n=p.multiplyVector3(z[j.c].position.clone()),p=j instanceof THREE.Face4?p.multiplyVector3(z[j.d].position.clone()):null,o=b.matrixRotationWorld.multiplyVector3(j.normal.clone()),t=u.dot(o),b.doubleSided||(b.flipSided?t>0: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=c<h?c:h,e=e<j?e:j,f=f>h?f:h,g=g>j?g:j);b()};this.add3Points=
-function(h,j,o,t,v,u){m?(m=!1,c=h<o?h<v?h:v:o<v?o:v,e=j<t?j<u?j:u:t<u?t:u,f=h>o?h>v?h:v:o>v?o:v,g=j>t?j>u?j:u:t>u?t:u):(c=h<o?h<v?h<c?h:c:v<c?v:c:o<v?o<c?o:c:v<c?v:c,e=j<t?j<u?j<e?j:e:u<e?u:e:t<u?t<e?t:e:u<e?u:e,f=h>o?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=c<h.getLeft()?c:h.getLeft(),e=e<h.getTop()?e:h.getTop(),f=f>h.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<h.getRight()?f:h.getRight();g=g<h.getBottom()?g:h.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=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;c<e;c++)f=f.concat(this.intersectObject(b[c]));f.sort(function(b,c){return b.distance-c.distance});return f},intersectObject:function(b){function c(b,c,e){var f,e=e.matrixWorld.getPosition();f=e.clone().subSelf(b).dot(c);b=b.clone().addSelf(c.clone().multiplyScalar(f));return e.distanceTo(b)}function e(b,c,e,f){var f=f.clone().subSelf(c),
+e=e.clone().subSelf(c),g=b.clone().subSelf(c),b=f.dot(f),c=f.dot(e),f=f.dot(g),h=e.dot(e),e=e.dot(g),g=1/(b*h-c*c),h=(h*f-c*e)*g,b=(b*e-c*f)*g;return h>0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,j,h,k,
+o,m,p,u,v,t,w=b.geometry,x=w.vertices,B=[],f=0;for(g=w.faces.length;f<g;f++)if(j=w.faces[f],v=this.origin.clone(),t=this.direction.clone(),m=b.matrixWorld,h=m.multiplyVector3(x[j.a].position.clone()),k=m.multiplyVector3(x[j.b].position.clone()),o=m.multiplyVector3(x[j.c].position.clone()),m=j instanceof THREE.Face4?m.multiplyVector3(x[j.d].position.clone()):null,p=b.matrixRotationWorld.multiplyVector3(j.normal.clone()),u=t.dot(p),b.doubleSided||(b.flipSided?u>0: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=c<h?c:h,e=e<j?e:j,f=f>h?f:h,g=g>j?g:j);b()};this.add3Points=
+function(h,j,p,u,v,t){k?(k=!1,c=h<p?h<v?h:v:p<v?p:v,e=j<u?j<t?j:t:u<t?u:t,f=h>p?h>v?h:v:p>v?p:v,g=j>u?j>t?j:t:u>t?u:t):(c=h<p?h<v?h<c?h:c:v<c?v:c:p<v?p<c?p:c:v<c?v:c,e=j<u?j<t?j<e?j:e:t<e?t:e:u<t?u<e?u:e:t<e?t:e,f=h>p?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=c<h.getLeft()?c:h.getLeft(),e=e<h.getTop()?e:h.getTop(),f=f>h.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<h.getRight()?f:h.getRight();g=g<h.getBottom()?g:h.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=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<f;e++){g=this.children[e];if(g.name===b)return g;if(c&&(g=g.getChildByName(b,c),g!==void 0))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),
 this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,c,e)}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,e=b.x*c,f=b.y*c,g=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-g),g=Math.sin(-g),j=Math.cos(e),e=Math.sin(e),h=b*c,m=f*g;this.w=h*j-m*e;this.x=h*e+m*j;this.y=f*c*j+b*g*e;this.z=b*g*j-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);
+THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,e=b.x*c,f=b.y*c,g=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-g),g=Math.sin(-g),j=Math.cos(e),e=Math.sin(e),h=b*c,k=f*g;this.w=h*j-k*e;this.x=h*e+k*j;this.y=f*c*j+b*g*e;this.z=b*g*j-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);
 this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=
-b,this.w*=b);return this},multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,g=this.w,j=b.x,h=b.y,m=b.z,b=b.w;this.x=c*b+g*j+e*m-f*h;this.y=e*b+g*h+f*j-c*m;this.z=f*b+g*m+c*h-e*j;this.w=g*b-c*j-e*h-f*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,f=b.y,g=b.z,j=this.x,h=this.y,m=this.z,
-n=this.w,p=n*e+h*g-m*f,o=n*f+m*e-j*g,t=n*g+j*f-h*e,e=-j*e-h*f-m*g;c.x=p*n+e*-j+o*-m-t*-h;c.y=o*n+e*-h+t*-j-p*-m;c.z=t*n+e*-m+p*-h-o*-j;return c}};
+b,this.w*=b);return this},multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,g=this.w,j=b.x,h=b.y,k=b.z,b=b.w;this.x=c*b+g*j+e*k-f*h;this.y=e*b+g*h+f*j-c*k;this.z=f*b+g*k+c*h-e*j;this.w=g*b-c*j-e*h-f*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,f=b.y,g=b.z,j=this.x,h=this.y,k=this.z,
+o=this.w,m=o*e+h*g-k*f,p=o*f+k*e-j*g,u=o*g+j*f-h*e,e=-j*e-h*f-k*g;c.x=m*o+e*-j+p*-k-u*-h;c.y=p*o+e*-h+u*-j-m*-k;c.z=u*o+e*-k+m*-h-p*-j;return c}};
 THREE.Quaternion.slerp=function(b,c,e,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var 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;b<c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),e.centroid.divideScalar(3)):e instanceof THREE.Face4&&(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),
-e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,g,j,h,m=new THREE.Vector3,n=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];if(b&&j.vertexNormals.length){m.set(0,0,0);c=0;for(e=j.vertexNormals.length;c<e;c++)m.addSelf(j.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[j.a],e=this.vertices[j.b],h=this.vertices[j.c],m.sub(h.position,e.position),n.sub(c.position,e.position),m.crossSelf(n);m.isZero()||
-m.normalize();j.normal.copy(m)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=
+e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,g,j,h,k=new THREE.Vector3,o=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];if(b&&j.vertexNormals.length){k.set(0,0,0);c=0;for(e=j.vertexNormals.length;c<e;c++)k.addSelf(j.vertexNormals[c]);k.divideScalar(3)}else c=this.vertices[j.a],e=this.vertices[j.b],h=this.vertices[j.c],k.sub(h.position,e.position),o.sub(c.position,e.position),k.crossSelf(o);k.isZero()||
+k.normalize();j.normal.copy(k)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=
 this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),
-e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,g,j,G){m=b.vertices[e].position;n=b.vertices[c].position;p=b.vertices[f].position;o=h[g];t=h[j];v=h[G];u=n.x-m.x;y=p.x-m.x;z=n.y-m.y;x=p.y-m.y;w=n.z-m.z;H=p.z-m.z;B=t.u-o.u;F=v.u-o.u;J=t.v-o.v;D=v.v-o.v;L=1/(B*D-F*J);da.set((D*u-J*y)*
-L,(D*z-J*x)*L,(D*w-J*H)*L);T.set((B*y-F*u)*L,(B*x-F*z)*L,(B*H-F*w)*L);I[e].addSelf(da);I[c].addSelf(da);I[f].addSelf(da);R[e].addSelf(T);R[c].addSelf(T);R[f].addSelf(T)}var c,e,f,g,j,h,m,n,p,o,t,v,u,y,z,x,w,H,B,F,J,D,L,G,I=[],R=[],da=new THREE.Vector3,T=new THREE.Vector3,C=new THREE.Vector3,ea=new THREE.Vector3,S=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)I[c]=new THREE.Vector3,R[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)j=this.faces[c],h=this.faceVertexUvs[0][c],j instanceof
-THREE.Face3?b(this,j.a,j.b,j.c,0,1,2):j instanceof THREE.Face4&&(b(this,j.a,j.b,j.c,0,1,2),b(this,j.a,j.b,j.d,0,1,3));var P=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){j=this.faces[c];for(f=0;f<j.vertexNormals.length;f++)S.copy(j.vertexNormals[f]),g=j[P[f]],G=I[g],C.copy(G),C.subSelf(S.multiplyScalar(S.dot(G))).normalize(),ea.cross(j.vertexNormals[f],G),g=ea.dot(R[g]),g=g<0?-1:1,j.vertexTangents[f]=new THREE.Vector4(C.x,C.y,C.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var b;
+e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,c,e,f,g,j,n){k=b.vertices[c].position;o=b.vertices[e].position;m=b.vertices[f].position;p=h[g];u=h[j];v=h[n];t=o.x-k.x;w=m.x-k.x;x=o.y-k.y;B=m.y-k.y;A=o.z-k.z;H=m.z-k.z;y=u.u-p.u;G=v.u-p.u;I=u.v-p.v;E=v.v-p.v;K=1/(y*E-G*I);X.set((E*t-I*w)*
+K,(E*x-I*B)*K,(E*A-I*H)*K);R.set((y*w-G*t)*K,(y*B-G*x)*K,(y*H-G*A)*K);J[c].addSelf(X);J[e].addSelf(X);J[f].addSelf(X);S[c].addSelf(R);S[e].addSelf(R);S[f].addSelf(R)}var c,e,f,g,j,h,k,o,m,p,u,v,t,w,x,B,A,H,y,G,I,E,K,D,J=[],S=[],X=new THREE.Vector3,R=new THREE.Vector3,C=new THREE.Vector3,n=new THREE.Vector3,W=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)J[c]=new THREE.Vector3,S[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)j=this.faces[c],h=this.faceVertexUvs[0][c],j instanceof
+THREE.Face3?b(this,j.a,j.b,j.c,0,1,2):j instanceof THREE.Face4&&(b(this,j.a,j.b,j.c,0,1,2),b(this,j.a,j.b,j.d,0,1,3));var V=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){j=this.faces[c];for(f=0;f<j.vertexNormals.length;f++)W.copy(j.vertexNormals[f]),g=j[V[f]],D=J[g],C.copy(D),C.subSelf(W.multiplyScalar(W.dot(D))).normalize(),n.cross(j.vertexNormals[f],D),g=n.dot(S[g]),g=g<0?-1:1,j.vertexTangents[f]=new THREE.Vector4(C.x,C.y,C.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var b;
 if(this.vertices.length>0){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;c<e;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;
-else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}function c(b,e,c){b[e]===
-void 0?(b[e]={set:{},array:[]},b[e].set[c]=1,b[e].array.push(c)):b[e].set[c]===void 0&&(b[e].set[c]=1,b[e].array.push(c))}var e,f,g,j,h,m={};e=0;for(f=this.faces.length;e<f;e++)h=this.faces[e],h instanceof THREE.Face3?(g=b(h.a,h.b),c(m,g,e),g=b(h.b,h.c),c(m,g,e),g=b(h.a,h.c),c(m,g,e)):h instanceof THREE.Face4&&(g=b(h.b,h.d),c(m,g,e),g=b(h.a,h.b),c(m,g,e),g=b(h.a,h.d),c(m,g,e),g=b(h.b,h.c),c(m,g,e),g=b(h.c,h.d),c(m,g,e));e=0;for(f=this.edges.length;e<f;e++){h=this.edges[e];g=h.vertexIndices[0];j=h.vertexIndices[1];
-h.faceIndices=m[b(g,j)].array;for(g=0;g<h.faceIndices.length;g++)j=h.faceIndices[g],h.faces.push(this.faces[j])}}};THREE.GeometryIdCounter=0;
-THREE.Spline=function(b){function c(b,e,c,f,h,g,j){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*j+(-3*(e-c)-2*b-f)*g+b*h+e}this.points=b;var e=[],f={x:0,y:0,z:0},g,j,h,m,n,p,o,t,v;this.initFromArray=function(b){this.points=[];for(var e=0;e<b.length;e++)this.points[e]={x:b[e][0],y:b[e][1],z:b[e][2]}};this.getPoint=function(b){g=(this.points.length-1)*b;j=Math.floor(g);h=g-j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>this.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;b<c;b++)e=this.points[b],f[b]=[e.x,e.y,e.z];return f};this.getLength=function(b){var e,c,f=e=e=0,h=new THREE.Vector3,g=new THREE.Vector3,j=[],m=0;j[0]=0;b||(b=100);c=this.points.length*b;h.copy(this.points[0]);for(b=1;b<c;b++)e=b/c,position=this.getPoint(e),g.copy(position),
-m+=g.distanceTo(h),h.copy(position),e*=this.points.length-1,e=Math.floor(e),e!=f&&(j[e]=m,f=e);j[j.length]=m;return{chunks:j,total:m}};this.reparametrizeByArcLength=function(b){var e,c,f,h,g,j,m=[],n=new THREE.Vector3,t=this.getLength();m.push(n.copy(this.points[0]).clone());for(e=1;e<this.points.length;e++){c=t.chunks[e]-t.chunks[e-1];j=Math.ceil(b*c/t.total);h=(e-1)/(this.points.length-1);g=e/(this.points.length-1);for(c=1;c<j-1;c++)f=h+c*(1/j)*(g-h),position=this.getPoint(f),m.push(n.copy(position).clone());
-m.push(n.copy(this.points[e]).clone())}this.points=m}};THREE.Edge=function(b,c,e,f){this.vertices=[b,c];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,e,f,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
+else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,c){return Math.min(b,c)+"_"+Math.max(b,c)}function c(b,c,e){b[c]===
+void 0?(b[c]={set:{},array:[]},b[c].set[e]=1,b[c].array.push(e)):b[c].set[e]===void 0&&(b[c].set[e]=1,b[c].array.push(e))}var e,f,g,j,h,k={};e=0;for(f=this.faces.length;e<f;e++)h=this.faces[e],h instanceof THREE.Face3?(g=b(h.a,h.b),c(k,g,e),g=b(h.b,h.c),c(k,g,e),g=b(h.a,h.c),c(k,g,e)):h instanceof THREE.Face4&&(g=b(h.b,h.d),c(k,g,e),g=b(h.a,h.b),c(k,g,e),g=b(h.a,h.d),c(k,g,e),g=b(h.b,h.c),c(k,g,e),g=b(h.c,h.d),c(k,g,e));e=0;for(f=this.edges.length;e<f;e++){h=this.edges[e];g=h.vertexIndices[0];j=h.vertexIndices[1];
+h.faceIndices=k[b(g,j)].array;for(g=0;g<h.faceIndices.length;g++)j=h.faceIndices[g],h.faces.push(this.faces[j])}}};THREE.GeometryIdCounter=0;
+THREE.Spline=function(b){function c(b,c,e,f,h,g,j){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*j+(-3*(c-e)-2*b-f)*g+b*h+c}this.points=b;var e=[],f={x:0,y:0,z:0},g,j,h,k,o,m,p,u,v;this.initFromArray=function(b){this.points=[];for(var c=0;c<b.length;c++)this.points[c]={x:b[c][0],y:b[c][1],z:b[c][2]}};this.getPoint=function(b){g=(this.points.length-1)*b;j=Math.floor(g);h=g-j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>this.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;b<e;b++)c=this.points[b],f[b]=[c.x,c.y,c.z];return f};this.getLength=function(b){var c,e,f=c=c=0,h=new THREE.Vector3,g=new THREE.Vector3,j=[],k=0;j[0]=0;b||(b=100);e=this.points.length*b;h.copy(this.points[0]);for(b=1;b<e;b++)c=b/e,position=this.getPoint(c),g.copy(position),
+k+=g.distanceTo(h),h.copy(position),c*=this.points.length-1,c=Math.floor(c),c!=f&&(j[c]=k,f=c);j[j.length]=k;return{chunks:j,total:k}};this.reparametrizeByArcLength=function(b){var c,e,f,h,g,j,k=[],o=new THREE.Vector3,u=this.getLength();k.push(o.copy(this.points[0]).clone());for(c=1;c<this.points.length;c++){e=u.chunks[c]-u.chunks[c-1];j=Math.ceil(b*e/u.total);h=(c-1)/(this.points.length-1);g=c/(this.points.length-1);for(e=1;e<j-1;e++)f=h+e*(1/j)*(g-h),position=this.getPoint(f),k.push(o.copy(position).clone());
+k.push(o.copy(this.points[c]).clone())}this.points=k}};THREE.Edge=function(b,c,e,f){this.vertices=[b,c];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,e,f,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
 THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);c.multiplyScalar(b);this.position.addSelf(c);this.target.position.addSelf(c)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,e=-c,f=b*e,b=Math.abs(b*c-f),e=Math.abs(c-e);this.projectionMatrix=THREE.Matrix4.makeFrustum(f+this.x*b/this.fullWidth,f+(this.x+this.width)*b/this.fullWidth,c-(this.y+this.height)*e/this.fullHeight,c-this.y*e/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.setViewOffset=function(b,c,e,f,g,j){this.fullWidth=b;this.fullHeight=c;this.x=e;this.y=f;this.width=g;this.height=j;this.updateProjectionMatrix()};
@@ -80,9 +80,6 @@ THREE.Camera.prototype.update=function(b,c,e){if(this.useTarget)this.matrix.look
 !1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
 THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=e||0};
 THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(b,c,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=c||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
-THREE.LensFlare=function(b,c,e,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,c,e,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
-THREE.LensFlare.prototype.add=function(b,c,e,f){c===void 0&&(c=-1);e===void 0&&(e=0);if(f===void 0)f=THREE.BillboardBlending;e=Math.min(e,Math.max(0,e));this.lensFlares.push({texture:b,size:c,distance:e,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:f})};
-THREE.LensFlare.prototype.updateLensFlares=function(){var b,c=this.lensFlares.length,e,f=-this.positionScreen.x*2,g=-this.positionScreen.y*2;for(b=0;b<c;b++)e=this.lensFlares[b],e.x=this.positionScreen.x+f*e.distance,e.y=this.positionScreen.y+g*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
 THREE.Material=function(b){this.id=THREE.MaterialCount++;b=b||{};this.opacity=b.opacity!==void 0?b.opacity:1;this.transparent=b.transparent!==void 0?b.transparent:!1;this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==void 0?b.depthTest:!0;this.polygonOffset=b.polygonOffset!==void 0?b.polygonOffset:!1;this.polygonOffsetFactor=b.polygonOffsetFactor!==void 0?b.polygonOffsetFactor:0;this.polygonOffsetUnits=b.polygonOffsetUnits!==void 0?b.polygonOffsetUnits:
 0;this.alphaTest=b.alphaTest!==void 0?b.alphaTest:0};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.LineBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.linewidth=b.linewidth!==void 0?b.linewidth:1;this.linecap=b.linecap!==void 0?b.linecap:"round";this.linejoin=b.linejoin!==void 0?b.linejoin:"round";this.vertexColors=b.vertexColors?b.vertexColors:!1};
@@ -100,14 +97,11 @@ THREE.MeshDepthMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.sha
 THREE.MeshNormalMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading?b.shading:THREE.FlatShading;this.wireframe=b.wireframe?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth?b.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 THREE.MeshShaderMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.fragmentShader=b.fragmentShader!==void 0?b.fragmentShader:"void main() {}";this.vertexShader=b.vertexShader!==void 0?b.vertexShader:"void main() {}";this.uniforms=b.uniforms!==void 0?b.uniforms:{};this.attributes=b.attributes;this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.fog=
 b.fog!==void 0?b.fog:!1;this.lights=b.lights!==void 0?b.lights:!1;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};THREE.MeshShaderMaterial.prototype=new THREE.Material;THREE.MeshShaderMaterial.prototype.constructor=THREE.MeshShaderMaterial;
-THREE.ShadowVolumeDynamicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
-void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
-THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
 THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.size=b.size!==void 0?b.size:1;this.sizeAttenuation=b.sizeAttenuation!==void 0?b.sizeAttenuation:!0;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ParticleCanvasMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.program=b.program!==void 0?b.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(b){THREE.Material.call(this);this.domElement=b};
 THREE.Texture=function(b,c,e,f,g,j){this.id=THREE.TextureCount++;this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=e!==void 0?e:THREE.ClampToEdgeWrapping;this.wrapT=f!==void 0?f:THREE.ClampToEdgeWrapping;this.magFilter=g!==void 0?g:THREE.LinearFilter;this.minFilter=j!==void 0?j:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
 THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var b=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;
-THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(b,c,e,f,g,j,h,m,n){THREE.Texture.call(this,null,g,j,h,m,n);this.image={data:b,width:c,height:e};this.format=f!==void 0?f:THREE.RGBAFormat};
+THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(b,c,e,f,g,j,h,k,o){THREE.Texture.call(this,null,g,j,h,k,o);this.image={data:b,width:c,height:e};this.format=f!==void 0?f:THREE.RGBAFormat};
 THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;THREE.DataTexture.prototype={clone:function(){var b=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b]};THREE.Particle.prototype=new THREE.Object3D;
 THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,c,e){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=e!=void 0?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
 THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
@@ -116,7 +110,7 @@ e}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THR
 THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(b,c,e){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var f,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<g;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.skinMatrix,c,e):b.update(this.matrixWorld,!0,e)}else for(f=0;f<g;f++)this.children[f].update(this.skinMatrix,
 c,e)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
-THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,g,j,h,m;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)g=this.geometry.bones[e],j=g.pos,h=g.rotq,m=g.scl,f=this.addBone(),f.name=g.name,f.position.set(j[0],j[1],j[2]),f.quaternion.set(h[0],h[1],h[2],h[3]),f.useQuaternion=!0,m!==void 0?f.scale.set(m[0],m[1],m[2]):f.scale.set(1,1,1);for(e=0;e<this.bones.length;e++)g=this.geometry.bones[e],
+THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,g,j,h,k;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)g=this.geometry.bones[e],j=g.pos,h=g.rotq,k=g.scl,f=this.addBone(),f.name=g.name,f.position.set(j[0],j[1],j[2]),f.quaternion.set(h[0],h[1],h[2],h[3]),f.useQuaternion=!0,k!==void 0?f.scale.set(k[0],k[1],k[2]):f.scale.set(1,1,1);for(e=0;e<this.bones.length;e++)g=this.geometry.bones[e],
 f=this.bones[e],g.parent===-1?this.addChild(f):this.bones[g.parent].addChild(f);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
 THREE.SkinnedMesh.prototype.update=function(b,c,e){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var f,g=this.children.length;for(f=0;f<g;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,c,e);e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<e;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
 c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
@@ -124,15 +118,7 @@ THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[
 e.y,e.z);this.geometry.skinVerticesA.push(c[g].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(c[j].multiplyVector3(f));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=e,this.geometry.skinWeights[b].y+=e)}}};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};
 THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),e=0;e<this.LODs.length;e++)if(c<this.LODs[e].visibleAtDistance)break;this.LODs.splice(e,0,{visibleAtDistance:c,object3D:b});this.addChild(b)};
 THREE.LOD.prototype.update=function(b,c,e){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){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.length;f++)if(b>=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1,
-this.LODs[f].object3D.visible=!0;else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};THREE.ShadowVolume=function(b,c){b instanceof THREE.Mesh?(THREE.Mesh.call(this,b.geometry,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]),b.addChild(this)):THREE.Mesh.call(this,b,c?[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;
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,c,e,f,g,j,h,m,n,p,o,t,v,u,y=new THREE.Geometry;y.vertices=this.geometry.vertices;f=y.faces=this.geometry.faces;var z=y.egdes=this.geometry.edges,x=y.edgeFaces=[];g=0;var w=[];b=0;for(c=f.length;b<c;b++)if(e=f[b],w.push(g),g+=e instanceof THREE.Face3?3:4,e.vertexNormals[0]=e.normal,e.vertexNormals[1]=e.normal,e.vertexNormals[2]=e.normal,e instanceof THREE.Face4)e.vertexNormals[3]=
-e.normal;b=0;for(c=z.length;b<c;b++)m=z[b],e=m.faces[0],f=m.faces[1],g=m.faceIndices[0],j=m.faceIndices[1],h=m.vertexIndices[0],m=m.vertexIndices[1],e.a===h?(n="a",o=w[g]+0):e.b===h?(n="b",o=w[g]+1):e.c===h?(n="c",o=w[g]+2):e.d===h&&(n="d",o=w[g]+3),e.a===m?(n+="a",t=w[g]+0):e.b===m?(n+="b",t=w[g]+1):e.c===m?(n+="c",t=w[g]+2):e.d===m&&(n+="d",t=w[g]+3),f.a===h?(p="a",v=w[j]+0):f.b===h?(p="b",v=w[j]+1):f.c===h?(p="c",v=w[j]+2):f.d===h&&(p="d",v=w[j]+3),f.a===m?(p+="a",u=w[j]+0):f.b===m?(p+="b",u=w[j]+
-1):f.c===m?(p+="c",u=w[j]+2):f.d===m&&(p+="d",u=w[j]+3),n==="ac"||n==="ad"||n==="ca"||n==="da"?o>t&&(e=o,o=t,t=e):o<t&&(e=o,o=t,t=e),p==="ac"||p==="ad"||p==="ca"||p==="da"?v>u&&(e=v,v=u,u=e):v<u&&(e=v,v=u,u=e),e=new THREE.Face4(o,t,v,u),e.normal.set(1,0,0),x.push(e);this.geometry=y}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var c=this.geometry.vertices,e=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces,b=b.vertices,j=g.length,h,m,n,p,o,t=["a","b","c","d"];for(n=0;n<j;n++){m=c.length;h=g[n];h instanceof THREE.Face4?(p=4,m=new THREE.Face4(m,m+1,m+2,m+3)):(p=3,m=new THREE.Face3(m,m+1,m+2));m.normal.copy(h.normal);e.push(m);
-for(m=0;m<p;m++)o=b[h[t[m]]],c.push(new THREE.Vertex(o.position.clone()))}for(j=0;j<g.length-1;j++){b=e[j];for(h=j+1;h<g.length;h++)m=e[h],m=this.facesShareEdge(c,b,m),m!==void 0&&(m=new THREE.Face4(m.indices[0],m.indices[3],m.indices[2],m.indices[1]),m.normal.set(1,0,0),f.push(m))}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,c,e){var f,g,j,h,m,n,p,o,t,v,u,y,z,x=0,w=["a","b","c","d"];f=c instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(y=0;y<f;y++){j=c[w[y]];m=b[j];for(z=0;z<g;z++)if(h=e[w[z]],n=b[h],Math.abs(m.position.x-n.position.x)<1.0E-4&&Math.abs(m.position.y-n.position.y)<1.0E-4&&Math.abs(m.position.z-n.position.z)<1.0E-4&&(x++,x===1&&(p=m,o=n,t=j,v=h,u=w[y]),x===2))return u+=w[y],u==="ad"||u==="ac"?{faces:[c,e],vertices:[p,o,n,m],indices:[t,v,
-h,j],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,e],vertices:[p,m,n,o],indices:[t,j,h,v],vertexTypes:[1,1,2,2],extrudable:!0}}};
+this.LODs[f].object3D.visible=!0;else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};
 THREE.Sprite=function(b){THREE.Object3D.call(this);if(b.material!==void 0)this.material=b.material,this.map=void 0,this.blending=material.blending;else if(b.map!==void 0)this.map=b.map instanceof THREE.Texture?b.map:THREE.ImageUtils.loadTexture(b.map),this.material=void 0,this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.useScreenCoordinates=b.useScreenCoordinates!==void 0?b.useScreenCoordinates:!0;this.mergeWith3D=b.mergeWith3D!==void 0?b.mergeWith3D:!this.useScreenCoordinates;
 this.affectedByDistance=b.affectedByDistance!==void 0?b.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=b.scaleByViewport!==void 0?b.scaleByViewport:!this.affectedByDistance;this.alignment=b.alignment instanceof THREE.Vector2?b.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;
 THREE.Sprite.prototype.supr=THREE.Object3D.prototype;THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);
@@ -141,58 +127,58 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.c
 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<b.children.length;c++)this.addChildRecurse(b.children[c])};THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};
 THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var c=this.lights.indexOf(b);c!==-1&&this.lights.splice(c,1)}else b instanceof THREE.Camera||(c=this.objects.indexOf(b),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(b)));for(c=0;c<b.children.length;c++)this.removeChildRecurse(b.children[c])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,c,e){this.color=new THREE.Color(b);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
-THREE.Projector=function(){function b(){var b=n[m]=n[m]||new THREE.RenderableVertex;m++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,h=b.z+b.w,g=e.z+e.w,k=-b.z+b.w,j=-e.z+e.w;return h>=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))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,g,j=[],h,m,n=[],p,o,t=[],v,u=[],y,z,x=[],w,H,B=[],F=new THREE.Vector4,J=new THREE.Vector4,
-D=new THREE.Matrix4,L=new THREE.Matrix4,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,R=new THREE.Vector4;this.projectVector=function(b,e){D.multiply(e.projectionMatrix,e.matrixWorldInverse);D.multiplyVector3(b);return b};this.unprojectVector=function(b,e){D.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));D.multiplyVector3(b);return b};this.projectObjects=function(b,e,h){var e=[],m,n,t;g=0;n=
-b.objects;b=0;for(m=n.length;b<m;b++){t=n[b];var k;if(!(k=!t.visible))if(k=t instanceof THREE.Mesh){a:{k=void 0;for(var p=t.matrixWorld,u=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),o=0;o<6;o++)if(k=G[o].x*p.n14+G[o].y*p.n24+G[o].z*p.n34+G[o].w,k<=u){k=!1;break a}k=!0}k=!k}if(!k)k=j[g]=j[g]||new THREE.RenderableObject,g++,f=k,F.copy(t.position),D.multiplyVector3(F),f.object=t,f.z=F.z,e.push(f)}h&&e.sort(c);return e};this.projectScene=function(f,g,j){var F=[],
-S=g.near,P=g.far,k,M,Y,aa,Z,ha,ka,fa,U,X,ca,ma,la,sa,K,V,ga;H=z=v=o=0;g.matrixAutoUpdate&&g.update(void 0,!0);f.update(void 0,!1,g);D.multiply(g.projectionMatrix,g.matrixWorldInverse);G[0].set(D.n41-D.n11,D.n42-D.n12,D.n43-D.n13,D.n44-D.n14);G[1].set(D.n41+D.n11,D.n42+D.n12,D.n43+D.n13,D.n44+D.n14);G[2].set(D.n41+D.n21,D.n42+D.n22,D.n43+D.n23,D.n44+D.n24);G[3].set(D.n41-D.n21,D.n42-D.n22,D.n43-D.n23,D.n44-D.n24);G[4].set(D.n41-D.n31,D.n42-D.n32,D.n43-D.n33,D.n44-D.n34);G[5].set(D.n41+D.n31,D.n42+
-D.n32,D.n43+D.n33,D.n44+D.n34);for(k=0;k<6;k++)U=G[k],U.divideScalar(Math.sqrt(U.x*U.x+U.y*U.y+U.z*U.z));U=this.projectObjects(f,g,!0);f=0;for(k=U.length;f<k;f++)if(X=U[f].object,X.visible)if(ca=X.matrixWorld,ma=X.matrixRotationWorld,la=X.materials,sa=X.overdraw,m=0,X instanceof THREE.Mesh){K=X.geometry;aa=K.vertices;V=K.faces;K=K.faceVertexUvs;M=0;for(Y=aa.length;M<Y;M++)h=b(),h.positionWorld.copy(aa[M].position),ca.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),D.multiplyVector4(h.positionScreen),
-h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>S&&h.positionScreen.z<P;aa=0;for(M=V.length;aa<M;aa++){Y=V[aa];if(Y instanceof THREE.Face3)if(Z=n[Y.a],ha=n[Y.b],ka=n[Y.c],Z.visible&&ha.visible&&ka.visible&&(X.doubleSided||X.flipSided!=(ka.positionScreen.x-Z.positionScreen.x)*(ha.positionScreen.y-Z.positionScreen.y)-(ka.positionScreen.y-Z.positionScreen.y)*(ha.positionScreen.x-Z.positionScreen.x)<0))fa=t[o]=t[o]||new THREE.RenderableFace3,
-o++,p=fa,p.v1.copy(Z),p.v2.copy(ha),p.v3.copy(ka);else continue;else if(Y instanceof THREE.Face4)if(Z=n[Y.a],ha=n[Y.b],ka=n[Y.c],fa=n[Y.d],Z.visible&&ha.visible&&ka.visible&&fa.visible&&(X.doubleSided||X.flipSided!=((fa.positionScreen.x-Z.positionScreen.x)*(ha.positionScreen.y-Z.positionScreen.y)-(fa.positionScreen.y-Z.positionScreen.y)*(ha.positionScreen.x-Z.positionScreen.x)<0||(ha.positionScreen.x-ka.positionScreen.x)*(fa.positionScreen.y-ka.positionScreen.y)-(ha.positionScreen.y-ka.positionScreen.y)*
-(fa.positionScreen.x-ka.positionScreen.x)<0)))ga=u[v]=u[v]||new THREE.RenderableFace4,v++,p=ga,p.v1.copy(Z),p.v2.copy(ha),p.v3.copy(ka),p.v4.copy(fa);else continue;p.normalWorld.copy(Y.normal);ma.multiplyVector3(p.normalWorld);p.centroidWorld.copy(Y.centroid);ca.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);D.multiplyVector3(p.centroidScreen);ka=Y.vertexNormals;Z=0;for(ha=ka.length;Z<ha;Z++)fa=p.vertexNormalsWorld[Z],fa.copy(ka[Z]),ma.multiplyVector3(fa);Z=0;for(ha=K.length;Z<
-ha;Z++)if(ga=K[Z][aa]){ka=0;for(fa=ga.length;ka<fa;ka++)p.uvs[Z][ka]=ga[ka]}p.meshMaterials=la;p.faceMaterials=Y.materials;p.overdraw=sa;p.z=p.centroidScreen.z;F.push(p)}}else if(X instanceof THREE.Line){L.multiply(D,ca);aa=X.geometry.vertices;Z=b();Z.positionScreen.copy(aa[0].position);L.multiplyVector4(Z.positionScreen);M=1;for(Y=aa.length;M<Y;M++)if(Z=b(),Z.positionScreen.copy(aa[M].position),L.multiplyVector4(Z.positionScreen),ha=n[m-2],I.copy(Z.positionScreen),R.copy(ha.positionScreen),e(I,R))I.multiplyScalar(1/
-I.w),R.multiplyScalar(1/R.w),ca=x[z]=x[z]||new THREE.RenderableLine,z++,y=ca,y.v1.positionScreen.copy(I),y.v2.positionScreen.copy(R),y.z=Math.max(I.z,R.z),y.materials=X.materials,F.push(y)}else if(X instanceof THREE.Particle&&(J.set(X.matrixWorld.n14,X.matrixWorld.n24,X.matrixWorld.n34,1),D.multiplyVector4(J),J.z/=J.w,J.z>0&&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;n<p;n++)if(v=b[n],v instanceof THREE.RenderableParticle){y=v.x*g+g;z=v.y*j+j;o=0;for(t=v.material.length;o<t;o++)if(u=v.material[o],u instanceof THREE.ParticleDOMMaterial)u=u.domElement,u.style.left=y+"px",u.style.top=z+"px"}}};
-THREE.CanvasRenderer=function(b){function c(b){if(x!=b)u.globalAlpha=x=b}function e(b){if(w!=b){switch(b){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}w=b}}function f(b){if(H!=b)u.strokeStyle=H=b}function g(b){if(B!=b)u.fillStyle=B=b}var j=this,h=null,m=new THREE.Projector,b=b||{},n=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
-p,o,t,v,u=n.getContext("2d"),y=new THREE.Color(0),z=0,x=1,w=0,H=null,B=null,F=null,J=null,D=null,L,G,I,R,da=new THREE.RenderableVertex,T=new THREE.RenderableVertex,C,ea,S,P,k,M,Y,aa,Z,ha,ka,fa,U=new THREE.Color(0),X=new THREE.Color(0),ca=new THREE.Color(0),ma=new THREE.Color(0),la=new THREE.Color(0),sa=[],K,V,ga,ja,qa,wa,Aa,La,za,Oa,W=new THREE.Rectangle,ta=new THREE.Rectangle,na=new THREE.Rectangle,ua=!1,ia=new THREE.Color,ra=new THREE.Color,xa=new THREE.Color,Ba=new THREE.Color,pa=new THREE.Vector3,
-ya,Da,$,Q,Ea,O,b=16;ya=document.createElement("canvas");ya.width=ya.height=2;Da=ya.getContext("2d");Da.fillStyle="rgba(0,0,0,1)";Da.fillRect(0,0,2,2);$=Da.getImageData(0,0,2,2);Q=$.data;Ea=document.createElement("canvas");Ea.width=Ea.height=b;O=Ea.getContext("2d");O.translate(-b/2,-b/2);O.scale(b,b);b--;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(b,e){p=b;o=e;t=Math.floor(p/2);v=Math.floor(o/2);n.width=p;n.height=o;W.set(-t,
--v,t,v);ta.set(-t,-v,t,v);x=1;w=0;D=J=F=B=H=null};this.setClearColor=function(b,e){y.copy(b);z=e;ta.set(-t,-v,t,v)};this.setClearColorHex=function(b,e){y.setHex(b);z=e;ta.set(-t,-v,t,v)};this.clear=function(){u.setTransform(1,0,0,-1,t,v);ta.isEmpty()||(ta.inflate(2),ta.minSelf(W),z<1&&u.clearRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight())),z>0&&(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<e;b++)c=h[b],f=c.color,c instanceof THREE.AmbientLight?(ra.r+=f.r,ra.g+=f.g,ra.b+=f.b):c instanceof THREE.DirectionalLight?(xa.r+=f.r,xa.g+=f.g,xa.b+=f.b):c instanceof THREE.PointLight&&(Ba.r+=f.r,Ba.g+=f.g,Ba.b+=f.b)}function o(b,
-e,c,f){var h,g,k,j,m=b.lights,b=0;for(h=m.length;b<h;b++)g=m[b],k=g.color,g instanceof THREE.DirectionalLight?(j=c.dot(g.position),j<=0||(j*=g.intensity,f.r+=k.r*j,f.g+=k.g*j,f.b+=k.b*j)):g instanceof THREE.PointLight&&(j=c.dot(pa.sub(g.position,e).normalize()),j<=0||(j*=g.distance==0?1:1-Math.min(e.distanceTo(g.position)/g.distance,1),j!=0&&(j*=g.intensity,f.r+=k.r*j,f.g+=k.g*j,f.b+=k.b*j)))}function Sa(b,h,j){c(j.opacity);e(j.blending);var k,m,n,p,va,o;if(j instanceof THREE.ParticleBasicMaterial){if(j.map)p=
-j.map.image,va=p.width>>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;Ua<Xa;Ua++){oa=h[Ua];na.empty();if(oa instanceof THREE.RenderableParticle){L=oa;L.x*=t;L.y*=v;Ca=0;for(Ja=oa.materials.length;Ca<Ja;)E=oa.materials[Ca++],E.opacity!=0&&Sa(L,oa,E,b)}else if(oa instanceof THREE.RenderableLine){if(L=oa.v1,G=oa.v2,L.positionScreen.x*=t,
-L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,na.addPoint(L.positionScreen.x,L.positionScreen.y),na.addPoint(G.positionScreen.x,G.positionScreen.y),W.instersects(na)){Ca=0;for(Ja=oa.materials.length;Ca<Ja;)E=oa.materials[Ca++],E.opacity!=0&&Ya(L,G,oa,E,b)}}else if(oa instanceof THREE.RenderableFace3){if(L=oa.v1,G=oa.v2,I=oa.v3,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,oa.overdraw&&(Ia(L.positionScreen,
-G.positionScreen),Ia(G.positionScreen,I.positionScreen),Ia(I.positionScreen,L.positionScreen)),na.add3Points(L.positionScreen.x,L.positionScreen.y,G.positionScreen.x,G.positionScreen.y,I.positionScreen.x,I.positionScreen.y),W.instersects(na)){Ca=0;for(Ja=oa.meshMaterials.length;Ca<Ja;)if(E=oa.meshMaterials[Ca++],E instanceof THREE.MeshFaceMaterial){Ra=0;for(Va=oa.faceMaterials.length;Ra<Va;)(E=oa.faceMaterials[Ra++])&&E.opacity!=0&&y(L,G,I,0,1,2,oa,E,b)}else E.opacity!=0&&y(L,G,I,0,1,2,oa,E,b)}}else if(oa instanceof
-THREE.RenderableFace4&&(L=oa.v1,G=oa.v2,I=oa.v3,R=oa.v4,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,R.positionScreen.x*=t,R.positionScreen.y*=v,da.positionScreen.copy(G.positionScreen),T.positionScreen.copy(R.positionScreen),oa.overdraw&&(Ia(L.positionScreen,G.positionScreen),Ia(G.positionScreen,R.positionScreen),Ia(R.positionScreen,L.positionScreen),Ia(I.positionScreen,da.positionScreen),Ia(I.positionScreen,T.positionScreen)),
-na.addPoint(L.positionScreen.x,L.positionScreen.y),na.addPoint(G.positionScreen.x,G.positionScreen.y),na.addPoint(I.positionScreen.x,I.positionScreen.y),na.addPoint(R.positionScreen.x,R.positionScreen.y),W.instersects(na))){Ca=0;for(Ja=oa.meshMaterials.length;Ca<Ja;)if(E=oa.meshMaterials[Ca++],E instanceof THREE.MeshFaceMaterial){Ra=0;for(Va=oa.faceMaterials.length;Ra<Va;)(E=oa.faceMaterials[Ra++])&&E.opacity!=0&&w(L,G,I,R,da,T,oa,E,b)}else E.opacity!=0&&w(L,G,I,R,da,T,oa,E,b)}ta.addRectangle(na)}u.setTransform(1,
-0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function b(b,e,c){var f,h,g,j;f=0;for(h=b.lights.length;f<h;f++)g=b.lights[f],g instanceof THREE.DirectionalLight?(j=e.normalWorld.dot(g.position)*g.intensity,j>0&&(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<p;g++)o=U[g],F=o.color,o instanceof THREE.AmbientLight?(D.r+=F.r,D.g+=F.g,D.b+=F.b):o instanceof THREE.DirectionalLight?(L.r+=F.r,L.g+=F.g,L.b+=F.b):o instanceof THREE.PointLight&&(G.r+=F.r,G.g+=F.g,G.b+=F.b)}g=0;for(p=h.length;g<p;g++)if(U=h[g],H.empty(),
-U instanceof THREE.RenderableParticle){u=U;u.x*=t;u.y*=-v;o=0;for(F=U.materials.length;o<F;)o++}else if(U instanceof THREE.RenderableLine){if(u=U.v1,y=U.v2,u.positionScreen.x*=t,u.positionScreen.y*=-v,y.positionScreen.x*=t,y.positionScreen.y*=-v,H.addPoint(u.positionScreen.x,u.positionScreen.y),H.addPoint(y.positionScreen.x,y.positionScreen.y),w.instersects(H)){o=0;for(F=U.materials.length;o<F;)if((X=U.materials[o++])&&X.opacity!=0){J=u;I=y;var R=S++;T[R]==null&&(T[R]=document.createElementNS("http://www.w3.org/2000/svg",
-"line"),P==0&&T[R].setAttribute("shape-rendering","crispEdges"));C=T[R];C.setAttribute("x1",J.positionScreen.x);C.setAttribute("y1",J.positionScreen.y);C.setAttribute("x2",I.positionScreen.x);C.setAttribute("y2",I.positionScreen.y);X instanceof THREE.LineBasicMaterial&&(C.setAttribute("style","fill: none; stroke: "+X.color.getContextStyle()+"; stroke-width: "+X.linewidth+"; stroke-opacity: "+X.opacity+"; stroke-linecap: "+X.linecap+"; stroke-linejoin: "+X.linejoin),n.appendChild(C))}}}else if(U instanceof
-THREE.RenderableFace3){if(u=U.v1,y=U.v2,z=U.v3,u.positionScreen.x*=t,u.positionScreen.y*=-v,y.positionScreen.x*=t,y.positionScreen.y*=-v,z.positionScreen.x*=t,z.positionScreen.y*=-v,H.addPoint(u.positionScreen.x,u.positionScreen.y),H.addPoint(y.positionScreen.x,y.positionScreen.y),H.addPoint(z.positionScreen.x,z.positionScreen.y),w.instersects(H)){o=0;for(F=U.meshMaterials.length;o<F;)if(X=U.meshMaterials[o++],X instanceof THREE.MeshFaceMaterial){J=0;for(I=U.faceMaterials.length;J<I;)(X=U.faceMaterials[J++])&&
-X.opacity!=0&&c(u,y,z,U,X,b)}else X&&X.opacity!=0&&c(u,y,z,U,X,b)}}else if(U instanceof THREE.RenderableFace4&&(u=U.v1,y=U.v2,z=U.v3,x=U.v4,u.positionScreen.x*=t,u.positionScreen.y*=-v,y.positionScreen.x*=t,y.positionScreen.y*=-v,z.positionScreen.x*=t,z.positionScreen.y*=-v,x.positionScreen.x*=t,x.positionScreen.y*=-v,H.addPoint(u.positionScreen.x,u.positionScreen.y),H.addPoint(y.positionScreen.x,y.positionScreen.y),H.addPoint(z.positionScreen.x,z.positionScreen.y),H.addPoint(x.positionScreen.x,x.positionScreen.y),
-w.instersects(H))){o=0;for(F=U.meshMaterials.length;o<F;)if(X=U.meshMaterials[o++],X instanceof THREE.MeshFaceMaterial){J=0;for(I=U.faceMaterials.length;J<I;)(X=U.faceMaterials[J++])&&X.opacity!=0&&e(u,y,z,x,U,X,b)}else X&&X.opacity!=0&&e(u,y,z,x,U,X,b)}}};
+THREE.Projector=function(){function b(){var b=o[k]=o[k]||new THREE.RenderableVertex;k++;return b}function c(b,c){return c.z-b.z}function e(b,c){var e=0,f=1,h=b.z+b.w,g=c.z+c.w,j=-b.z+b.w,k=-c.z+c.w;return h>=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))),f<e?!1:(b.lerpSelf(c,e),c.lerpSelf(b,1-f),!0))}var f,g,j=[],h,k,o=[],m,p,u=[],v,t=[],w,x,B=[],A,H,y=[],G=new THREE.Vector4,I=new THREE.Vector4,
+E=new THREE.Matrix4,K=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],J=new THREE.Vector4,S=new THREE.Vector4;this.projectVector=function(b,c){E.multiply(c.projectionMatrix,c.matrixWorldInverse);E.multiplyVector3(b);return b};this.unprojectVector=function(b,c){E.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));E.multiplyVector3(b);return b};this.projectObjects=function(b,e,h){var e=[],k,o,u;g=0;o=
+b.objects;b=0;for(k=o.length;b<k;b++){u=o[b];var m;if(!(m=!u.visible))if(m=u instanceof THREE.Mesh){a:{m=void 0;for(var t=u.matrixWorld,p=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),v=0;v<6;v++)if(m=D[v].x*t.n14+D[v].y*t.n24+D[v].z*t.n34+D[v].w,m<=p){m=!1;break a}m=!0}m=!m}if(!m)m=j[g]=j[g]||new THREE.RenderableObject,g++,f=m,G.copy(u.position),E.multiplyVector3(G),f.object=u,f.z=G.z,e.push(f)}h&&e.sort(c);return e};this.projectScene=function(f,g,j){var n=[],
+G=g.near,V=g.far,fa,L,ea,T,U,da,ha,ia,M,P,aa,Y,Z,ca,ja,la,ka;H=x=v=p=0;g.matrixAutoUpdate&&g.update(void 0,!0);f.update(void 0,!1,g);E.multiply(g.projectionMatrix,g.matrixWorldInverse);D[0].set(E.n41-E.n11,E.n42-E.n12,E.n43-E.n13,E.n44-E.n14);D[1].set(E.n41+E.n11,E.n42+E.n12,E.n43+E.n13,E.n44+E.n14);D[2].set(E.n41+E.n21,E.n42+E.n22,E.n43+E.n23,E.n44+E.n24);D[3].set(E.n41-E.n21,E.n42-E.n22,E.n43-E.n23,E.n44-E.n24);D[4].set(E.n41-E.n31,E.n42-E.n32,E.n43-E.n33,E.n44-E.n34);D[5].set(E.n41+E.n31,E.n42+
+E.n32,E.n43+E.n33,E.n44+E.n34);for(fa=0;fa<6;fa++)M=D[fa],M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z));M=this.projectObjects(f,g,!0);f=0;for(fa=M.length;f<fa;f++)if(P=M[f].object,P.visible)if(aa=P.matrixWorld,Y=P.matrixRotationWorld,Z=P.materials,ca=P.overdraw,k=0,P instanceof THREE.Mesh){ja=P.geometry;T=ja.vertices;la=ja.faces;ja=ja.faceVertexUvs;L=0;for(ea=T.length;L<ea;L++)h=b(),h.positionWorld.copy(T[L].position),aa.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),
+E.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>G&&h.positionScreen.z<V;T=0;for(L=la.length;T<L;T++){ea=la[T];if(ea instanceof THREE.Face3)if(U=o[ea.a],da=o[ea.b],ha=o[ea.c],U.visible&&da.visible&&ha.visible&&(P.doubleSided||P.flipSided!=(ha.positionScreen.x-U.positionScreen.x)*(da.positionScreen.y-U.positionScreen.y)-(ha.positionScreen.y-U.positionScreen.y)*(da.positionScreen.x-U.positionScreen.x)<0))ia=
+u[p]=u[p]||new THREE.RenderableFace3,p++,m=ia,m.v1.copy(U),m.v2.copy(da),m.v3.copy(ha);else continue;else if(ea instanceof THREE.Face4)if(U=o[ea.a],da=o[ea.b],ha=o[ea.c],ia=o[ea.d],U.visible&&da.visible&&ha.visible&&ia.visible&&(P.doubleSided||P.flipSided!=((ia.positionScreen.x-U.positionScreen.x)*(da.positionScreen.y-U.positionScreen.y)-(ia.positionScreen.y-U.positionScreen.y)*(da.positionScreen.x-U.positionScreen.x)<0||(da.positionScreen.x-ha.positionScreen.x)*(ia.positionScreen.y-ha.positionScreen.y)-
+(da.positionScreen.y-ha.positionScreen.y)*(ia.positionScreen.x-ha.positionScreen.x)<0)))ka=t[v]=t[v]||new THREE.RenderableFace4,v++,m=ka,m.v1.copy(U),m.v2.copy(da),m.v3.copy(ha),m.v4.copy(ia);else continue;m.normalWorld.copy(ea.normal);Y.multiplyVector3(m.normalWorld);m.centroidWorld.copy(ea.centroid);aa.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);E.multiplyVector3(m.centroidScreen);ha=ea.vertexNormals;U=0;for(da=ha.length;U<da;U++)ia=m.vertexNormalsWorld[U],ia.copy(ha[U]),
+Y.multiplyVector3(ia);U=0;for(da=ja.length;U<da;U++)if(ka=ja[U][T]){ha=0;for(ia=ka.length;ha<ia;ha++)m.uvs[U][ha]=ka[ha]}m.meshMaterials=Z;m.faceMaterials=ea.materials;m.overdraw=ca;m.z=m.centroidScreen.z;n.push(m)}}else if(P instanceof THREE.Line){K.multiply(E,aa);T=P.geometry.vertices;U=b();U.positionScreen.copy(T[0].position);K.multiplyVector4(U.positionScreen);L=1;for(ea=T.length;L<ea;L++)if(U=b(),U.positionScreen.copy(T[L].position),K.multiplyVector4(U.positionScreen),da=o[k-2],J.copy(U.positionScreen),
+S.copy(da.positionScreen),e(J,S))J.multiplyScalar(1/J.w),S.multiplyScalar(1/S.w),aa=B[x]=B[x]||new THREE.RenderableLine,x++,w=aa,w.v1.positionScreen.copy(J),w.v2.positionScreen.copy(S),w.z=Math.max(J.z,S.z),w.materials=P.materials,n.push(w)}else if(P instanceof THREE.Particle&&(I.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34,1),E.multiplyVector4(I),I.z/=I.w,I.z>0&&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;o<m;o++)if(v=b[o],v instanceof THREE.RenderableParticle){w=v.x*g+g;x=v.y*j+j;p=0;for(u=v.material.length;p<u;p++)if(t=v.material[p],t instanceof THREE.ParticleDOMMaterial)t=t.domElement,t.style.left=w+"px",t.style.top=x+"px"}}};
+THREE.CanvasRenderer=function(b){function c(b){if(B!=b)t.globalAlpha=B=b}function e(b){if(A!=b){switch(b){case THREE.NormalBlending:t.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:t.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:t.globalCompositeOperation="darker"}A=b}}function f(b){if(H!=b)t.strokeStyle=H=b}function g(b){if(y!=b)t.fillStyle=y=b}var j=this,h=null,k=new THREE.Projector,b=b||{},o=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
+m,p,u,v,t=o.getContext("2d"),w=new THREE.Color(0),x=0,B=1,A=0,H=null,y=null,G=null,I=null,E=null,K,D,J,S,X=new THREE.RenderableVertex,R=new THREE.RenderableVertex,C,n,W,V,fa,L,ea,T,U,da,ha,ia,M=new THREE.Color(0),P=new THREE.Color(0),aa=new THREE.Color(0),Y=new THREE.Color(0),Z=new THREE.Color(0),ca=[],ja,la,ka,pa,sa,ua,Ia,Ja,Ka,va,ya=new THREE.Rectangle,$=new THREE.Rectangle,ta=new THREE.Rectangle,Ea=!1,oa=new THREE.Color,ma=new THREE.Color,Ga=new THREE.Color,Da=new THREE.Color,N=new THREE.Vector3,
+za,ga,Ya,Aa,Ba,Va,b=16;za=document.createElement("canvas");za.width=za.height=2;ga=za.getContext("2d");ga.fillStyle="rgba(0,0,0,1)";ga.fillRect(0,0,2,2);Ya=ga.getImageData(0,0,2,2);Aa=Ya.data;Ba=document.createElement("canvas");Ba.width=Ba.height=b;Va=Ba.getContext("2d");Va.translate(-b/2,-b/2);Va.scale(b,b);b--;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(b,c){m=b;p=c;u=Math.floor(m/2);v=Math.floor(p/2);o.width=m;o.height=
+p;ya.set(-u,-v,u,v);$.set(-u,-v,u,v);B=1;A=0;E=I=G=y=H=null};this.setClearColor=function(b,c){w.copy(b);x=c;$.set(-u,-v,u,v)};this.setClearColorHex=function(b,c){w.setHex(b);x=c;$.set(-u,-v,u,v)};this.clear=function(){t.setTransform(1,0,0,-1,u,v);$.isEmpty()||($.minSelf(ya),$.inflate(2),x<1&&t.clearRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight())),x>0&&(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<c;b++)e=h[b],f=e.color,e instanceof THREE.AmbientLight?(ma.r+=f.r,ma.g+=f.g,ma.b+=f.b):e instanceof THREE.DirectionalLight?(Ga.r+=f.r,Ga.g+=f.g,Ga.b+=f.b):e instanceof THREE.PointLight&&(Da.r+=f.r,Da.g+=f.g,Da.b+=f.b)}function p(b,c,e,
+f){var h,g,j,k,n=b.lights,b=0;for(h=n.length;b<h;b++)g=n[b],j=g.color,g instanceof THREE.DirectionalLight?(k=e.dot(g.position),k<=0||(k*=g.intensity,f.r+=j.r*k,f.g+=j.g*k,f.b+=j.b*k)):g instanceof THREE.PointLight&&(k=e.dot(N.sub(g.position,c).normalize()),k<=0||(k*=g.distance==0?1:1-Math.min(c.distanceTo(g.position)/g.distance,1),k!=0&&(k*=g.intensity,f.r+=j.r*k,f.g+=j.g*k,f.b+=j.b*k)))}function w(b,h,j){c(j.opacity);e(j.blending);var k,n,o,m,p,ga;if(j instanceof THREE.ParticleBasicMaterial){if(j.map)m=
+j.map.image,p=m.width>>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;Ca<F;)wa=na.materials[Ca++],wa.opacity!=0&&w(K,na,wa,b)}else if(na instanceof THREE.RenderableLine){if(K=
+na.v1,D=na.v2,K.positionScreen.x*=u,K.positionScreen.y*=v,D.positionScreen.x*=u,D.positionScreen.y*=v,ta.addPoint(K.positionScreen.x,K.positionScreen.y),ta.addPoint(D.positionScreen.x,D.positionScreen.y),ya.instersects(ta)){Ca=0;for(F=na.materials.length;Ca<F;)wa=na.materials[Ca++],wa.opacity!=0&&x(K,D,na,wa,b)}}else if(na instanceof THREE.RenderableFace3){if(K=na.v1,D=na.v2,J=na.v3,K.positionScreen.x*=u,K.positionScreen.y*=v,D.positionScreen.x*=u,D.positionScreen.y*=v,J.positionScreen.x*=u,J.positionScreen.y*=
+v,na.overdraw&&(Na(K.positionScreen,D.positionScreen),Na(D.positionScreen,J.positionScreen),Na(J.positionScreen,K.positionScreen)),ta.add3Points(K.positionScreen.x,K.positionScreen.y,D.positionScreen.x,D.positionScreen.y,J.positionScreen.x,J.positionScreen.y),ya.instersects(ta)){Ca=0;for(F=na.meshMaterials.length;Ca<F;)if(wa=na.meshMaterials[Ca++],wa instanceof THREE.MeshFaceMaterial){z=0;for(Q=na.faceMaterials.length;z<Q;)(wa=na.faceMaterials[z++])&&wa.opacity!=0&&A(K,D,J,0,1,2,na,wa,b)}else wa.opacity!=
+0&&A(K,D,J,0,1,2,na,wa,b)}}else if(na instanceof THREE.RenderableFace4&&(K=na.v1,D=na.v2,J=na.v3,S=na.v4,K.positionScreen.x*=u,K.positionScreen.y*=v,D.positionScreen.x*=u,D.positionScreen.y*=v,J.positionScreen.x*=u,J.positionScreen.y*=v,S.positionScreen.x*=u,S.positionScreen.y*=v,X.positionScreen.copy(D.positionScreen),R.positionScreen.copy(S.positionScreen),na.overdraw&&(Na(K.positionScreen,D.positionScreen),Na(D.positionScreen,S.positionScreen),Na(S.positionScreen,K.positionScreen),Na(J.positionScreen,
+X.positionScreen),Na(J.positionScreen,R.positionScreen)),ta.addPoint(K.positionScreen.x,K.positionScreen.y),ta.addPoint(D.positionScreen.x,D.positionScreen.y),ta.addPoint(J.positionScreen.x,J.positionScreen.y),ta.addPoint(S.positionScreen.x,S.positionScreen.y),ya.instersects(ta))){Ca=0;for(F=na.meshMaterials.length;Ca<F;)if(wa=na.meshMaterials[Ca++],wa instanceof THREE.MeshFaceMaterial){z=0;for(Q=na.faceMaterials.length;z<Q;)(wa=na.faceMaterials[z++])&&wa.opacity!=0&&B(K,D,J,S,X,R,na,wa,b)}else wa.opacity!=
+0&&B(K,D,J,S,X,R,na,wa,b)}$.addRectangle(ta)}t.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function b(b,c,e){var f,h,g,j;f=0;for(h=b.lights.length;f<h;f++)g=b.lights[f],g instanceof THREE.DirectionalLight?(j=c.normalWorld.dot(g.position)*g.intensity,j>0&&(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<m;g++)p=M[g],G=p.color,p instanceof THREE.AmbientLight?(E.r+=G.r,E.g+=G.g,E.b+=G.b):p instanceof THREE.DirectionalLight?(K.r+=G.r,K.g+=G.g,K.b+=G.b):p instanceof THREE.PointLight&&(D.r+=G.r,D.g+=G.g,D.b+=G.b)}g=0;for(m=h.length;g<m;g++)if(M=h[g],H.empty(),
+M instanceof THREE.RenderableParticle){t=M;t.x*=u;t.y*=-v;p=0;for(G=M.materials.length;p<G;)p++}else if(M instanceof THREE.RenderableLine){if(t=M.v1,w=M.v2,t.positionScreen.x*=u,t.positionScreen.y*=-v,w.positionScreen.x*=u,w.positionScreen.y*=-v,H.addPoint(t.positionScreen.x,t.positionScreen.y),H.addPoint(w.positionScreen.x,w.positionScreen.y),A.instersects(H)){p=0;for(G=M.materials.length;p<G;)if((P=M.materials[p++])&&P.opacity!=0){I=t;J=w;var S=W++;R[S]==null&&(R[S]=document.createElementNS("http://www.w3.org/2000/svg",
+"line"),V==0&&R[S].setAttribute("shape-rendering","crispEdges"));C=R[S];C.setAttribute("x1",I.positionScreen.x);C.setAttribute("y1",I.positionScreen.y);C.setAttribute("x2",J.positionScreen.x);C.setAttribute("y2",J.positionScreen.y);P instanceof THREE.LineBasicMaterial&&(C.setAttribute("style","fill: none; stroke: "+P.color.getContextStyle()+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin),o.appendChild(C))}}}else if(M instanceof
+THREE.RenderableFace3){if(t=M.v1,w=M.v2,x=M.v3,t.positionScreen.x*=u,t.positionScreen.y*=-v,w.positionScreen.x*=u,w.positionScreen.y*=-v,x.positionScreen.x*=u,x.positionScreen.y*=-v,H.addPoint(t.positionScreen.x,t.positionScreen.y),H.addPoint(w.positionScreen.x,w.positionScreen.y),H.addPoint(x.positionScreen.x,x.positionScreen.y),A.instersects(H)){p=0;for(G=M.meshMaterials.length;p<G;)if(P=M.meshMaterials[p++],P instanceof THREE.MeshFaceMaterial){I=0;for(J=M.faceMaterials.length;I<J;)(P=M.faceMaterials[I++])&&
+P.opacity!=0&&c(t,w,x,M,P,b)}else P&&P.opacity!=0&&c(t,w,x,M,P,b)}}else if(M instanceof THREE.RenderableFace4&&(t=M.v1,w=M.v2,x=M.v3,B=M.v4,t.positionScreen.x*=u,t.positionScreen.y*=-v,w.positionScreen.x*=u,w.positionScreen.y*=-v,x.positionScreen.x*=u,x.positionScreen.y*=-v,B.positionScreen.x*=u,B.positionScreen.y*=-v,H.addPoint(t.positionScreen.x,t.positionScreen.y),H.addPoint(w.positionScreen.x,w.positionScreen.y),H.addPoint(x.positionScreen.x,x.positionScreen.y),H.addPoint(B.positionScreen.x,B.positionScreen.y),
+A.instersects(H))){p=0;for(G=M.meshMaterials.length;p<G;)if(P=M.meshMaterials[p++],P instanceof THREE.MeshFaceMaterial){I=0;for(J=M.faceMaterials.length;I<J;)(P=M.faceMaterials[I++])&&P.opacity!=0&&e(t,w,x,B,M,P,b)}else P&&P.opacity!=0&&e(t,w,x,B,M,P,b)}}};
 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",
@@ -228,145 +214,127 @@ THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderCh
 "void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},depthRGBA:{uniforms:{},fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}",vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,
 "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function c(b,e,c){var f,h,g,j=b.vertices,m=j.length,t=b.colors,n=t.length,p=b.__vertexArray,u=b.__colorArray,o=b.__sortArray,v=b.__dirtyVertices,y=b.__dirtyColors,w=b.__webglCustomAttributes,z,x;if(w)for(z in w)w[z].offset=0;if(c.sortParticles){ja.multiplySelf(c.matrixWorld);for(f=0;f<m;f++)h=j[f].position,Aa.copy(h),ja.multiplyVector3(Aa),o[f]=[Aa.z,f];o.sort(function(b,e){return e[0]-b[0]});for(f=0;f<m;f++)h=j[o[f][1]].position,g=f*3,p[g]=h.x,p[g+1]=h.y,p[g+2]=h.z;
-for(f=0;f<n;f++)g=f*3,color=t[o[f][1]],u[g]=color.r,u[g+1]=color.g,u[g+2]=color.b;if(w)for(z in w){f=w[z];t=f.value.length;for(g=0;g<t;g++){index=o[g][1];n=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[n]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")x=f.value[index];f.size===2?(f.array[n]=x.x,f.array[n+1]=x.y):f.size===3?f.type==="c"?(f.array[n]=x.r,f.array[n+1]=x.g,f.array[n+2]=x.b):(f.array[n]=x.x,f.array[n+1]=x.y,f.array[n+2]=x.z):(f.array[n]=
-x.x,f.array[n+1]=x.y,f.array[n+2]=x.z,f.array[n+3]=x.w)}f.offset+=f.size}}}else{if(v)for(f=0;f<m;f++)h=j[f].position,g=f*3,p[g]=h.x,p[g+1]=h.y,p[g+2]=h.z;if(y)for(f=0;f<n;f++)color=t[f],g=f*3,u[g]=color.r,u[g+1]=color.g,u[g+2]=color.b;if(w)for(z in w)if(f=w[z],f.__original.needsUpdate){t=f.value.length;for(g=0;g<t;g++){n=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[n]=f.value[g]}else{if(f.boundTo===void 0||f.boundTo==="vertices")x=f.value[g];f.size===2?(f.array[n]=
-x.x,f.array[n+1]=x.y):f.size===3?f.type==="c"?(f.array[n]=x.r,f.array[n+1]=x.g,f.array[n+2]=x.b):(f.array[n]=x.x,f.array[n+1]=x.y,f.array[n+2]=x.z):(f.array[n]=x.x,f.array[n+1]=x.y,f.array[n+2]=x.z,f.array[n+3]=x.w)}f.offset+=f.size}}}if(v||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,p,e);if(y||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,b.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,u,e);if(w)for(z in w)if(f=w[z],f.__original.needsUpdate||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,
-f.buffer),k.bufferData(k.ARRAY_BUFFER,f.array,e)}function e(b,e,c,f,h){f.program||P.initMaterial(f,e,c,h);if(f.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(P.maxMorphTargets);for(var g=0,j=P.maxMorphTargets;g<j;g++)h.__webglMorphTargetInfluences[g]=0}var g=f.program,j=g.uniforms,m=f.uniforms;g!=Y&&(k.useProgram(g),Y=g);k.uniformMatrix4fv(j.projectionMatrix,!1,qa);if(c&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||
-f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(m.fogColor.value=c.color,c instanceof THREE.Fog)m.fogNear.value=c.near,m.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)m.fogDensity.value=c.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var n,t,p,u=0,o=0,v=0,y,w,x,z=La,B=z.directional.colors,F=z.directional.positions,H=z.point.colors,G=z.point.positions,J=z.point.distances,
-K=0,E=0,c=t=x=0;for(n=e.length;c<n;c++)if(t=e[c],p=t.color,y=t.position,w=t.intensity,x=t.distance,t instanceof THREE.AmbientLight)u+=p.r,o+=p.g,v+=p.b;else if(t instanceof THREE.DirectionalLight)x=K*3,B[x]=p.r*w,B[x+1]=p.g*w,B[x+2]=p.b*w,F[x]=y.x,F[x+1]=y.y,F[x+2]=y.z,K+=1;else if(t instanceof THREE.SpotLight)x=K*3,B[x]=p.r*w,B[x+1]=p.g*w,B[x+2]=p.b*w,p=1/y.length(),F[x]=y.x*p,F[x+1]=y.y*p,F[x+2]=y.z*p,K+=1;else if(t instanceof THREE.PointLight)t=E*3,H[t]=p.r*w,H[t+1]=p.g*w,H[t+2]=p.b*w,G[t]=y.x,
-G[t+1]=y.y,G[t+2]=y.z,J[E]=x,E+=1;for(c=K*3;c<B.length;c++)B[c]=0;for(c=E*3;c<H.length;c++)H[c]=0;z.point.length=E;z.directional.length=K;z.ambient[0]=u;z.ambient[1]=o;z.ambient[2]=v;c=La;m.enableLighting.value=c.directional.length+c.point.length;m.ambientLightColor.value=c.ambient;m.directionalLightColor.value=c.directional.colors;m.directionalLightDirection.value=c.directional.positions;m.pointLightColor.value=c.point.colors;m.pointLightPosition.value=c.point.positions;m.pointLightDistance.value=
-c.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)m.diffuse.value=f.color,m.opacity.value=f.opacity,(m.map.texture=f.map)&&m.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),m.lightMap.texture=f.lightMap,m.envMap.texture=f.envMap,m.reflectivity.value=f.reflectivity,m.refractionRatio.value=f.refractionRatio,m.combine.value=f.combine,m.useRefract.value=f.envMap&&f.envMap.mapping instanceof
-THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)m.diffuse.value=f.color,m.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)m.psColor.value=f.color,m.opacity.value=f.opacity,m.size.value=f.size,m.scale.value=za.height/2,m.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)m.ambient.value=f.ambient,m.specular.value=f.specular,m.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)m.mNear.value=b.near,m.mFar.value=b.far,m.opacity.value=
-f.opacity;else if(f instanceof THREE.MeshNormalMaterial)m.opacity.value=f.opacity;if(h.receiveShadow&&!f._shadowPass&&m.shadowMatrix){for(c=0;c<ra.length;c++)m.shadowMatrix.value[c]=ra[c],m.shadowMap.texture[c]=P.shadowMap[c];m.shadowDarkness.value=P.shadowMapDarkness;m.shadowBias.value=P.shadowMapBias}for(var A in m)if(u=g.uniforms[A])if(n=m[A],o=n.type,c=n.value,o=="i")k.uniform1i(u,c);else if(o=="f")k.uniform1f(u,c);else if(o=="fv1")k.uniform1fv(u,c);else if(o=="fv")k.uniform3fv(u,c);else if(o==
-"v2")k.uniform2f(u,c.x,c.y);else if(o=="v3")k.uniform3f(u,c.x,c.y,c.z);else if(o=="v4")k.uniform4f(u,c.x,c.y,c.z,c.w);else if(o=="m4"){if(!n._array)n._array=new Float32Array(16);c.flattenToArray(n._array);k.uniformMatrix4fv(u,!1,n._array)}else if(o=="m4v"){if(!n._array)n._array=new Float32Array(16*c.length);o=0;for(v=c.length;o<v;o++)c[o].flattenToArrayOffset(n._array,o*16);k.uniformMatrix4fv(u,!1,n._array)}else if(o=="c")k.uniform3f(u,c.r,c.g,c.b);else if(o=="t"){if(k.uniform1i(u,c),u=n.texture)if(u.image instanceof
-Array&&u.image.length==6){if(n=u,n.image.length==6){if(n.needsUpdate){if(n.__webglInit){k.bindTexture(k.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(u=0;u<6;++u)k.texSubImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,0,0,k.RGBA,k.UNSIGNED_BYTE,n.image[u])}else{n.image.__webglTextureCube=k.createTexture();k.bindTexture(k.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(u=0;u<6;++u)k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,n.image[u]);n.__webglInit=!0}R(k.TEXTURE_CUBE_MAP,
-n,n.image[0]);k.bindTexture(k.TEXTURE_CUBE_MAP,null);n.needsUpdate=!1}k.activeTexture(k.TEXTURE0+c);k.bindTexture(k.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}}else da(u,c)}else if(o=="tv"){if(!n._array){n._array=[];o=0;for(v=n.texture.length;o<v;o++)n._array[o]=c+o}k.uniform1iv(u,n._array);o=0;for(v=n.texture.length;o<v;o++)(u=n.texture[o])&&da(u,n._array[o])}k.uniformMatrix4fv(j.modelViewMatrix,!1,h._modelViewMatrixArray);k.uniformMatrix3fv(j.normalMatrix,!1,h._normalMatrixArray);(f instanceof
-THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&j.cameraPosition!==null&&k.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||h.receiveShadow)&&j.objectMatrix!==null&&k.uniformMatrix4fv(j.objectMatrix,!1,h._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&j.viewMatrix!==null&&k.uniformMatrix4fv(j.viewMatrix,
-!1,wa);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=m.directionalLightDirection.value,b[0]=-e[1].position.x,b[1]=-e[1].position.y,b[2]=-e[1].position.z,k.uniform3fv(j.directionalLightDirection,b),k.uniformMatrix4fv(j.objectMatrix,!1,h._objectMatrixArray),k.uniformMatrix4fv(j.viewMatrix,!1,wa);f.skinning&&(k.uniformMatrix4fv(j.cameraInverseMatrix,!1,wa),k.uniformMatrix4fv(j.boneGlobalMatrices,!1,h.boneMatrices));return g}function f(b,c,f,h,g,j){if(h.opacity!=0){var m,b=e(b,c,f,h,j).attributes;
-if(!h.morphTargets&&b.position>=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;f<h.numSupportedMorphTargets&&f<n.length;)k.bindBuffer(k.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[n[f]]),k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[f]=t[n[f]],f++;else{var n=[],p=-1,u=0,t=j.morphTargetInfluences,o,v=t.length,f=0;for(j.morphTargetBase!==-1&&(n[j.morphTargetBase]=!0);f<h.numSupportedMorphTargets;){for(o=0;o<v;o++)!n[o]&&t[o]>p&&(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;o<v;o+=9)e=b.normalArray,f=e[o],g=e[o+1],h=e[o+2],j=e[o+3],n=e[o+4],p=e[o+5],m=e[o+6],t=e[o+7],u=e[o+8],f=(f+j+m)/
-3,g=(g+n+t)/3,h=(h+p+u)/3,e[o]=f,e[o+1]=g,e[o+2]=h,e[o+3]=f,e[o+4]=g,e[o+5]=h,e[o+6]=f,e[o+7]=g,e[o+8]=h}k.bufferData(k.ARRAY_BUFFER,b.normalArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(c.attributes.normal);k.vertexAttribPointer(c.attributes.normal,3,k.FLOAT,!1,0,0)}k.drawArrays(k.TRIANGLES,0,b.count);b.count=0}function j(b){if(ha!=b.doubleSided)b.doubleSided?k.disable(k.CULL_FACE):k.enable(k.CULL_FACE),ha=b.doubleSided;if(ka!=b.flipSided)b.flipSided?k.frontFace(k.CW):k.frontFace(k.CCW),ka=b.flipSided}
-function h(b){U!=b&&(b?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST),U=b)}function m(b,c,e){X!=b&&(b?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL),X=b);if(b&&(ca!=c||ma!=e))k.polygonOffset(c,e),ca=c,ma=e}function n(b){ga[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);ga[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);ga[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);ga[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);ga[4].set(b.n41-b.n31,b.n42-
-b.n32,b.n43-b.n33,b.n44-b.n34);ga[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=ga[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function p(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),f=0;f<6;f++)if(b=ga[f].x*c.n14+ga[f].y*c.n24+ga[f].z*c.n34+ga[f].w,b<=e)return!1;return!0}function o(b,c){b.list[b.count]=c;b.count+=1}function t(b){var c,e,f=b.object,g=b.opaque,h=b.transparent;h.count=0;b=
-g.count=0;for(c=f.materials.length;b<c;b++)e=f.materials[b],e.transparent?o(h,e):o(g,e)}function v(b){var c,e,f,g,h=b.object,j=b.buffer,k=b.opaque,m=b.transparent;m.count=0;b=k.count=0;for(f=h.materials.length;b<f;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(e=j.materials.length;c<e;c++)(g=j.materials[c])&&(g.transparent?o(m,g):o(k,g))}else(g=c)&&(g.transparent?o(m,g):o(k,g))}function u(b,c){return c.z-b.z}function y(b,c){var m,t,o,u=0,v,y,x,w,z=b.lights;ia||(ia=new THREE.Camera(P.shadowCameraFov,
-c.aspect,P.shadowCameraNear,P.shadowCameraFar));m=0;for(t=z.length;m<t;m++)if(o=z[m],o instanceof THREE.SpotLight&&o.castShadow){P.shadowMap[u]||(P.shadowMap[u]=new THREE.WebGLRenderTarget(P.shadowMapWidth,P.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ra[u]||(ra[u]=new THREE.Matrix4);v=P.shadowMap[u];y=ra[u];ia.position.copy(o.position);ia.target.position.copy(o.target.position);ia.update(void 0,!0);b.update(void 0,!1,ia);y.set(0.5,0,0,0.5,
-0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);y.multiplySelf(ia.projectionMatrix);y.multiplySelf(ia.matrixWorldInverse);ia.matrixWorldInverse.flattenToArray(wa);ia.projectionMatrix.flattenToArray(qa);ja.multiply(ia.projectionMatrix,ia.matrixWorldInverse);n(ja);P.initWebGLObjects(b);T(v);k.clearColor(1,1,1,1);P.clear();k.clearColor(na.r,na.g,na.b,ua);y=b.__webglObjects.length;o=b.__webglObjectsImmediate.length;for(v=0;v<y;v++)x=b.__webglObjects[v],w=x.object,w.visible&&w.castShadow?!(w instanceof THREE.Mesh)||
-p(w)?(w.matrixWorld.flattenToArray(w._objectMatrixArray),H(w,ia,!1),x.render=!0):x.render=!1:x.render=!1;h(!0);I(THREE.NormalBlending);for(v=0;v<y;v++)if(x=b.__webglObjects[v],x.render)w=x.object,buffer=x.buffer,j(w),x=w.customDepthMaterial?w.customDepthMaterial:w.geometry.morphTargets.length?pa:Ba,f(ia,z,null,x,buffer,w);for(v=0;v<o;v++)x=b.__webglObjectsImmediate[v],w=x.object,w.visible&&w.castShadow&&(w.matrixAutoUpdate&&w.matrixWorld.flattenToArray(w._objectMatrixArray),H(w,ia,!1),j(w),program=
-e(ia,z,null,Ba,w),w.render(function(b){g(b,program,Ba.shading)}));u++}}function z(b){k.enable(k.POLYGON_OFFSET_FILL);k.polygonOffset(0.1,1);k.enable(k.STENCIL_TEST);k.enable(k.DEPTH_TEST);k.depthMask(!1);k.colorMask(!1,!1,!1,!1);k.stencilFunc(k.ALWAYS,1,255);k.stencilOpSeparate(k.BACK,k.KEEP,k.INCR,k.KEEP);k.stencilOpSeparate(k.FRONT,k.KEEP,k.DECR,k.KEEP);var c,e=b.lights.length,f,g=b.lights,h=[],j,m,n,t,p,o=b.__webglShadowVolumes.length;for(c=0;c<e;c++)if(f=b.lights[c],f instanceof THREE.DirectionalLight&&
-f.castShadow){h[0]=-f.position.x;h[1]=-f.position.y;h[2]=-f.position.z;for(p=0;p<o;p++)f=b.__webglShadowVolumes[p].object,j=b.__webglShadowVolumes[p].buffer,m=f.materials[0],m.program||P.initMaterial(m,g,void 0,f),m=m.program,n=m.uniforms,t=m.attributes,Y!==m&&(k.useProgram(m),Y=m,k.uniformMatrix4fv(n.projectionMatrix,!1,qa),k.uniformMatrix4fv(n.viewMatrix,!1,wa),k.uniform3fv(n.directionalLightDirection,h)),f.matrixWorld.flattenToArray(f._objectMatrixArray),k.uniformMatrix4fv(n.objectMatrix,!1,f._objectMatrixArray),
-k.bindBuffer(k.ARRAY_BUFFER,j.__webglVertexBuffer),k.vertexAttribPointer(t.position,3,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,j.__webglNormalBuffer),k.vertexAttribPointer(t.normal,3,k.FLOAT,!1,0,0),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,j.__webglFaceBuffer),k.cullFace(k.FRONT),k.drawElements(k.TRIANGLES,j.__webglFaceCount,k.UNSIGNED_SHORT,0),k.cullFace(k.BACK),k.drawElements(k.TRIANGLES,j.__webglFaceCount,k.UNSIGNED_SHORT,0)}k.disable(k.POLYGON_OFFSET_FILL);k.colorMask(!0,!0,!0,!0);k.stencilFunc(k.NOTEQUAL,
-0,255);k.stencilOp(k.KEEP,k.KEEP,k.KEEP);k.disable(k.DEPTH_TEST);U=fa=-1;Y=$.program;k.useProgram($.program);k.uniformMatrix4fv($.projectionLocation,!1,qa);k.uniform1f($.darknessLocation,$.darkness);k.bindBuffer(k.ARRAY_BUFFER,$.vertexBuffer);k.vertexAttribPointer($.vertexLocation,3,k.FLOAT,!1,0,0);k.enableVertexAttribArray($.vertexLocation);k.blendFunc(k.ONE,k.ONE_MINUS_SRC_ALPHA);k.blendEquation(k.FUNC_ADD);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,$.elementBuffer);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,
-0);k.disable(k.STENCIL_TEST);k.enable(k.DEPTH_TEST);k.depthMask(Z)}function x(b,c){var e,f,g;e=O.attributes;var h=O.uniforms,j=V/K,m,n=[],t=K*0.5,p=V*0.5,o=!0;k.useProgram(O.program);Y=O.program;U=fa=-1;Wa||(k.enableVertexAttribArray(O.attributes.position),k.enableVertexAttribArray(O.attributes.uv),Wa=!0);k.disable(k.CULL_FACE);k.enable(k.BLEND);k.depthMask(!0);k.bindBuffer(k.ARRAY_BUFFER,O.vertexBuffer);k.vertexAttribPointer(e.position,2,k.FLOAT,!1,16,0);k.vertexAttribPointer(e.uv,2,k.FLOAT,!1,16,
-8);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,O.elementBuffer);k.uniformMatrix4fv(h.projectionMatrix,!1,qa);k.activeTexture(k.TEXTURE0);k.uniform1i(h.map,0);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.useScreenCoordinates?g.z=-g.position.z:(g._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,g.matrixWorld,g._modelViewMatrixArray),g.z=-g._modelViewMatrix.n34);b.__webglSprites.sort(u);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.material===void 0&&g.map&&g.map.image&&
-g.map.image.width&&(g.useScreenCoordinates?(k.uniform1i(h.useScreenCoordinates,1),k.uniform3f(h.screenPosition,(g.position.x-t)/t,(p-g.position.y)/p,Math.max(0,Math.min(1,g.position.z)))):(k.uniform1i(h.useScreenCoordinates,0),k.uniform1i(h.affectedByDistance,g.affectedByDistance?1:0),k.uniformMatrix4fv(h.modelViewMatrix,!1,g._modelViewMatrixArray)),m=g.map.image.width/(g.scaleByViewport?V:1),n[0]=m*j*g.scale.x,n[1]=m*g.scale.y,k.uniform2f(h.uvScale,g.uvScale.x,g.uvScale.y),k.uniform2f(h.uvOffset,
-g.uvOffset.x,g.uvOffset.y),k.uniform2f(h.alignment,g.alignment.x,g.alignment.y),k.uniform1f(h.opacity,g.opacity),k.uniform1f(h.rotation,g.rotation),k.uniform2fv(h.scale,n),g.mergeWith3D&&!o?(k.enable(k.DEPTH_TEST),o=!0):!g.mergeWith3D&&o&&(k.disable(k.DEPTH_TEST),o=!1),I(g.blending),da(g.map,0),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0));k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(Z)}function w(b,c){var e,f,g=b.__webglLensFlares.length,h,j,m,n=new THREE.Vector3,t=V/K,p=K*0.5,o=
-V*0.5,u=16/V,v=[u*t,u],y=[1,1,0],w=[1,1],x=Q.uniforms;e=Q.attributes;k.useProgram(Q.program);Y=Q.program;U=fa=-1;Ea||(k.enableVertexAttribArray(Q.attributes.vertex),k.enableVertexAttribArray(Q.attributes.uv),Ea=!0);k.uniform1i(x.occlusionMap,0);k.uniform1i(x.map,1);k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.vertexAttribPointer(e.vertex,2,k.FLOAT,!1,16,0);k.vertexAttribPointer(e.uv,2,k.FLOAT,!1,16,8);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.disable(k.CULL_FACE);k.depthMask(!1);k.activeTexture(k.TEXTURE0);
-k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.activeTexture(k.TEXTURE1);for(f=0;f<g;f++)if(e=b.__webglLensFlares[f].object,n.set(e.matrixWorld.n14,e.matrixWorld.n24,e.matrixWorld.n34),c.matrixWorldInverse.multiplyVector3(n),c.projectionMatrix.multiplyVector3(n),y[0]=n.x,y[1]=n.y,y[2]=n.z,w[0]=y[0]*p+p,w[1]=y[1]*o+o,Q.hasVertexTexture||w[0]>0&&w[0]<K&&w[1]>0&&w[1]<V){k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.copyTexImage2D(k.TEXTURE_2D,0,k.RGB,w[0]-8,w[1]-8,16,16,0);k.uniform1i(x.renderType,0);
-k.uniform2fv(x.scale,v);k.uniform3fv(x.screenPosition,y);k.disable(k.BLEND);k.enable(k.DEPTH_TEST);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0);k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.copyTexImage2D(k.TEXTURE_2D,0,k.RGBA,w[0]-8,w[1]-8,16,16,0);k.uniform1i(x.renderType,1);k.disable(k.DEPTH_TEST);k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0);e.positionScreen.x=y[0];e.positionScreen.y=y[1];e.positionScreen.z=y[2];e.customUpdateCallback?e.customUpdateCallback(e):
-e.updateLensFlares();k.uniform1i(x.renderType,2);k.enable(k.BLEND);h=0;for(j=e.lensFlares.length;h<j;h++)if(m=e.lensFlares[h],m.opacity>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;b<e;b++)if(f=g[b],f.attributes)for(c in f.attributes)if(f.attributes[c].needsUpdate)return!0;return!1}function F(b){var c,e,f,g;g=b.__materials;b=0;for(e=g.length;b<e;b++)if(f=g[b],f.attributes)for(c in f.attributes)f.attributes[c].needsUpdate=!1}function J(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;
-for(e in f.geometryGroups)if(g=f.geometryGroups[e],h=B(g),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||h){h=g;var j=k.DYNAMIC_DRAW,m=!f.dynamic;if(h.__inittedArrays){var n=void 0,t=void 0,p=void 0,o=void 0,u=p=void 0,v=void 0,y=void 0,w=void 0,x=void 0,z=void 0,H=void 0,G=void 0,J=void 0,K=void 0,D=void 0,I=void 0,V=void 0,E=o=w=o=y=v=void 0,A=void 0,C=A=E=v=void 0,M=void 0,U=C=A=E=p=p=u=w=o=C=A=E=M=C=A=E=M=C=A=E=
-void 0,L=0,ga=0,X=0,Q=0,R=0,Z=0,O=0,T=0,ja=0,N=0,P=0,C=E=0,C=void 0,S=h.__vertexArray,da=h.__uvArray,ea=h.__uv2Array,ka=h.__normalArray,W=h.__tangentArray,aa=h.__colorArray,Y=h.__skinVertexAArray,fa=h.__skinVertexBArray,ca=h.__skinIndexArray,$=h.__skinWeightArray,ma=h.__morphTargetsArrays,ha=h.__webglCustomAttributes,A=void 0,qa=h.__faceArray,la=h.__lineArray,na=h.__needsSmoothNormals,z=h.__vertexColorType,x=h.__uvType,H=h.__normalType,ia=b.geometry,sa=ia.__dirtyVertices,pa=ia.__dirtyElements,wa=
-ia.__dirtyUvs,ra=ia.__dirtyNormals,Aa=ia.__dirtyTangents,ta=ia.__dirtyColors,za=ia.__dirtyMorphTargets,ua=ia.vertices,Ba=h.faces,La=ia.faces,Da=ia.faceVertexUvs[0],Ea=ia.faceVertexUvs[1],xa=ia.skinVerticesA,ya=ia.skinVerticesB,Na=ia.skinIndices,Ga=ia.skinWeights,Ka=b instanceof THREE.ShadowVolume?ia.edgeFaces:void 0,Fa=ia.morphTargets;if(ha)for(U in ha)ha[U].offset=0,ha[U].offsetSrc=0;n=0;for(t=Ba.length;n<t;n++)if(p=Ba[n],o=La[p],Da&&(G=Da[p]),Ea&&(J=Ea[p]),p=o.vertexNormals,u=o.normal,v=o.vertexColors,
-y=o.color,w=o.vertexTangents,o instanceof THREE.Face3){if(sa)K=ua[o.a].position,D=ua[o.b].position,I=ua[o.c].position,S[ga]=K.x,S[ga+1]=K.y,S[ga+2]=K.z,S[ga+3]=D.x,S[ga+4]=D.y,S[ga+5]=D.z,S[ga+6]=I.x,S[ga+7]=I.y,S[ga+8]=I.z,ga+=9;if(ha)for(U in ha)if(A=ha[U],A.__original.needsUpdate)E=A.offset,C=A.offsetSrc,A.size===1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[E]=A.value[o.a],A.array[E+1]=A.value[o.b],A.array[E+2]=A.value[o.c]):A.boundTo==="faces"?(C=A.value[C],A.array[E]=C,A.array[E+1]=
-C,A.array[E+2]=C,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[E]=A.value[C],A.array[E+1]=A.value[C+1],A.array[E+2]=A.value[C+2],A.offsetSrc+=3),A.offset+=3):(A.boundTo===void 0||A.boundTo==="vertices"?(K=A.value[o.a],D=A.value[o.b],I=A.value[o.c]):A.boundTo==="faces"?(I=D=K=C=A.value[C],A.offsetSrc++):A.boundTo==="faceVertices"&&(K=A.value[C],D=A.value[C+1],I=A.value[C+2],A.offsetSrc+=3),A.size===2?(A.array[E]=K.x,A.array[E+1]=K.y,A.array[E+2]=D.x,A.array[E+3]=D.y,A.array[E+4]=I.x,A.array[E+
-5]=I.y,A.offset+=6):A.size===3?(A.type==="c"?(A.array[E]=K.r,A.array[E+1]=K.g,A.array[E+2]=K.b,A.array[E+3]=D.r,A.array[E+4]=D.g,A.array[E+5]=D.b,A.array[E+6]=I.r,A.array[E+7]=I.g,A.array[E+8]=I.b):(A.array[E]=K.x,A.array[E+1]=K.y,A.array[E+2]=K.z,A.array[E+3]=D.x,A.array[E+4]=D.y,A.array[E+5]=D.z,A.array[E+6]=I.x,A.array[E+7]=I.y,A.array[E+8]=I.z),A.offset+=9):(A.array[E]=K.x,A.array[E+1]=K.y,A.array[E+2]=K.z,A.array[E+3]=K.w,A.array[E+4]=D.x,A.array[E+5]=D.y,A.array[E+6]=D.z,A.array[E+7]=D.w,A.array[E+
-8]=I.x,A.array[E+9]=I.y,A.array[E+10]=I.z,A.array[E+11]=I.w,A.offset+=12));if(za){E=0;for(A=Fa.length;E<A;E++)K=Fa[E].vertices[o.a].position,D=Fa[E].vertices[o.b].position,I=Fa[E].vertices[o.c].position,C=ma[E],C[P]=K.x,C[P+1]=K.y,C[P+2]=K.z,C[P+3]=D.x,C[P+4]=D.y,C[P+5]=D.z,C[P+6]=I.x,C[P+7]=I.y,C[P+8]=I.z;P+=9}if(Ga.length)E=Ga[o.a],A=Ga[o.b],C=Ga[o.c],$[N]=E.x,$[N+1]=E.y,$[N+2]=E.z,$[N+3]=E.w,$[N+4]=A.x,$[N+5]=A.y,$[N+6]=A.z,$[N+7]=A.w,$[N+8]=C.x,$[N+9]=C.y,$[N+10]=C.z,$[N+11]=C.w,E=Na[o.a],A=Na[o.b],
-C=Na[o.c],ca[N]=E.x,ca[N+1]=E.y,ca[N+2]=E.z,ca[N+3]=E.w,ca[N+4]=A.x,ca[N+5]=A.y,ca[N+6]=A.z,ca[N+7]=A.w,ca[N+8]=C.x,ca[N+9]=C.y,ca[N+10]=C.z,ca[N+11]=C.w,E=xa[o.a],A=xa[o.b],C=xa[o.c],Y[N]=E.x,Y[N+1]=E.y,Y[N+2]=E.z,Y[N+3]=1,Y[N+4]=A.x,Y[N+5]=A.y,Y[N+6]=A.z,Y[N+7]=1,Y[N+8]=C.x,Y[N+9]=C.y,Y[N+10]=C.z,Y[N+11]=1,E=ya[o.a],A=ya[o.b],C=ya[o.c],fa[N]=E.x,fa[N+1]=E.y,fa[N+2]=E.z,fa[N+3]=1,fa[N+4]=A.x,fa[N+5]=A.y,fa[N+6]=A.z,fa[N+7]=1,fa[N+8]=C.x,fa[N+9]=C.y,fa[N+10]=C.z,fa[N+11]=1,N+=12;if(ta&&z)v.length==
-3&&z==THREE.VertexColors?(o=v[0],E=v[1],A=v[2]):A=E=o=y,aa[ja]=o.r,aa[ja+1]=o.g,aa[ja+2]=o.b,aa[ja+3]=E.r,aa[ja+4]=E.g,aa[ja+5]=E.b,aa[ja+6]=A.r,aa[ja+7]=A.g,aa[ja+8]=A.b,ja+=9;if(Aa&&ia.hasTangents)v=w[0],y=w[1],o=w[2],W[O]=v.x,W[O+1]=v.y,W[O+2]=v.z,W[O+3]=v.w,W[O+4]=y.x,W[O+5]=y.y,W[O+6]=y.z,W[O+7]=y.w,W[O+8]=o.x,W[O+9]=o.y,W[O+10]=o.z,W[O+11]=o.w,O+=12;if(ra&&H)if(p.length==3&&na)for(w=0;w<3;w++)u=p[w],ka[Z]=u.x,ka[Z+1]=u.y,ka[Z+2]=u.z,Z+=3;else for(w=0;w<3;w++)ka[Z]=u.x,ka[Z+1]=u.y,ka[Z+2]=u.z,
-Z+=3;if(wa&&G!==void 0&&x)for(w=0;w<3;w++)p=G[w],da[X]=p.u,da[X+1]=p.v,X+=2;if(wa&&J!==void 0&&x)for(w=0;w<3;w++)p=J[w],ea[Q]=p.u,ea[Q+1]=p.v,Q+=2;pa&&(qa[R]=L,qa[R+1]=L+1,qa[R+2]=L+2,R+=3,la[T]=L,la[T+1]=L+1,la[T+2]=L,la[T+3]=L+2,la[T+4]=L+1,la[T+5]=L+2,T+=6,L+=3)}else if(o instanceof THREE.Face4){if(sa)K=ua[o.a].position,D=ua[o.b].position,I=ua[o.c].position,V=ua[o.d].position,S[ga]=K.x,S[ga+1]=K.y,S[ga+2]=K.z,S[ga+3]=D.x,S[ga+4]=D.y,S[ga+5]=D.z,S[ga+6]=I.x,S[ga+7]=I.y,S[ga+8]=I.z,S[ga+9]=V.x,S[ga+
-10]=V.y,S[ga+11]=V.z,ga+=12;if(ha)for(U in ha)if(A=ha[U],A.__original.needsUpdate)E=A.offset,C=A.offsetSrc,A.size===1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[E]=A.value[o.a],A.array[E+1]=A.value[o.b],A.array[E+2]=A.value[o.c],A.array[E+3]=A.value[o.d]):A.boundTo==="faces"?(C=A.value[C],A.array[E]=C,A.array[E+1]=C,A.array[E+2]=C,A.array[E+3]=C,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[E]=A.value[C],A.array[E+1]=A.value[C+1],A.array[E+2]=A.value[C+2],A.array[E+3]=A.value[C+3],
-A.offsetSrc+=4),A.offset+=4):(A.boundTo===void 0||A.boundTo==="vertices"?(K=A.value[o.a],D=A.value[o.b],I=A.value[o.c],V=A.value[o.d]):A.boundTo==="faces"?(V=I=D=K=C=A.value[C],A.offsetSrc++):A.boundTo==="faceVertices"&&(K=A.value[C],D=A.value[C+1],I=A.value[C+2],V=A.value[C+3],A.offsetSrc+=4),A.size===2?(A.array[E]=K.x,A.array[E+1]=K.y,A.array[E+2]=D.x,A.array[E+3]=D.y,A.array[E+4]=I.x,A.array[E+5]=I.y,A.array[E+6]=V.x,A.array[E+7]=V.y,A.offset+=8):A.size===3?(A.type==="c"?(A.array[E]=K.r,A.array[E+
-1]=K.g,A.array[E+2]=K.b,A.array[E+3]=D.r,A.array[E+4]=D.g,A.array[E+5]=D.b,A.array[E+6]=I.r,A.array[E+7]=I.g,A.array[E+8]=I.b,A.array[E+9]=V.r,A.array[E+10]=V.g,A.array[E+11]=V.b):(A.array[E]=K.x,A.array[E+1]=K.y,A.array[E+2]=K.z,A.array[E+3]=D.x,A.array[E+4]=D.y,A.array[E+5]=D.z,A.array[E+6]=I.x,A.array[E+7]=I.y,A.array[E+8]=I.z,A.array[E+9]=V.x,A.array[E+10]=V.y,A.array[E+11]=V.z),A.offset+=12):(A.array[E]=K.x,A.array[E+1]=K.y,A.array[E+2]=K.z,A.array[E+3]=K.w,A.array[E+4]=D.x,A.array[E+5]=D.y,
-A.array[E+6]=D.z,A.array[E+7]=D.w,A.array[E+8]=I.x,A.array[E+9]=I.y,A.array[E+10]=I.z,A.array[E+11]=I.w,A.array[E+12]=V.x,A.array[E+13]=V.y,A.array[E+14]=V.z,A.array[E+15]=V.w,A.offset+=16));if(za){E=0;for(A=Fa.length;E<A;E++)K=Fa[E].vertices[o.a].position,D=Fa[E].vertices[o.b].position,I=Fa[E].vertices[o.c].position,V=Fa[E].vertices[o.d].position,C=ma[E],C[P]=K.x,C[P+1]=K.y,C[P+2]=K.z,C[P+3]=D.x,C[P+4]=D.y,C[P+5]=D.z,C[P+6]=I.x,C[P+7]=I.y,C[P+8]=I.z,C[P+9]=V.x,C[P+10]=V.y,C[P+11]=V.z;P+=12}if(Ga.length)E=
-Ga[o.a],A=Ga[o.b],C=Ga[o.c],M=Ga[o.d],$[N]=E.x,$[N+1]=E.y,$[N+2]=E.z,$[N+3]=E.w,$[N+4]=A.x,$[N+5]=A.y,$[N+6]=A.z,$[N+7]=A.w,$[N+8]=C.x,$[N+9]=C.y,$[N+10]=C.z,$[N+11]=C.w,$[N+12]=M.x,$[N+13]=M.y,$[N+14]=M.z,$[N+15]=M.w,E=Na[o.a],A=Na[o.b],C=Na[o.c],M=Na[o.d],ca[N]=E.x,ca[N+1]=E.y,ca[N+2]=E.z,ca[N+3]=E.w,ca[N+4]=A.x,ca[N+5]=A.y,ca[N+6]=A.z,ca[N+7]=A.w,ca[N+8]=C.x,ca[N+9]=C.y,ca[N+10]=C.z,ca[N+11]=C.w,ca[N+12]=M.x,ca[N+13]=M.y,ca[N+14]=M.z,ca[N+15]=M.w,E=xa[o.a],A=xa[o.b],C=xa[o.c],M=xa[o.d],Y[N]=E.x,
-Y[N+1]=E.y,Y[N+2]=E.z,Y[N+3]=1,Y[N+4]=A.x,Y[N+5]=A.y,Y[N+6]=A.z,Y[N+7]=1,Y[N+8]=C.x,Y[N+9]=C.y,Y[N+10]=C.z,Y[N+11]=1,Y[N+12]=M.x,Y[N+13]=M.y,Y[N+14]=M.z,Y[N+15]=1,E=ya[o.a],A=ya[o.b],C=ya[o.c],o=ya[o.d],fa[N]=E.x,fa[N+1]=E.y,fa[N+2]=E.z,fa[N+3]=1,fa[N+4]=A.x,fa[N+5]=A.y,fa[N+6]=A.z,fa[N+7]=1,fa[N+8]=C.x,fa[N+9]=C.y,fa[N+10]=C.z,fa[N+11]=1,fa[N+12]=o.x,fa[N+13]=o.y,fa[N+14]=o.z,fa[N+15]=1,N+=16;if(ta&&z)v.length==4&&z==THREE.VertexColors?(o=v[0],E=v[1],A=v[2],v=v[3]):v=A=E=o=y,aa[ja]=o.r,aa[ja+1]=
-o.g,aa[ja+2]=o.b,aa[ja+3]=E.r,aa[ja+4]=E.g,aa[ja+5]=E.b,aa[ja+6]=A.r,aa[ja+7]=A.g,aa[ja+8]=A.b,aa[ja+9]=v.r,aa[ja+10]=v.g,aa[ja+11]=v.b,ja+=12;if(Aa&&ia.hasTangents)v=w[0],y=w[1],o=w[2],w=w[3],W[O]=v.x,W[O+1]=v.y,W[O+2]=v.z,W[O+3]=v.w,W[O+4]=y.x,W[O+5]=y.y,W[O+6]=y.z,W[O+7]=y.w,W[O+8]=o.x,W[O+9]=o.y,W[O+10]=o.z,W[O+11]=o.w,W[O+12]=w.x,W[O+13]=w.y,W[O+14]=w.z,W[O+15]=w.w,O+=16;if(ra&&H)if(p.length==4&&na)for(w=0;w<4;w++)u=p[w],ka[Z]=u.x,ka[Z+1]=u.y,ka[Z+2]=u.z,Z+=3;else for(w=0;w<4;w++)ka[Z]=u.x,ka[Z+
-1]=u.y,ka[Z+2]=u.z,Z+=3;if(wa&&G!==void 0&&x)for(w=0;w<4;w++)p=G[w],da[X]=p.u,da[X+1]=p.v,X+=2;if(wa&&J!==void 0&&x)for(w=0;w<4;w++)p=J[w],ea[Q]=p.u,ea[Q+1]=p.v,Q+=2;pa&&(qa[R]=L,qa[R+1]=L+1,qa[R+2]=L+3,qa[R+3]=L+1,qa[R+4]=L+2,qa[R+5]=L+3,R+=6,la[T]=L,la[T+1]=L+1,la[T+2]=L,la[T+3]=L+3,la[T+4]=L+1,la[T+5]=L+2,la[T+6]=L+2,la[T+7]=L+3,T+=8,L+=4)}if(Ka){n=0;for(t=Ka.length;n<t;n++)qa[R]=Ka[n].a,qa[R+1]=Ka[n].b,qa[R+2]=Ka[n].c,qa[R+3]=Ka[n].a,qa[R+4]=Ka[n].c,qa[R+5]=Ka[n].d,R+=6}sa&&(k.bindBuffer(k.ARRAY_BUFFER,
-h.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,S,j));if(ha)for(U in ha)A=ha[U],A.__original.needsUpdate&&(k.bindBuffer(k.ARRAY_BUFFER,A.buffer),k.bufferData(k.ARRAY_BUFFER,A.array,j));if(za){E=0;for(A=Fa.length;E<A;E++)k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[E]),k.bufferData(k.ARRAY_BUFFER,ma[E],j)}ta&&ja>0&&(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<z;n++)t=x[n].position,g=n*3,H[g]=t.x,H[g+1]=t.y,H[g+2]=t.z;k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,H,e)}if(G){for(n=0;n<j;n++)color=h[n],g=n*3,m[g]=color.r,m[g+1]=color.g,m[g+2]=color.b;k.bindBuffer(k.ARRAY_BUFFER,b.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,m,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){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<z;n++)t=x[n].position,g=n*3,H[g]=t.x,H[g+1]=t.y,H[g+2]=t.z;k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,H,e)}if(G){for(n=0;n<j;n++)color=h[n],g=n*3,m[g]=color.r,m[g+1]=color.g,m[g+2]=color.b;k.bindBuffer(k.ARRAY_BUFFER,b.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,m,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=
-b.geometry,h=B(f),(f.__dirtyVertices||f.__dirtyColors||b.sortParticles||h)&&c(f,k.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1,F(f)}function D(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function L(b){function e(b){var h=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?h.push("undefined"):h.push(b[c].id);return h.join("_")}var c,f,h,g,j,k,m,n,o={},t=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};h=0;for(g=b.faces.length;h<g;h++)j=b.faces[h],k=j.materials,
-m=e(k),o[m]==void 0&&(o[m]={hash:m,counter:0}),n=o[m].hash+"_"+o[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:t}),j=j instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+j>65535&&(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<o;n++)g=c[n],g instanceof THREE.SpotLight&&t++,g instanceof THREE.DirectionalLight&&t++,g instanceof THREE.PointLight&&
-m++;m+t<=4?n=t:(n=Math.ceil(4*t/(m+t)),m=4-n);g={directional:n,point:m};m=t=0;for(n=c.length;m<n;m++)o=c[m],o instanceof THREE.SpotLight&&o.castShadow&&t++;var p=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)p=f.bones.length;var u;a:{n=b.fragmentShader;o=b.vertexShader;var m=b.uniforms,c=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,
-maxDirLights:g.directional,maxPointLights:g.point,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:t,alphaTest:b.alphaTest},v,f=[];j?f.push(j):(f.push(n),f.push(o));for(v in e)f.push(v),f.push(e[v]);j=f.join();v=0;for(f=M.length;v<f;v++)if(M[v].code==j){u=M[v].program;break a}v=k.createProgram();f=[Da?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,
+THREE.WebGLRenderer=function(b){function c(b,c,e){var f,h,g,j=b.vertices,k=j.length,m=b.colors,o=m.length,u=b.__vertexArray,t=b.__colorArray,p=b.__sortArray,v=b.__dirtyVertices,w=b.__dirtyColors,x=b.__webglCustomAttributes,A,B;if(x)for(A in x)x[A].offset=0;if(e.sortParticles){ja.multiplySelf(e.matrixWorld);for(f=0;f<k;f++)h=j[f].position,pa.copy(h),ja.multiplyVector3(pa),p[f]=[pa.z,f];p.sort(function(b,c){return c[0]-b[0]});for(f=0;f<k;f++)h=j[p[f][1]].position,g=f*3,u[g]=h.x,u[g+1]=h.y,u[g+2]=h.z;
+for(f=0;f<o;f++)g=f*3,color=m[p[f][1]],t[g]=color.r,t[g+1]=color.g,t[g+2]=color.b;if(x)for(A in x){f=x[A];m=f.value.length;for(g=0;g<m;g++){index=p[g][1];o=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[o]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")B=f.value[index];f.size===2?(f.array[o]=B.x,f.array[o+1]=B.y):f.size===3?f.type==="c"?(f.array[o]=B.r,f.array[o+1]=B.g,f.array[o+2]=B.b):(f.array[o]=B.x,f.array[o+1]=B.y,f.array[o+2]=B.z):(f.array[o]=
+B.x,f.array[o+1]=B.y,f.array[o+2]=B.z,f.array[o+3]=B.w)}f.offset+=f.size}}}else{if(v)for(f=0;f<k;f++)h=j[f].position,g=f*3,u[g]=h.x,u[g+1]=h.y,u[g+2]=h.z;if(w)for(f=0;f<o;f++)color=m[f],g=f*3,t[g]=color.r,t[g+1]=color.g,t[g+2]=color.b;if(x)for(A in x)if(f=x[A],f.__original.needsUpdate){m=f.value.length;for(g=0;g<m;g++){o=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[o]=f.value[g]}else{if(f.boundTo===void 0||f.boundTo==="vertices")B=f.value[g];f.size===2?(f.array[o]=
+B.x,f.array[o+1]=B.y):f.size===3?f.type==="c"?(f.array[o]=B.r,f.array[o+1]=B.g,f.array[o+2]=B.b):(f.array[o]=B.x,f.array[o+1]=B.y,f.array[o+2]=B.z):(f.array[o]=B.x,f.array[o+1]=B.y,f.array[o+2]=B.z,f.array[o+3]=B.w)}f.offset+=f.size}}}if(v||e.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,u,c);if(w||e.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,b.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,t,c);if(x)for(A in x)if(f=x[A],f.__original.needsUpdate||e.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,
+f.buffer),n.bufferData(n.ARRAY_BUFFER,f.array,c)}function e(b,c,e,f,h){f.program||C.initMaterial(f,c,e,h);if(f.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(C.maxMorphTargets);for(var g=0,j=C.maxMorphTargets;g<j;g++)h.__webglMorphTargetInfluences[g]=0}var g=f.program,j=g.uniforms,k=f.uniforms;g!=V&&(n.useProgram(g),V=g);n.uniformMatrix4fv(j.projectionMatrix,!1,la);if(e&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||
+f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(k.fogColor.value=e.color,e instanceof THREE.Fog)k.fogNear.value=e.near,k.fogFar.value=e.far;else if(e instanceof THREE.FogExp2)k.fogDensity.value=e.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var m,o,u,t=0,p=0,v=0,w,B,x,A=sa,y=A.directional.colors,G=A.directional.positions,H=A.point.colors,I=A.point.positions,ja=A.point.distances,
+E=0,J=0,e=o=x=0;for(m=c.length;e<m;e++)if(o=c[e],u=o.color,w=o.position,B=o.intensity,x=o.distance,o instanceof THREE.AmbientLight)t+=u.r,p+=u.g,v+=u.b;else if(o instanceof THREE.DirectionalLight)x=E*3,y[x]=u.r*B,y[x+1]=u.g*B,y[x+2]=u.b*B,G[x]=w.x,G[x+1]=w.y,G[x+2]=w.z,E+=1;else if(o instanceof THREE.SpotLight)x=E*3,y[x]=u.r*B,y[x+1]=u.g*B,y[x+2]=u.b*B,u=1/w.length(),G[x]=w.x*u,G[x+1]=w.y*u,G[x+2]=w.z*u,E+=1;else if(o instanceof THREE.PointLight)o=J*3,H[o]=u.r*B,H[o+1]=u.g*B,H[o+2]=u.b*B,I[o]=w.x,
+I[o+1]=w.y,I[o+2]=w.z,ja[J]=x,J+=1;for(e=E*3;e<y.length;e++)y[e]=0;for(e=J*3;e<H.length;e++)H[e]=0;A.point.length=J;A.directional.length=E;A.ambient[0]=t;A.ambient[1]=p;A.ambient[2]=v;c=sa;k.enableLighting.value=c.directional.length+c.point.length;k.ambientLightColor.value=c.ambient;k.directionalLightColor.value=c.directional.colors;k.directionalLightDirection.value=c.directional.positions;k.pointLightColor.value=c.point.colors;k.pointLightPosition.value=c.point.positions;k.pointLightDistance.value=
+c.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)k.diffuse.value=f.color,k.opacity.value=f.opacity,(k.map.texture=f.map)&&k.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),k.lightMap.texture=f.lightMap,k.envMap.texture=f.envMap,k.reflectivity.value=f.reflectivity,k.refractionRatio.value=f.refractionRatio,k.combine.value=f.combine,k.useRefract.value=f.envMap&&f.envMap.mapping instanceof
+THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)k.diffuse.value=f.color,k.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)k.psColor.value=f.color,k.opacity.value=f.opacity,k.size.value=f.size,k.scale.value=ua.height/2,k.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)k.ambient.value=f.ambient,k.specular.value=f.specular,k.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)k.mNear.value=b.near,k.mFar.value=b.far,k.opacity.value=
+f.opacity;else if(f instanceof THREE.MeshNormalMaterial)k.opacity.value=f.opacity;if(h.receiveShadow&&!f._shadowPass&&k.shadowMatrix){for(c=0;c<ta.length;c++)k.shadowMatrix.value[c]=ta[c],k.shadowMap.texture[c]=C.shadowMap[c];k.shadowDarkness.value=C.shadowMapDarkness;k.shadowBias.value=C.shadowMapBias}for(var L in k)if(m=g.uniforms[L])if(e=k[L],t=e.type,c=e.value,t=="i")n.uniform1i(m,c);else if(t=="f")n.uniform1f(m,c);else if(t=="fv1")n.uniform1fv(m,c);else if(t=="fv")n.uniform3fv(m,c);else if(t==
+"v2")n.uniform2f(m,c.x,c.y);else if(t=="v3")n.uniform3f(m,c.x,c.y,c.z);else if(t=="v4")n.uniform4f(m,c.x,c.y,c.z,c.w);else if(t=="m4"){if(!e._array)e._array=new Float32Array(16);c.flattenToArray(e._array);n.uniformMatrix4fv(m,!1,e._array)}else if(t=="m4v"){if(!e._array)e._array=new Float32Array(16*c.length);t=0;for(p=c.length;t<p;t++)c[t].flattenToArrayOffset(e._array,t*16);n.uniformMatrix4fv(m,!1,e._array)}else if(t=="c")n.uniform3f(m,c.r,c.g,c.b);else if(t=="t"){if(n.uniform1i(m,c),m=e.texture)if(m.image instanceof
+Array&&m.image.length==6){if(e=m,e.image.length==6){if(e.needsUpdate){if(e.__webglInit){n.bindTexture(n.TEXTURE_CUBE_MAP,e.image.__webglTextureCube);for(m=0;m<6;++m)n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,0,0,n.RGBA,n.UNSIGNED_BYTE,e.image[m])}else{e.image.__webglTextureCube=n.createTexture();n.bindTexture(n.TEXTURE_CUBE_MAP,e.image.__webglTextureCube);for(m=0;m<6;++m)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.image[m]);e.__webglInit=!0}K(n.TEXTURE_CUBE_MAP,
+e,e.image[0]);n.bindTexture(n.TEXTURE_CUBE_MAP,null);e.needsUpdate=!1}n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_CUBE_MAP,e.image.__webglTextureCube)}}else D(m,c)}else if(t=="tv"){if(!e._array){e._array=[];t=0;for(p=e.texture.length;t<p;t++)e._array[t]=c+t}n.uniform1iv(m,e._array);t=0;for(p=e.texture.length;t<p;t++)(m=e.texture[t])&&D(m,e._array[t])}n.uniformMatrix4fv(j.modelViewMatrix,!1,h._modelViewMatrixArray);n.uniformMatrix3fv(j.normalMatrix,!1,h._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||
+f instanceof THREE.MeshPhongMaterial||f.envMap)&&j.cameraPosition!==null&&n.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||h.receiveShadow)&&j.objectMatrix!==null&&n.uniformMatrix4fv(j.objectMatrix,!1,h._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&j.viewMatrix!==null&&n.uniformMatrix4fv(j.viewMatrix,!1,ka);f.skinning&&
+(n.uniformMatrix4fv(j.cameraInverseMatrix,!1,ka),n.uniformMatrix4fv(j.boneGlobalMatrices,!1,h.boneMatrices));return g}function f(b,c,f,h,g,j){if(h.opacity!=0){var k,b=e(b,c,f,h,j).attributes;if(!h.morphTargets&&b.position>=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;f<h.numSupportedMorphTargets&&f<m.length;)n.bindBuffer(n.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[m[f]]),n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[f]=o[m[f]],f++;else{var m=[],u=-1,t=0,o=j.morphTargetInfluences,p,v=
+o.length,f=0;for(j.morphTargetBase!==-1&&(m[j.morphTargetBase]=!0);f<h.numSupportedMorphTargets;){for(p=0;p<v;p++)!m[p]&&o[p]>u&&(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<v;p+=9)e=b.normalArray,f=e[p],g=e[p+1],h=e[p+2],j=e[p+3],m=e[p+4],u=e[p+5],k=e[p+6],o=e[p+7],t=e[p+8],f=(f+j+k)/3,g=(g+m+o)/3,h=(h+u+t)/3,e[p]=f,e[p+1]=g,e[p+2]=h,e[p+3]=f,e[p+4]=g,e[p+5]=h,e[p+6]=f,e[p+7]=g,e[p+8]=h}n.bufferData(n.ARRAY_BUFFER,b.normalArray,n.DYNAMIC_DRAW);n.enableVertexAttribArray(c.attributes.normal);n.vertexAttribPointer(c.attributes.normal,3,n.FLOAT,!1,0,0)}n.drawArrays(n.TRIANGLES,
+0,b.count);b.count=0}function j(b){if(ea!=b.doubleSided)b.doubleSided?n.disable(n.CULL_FACE):n.enable(n.CULL_FACE),ea=b.doubleSided;if(T!=b.flipSided)b.flipSided?n.frontFace(n.CW):n.frontFace(n.CCW),T=b.flipSided}function h(b){da!=b&&(b?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),da=b)}function k(b,c,e){ha!=b&&(b?n.enable(n.POLYGON_OFFSET_FILL):n.disable(n.POLYGON_OFFSET_FILL),ha=b);if(b&&(ia!=c||M!=e))n.polygonOffset(c,e),ia=c,M=e}function o(b){ca[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-
+b.n14);ca[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);ca[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);ca[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);ca[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);ca[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=ca[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function m(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),
+f=0;f<6;f++)if(b=ca[f].x*c.n14+ca[f].y*c.n24+ca[f].z*c.n34+ca[f].w,b<=e)return!1;return!0}function p(b,c){b.list[b.count]=c;b.count+=1}function u(b){var c,e,f=b.object,g=b.opaque,h=b.transparent;h.count=0;b=g.count=0;for(c=f.materials.length;b<c;b++)e=f.materials[b],e.transparent?p(h,e):p(g,e)}function v(b){var c,e,f,g,h=b.object,j=b.buffer,k=b.opaque,n=b.transparent;n.count=0;b=k.count=0;for(f=h.materials.length;b<f;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(e=j.materials.length;c<
+e;c++)(g=j.materials[c])&&(g.transparent?p(n,g):p(k,g))}else(g=c)&&(g.transparent?p(n,g):p(k,g))}function t(b,c){return c.z-b.z}function w(b,c){var k,u,t,p=0,v,w,x,A,y=b.lights;$||($=new THREE.Camera(C.shadowCameraFov,c.aspect,C.shadowCameraNear,C.shadowCameraFar));k=0;for(u=y.length;k<u;k++)if(t=y[k],t instanceof THREE.SpotLight&&t.castShadow){C.shadowMap[p]||(C.shadowMap[p]=new THREE.WebGLRenderTarget(C.shadowMapWidth,C.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
+format:THREE.RGBAFormat}));ta[p]||(ta[p]=new THREE.Matrix4);v=C.shadowMap[p];w=ta[p];$.position.copy(t.position);$.target.position.copy(t.target.position);$.update(void 0,!0);b.update(void 0,!1,$);w.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);w.multiplySelf($.projectionMatrix);w.multiplySelf($.matrixWorldInverse);$.matrixWorldInverse.flattenToArray(ka);$.projectionMatrix.flattenToArray(la);ja.multiply($.projectionMatrix,$.matrixWorldInverse);o(ja);C.initWebGLObjects(b);J(v);n.clearColor(1,1,
+1,1);C.clear();n.clearColor(va.r,va.g,va.b,ya);w=b.__webglObjects.length;t=b.__webglObjectsImmediate.length;for(v=0;v<w;v++)x=b.__webglObjects[v],A=x.object,A.visible&&A.castShadow?!(A instanceof THREE.Mesh)||m(A)?(A.matrixWorld.flattenToArray(A._objectMatrixArray),B(A,$,!1),x.render=!0):x.render=!1:x.render=!1;h(!0);E(THREE.NormalBlending);for(v=0;v<w;v++)if(x=b.__webglObjects[v],x.render)A=x.object,buffer=x.buffer,j(A),x=A.customDepthMaterial?A.customDepthMaterial:A.geometry.morphTargets.length?
+ma:oa,f($,y,null,x,buffer,A);for(v=0;v<t;v++)x=b.__webglObjectsImmediate[v],A=x.object,A.visible&&A.castShadow&&(A.matrixAutoUpdate&&A.matrixWorld.flattenToArray(A._objectMatrixArray),B(A,$,!1),j(A),program=e($,y,null,oa,A),A.render(function(b){g(b,program,oa.shading)}));p++}}function x(b,c){var e,f,g;e=N.attributes;var h=N.uniforms,j=Z/Y,k,m=[],o=Y*0.5,u=Z*0.5,p=!0;n.useProgram(N.program);V=N.program;da=U=-1;za||(n.enableVertexAttribArray(N.attributes.position),n.enableVertexAttribArray(N.attributes.uv),
+za=!0);n.disable(n.CULL_FACE);n.enable(n.BLEND);n.depthMask(!0);n.bindBuffer(n.ARRAY_BUFFER,N.vertexBuffer);n.vertexAttribPointer(e.position,2,n.FLOAT,!1,16,0);n.vertexAttribPointer(e.uv,2,n.FLOAT,!1,16,8);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,N.elementBuffer);n.uniformMatrix4fv(h.projectionMatrix,!1,la);n.activeTexture(n.TEXTURE0);n.uniform1i(h.map,0);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.useScreenCoordinates?g.z=-g.position.z:(g._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
+g.matrixWorld,g._modelViewMatrixArray),g.z=-g._modelViewMatrix.n34);b.__webglSprites.sort(t);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.material===void 0&&g.map&&g.map.image&&g.map.image.width&&(g.useScreenCoordinates?(n.uniform1i(h.useScreenCoordinates,1),n.uniform3f(h.screenPosition,(g.position.x-o)/o,(u-g.position.y)/u,Math.max(0,Math.min(1,g.position.z)))):(n.uniform1i(h.useScreenCoordinates,0),n.uniform1i(h.affectedByDistance,g.affectedByDistance?1:0),n.uniformMatrix4fv(h.modelViewMatrix,
+!1,g._modelViewMatrixArray)),k=g.map.image.width/(g.scaleByViewport?Z:1),m[0]=k*j*g.scale.x,m[1]=k*g.scale.y,n.uniform2f(h.uvScale,g.uvScale.x,g.uvScale.y),n.uniform2f(h.uvOffset,g.uvOffset.x,g.uvOffset.y),n.uniform2f(h.alignment,g.alignment.x,g.alignment.y),n.uniform1f(h.opacity,g.opacity),n.uniform1f(h.rotation,g.rotation),n.uniform2fv(h.scale,m),g.mergeWith3D&&!p?(n.enable(n.DEPTH_TEST),p=!0):!g.mergeWith3D&&p&&(n.disable(n.DEPTH_TEST),p=!1),E(g.blending),D(g.map,0),n.drawElements(n.TRIANGLES,
+6,n.UNSIGNED_SHORT,0));n.enable(n.CULL_FACE);n.enable(n.DEPTH_TEST);n.depthMask(L)}function B(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);e&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function A(b){var c,e,f,g;g=b.__materials;b=0;for(e=g.length;b<e;b++)if(f=g[b],f.attributes)for(c in f.attributes)if(f.attributes[c].needsUpdate)return!0;return!1}function H(b){var c,e,f,g;g=b.__materials;b=0;for(e=
+g.length;b<e;b++)if(f=g[b],f.attributes)for(c in f.attributes)f.attributes[c].needsUpdate=!1}function y(b,c){var e;for(e=b.length-1;e>=0;e--)b[e].object==c&&b.splice(e,1)}function G(b){function c(b){var g=[];e=0;for(f=b.length;e<f;e++)b[e]==void 0?g.push("undefined"):g.push(b[e].id);return g.join("_")}var e,f,g,h,j,k,n,m,o={},u=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};g=0;for(h=b.faces.length;g<h;g++)j=b.faces[g],k=j.materials,n=c(k),o[n]==void 0&&(o[n]={hash:n,counter:0}),
+m=o[n].hash+"_"+o[n].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:k,vertices:0,numMorphTargets:u}),j=j instanceof THREE.Face3?3:4,b.geometryGroups[m].vertices+j>65535&&(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<o;m++)h=c[m],h instanceof THREE.SpotLight&&u++,h instanceof THREE.DirectionalLight&&u++,h instanceof THREE.PointLight&&
+k++;k+u<=4?m=u:(m=Math.ceil(4*u/(k+u)),k=4-m);h={directional:m,point:k};k=u=0;for(m=c.length;k<m;k++)o=c[k],o instanceof THREE.SpotLight&&o.castShadow&&u++;var t=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)t=f.bones.length;var p;a:{m=b.fragmentShader;o=b.vertexShader;var k=b.uniforms,c=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,
+maxDirLights:h.directional,maxPointLights:h.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:u,alphaTest:b.alphaTest},v,f=[];j?f.push(j):(f.push(m),f.push(o));for(v in e)f.push(v),f.push(e[v]);j=f.join();v=0;for(f=W.length;v<f;v++)if(W[v].code==j){p=W[v].program;break a}v=n.createProgram();f=[Da?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,
 "#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
-"",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k.attachShader(v,C("fragment",g+n));k.attachShader(v,C("vertex",f+o));k.linkProgram(v);k.getProgramParameter(v,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(v,k.VALIDATE_STATUS)+", gl error ["+k.getError()+"]");v.uniforms=
-{};v.attributes={};var w,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in m)f.push(w);w=f;f=0;for(m=w.length;f<m;f++)n=w[f],v.uniforms[n]=k.getUniformLocation(v,n);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<e.maxMorphTargets;w++)f.push("morphTarget"+w);for(u in c)f.push(u);u=f;w=0;for(c=u.length;w<c;w++)e=
-u[w],v.attributes[e]=k.getAttribLocation(v,e);M.push({program:v,code:j});u=v}b.program=u;u=b.program.attributes;u.position>=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<this.maxMorphTargets;h++)w="morphTarget"+h,u[w]>=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<G;B++)if(K=b.__webglObjects[B],V=K.object,V.visible)if(!(V instanceof THREE.Mesh)||p(V)){if(V.matrixWorld.flattenToArray(V._objectMatrixArray),H(V,c,!0),v(K),K.render=!0,this.sortObjects)K.object.renderDepth?K.z=K.object.renderDepth:(Aa.copy(V.position),ja.multiplyVector3(Aa),
-K.z=Aa.z)}else K.render=!1;else K.render=!1;this.sortObjects&&b.__webglObjects.sort(u);J=b.__webglObjectsImmediate.length;for(B=0;B<J;B++)K=b.__webglObjectsImmediate[B],V=K.object,V.visible&&(V.matrixAutoUpdate&&V.matrixWorld.flattenToArray(V._objectMatrixArray),H(V,c,!0),t(K));if(b.overrideMaterial){h(b.overrideMaterial.depthTest);I(b.overrideMaterial.blending);for(B=0;B<G;B++)if(K=b.__webglObjects[B],K.render)V=K.object,L=K.buffer,j(V),f(c,M,ga,b.overrideMaterial,L,V);for(B=0;B<J;B++)K=b.__webglObjectsImmediate[B],
-V=K.object,V.visible&&(j(V),C=e(c,M,ga,b.overrideMaterial,V),V.render(function(e){g(e,C,b.overrideMaterial.shading)}))}else{I(THREE.NormalBlending);for(B=G-1;B>=0;B--)if(K=b.__webglObjects[B],K.render){V=K.object;L=K.buffer;F=K.opaque;j(V);for(K=0;K<F.count;K++)D=F.list[K],h(D.depthTest),m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),f(c,M,ga,D,L,V)}for(B=0;B<J;B++)if(K=b.__webglObjectsImmediate[B],V=K.object,V.visible){F=K.opaque;j(V);for(K=0;K<F.count;K++)D=F.list[K],h(D.depthTest),
-m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),C=e(c,M,ga,D,V),V.render(function(b){g(b,C,D.shading)})}for(B=0;B<G;B++)if(K=b.__webglObjects[B],K.render){V=K.object;L=K.buffer;F=K.transparent;j(V);for(K=0;K<F.count;K++)D=F.list[K],I(D.blending),h(D.depthTest),m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),f(c,M,ga,D,L,V)}for(B=0;B<J;B++)if(K=b.__webglObjectsImmediate[B],V=K.object,V.visible){F=K.transparent;j(V);for(K=0;K<F.count;K++)D=F.list[K],I(D.blending),h(D.depthTest),
-m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),C=e(c,M,ga,D,V),V.render(function(b){g(b,C,D.shading)})}}b.__webglSprites.length&&x(b,c);Oa&&b.__webglShadowVolumes.length&&b.lights.length&&z(b);b.__webglLensFlares.length&&w(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&(k.bindTexture(k.TEXTURE_2D,o.__webglTexture),k.generateMipmap(k.TEXTURE_2D),k.bindTexture(k.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],
-b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],c=b,f=void 0,h=void 0,g=void 0;if(e._modelViewMatrix==void 0)e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray);if(e instanceof THREE.Mesh)for(f in h=e.geometry,h.geometryGroups==void 0&&
-L(h),h.geometryGroups){g=h.geometryGroups[f];if(!g.__webglVertexBuffer){var j=g;j.__webglVertexBuffer=k.createBuffer();j.__webglNormalBuffer=k.createBuffer();j.__webglTangentBuffer=k.createBuffer();j.__webglColorBuffer=k.createBuffer();j.__webglUVBuffer=k.createBuffer();j.__webglUV2Buffer=k.createBuffer();j.__webglSkinVertexABuffer=k.createBuffer();j.__webglSkinVertexBBuffer=k.createBuffer();j.__webglSkinIndicesBuffer=k.createBuffer();j.__webglSkinWeightsBuffer=k.createBuffer();j.__webglFaceBuffer=
-k.createBuffer();j.__webglLineBuffer=k.createBuffer();if(j.numMorphTargets){var m=void 0,n=void 0;j.__webglMorphTargetsBuffers=[];m=0;for(n=j.numMorphTargets;m<n;m++)j.__webglMorphTargetsBuffers.push(k.createBuffer())}for(var j=g,m=e,o=void 0,t=void 0,u=void 0,p=u=void 0,v=void 0,w=void 0,y=w=n=0,x=u=t=void 0,z=x=t=o=void 0,u=void 0,p=m.geometry,v=p.faces,x=j.faces,o=0,t=x.length;o<t;o++)u=x[o],u=v[u],u instanceof THREE.Face3?(n+=3,w+=1,y+=3):u instanceof THREE.Face4&&(n+=4,w+=2,y+=4);for(var o=j,
-t=m,K=x=v=void 0,B=void 0,K=void 0,u=[],v=0,x=t.materials.length;v<x;v++)if(K=t.materials[v],K instanceof THREE.MeshFaceMaterial){K=0;for(l=o.materials.length;K<l;K++)(B=o.materials[K])&&u.push(B)}else(B=K)&&u.push(B);o=u;j.__materials=o;a:{v=t=void 0;x=o.length;for(t=0;t<x;t++)if(v=o[t],v.map||v.lightMap||v instanceof THREE.MeshShaderMaterial){t=!0;break a}t=!1}a:{x=v=void 0;u=o.length;for(v=0;v<u;v++)if(x=o[v],!(x instanceof THREE.MeshBasicMaterial&&!x.envMap||x instanceof THREE.MeshDepthMaterial)){x=
-x&&x.shading!=void 0&&x.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}x=!1}a:{u=v=void 0;K=o.length;for(v=0;v<K;v++)if(u=o[v],u.vertexColors){u=u.vertexColors;break a}u=!1}j.__vertexArray=new Float32Array(n*3);if(x)j.__normalArray=new Float32Array(n*3);if(p.hasTangents)j.__tangentArray=new Float32Array(n*4);if(u)j.__colorArray=new Float32Array(n*3);if(t){if(p.faceUvs.length>0||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<v;p++)j.__morphTargetsArrays.push(new Float32Array(n*
-3))}j.__needsSmoothNormals=x==THREE.SmoothShading;j.__uvType=t;j.__vertexColorType=u;j.__normalType=x;j.__webglFaceCount=w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0);j.__webglLineCount=y*2;p=0;for(v=o.length;p<v;p++)if(t=o[p],t.attributes){if(j.__webglCustomAttributes===void 0)j.__webglCustomAttributes={};for(a in t.attributes){u=t.attributes[a];x={};for(z in u)x[z]=u[z];if(!x.__webglInitialized||x.createUniqueBuffers)x.__webglInitialized=!0,w=1,x.type==="v2"?w=2:x.type==="v3"?w=3:x.type===
-"v4"?w=4:x.type==="c"&&(w=3),x.size=w,x.array=new Float32Array(n*w),x.buffer=k.createBuffer(),x.buffer.belongsToAttribute=a,u.needsUpdate=!0,x.__original=u;j.__webglCustomAttributes[a]=x}}j.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}e instanceof THREE.ShadowVolume?G(c.__webglShadowVolumes,g,e):G(c.__webglObjects,g,e)}else if(e instanceof THREE.LensFlare)G(c.__webglLensFlares,void 0,
-e);else if(e instanceof THREE.Ribbon){h=e.geometry;if(!h.__webglVertexBuffer)f=h,f.__webglVertexBuffer=k.createBuffer(),f.__webglColorBuffer=k.createBuffer(),f=h,g=f.vertices.length,f.__vertexArray=new Float32Array(g*3),f.__colorArray=new Float32Array(g*3),f.__webglVertexCount=g,h.__dirtyVertices=!0,h.__dirtyColors=!0;G(c.__webglObjects,h,e)}else if(e instanceof THREE.Line){h=e.geometry;if(!h.__webglVertexBuffer)f=h,f.__webglVertexBuffer=k.createBuffer(),f.__webglColorBuffer=k.createBuffer(),f=h,
-g=f.vertices.length,f.__vertexArray=new Float32Array(g*3),f.__colorArray=new Float32Array(g*3),f.__webglLineCount=g,h.__dirtyVertices=!0,h.__dirtyColors=!0;G(c.__webglObjects,h,e)}else if(e instanceof THREE.ParticleSystem){h=e.geometry;if(!h.__webglVertexBuffer){f=h;f.__webglVertexBuffer=k.createBuffer();f.__webglColorBuffer=k.createBuffer();f=h;g=e;j=f.vertices.length;f.__vertexArray=new Float32Array(j*3);f.__colorArray=new Float32Array(j*3);f.__sortArray=[];f.__webglParticleCount=j;f.__materials=
-g.materials;z=n=m=void 0;m=0;for(n=g.materials.length;m<n;m++)if(z=g.materials[m],z.attributes){if(f.__webglCustomAttributes===void 0)f.__webglCustomAttributes={};for(a in z.attributes){originalAttribute=z.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=
-4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(j*size),attribute.buffer=k.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;f.__webglCustomAttributes[a]=attribute}}h.__dirtyVertices=!0;h.__dirtyColors=!0}G(c.__webglObjects,h,e)}else THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?c.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):
-e instanceof THREE.Sprite&&c.__webglSprites.push(e);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){c=b.__objectsRemoved[0];e=b;if(c instanceof THREE.ShadowVolume)D(e.__webglShadowVolumes,c);else if(c instanceof THREE.Mesh||c instanceof THREE.ParticleSystem||c instanceof THREE.Ribbon||c instanceof THREE.Line)D(e.__webglObjects,c);else if(c instanceof THREE.Sprite){e=e.__webglSprites;h=void 0;for(h=e.length-1;h>=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<c;e++)J(b.__webglObjects[e].object,b);e=0;for(c=b.__webglShadowVolumes.length;e<c;e++)J(b.__webglShadowVolumes[e].object,b);e=0;for(c=b.__webglLensFlares.length;e<c;e++)J(b.__webglLensFlares[e].object,b)};this.setFaceCulling=function(b,e){b?(!e||e=="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW),b=="back"?k.cullFace(k.BACK):b=="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK),
-k.enable(k.CULL_FACE)):k.disable(k.CULL_FACE)};this.supportsVertexTextures=function(){return Da}};
+h=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
+"",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");n.attachShader(v,S("fragment",h+m));n.attachShader(v,S("vertex",f+o));n.linkProgram(v);n.getProgramParameter(v,n.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+n.getProgramParameter(v,n.VALIDATE_STATUS)+", gl error ["+n.getError()+"]");v.uniforms=
+{};v.attributes={};var w,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in k)f.push(w);w=f;f=0;for(k=w.length;f<k;f++)m=w[f],v.uniforms[m]=n.getUniformLocation(v,m);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<e.maxMorphTargets;w++)f.push("morphTarget"+w);for(p in c)f.push(p);p=f;w=0;for(c=p.length;w<c;w++)e=
+p[w],v.attributes[e]=n.getAttribLocation(v,e);W.push({program:v,code:j});p=v}b.program=p;p=b.program.attributes;p.position>=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<this.maxMorphTargets;g++)w="morphTarget"+g,p[w]>=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<D;A++)if(y=b.__webglObjects[A],K=y.object,K.visible)if(!(K instanceof THREE.Mesh)||m(K)){if(K.matrixWorld.flattenToArray(K._objectMatrixArray),B(K,c,!0),v(y),y.render=!0,this.sortObjects)y.object.renderDepth?y.z=y.object.renderDepth:(pa.copy(K.position),ja.multiplyVector3(pa),
+y.z=pa.z)}else y.render=!1;else y.render=!1;this.sortObjects&&b.__webglObjects.sort(t);L=b.__webglObjectsImmediate.length;for(A=0;A<L;A++)y=b.__webglObjectsImmediate[A],K=y.object,K.visible&&(K.matrixAutoUpdate&&K.matrixWorld.flattenToArray(K._objectMatrixArray),B(K,c,!0),u(y));if(b.overrideMaterial){h(b.overrideMaterial.depthTest);E(b.overrideMaterial.blending);for(A=0;A<D;A++)if(y=b.__webglObjects[A],y.render)K=y.object,N=y.buffer,j(K),f(c,M,P,b.overrideMaterial,N,K);for(A=0;A<L;A++)y=b.__webglObjectsImmediate[A],
+K=y.object,K.visible&&(j(K),G=e(c,M,P,b.overrideMaterial,K),K.render(function(c){g(c,G,b.overrideMaterial.shading)}))}else{E(THREE.NormalBlending);for(A=D-1;A>=0;A--)if(y=b.__webglObjects[A],y.render){K=y.object;N=y.buffer;H=y.opaque;j(K);for(y=0;y<H.count;y++)I=H.list[y],h(I.depthTest),k(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),f(c,M,P,I,N,K)}for(A=0;A<L;A++)if(y=b.__webglObjectsImmediate[A],K=y.object,K.visible){H=y.opaque;j(K);for(y=0;y<H.count;y++)I=H.list[y],h(I.depthTest),
+k(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),G=e(c,M,P,I,K),K.render(function(b){g(b,G,I.shading)})}for(A=0;A<D;A++)if(y=b.__webglObjects[A],y.render){K=y.object;N=y.buffer;H=y.transparent;j(K);for(y=0;y<H.count;y++)I=H.list[y],E(I.blending),h(I.depthTest),k(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),f(c,M,P,I,N,K)}for(A=0;A<L;A++)if(y=b.__webglObjectsImmediate[A],K=y.object,K.visible){H=y.transparent;j(K);for(y=0;y<H.count;y++)I=H.list[y],E(I.blending),h(I.depthTest),
+k(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),G=e(c,M,P,I,K),K.render(function(b){g(b,G,I.shading)})}}b.__webglSprites.length&&x(b,c);p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter&&(n.bindTexture(n.TEXTURE_2D,p.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],
+f=b,g=void 0,h=void 0,j=void 0;if(e._modelViewMatrix==void 0)e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray);if(e instanceof THREE.Mesh)for(g in h=e.geometry,h.geometryGroups==void 0&&G(h),h.geometryGroups){j=h.geometryGroups[g];if(!j.__webglVertexBuffer){var k=j;k.__webglVertexBuffer=n.createBuffer();k.__webglNormalBuffer=n.createBuffer();
+k.__webglTangentBuffer=n.createBuffer();k.__webglColorBuffer=n.createBuffer();k.__webglUVBuffer=n.createBuffer();k.__webglUV2Buffer=n.createBuffer();k.__webglSkinVertexABuffer=n.createBuffer();k.__webglSkinVertexBBuffer=n.createBuffer();k.__webglSkinIndicesBuffer=n.createBuffer();k.__webglSkinWeightsBuffer=n.createBuffer();k.__webglFaceBuffer=n.createBuffer();k.__webglLineBuffer=n.createBuffer();if(k.numMorphTargets){var m=void 0,o=void 0;k.__webglMorphTargetsBuffers=[];m=0;for(o=k.numMorphTargets;m<
+o;m++)k.__webglMorphTargetsBuffers.push(n.createBuffer())}for(var k=j,m=e,u=void 0,p=void 0,t=void 0,v=t=void 0,w=void 0,x=void 0,B=x=o=0,D=t=p=void 0,ja=D=p=u=void 0,t=void 0,v=m.geometry,w=v.faces,D=k.faces,u=0,p=D.length;u<p;u++)t=D[u],t=w[t],t instanceof THREE.Face3?(o+=3,x+=1,B+=3):t instanceof THREE.Face4&&(o+=4,x+=2,B+=4);for(var u=k,p=m,E=D=w=void 0,J=void 0,E=void 0,t=[],w=0,D=p.materials.length;w<D;w++)if(E=p.materials[w],E instanceof THREE.MeshFaceMaterial){E=0;for(l=u.materials.length;E<
+l;E++)(J=u.materials[E])&&t.push(J)}else(J=E)&&t.push(J);u=t;k.__materials=u;a:{w=p=void 0;D=u.length;for(p=0;p<D;p++)if(w=u[p],w.map||w.lightMap||w instanceof THREE.MeshShaderMaterial){p=!0;break a}p=!1}a:{D=w=void 0;t=u.length;for(w=0;w<t;w++)if(D=u[w],!(D instanceof THREE.MeshBasicMaterial&&!D.envMap||D instanceof THREE.MeshDepthMaterial)){D=D&&D.shading!=void 0&&D.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}D=!1}a:{t=w=void 0;E=u.length;for(w=0;w<E;w++)if(t=u[w],
+t.vertexColors){t=t.vertexColors;break a}t=!1}k.__vertexArray=new Float32Array(o*3);if(D)k.__normalArray=new Float32Array(o*3);if(v.hasTangents)k.__tangentArray=new Float32Array(o*4);if(t)k.__colorArray=new Float32Array(o*3);if(p){if(v.faceUvs.length>0||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<w;v++)k.__morphTargetsArrays.push(new Float32Array(o*3))}k.__needsSmoothNormals=D==THREE.SmoothShading;k.__uvType=p;k.__vertexColorType=t;k.__normalType=D;k.__webglFaceCount=
+x*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0);k.__webglLineCount=B*2;v=0;for(w=u.length;v<w;v++)if(p=u[v],p.attributes){if(k.__webglCustomAttributes===void 0)k.__webglCustomAttributes={};for(a in p.attributes){t=p.attributes[a];D={};for(ja in t)D[ja]=t[ja];if(!D.__webglInitialized||D.createUniqueBuffers)D.__webglInitialized=!0,x=1,D.type==="v2"?x=2:D.type==="v3"?x=3:D.type==="v4"?x=4:D.type==="c"&&(x=3),D.size=x,D.array=new Float32Array(o*x),D.buffer=n.createBuffer(),D.buffer.belongsToAttribute=
+a,t.needsUpdate=!0,D.__original=t;k.__webglCustomAttributes[a]=D}}k.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}I(f.__webglObjects,j,e)}else if(e instanceof THREE.Ribbon){h=e.geometry;if(!h.__webglVertexBuffer)g=h,g.__webglVertexBuffer=n.createBuffer(),g.__webglColorBuffer=n.createBuffer(),g=h,j=g.vertices.length,g.__vertexArray=new Float32Array(j*3),g.__colorArray=new Float32Array(j*
+3),g.__webglVertexCount=j,h.__dirtyVertices=!0,h.__dirtyColors=!0;I(f.__webglObjects,h,e)}else if(e instanceof THREE.Line){h=e.geometry;if(!h.__webglVertexBuffer)g=h,g.__webglVertexBuffer=n.createBuffer(),g.__webglColorBuffer=n.createBuffer(),g=h,j=g.vertices.length,g.__vertexArray=new Float32Array(j*3),g.__colorArray=new Float32Array(j*3),g.__webglLineCount=j,h.__dirtyVertices=!0,h.__dirtyColors=!0;I(f.__webglObjects,h,e)}else if(e instanceof THREE.ParticleSystem){h=e.geometry;if(!h.__webglVertexBuffer){g=
+h;g.__webglVertexBuffer=n.createBuffer();g.__webglColorBuffer=n.createBuffer();g=h;j=e;k=g.vertices.length;g.__vertexArray=new Float32Array(k*3);g.__colorArray=new Float32Array(k*3);g.__sortArray=[];g.__webglParticleCount=k;g.__materials=j.materials;ja=o=m=void 0;m=0;for(o=j.materials.length;m<o;m++)if(ja=j.materials[m],ja.attributes){if(g.__webglCustomAttributes===void 0)g.__webglCustomAttributes={};for(a in ja.attributes){originalAttribute=ja.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=
+originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(k*size),attribute.buffer=n.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;g.__webglCustomAttributes[a]=attribute}}h.__dirtyVertices=
+!0;h.__dirtyColors=!0}I(f.__webglObjects,h,e)}else THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){f=b.__objectsRemoved[0];e=b;if(f instanceof THREE.Mesh||f instanceof THREE.ParticleSystem||f instanceof THREE.Ribbon||f instanceof THREE.Line)y(e.__webglObjects,f);else if(f instanceof
+THREE.Sprite){e=e.__webglSprites;h=void 0;for(h=e.length-1;h>=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;e<f;e++)if(g=b.__webglObjects[e].object,m=k=h=j=void 0,g instanceof THREE.Mesh){h=g.geometry;for(j in h.geometryGroups)if(k=h.geometryGroups[j],m=A(k),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||
+m)if(m=k,o=n.DYNAMIC_DRAW,ja=!h.dynamic,m.__inittedArrays){var K=B=x=void 0,C=void 0,la=K=void 0,L=void 0,N=void 0,M=void 0,P=J=E=t=D=w=p=u=v=void 0,F=C=M=C=N=L=void 0,z=void 0,Q=z=F=L=void 0,S=void 0,R=Q=z=F=K=K=la=M=C=Q=z=F=S=Q=z=F=S=Q=z=F=void 0,ka=0,U=0,pa=0,X=0,W=0,ha=0,T=0,aa=0,V=0,O=0,Y=0,Q=F=0,Q=void 0,ia=m.__vertexArray,ea=m.__uvArray,fa=m.__uv2Array,da=m.__normalArray,Z=m.__tangentArray,sa=m.__colorArray,ca=m.__skinVertexAArray,$=m.__skinVertexBArray,qa=m.__skinIndexArray,ra=m.__skinWeightArray,
+ta=m.__morphTargetsArrays,ua=m.__webglCustomAttributes,z=void 0,oa=m.__faceArray,ma=m.__lineArray,va=m.__needsSmoothNormals,u=m.__vertexColorType,v=m.__uvType,p=m.__normalType,xa=g.geometry,ya=xa.__dirtyVertices,Ia=xa.__dirtyElements,za=xa.__dirtyUvs,Ja=xa.__dirtyNormals,Ka=xa.__dirtyTangents,Da=xa.__dirtyColors,Ea=xa.__dirtyMorphTargets,Pa=xa.vertices,Ga=m.faces,cb=xa.faces,ab=xa.faceVertexUvs[0],bb=xa.faceVertexUvs[1],Qa=xa.skinVerticesA,Ra=xa.skinVerticesB,Sa=xa.skinIndices,Ha=xa.skinWeights,Fa=
+xa.morphTargets;if(ua)for(R in ua)ua[R].offset=0,ua[R].offsetSrc=0;x=0;for(B=Ga.length;x<B;x++)if(K=Ga[x],C=cb[K],ab&&(w=ab[K]),bb&&(D=bb[K]),K=C.vertexNormals,la=C.normal,L=C.vertexColors,N=C.color,M=C.vertexTangents,C instanceof THREE.Face3){if(ya)t=Pa[C.a].position,E=Pa[C.b].position,J=Pa[C.c].position,ia[U]=t.x,ia[U+1]=t.y,ia[U+2]=t.z,ia[U+3]=E.x,ia[U+4]=E.y,ia[U+5]=E.z,ia[U+6]=J.x,ia[U+7]=J.y,ia[U+8]=J.z,U+=9;if(ua)for(R in ua)if(z=ua[R],z.__original.needsUpdate)F=z.offset,Q=z.offsetSrc,z.size===
+1?(z.boundTo===void 0||z.boundTo==="vertices"?(z.array[F]=z.value[C.a],z.array[F+1]=z.value[C.b],z.array[F+2]=z.value[C.c]):z.boundTo==="faces"?(Q=z.value[Q],z.array[F]=Q,z.array[F+1]=Q,z.array[F+2]=Q,z.offsetSrc++):z.boundTo==="faceVertices"&&(z.array[F]=z.value[Q],z.array[F+1]=z.value[Q+1],z.array[F+2]=z.value[Q+2],z.offsetSrc+=3),z.offset+=3):(z.boundTo===void 0||z.boundTo==="vertices"?(t=z.value[C.a],E=z.value[C.b],J=z.value[C.c]):z.boundTo==="faces"?(J=E=t=Q=z.value[Q],z.offsetSrc++):z.boundTo===
+"faceVertices"&&(t=z.value[Q],E=z.value[Q+1],J=z.value[Q+2],z.offsetSrc+=3),z.size===2?(z.array[F]=t.x,z.array[F+1]=t.y,z.array[F+2]=E.x,z.array[F+3]=E.y,z.array[F+4]=J.x,z.array[F+5]=J.y,z.offset+=6):z.size===3?(z.type==="c"?(z.array[F]=t.r,z.array[F+1]=t.g,z.array[F+2]=t.b,z.array[F+3]=E.r,z.array[F+4]=E.g,z.array[F+5]=E.b,z.array[F+6]=J.r,z.array[F+7]=J.g,z.array[F+8]=J.b):(z.array[F]=t.x,z.array[F+1]=t.y,z.array[F+2]=t.z,z.array[F+3]=E.x,z.array[F+4]=E.y,z.array[F+5]=E.z,z.array[F+6]=J.x,z.array[F+
+7]=J.y,z.array[F+8]=J.z),z.offset+=9):(z.array[F]=t.x,z.array[F+1]=t.y,z.array[F+2]=t.z,z.array[F+3]=t.w,z.array[F+4]=E.x,z.array[F+5]=E.y,z.array[F+6]=E.z,z.array[F+7]=E.w,z.array[F+8]=J.x,z.array[F+9]=J.y,z.array[F+10]=J.z,z.array[F+11]=J.w,z.offset+=12));if(Ea){F=0;for(z=Fa.length;F<z;F++)t=Fa[F].vertices[C.a].position,E=Fa[F].vertices[C.b].position,J=Fa[F].vertices[C.c].position,Q=ta[F],Q[Y]=t.x,Q[Y+1]=t.y,Q[Y+2]=t.z,Q[Y+3]=E.x,Q[Y+4]=E.y,Q[Y+5]=E.z,Q[Y+6]=J.x,Q[Y+7]=J.y,Q[Y+8]=J.z;Y+=9}if(Ha.length)F=
+Ha[C.a],z=Ha[C.b],Q=Ha[C.c],ra[O]=F.x,ra[O+1]=F.y,ra[O+2]=F.z,ra[O+3]=F.w,ra[O+4]=z.x,ra[O+5]=z.y,ra[O+6]=z.z,ra[O+7]=z.w,ra[O+8]=Q.x,ra[O+9]=Q.y,ra[O+10]=Q.z,ra[O+11]=Q.w,F=Sa[C.a],z=Sa[C.b],Q=Sa[C.c],qa[O]=F.x,qa[O+1]=F.y,qa[O+2]=F.z,qa[O+3]=F.w,qa[O+4]=z.x,qa[O+5]=z.y,qa[O+6]=z.z,qa[O+7]=z.w,qa[O+8]=Q.x,qa[O+9]=Q.y,qa[O+10]=Q.z,qa[O+11]=Q.w,F=Qa[C.a],z=Qa[C.b],Q=Qa[C.c],ca[O]=F.x,ca[O+1]=F.y,ca[O+2]=F.z,ca[O+3]=1,ca[O+4]=z.x,ca[O+5]=z.y,ca[O+6]=z.z,ca[O+7]=1,ca[O+8]=Q.x,ca[O+9]=Q.y,ca[O+10]=Q.z,
+ca[O+11]=1,F=Ra[C.a],z=Ra[C.b],Q=Ra[C.c],$[O]=F.x,$[O+1]=F.y,$[O+2]=F.z,$[O+3]=1,$[O+4]=z.x,$[O+5]=z.y,$[O+6]=z.z,$[O+7]=1,$[O+8]=Q.x,$[O+9]=Q.y,$[O+10]=Q.z,$[O+11]=1,O+=12;if(Da&&u)L.length==3&&u==THREE.VertexColors?(C=L[0],F=L[1],z=L[2]):z=F=C=N,sa[V]=C.r,sa[V+1]=C.g,sa[V+2]=C.b,sa[V+3]=F.r,sa[V+4]=F.g,sa[V+5]=F.b,sa[V+6]=z.r,sa[V+7]=z.g,sa[V+8]=z.b,V+=9;if(Ka&&xa.hasTangents)L=M[0],N=M[1],C=M[2],Z[T]=L.x,Z[T+1]=L.y,Z[T+2]=L.z,Z[T+3]=L.w,Z[T+4]=N.x,Z[T+5]=N.y,Z[T+6]=N.z,Z[T+7]=N.w,Z[T+8]=C.x,Z[T+
+9]=C.y,Z[T+10]=C.z,Z[T+11]=C.w,T+=12;if(Ja&&p)if(K.length==3&&va)for(M=0;M<3;M++)la=K[M],da[ha]=la.x,da[ha+1]=la.y,da[ha+2]=la.z,ha+=3;else for(M=0;M<3;M++)da[ha]=la.x,da[ha+1]=la.y,da[ha+2]=la.z,ha+=3;if(za&&w!==void 0&&v)for(M=0;M<3;M++)K=w[M],ea[pa]=K.u,ea[pa+1]=K.v,pa+=2;if(za&&D!==void 0&&v)for(M=0;M<3;M++)K=D[M],fa[X]=K.u,fa[X+1]=K.v,X+=2;Ia&&(oa[W]=ka,oa[W+1]=ka+1,oa[W+2]=ka+2,W+=3,ma[aa]=ka,ma[aa+1]=ka+1,ma[aa+2]=ka,ma[aa+3]=ka+2,ma[aa+4]=ka+1,ma[aa+5]=ka+2,aa+=6,ka+=3)}else if(C instanceof
+THREE.Face4){if(ya)t=Pa[C.a].position,E=Pa[C.b].position,J=Pa[C.c].position,P=Pa[C.d].position,ia[U]=t.x,ia[U+1]=t.y,ia[U+2]=t.z,ia[U+3]=E.x,ia[U+4]=E.y,ia[U+5]=E.z,ia[U+6]=J.x,ia[U+7]=J.y,ia[U+8]=J.z,ia[U+9]=P.x,ia[U+10]=P.y,ia[U+11]=P.z,U+=12;if(ua)for(R in ua)if(z=ua[R],z.__original.needsUpdate)F=z.offset,Q=z.offsetSrc,z.size===1?(z.boundTo===void 0||z.boundTo==="vertices"?(z.array[F]=z.value[C.a],z.array[F+1]=z.value[C.b],z.array[F+2]=z.value[C.c],z.array[F+3]=z.value[C.d]):z.boundTo==="faces"?
+(Q=z.value[Q],z.array[F]=Q,z.array[F+1]=Q,z.array[F+2]=Q,z.array[F+3]=Q,z.offsetSrc++):z.boundTo==="faceVertices"&&(z.array[F]=z.value[Q],z.array[F+1]=z.value[Q+1],z.array[F+2]=z.value[Q+2],z.array[F+3]=z.value[Q+3],z.offsetSrc+=4),z.offset+=4):(z.boundTo===void 0||z.boundTo==="vertices"?(t=z.value[C.a],E=z.value[C.b],J=z.value[C.c],P=z.value[C.d]):z.boundTo==="faces"?(P=J=E=t=Q=z.value[Q],z.offsetSrc++):z.boundTo==="faceVertices"&&(t=z.value[Q],E=z.value[Q+1],J=z.value[Q+2],P=z.value[Q+3],z.offsetSrc+=
+4),z.size===2?(z.array[F]=t.x,z.array[F+1]=t.y,z.array[F+2]=E.x,z.array[F+3]=E.y,z.array[F+4]=J.x,z.array[F+5]=J.y,z.array[F+6]=P.x,z.array[F+7]=P.y,z.offset+=8):z.size===3?(z.type==="c"?(z.array[F]=t.r,z.array[F+1]=t.g,z.array[F+2]=t.b,z.array[F+3]=E.r,z.array[F+4]=E.g,z.array[F+5]=E.b,z.array[F+6]=J.r,z.array[F+7]=J.g,z.array[F+8]=J.b,z.array[F+9]=P.r,z.array[F+10]=P.g,z.array[F+11]=P.b):(z.array[F]=t.x,z.array[F+1]=t.y,z.array[F+2]=t.z,z.array[F+3]=E.x,z.array[F+4]=E.y,z.array[F+5]=E.z,z.array[F+
+6]=J.x,z.array[F+7]=J.y,z.array[F+8]=J.z,z.array[F+9]=P.x,z.array[F+10]=P.y,z.array[F+11]=P.z),z.offset+=12):(z.array[F]=t.x,z.array[F+1]=t.y,z.array[F+2]=t.z,z.array[F+3]=t.w,z.array[F+4]=E.x,z.array[F+5]=E.y,z.array[F+6]=E.z,z.array[F+7]=E.w,z.array[F+8]=J.x,z.array[F+9]=J.y,z.array[F+10]=J.z,z.array[F+11]=J.w,z.array[F+12]=P.x,z.array[F+13]=P.y,z.array[F+14]=P.z,z.array[F+15]=P.w,z.offset+=16));if(Ea){F=0;for(z=Fa.length;F<z;F++)t=Fa[F].vertices[C.a].position,E=Fa[F].vertices[C.b].position,J=Fa[F].vertices[C.c].position,
+P=Fa[F].vertices[C.d].position,Q=ta[F],Q[Y]=t.x,Q[Y+1]=t.y,Q[Y+2]=t.z,Q[Y+3]=E.x,Q[Y+4]=E.y,Q[Y+5]=E.z,Q[Y+6]=J.x,Q[Y+7]=J.y,Q[Y+8]=J.z,Q[Y+9]=P.x,Q[Y+10]=P.y,Q[Y+11]=P.z;Y+=12}if(Ha.length)F=Ha[C.a],z=Ha[C.b],Q=Ha[C.c],S=Ha[C.d],ra[O]=F.x,ra[O+1]=F.y,ra[O+2]=F.z,ra[O+3]=F.w,ra[O+4]=z.x,ra[O+5]=z.y,ra[O+6]=z.z,ra[O+7]=z.w,ra[O+8]=Q.x,ra[O+9]=Q.y,ra[O+10]=Q.z,ra[O+11]=Q.w,ra[O+12]=S.x,ra[O+13]=S.y,ra[O+14]=S.z,ra[O+15]=S.w,F=Sa[C.a],z=Sa[C.b],Q=Sa[C.c],S=Sa[C.d],qa[O]=F.x,qa[O+1]=F.y,qa[O+2]=F.z,qa[O+
+3]=F.w,qa[O+4]=z.x,qa[O+5]=z.y,qa[O+6]=z.z,qa[O+7]=z.w,qa[O+8]=Q.x,qa[O+9]=Q.y,qa[O+10]=Q.z,qa[O+11]=Q.w,qa[O+12]=S.x,qa[O+13]=S.y,qa[O+14]=S.z,qa[O+15]=S.w,F=Qa[C.a],z=Qa[C.b],Q=Qa[C.c],S=Qa[C.d],ca[O]=F.x,ca[O+1]=F.y,ca[O+2]=F.z,ca[O+3]=1,ca[O+4]=z.x,ca[O+5]=z.y,ca[O+6]=z.z,ca[O+7]=1,ca[O+8]=Q.x,ca[O+9]=Q.y,ca[O+10]=Q.z,ca[O+11]=1,ca[O+12]=S.x,ca[O+13]=S.y,ca[O+14]=S.z,ca[O+15]=1,F=Ra[C.a],z=Ra[C.b],Q=Ra[C.c],C=Ra[C.d],$[O]=F.x,$[O+1]=F.y,$[O+2]=F.z,$[O+3]=1,$[O+4]=z.x,$[O+5]=z.y,$[O+6]=z.z,$[O+
+7]=1,$[O+8]=Q.x,$[O+9]=Q.y,$[O+10]=Q.z,$[O+11]=1,$[O+12]=C.x,$[O+13]=C.y,$[O+14]=C.z,$[O+15]=1,O+=16;if(Da&&u)L.length==4&&u==THREE.VertexColors?(C=L[0],F=L[1],z=L[2],L=L[3]):L=z=F=C=N,sa[V]=C.r,sa[V+1]=C.g,sa[V+2]=C.b,sa[V+3]=F.r,sa[V+4]=F.g,sa[V+5]=F.b,sa[V+6]=z.r,sa[V+7]=z.g,sa[V+8]=z.b,sa[V+9]=L.r,sa[V+10]=L.g,sa[V+11]=L.b,V+=12;if(Ka&&xa.hasTangents)L=M[0],N=M[1],C=M[2],M=M[3],Z[T]=L.x,Z[T+1]=L.y,Z[T+2]=L.z,Z[T+3]=L.w,Z[T+4]=N.x,Z[T+5]=N.y,Z[T+6]=N.z,Z[T+7]=N.w,Z[T+8]=C.x,Z[T+9]=C.y,Z[T+10]=
+C.z,Z[T+11]=C.w,Z[T+12]=M.x,Z[T+13]=M.y,Z[T+14]=M.z,Z[T+15]=M.w,T+=16;if(Ja&&p)if(K.length==4&&va)for(M=0;M<4;M++)la=K[M],da[ha]=la.x,da[ha+1]=la.y,da[ha+2]=la.z,ha+=3;else for(M=0;M<4;M++)da[ha]=la.x,da[ha+1]=la.y,da[ha+2]=la.z,ha+=3;if(za&&w!==void 0&&v)for(M=0;M<4;M++)K=w[M],ea[pa]=K.u,ea[pa+1]=K.v,pa+=2;if(za&&D!==void 0&&v)for(M=0;M<4;M++)K=D[M],fa[X]=K.u,fa[X+1]=K.v,X+=2;Ia&&(oa[W]=ka,oa[W+1]=ka+1,oa[W+2]=ka+3,oa[W+3]=ka+1,oa[W+4]=ka+2,oa[W+5]=ka+3,W+=6,ma[aa]=ka,ma[aa+1]=ka+1,ma[aa+2]=ka,ma[aa+
+3]=ka+3,ma[aa+4]=ka+1,ma[aa+5]=ka+2,ma[aa+6]=ka+2,ma[aa+7]=ka+3,aa+=8,ka+=4)}ya&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,ia,o));if(ua)for(R in ua)z=ua[R],z.__original.needsUpdate&&(n.bindBuffer(n.ARRAY_BUFFER,z.buffer),n.bufferData(n.ARRAY_BUFFER,z.array,o));if(Ea){F=0;for(z=Fa.length;F<z;F++)n.bindBuffer(n.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[F]),n.bufferData(n.ARRAY_BUFFER,ta[F],o)}Da&&V>0&&(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;x<u;x++)B=v[x].position,k=x*3,p[k]=B.x,p[k+1]=B.y,p[k+2]=B.z;n.bindBuffer(n.ARRAY_BUFFER,g.__webglVertexBuffer);n.bufferData(n.ARRAY_BUFFER,p,j)}if(w){for(x=0;x<o;x++)color=m[x],k=x*3,ja[k]=color.r,ja[k+1]=color.g,ja[k+2]=color.b;n.bindBuffer(n.ARRAY_BUFFER,g.__webglColorBuffer);n.bufferData(n.ARRAY_BUFFER,ja,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(g instanceof
+THREE.Line){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;x<u;x++)B=v[x].position,k=x*3,p[k]=B.x,p[k+1]=B.y,p[k+2]=B.z;n.bindBuffer(n.ARRAY_BUFFER,g.__webglVertexBuffer);n.bufferData(n.ARRAY_BUFFER,p,j)}if(w){for(x=0;x<o;x++)color=m[x],k=x*3,ja[k]=color.r,ja[k+1]=color.g,ja[k+2]=color.b;n.bindBuffer(n.ARRAY_BUFFER,g.__webglColorBuffer);
+n.bufferData(n.ARRAY_BUFFER,ja,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(g instanceof THREE.ParticleSystem)h=g.geometry,m=A(h),(h.__dirtyVertices||h.__dirtyColors||g.sortParticles||m)&&c(h,n.DYNAMIC_DRAW,g),h.__dirtyVertices=!1,h.__dirtyColors=!1,H(h)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?n.frontFace(n.CCW):n.frontFace(n.CW),b=="back"?n.cullFace(n.BACK):b=="front"?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK),n.enable(n.CULL_FACE)):n.disable(n.CULL_FACE)};this.supportsVertexTextures=
+function(){return Da}};
 THREE.WebGLRenderTarget=function(b,c,e){this.width=b;this.height=c;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
 THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(b){this.positionWorld.copy(b.positionWorld);this.positionScreen.copy(b.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
-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 m=j-h,h=m/j,e=e==j?(f-g)/m:f==j?2+(g-e)/m:4+(e-f)/m;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=h;c.v=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 b<c?c:b>e?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;o<t;o++){var v=new THREE.Vertex(h[o].position.clone());e&&c.matrix.multiplyVector3(v.position);j.push(v)}o=0;for(t=n.length;o<t;o++){var h=n[o],u,y,z=h.vertexNormals,v=h.vertexColors;h instanceof THREE.Face3?u=new THREE.Face3(h.a+f,h.b+f,h.c+
-f):h instanceof THREE.Face4&&(u=new THREE.Face4(h.a+f,h.b+f,h.c+f,h.d+f));u.normal.copy(h.normal);e=0;for(j=z.length;e<j;e++)y=z[e],u.vertexNormals.push(y.clone());u.color.copy(h.color);e=0;for(j=v.length;e<j;e++)y=v[e],u.vertexColors.push(y.clone());u.materials=h.materials.slice();u.centroid.copy(h.centroid);m.push(u)}o=0;for(t=g.length;o<t;o++){f=g[o];m=[];e=0;for(j=f.length;e<j;e++)m.push(new THREE.UV(f[e].u,f[e].v));p.push(m)}},clone:function(b){var c=new THREE.Geometry,e,f=b.vertices,g=b.faces,
-j=b.faceVertexUvs[0],b=0;for(e=f.length;b<e;b++){var h=new THREE.Vertex(f[b].position.clone());c.vertices.push(h)}b=0;for(e=g.length;b<e;b++){var m=g[b],n,p,o=m.vertexNormals,t=m.vertexColors;m instanceof THREE.Face3?n=new THREE.Face3(m.a,m.b,m.c):m instanceof THREE.Face4&&(n=new THREE.Face4(m.a,m.b,m.c,m.d));n.normal.copy(m.normal);f=0;for(h=o.length;f<h;f++)p=o[f],n.vertexNormals.push(p.clone());n.color.copy(m.color);f=0;for(h=t.length;f<h;f++)p=t[f],n.vertexColors.push(p.clone());n.materials=m.materials.slice();
-n.centroid.copy(m.centroid);c.faces.push(n)}b=0;for(e=j.length;b<e;b++){g=j[b];n=[];f=0;for(h=g.length;f<h;f++)n.push(new THREE.UV(g[f].u,g[f].v));c.faceVertexUvs[0].push(n)}return c},randomPointInTriangle:function(b,c,e){var f,g,j,h=new THREE.Vector3,m=THREE.GeometryUtils.__v1;f=THREE.GeometryUtils.random();g=THREE.GeometryUtils.random();f+g>1&&(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;p<u;p++){var v=new THREE.Vertex(h[p].position.clone());e&&c.matrix.multiplyVector3(v.position);j.push(v)}p=0;for(u=o.length;p<u;p++){var h=o[p],t,w,x=h.vertexNormals,v=h.vertexColors;h instanceof THREE.Face3?t=new THREE.Face3(h.a+f,h.b+f,h.c+
+f):h instanceof THREE.Face4&&(t=new THREE.Face4(h.a+f,h.b+f,h.c+f,h.d+f));t.normal.copy(h.normal);e=0;for(j=x.length;e<j;e++)w=x[e],t.vertexNormals.push(w.clone());t.color.copy(h.color);e=0;for(j=v.length;e<j;e++)w=v[e],t.vertexColors.push(w.clone());t.materials=h.materials.slice();t.centroid.copy(h.centroid);k.push(t)}p=0;for(u=g.length;p<u;p++){f=g[p];k=[];e=0;for(j=f.length;e<j;e++)k.push(new THREE.UV(f[e].u,f[e].v));m.push(k)}},clone:function(b){var c=new THREE.Geometry,e,f=b.vertices,g=b.faces,
+j=b.faceVertexUvs[0],b=0;for(e=f.length;b<e;b++){var h=new THREE.Vertex(f[b].position.clone());c.vertices.push(h)}b=0;for(e=g.length;b<e;b++){var k=g[b],o,m,p=k.vertexNormals,u=k.vertexColors;k instanceof THREE.Face3?o=new THREE.Face3(k.a,k.b,k.c):k instanceof THREE.Face4&&(o=new THREE.Face4(k.a,k.b,k.c,k.d));o.normal.copy(k.normal);f=0;for(h=p.length;f<h;f++)m=p[f],o.vertexNormals.push(m.clone());o.color.copy(k.color);f=0;for(h=u.length;f<h;f++)m=u[f],o.vertexColors.push(m.clone());o.materials=k.materials.slice();
+o.centroid.copy(k.centroid);c.faces.push(o)}b=0;for(e=j.length;b<e;b++){g=j[b];o=[];f=0;for(h=g.length;f<h;f++)o.push(new THREE.UV(g[f].u,g[f].v));c.faceVertexUvs[0].push(o)}return c},randomPointInTriangle:function(b,c,e){var f,g,j,h=new THREE.Vector3,k=THREE.GeometryUtils.__v1;f=THREE.GeometryUtils.random();g=THREE.GeometryUtils.random();f+g>1&&(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)<e?THREE.GeometryUtils.randomPointInTriangle(f,g,c):THREE.GeometryUtils.randomPointInTriangle(g,j,c)}},randomPointsInGeometry:function(b,c){function e(b){function e(c,f){if(f<c)return c;var h=c+Math.floor((f-c)/2);return p[h]>b?e(c,h-1):p[h]<b?e(h+1,f):h}return e(0,p.length-1)}var f,g,j=b.faces,h=b.vertices,m=j.length,n=0,p=[],o,t,v,u;for(g=0;g<m;g++){f=j[g];if(f instanceof THREE.Face3)o=h[f.a].position,t=h[f.b].position,
-v=h[f.c].position,f._area=THREE.GeometryUtils.triangleArea(o,t,v);else if(f instanceof THREE.Face4)o=h[f.a].position,t=h[f.b].position,v=h[f.c].position,u=h[f.d].position,f._area1=THREE.GeometryUtils.triangleArea(o,t,u),f._area2=THREE.GeometryUtils.triangleArea(t,v,u),f._area=f._area1+f._area2;n+=f._area;p[g]=n}f=[];h={};for(g=0;g<c;g++)m=THREE.GeometryUtils.random()*n,m=e(m),f[g]=THREE.GeometryUtils.randomPointInFace(j[m],b,!0),h[m]?h[m]+=1:h[m]=1;return f},triangleArea:function(b,c,e){var f,g=THREE.GeometryUtils.__v1;
+g,c),h=THREE.GeometryUtils.triangleArea(g,j,c));return THREE.GeometryUtils.random()*(e+h)<e?THREE.GeometryUtils.randomPointInTriangle(f,g,c):THREE.GeometryUtils.randomPointInTriangle(g,j,c)}},randomPointsInGeometry:function(b,c){function e(b){function c(e,f){if(f<e)return e;var g=e+Math.floor((f-e)/2);return m[g]>b?c(e,g-1):m[g]<b?c(g+1,f):g}return c(0,m.length-1)}var f,g,j=b.faces,h=b.vertices,k=j.length,o=0,m=[],p,u,v,t;for(g=0;g<k;g++){f=j[g];if(f instanceof THREE.Face3)p=h[f.a].position,u=h[f.b].position,
+v=h[f.c].position,f._area=THREE.GeometryUtils.triangleArea(p,u,v);else if(f instanceof THREE.Face4)p=h[f.a].position,u=h[f.b].position,v=h[f.c].position,t=h[f.d].position,f._area1=THREE.GeometryUtils.triangleArea(p,u,t),f._area2=THREE.GeometryUtils.triangleArea(u,v,t),f._area=f._area1+f._area2;o+=f._area;m[g]=o}f=[];h={};for(g=0;g<c;g++)k=THREE.GeometryUtils.random()*o,k=e(k),f[g]=THREE.GeometryUtils.randomPointInFace(j[k],b,!0),h[k]?h[k]+=1:h[k]=1;return f},triangleArea:function(b,c,e){var f,g=THREE.GeometryUtils.__v1;
 g.sub(b,c);f=g.length();g.sub(b,e);b=g.length();g.sub(c,e);e=g.length();c=0.5*(f+b+e);return Math.sqrt(c*(c-f)*(c-b)*(c-e))},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.GeometryUtils.random=THREE.GeometryUtils.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,g=new THREE.Texture(f,c);f.onload=function(){g.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return g},loadTextureCube:function(b,c,e){var f,g=[],j=new THREE.Texture(g,c),c=g.loadCount=0;for(f=b.length;c<f;++c)g[c]=new Image,g[c].onload=function(){g.loadCount+=1;if(g.loadCount==6)j.needsUpdate=!0;e&&e(this)},g[c].crossOrigin="",g[c].src=b[c];return j}};
 THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,g=b.children.length;for(f=0;f<g;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
@@ -380,21 +348,21 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var c,e,f,g,j=2*Math.ceil(b*3)+1;j>25&&(j=25);g=(j-1)*0.5;e=Array(j);for(c=f=0;c<j;++c)e[c]=Math.exp(-((c-g)*(c-g))/(2*b*b)),f+=e[c];for(c=0;c<j;++c)e[c]/=f;return e}};
-THREE.AnimationHandler=function(){var b=[],c={},e={update:function(e){for(var c=0;c<b.length;c++)b[c].update(e)},addToUpdate:function(e){b.indexOf(e)===-1&&b.push(e)},removeFromUpdate:function(e){e=b.indexOf(e);e!==-1&&b.splice(e,1)},add:function(b){c[b.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+b.name+" already exists in library. Overwriting.");c[b.name]=b;if(b.initialized!==!0){for(var e=0;e<b.hierarchy.length;e++){for(var f=0;f<b.hierarchy[e].keys.length;f++){if(b.hierarchy[e].keys[f].time<
-0)b.hierarchy[e].keys[f].time=0;if(b.hierarchy[e].keys[f].rot!==void 0&&!(b.hierarchy[e].keys[f].rot instanceof THREE.Quaternion)){var m=b.hierarchy[e].keys[f].rot;b.hierarchy[e].keys[f].rot=new THREE.Quaternion(m[0],m[1],m[2],m[3])}}if(b.hierarchy[e].keys[0].morphTargets!==void 0){m={};for(f=0;f<b.hierarchy[e].keys.length;f++)for(var n=0;n<b.hierarchy[e].keys[f].morphTargets.length;n++){var p=b.hierarchy[e].keys[f].morphTargets[n];m[p]=-1}b.hierarchy[e].usedMorphTargets=m;for(f=0;f<b.hierarchy[e].keys.length;f++){var o=
-{};for(p in m){for(n=0;n<b.hierarchy[e].keys[f].morphTargets.length;n++)if(b.hierarchy[e].keys[f].morphTargets[n]===p){o[p]=b.hierarchy[e].keys[f].morphTargetsInfluences[n];break}n===b.hierarchy[e].keys[f].morphTargets.length&&(o[p]=0)}b.hierarchy[e].keys[f].morphTargetsInfluences=o}}for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].time===b.hierarchy[e].keys[f-1].time&&(b.hierarchy[e].keys.splice(f,1),f--);for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].index=f}f=parseInt(b.length*
+THREE.AnimationHandler=function(){var b=[],c={},e={update:function(c){for(var e=0;e<b.length;e++)b[e].update(c)},addToUpdate:function(c){b.indexOf(c)===-1&&b.push(c)},removeFromUpdate:function(c){c=b.indexOf(c);c!==-1&&b.splice(c,1)},add:function(b){c[b.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+b.name+" already exists in library. Overwriting.");c[b.name]=b;if(b.initialized!==!0){for(var e=0;e<b.hierarchy.length;e++){for(var f=0;f<b.hierarchy[e].keys.length;f++){if(b.hierarchy[e].keys[f].time<
+0)b.hierarchy[e].keys[f].time=0;if(b.hierarchy[e].keys[f].rot!==void 0&&!(b.hierarchy[e].keys[f].rot instanceof THREE.Quaternion)){var k=b.hierarchy[e].keys[f].rot;b.hierarchy[e].keys[f].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(b.hierarchy[e].keys[0].morphTargets!==void 0){k={};for(f=0;f<b.hierarchy[e].keys.length;f++)for(var o=0;o<b.hierarchy[e].keys[f].morphTargets.length;o++){var m=b.hierarchy[e].keys[f].morphTargets[o];k[m]=-1}b.hierarchy[e].usedMorphTargets=k;for(f=0;f<b.hierarchy[e].keys.length;f++){var p=
+{};for(m in k){for(o=0;o<b.hierarchy[e].keys[f].morphTargets.length;o++)if(b.hierarchy[e].keys[f].morphTargets[o]===m){p[m]=b.hierarchy[e].keys[f].morphTargetsInfluences[o];break}o===b.hierarchy[e].keys[f].morphTargets.length&&(p[m]=0)}b.hierarchy[e].keys[f].morphTargetsInfluences=p}}for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].time===b.hierarchy[e].keys[f-1].time&&(b.hierarchy[e].keys.splice(f,1),f--);for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].index=f}f=parseInt(b.length*
 b.fps,10);b.JIT={};b.JIT.hierarchy=[];for(e=0;e<b.hierarchy.length;e++)b.JIT.hierarchy.push(Array(f));b.initialized=!0}},get:function(b){if(typeof b==="string")return c[b]?c[b]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+b),null)},parse:function(b){var e=[];if(b instanceof THREE.SkinnedMesh)for(var c=0;c<b.bones.length;c++)e.push(b.bones[c]);else f(b,e);return e}},f=function(b,e){e.push(b);for(var c=0;c<b.children.length;c++)f(b.children[c],e)};e.LINEAR=0;e.CATMULLROM=1;e.CATMULLROM_FORWARD=
 2;return e}();THREE.Animation=function(b,c,e,f){this.root=b;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=e!==void 0?e:THREE.AnimationHandler.LINEAR;this.JITCompile=f!==void 0?f:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(b,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==void 0?b:!0;this.currentTime=c!==void 0?c:0;var e,f=this.hierarchy.length,g;for(e=0;e<f;e++){g=this.hierarchy[e];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===void 0)g.animationCache={},g.animationCache.prevKey={pos:0,rot:0,scl:0},g.animationCache.nextKey={pos:0,rot:0,scl:0},g.animationCache.originalMatrix=g instanceof
 THREE.Bone?g.skinMatrix:g.matrix;var j=g.animationCache.prevKey;g=g.animationCache.nextKey;j.pos=this.data.hierarchy[e].keys[0];j.rot=this.data.hierarchy[e].keys[0];j.scl=this.data.hierarchy[e].keys[0];g.pos=this.getNextKeyWith("pos",e,1);g.rot=this.getNextKeyWith("rot",e,1);g.scl=this.getNextKeyWith("scl",e,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==void 0)this.hierarchy[b]instanceof THREE.Bone?this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix:this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix,delete this.hierarchy[b].animationCache};
-THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,g,j,h,m,n,p,o=this.data.JIT.hierarchy,t,v;this.currentTime+=b*this.timeScale;v=this.currentTime;t=this.currentTime%=this.data.length;p=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,y=this.hierarchy.length;u<y;u++)if(b=this.hierarchy[u],n=b.animationCache,this.JITCompile&&o[u][p]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=o[u][p],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
-!1):(b.matrix=o[u][p],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)b instanceof THREE.Bone?b.skinMatrix=b.animationCache.originalMatrix:b.matrix=b.animationCache.originalMatrix;for(var z=0;z<3;z++){e=c[z];h=n.prevKey[e];m=n.nextKey[e];if(m.time<=v){if(t<v)if(this.loop){h=this.data.hierarchy[u].keys[0];for(m=this.getNextKeyWith(e,u,1);m.time<t;)h=m,m=this.getNextKeyWith(e,u,m.index+1)}else{this.stop();return}else{do h=m,m=this.getNextKeyWith(e,u,m.index+1);while(m.time<
-t)}n.prevKey[e]=h;n.nextKey[e]=m}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(t-h.time)/(m.time-h.time);g=h[e];j=m[e];if(f<0||f>1)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;u<this.hierarchy.length;u++)o[u][p]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],g,j,h,m,n,p;g=(b.length-1)*c;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.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;t<w;t++)if(b=this.hierarchy[t],o=b.animationCache,this.JITCompile&&p[t][m]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=p[t][m],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
+!1):(b.matrix=p[t][m],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)b instanceof THREE.Bone?b.skinMatrix=b.animationCache.originalMatrix:b.matrix=b.animationCache.originalMatrix;for(var x=0;x<3;x++){e=c[x];h=o.prevKey[e];k=o.nextKey[e];if(k.time<=v){if(u<v)if(this.loop){h=this.data.hierarchy[t].keys[0];for(k=this.getNextKeyWith(e,t,1);k.time<u;)h=k,k=this.getNextKeyWith(e,t,k.index+1)}else{this.stop();return}else{do h=k,k=this.getNextKeyWith(e,t,k.index+1);while(k.time<
+u)}o.prevKey[e]=h;o.nextKey[e]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(u-h.time)/(k.time-h.time);g=h[e];j=k[e];if(f<0||f>1)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;t<this.hierarchy.length;t++)p[t][m]=this.hierarchy[t]instanceof THREE.Bone?this.hierarchy[t].skinMatrix.clone():this.hierarchy[t].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],g,j,h,k,o,m;g=(b.length-1)*c;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.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=e<f.length-1?e:f.length-1:e%=f.length;e<f.length;e++)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,c,e){for(var f=this.data.hierarchy[c].keys,e=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e>0?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<n-1;g++)H=f*m.chunks[g]/m.total,e.keys[g]={time:H,pos:j[g]};h.hierarchy[0]=e;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
-f,h=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),h.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return h}function f(b,c){var f=e(c,10),h=e(c,10),g=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,g);particleObj=new THREE.ParticleSystem(h,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);h=new THREE.SphereGeometry(1,
-16,8);g=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,g),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=
+THREE.PathCamera=function(b){function c(b,c,e,f){var g={name:e,fps:0.6,length:f,hierarchy:[]},h,j=c.getControlPointsArray(),k=c.getLength(),o=j.length,H=0;h=o-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:f,pos:j[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<o-1;h++)H=f*k.chunks[h]/k.total,c.keys[h]={time:H,pos:j[h]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(b,e,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,c){var e,
+f,g=new THREE.Geometry;for(e=0;e<b.points.length*c;e++)f=e/(b.points.length*c),f=b.getPoint(f),g.vertices[e]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return g}function f(b,c){var f=e(c,10),g=e(c,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,h);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);g=new THREE.SphereGeometry(1,
+16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(g,h),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=
 this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(b){if(b.duration!==void 0)this.duration=b.duration*1E3;if(b.waypoints!==void 0)this.waypoints=b.waypoints;if(b.useConstantSpeed!==void 0)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==void 0)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==void 0)this.createDebugPath=b.createDebugPath;if(b.createDebugDummy!==
 void 0)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==void 0)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==void 0)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==void 0)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=
-window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,j=Math.PI/180;this.update=function(b,e,c){var f,h;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*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 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.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();h.copy(this.forward);j.set(0,1,0);g.cross(j,h).normalize();j.cross(h,g).normalize();this.matrix.n11=g.x;this.matrix.n12=j.x;this.matrix.n13=h.x;this.matrix.n21=g.y;this.matrix.n22=j.y;this.matrix.n23=h.y;this.matrix.n31=g.z;this.matrix.n32=j.z;this.matrix.n33=h.z;m.identity();m.n11=Math.cos(this.roll);m.n12=-Math.sin(this.roll);m.n21=Math.sin(this.roll);m.n22=Math.cos(this.roll);this.matrix.multiplySelf(m);
+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,k=new THREE.Matrix4,o=!1,m=1,p=0,u=0,v=0,t=0,w=0,x=window.innerWidth/2,B=window.innerHeight/2;this.update=
+function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*t),this.rotateVertically(b*w));b=this.delta*this.movementSpeed;this.translateZ(b*(p>0||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.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();h.copy(this.forward);j.set(0,1,0);g.cross(j,h).normalize();j.cross(h,g).normalize();this.matrix.n11=g.x;this.matrix.n12=j.x;this.matrix.n13=h.x;this.matrix.n21=g.y;this.matrix.n22=j.y;this.matrix.n23=h.y;this.matrix.n31=g.z;this.matrix.n32=j.z;this.matrix.n33=h.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k);
 this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(b){this.position.x+=this.matrix.n11*b;this.position.y+=this.matrix.n21*b;this.position.z+=this.matrix.n31*b};this.translateY=function(b){this.position.x+=this.matrix.n12*b;this.position.y+=this.matrix.n22*b;this.position.z+=this.matrix.n32*b};this.translateZ=function(b){this.position.x-=this.matrix.n13*b;this.position.y-=
 this.matrix.n23*b;this.position.z-=this.matrix.n33*b};this.rotateHorizontally=function(b){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(b);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(b){j.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);j.multiplyScalar(b);this.forward.addSelf(j);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
-function(b){u=(b.clientX-z)/window.innerWidth;y=(b.clientY-x)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=1;break;case 2:o=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=0;break;case 2:o=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:o=1;break;case 37:case 65:t=-1;break;
-case 40:case 83:o=-1;break;case 39:case 68:t=1;break;case 81:n=!0;p=1;break;case 69:n=!0;p=-1;break;case 82:v=1;break;case 70:v=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:o=0;break;case 37:case 65:t=0;break;case 40:case 83:o=0;break;case 39:case 68:t=0;break;case 81:n=!1;break;case 69:n=!1;break;case 82:v=0;break;case 70:v=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
+function(b){t=(b.clientX-x)/window.innerWidth;w=(b.clientY-B)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:p=1;break;case 2:p=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:p=0;break;case 2:p=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:p=1;break;case 37:case 65:u=-1;break;
+case 40:case 83:p=-1;break;case 39:case 68:u=1;break;case 81:o=!0;m=1;break;case 69:o=!0;m=-1;break;case 82:v=1;break;case 70:v=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:p=0;break;case 37:case 65:u=0;break;case 40:case 83:p=0;break;case 39:case 68:u=0;break;case 81:o=!1;break;case 69:o=!1;break;case 82:v=0;break;case 70:v=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
 THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
 THREE.TrackballCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}b=b||{};THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.domElement=b.domElement||document;this.screen=b.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=b.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=b.rotateSpeed||1;this.zoomSpeed=b.zoomSpeed||1.2;this.panSpeed=b.panSpeed||0.3;this.noZoom=b.noZoom||!1;this.noPan=b.noPan||
-!1;this.staticMoving=b.staticMoving||!1;this.dynamicDampingFactor=b.dynamicDampingFactor||0.2;this.minDistance=b.minDistance||0;this.maxDistance=b.maxDistance||Infinity;this.keys=b.keys||[65,83,68];this.useTarget=!0;var e=!1,f=this.STATE.NONE,g=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,m=new THREE.Vector2,n=new THREE.Vector2,p=new THREE.Vector2,o=new THREE.Vector2;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.getMouseOnScreen=function(b,c){return new THREE.Vector2((b-
+!1;this.staticMoving=b.staticMoving||!1;this.dynamicDampingFactor=b.dynamicDampingFactor||0.2;this.minDistance=b.minDistance||0;this.maxDistance=b.maxDistance||Infinity;this.keys=b.keys||[65,83,68];this.useTarget=!0;var e=!1,f=this.STATE.NONE,g=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector2,o=new THREE.Vector2,m=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.getMouseOnScreen=function(b,c){return new THREE.Vector2((b-
 this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(b,c){var e=new THREE.Vector3((b-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),f=e.length();f>1?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()<this.minDistance*this.minDistance&&this.position.add(this.target.position,g.setLength(this.minDistance))};this.update=function(b,c,e){g=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,g);this.checkDistances();this.supr.update.call(this,b,c,e)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
-c(this,function(b){e&&(j=h=this.getMouseProjectionOnBall(b.clientX,b.clientY),m=n=this.getMouseOnScreen(b.clientX,b.clientY),p=o=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?h=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?n=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(o=this.getMouseOnScreen(b.clientX,b.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(b){b.preventDefault();
-b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?j=h=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?m=n=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(p=o=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();f=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(f===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])f=
+c(this,function(b){e&&(j=h=this.getMouseProjectionOnBall(b.clientX,b.clientY),k=o=this.getMouseOnScreen(b.clientX,b.clientY),m=p=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?h=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?o=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(p=this.getMouseOnScreen(b.clientX,b.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(b){b.preventDefault();
+b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?j=h=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?k=o=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(m=p=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();f=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(f===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])f=
 this.STATE.ROTATE;else if(b.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)f=this.STATE.ZOOM;else if(b.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)f=this.STATE.PAN;f!==this.STATE.NONE&&(e=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(f!==this.STATE.NONE)f=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
 THREE.TrackballCamera.prototype.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};THREE.QuakeCamera=THREE.FirstPersonCamera;THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPoint(c/b));return e};
 THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPointAt(c/b));return e};THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};
 THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==b+1)return this.cacheArcLengths;var c=[],e,f=this.getPoint(0),g,j=0;c.push(0);for(g=1;g<=b;g++)e=this.getPoint(g/b),j+=e.distanceTo(f),c.push(j),f=e;return this.cacheArcLengths=c};
-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,m=g-1,n;h<=m;)if(f=Math.floor(h+(m-h)/2),n=e[f]-j,n<0)h=f+1;else if(n>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<e.length;){if(e[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;e<f;e++)c+=this.curves[e].getLength(),b.push(c);return this.cacheLengths=b};
-THREE.CurvePath.prototype.getBoundingBox=function(){var b=this.getPoints(),c,e,f,g;c=e=Number.NEGATIVE_INFINITY;f=g=Number.POSITIVE_INFINITY;var j,h,m,n;n=new THREE.Vector2;h=0;for(m=b.length;h<m;h++){j=b[h];if(j.x>c)c=j.x;else if(j.x<f)f=j.x;if(j.y>e)e=j.y;else if(j.y<e)g=j.y;n.addSelf(j.x,j.y)}return{minX:f,minY:g,maxX:c,maxY:e,centroid:n.divideScalar(m)}};THREE.CurvePath.prototype.createPointsGeometry=function(b){return this.createGeometry(this.getPoints(b,!0))};
+THREE.CurvePath.prototype.getBoundingBox=function(){var b=this.getPoints(),c,e,f,g;c=e=Number.NEGATIVE_INFINITY;f=g=Number.POSITIVE_INFINITY;var j,h,k,o;o=new THREE.Vector2;h=0;for(k=b.length;h<k;h++){j=b[h];if(j.x>c)c=j.x;else if(j.x<f)f=j.x;if(j.y>e)e=j.y;else if(j.y<e)g=j.y;o.addSelf(j.x,j.y)}return{minX:f,minY:g,maxX:c,maxY:e,centroid:o.divideScalar(k)}};THREE.CurvePath.prototype.createPointsGeometry=function(b){return this.createGeometry(this.getPoints(b,!0))};
 THREE.CurvePath.prototype.createSpacedPointsGeometry=function(b){return this.createGeometry(this.getSpacedPoints(b,!0))};THREE.CurvePath.prototype.createGeometry=function(b){for(var c=new THREE.Geometry,e=0;e<b.length;e++)c.vertices.push(new THREE.Vertex(new THREE.Vector3(b[e].x,b[e].y,0)));return c};THREE.CurvePath.prototype.addWrapPath=function(b){this.bends.push(b)};
 THREE.CurvePath.prototype.getTransformedPoints=function(b,c){var e=this.getPoints(b),f,g;if(!c)c=this.bends;f=0;for(g=c.length;f<g;f++)e=this.getWrapPoints(e,c[f]);return e};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(b,c){var e=this.getSpacedPoints(b),f,g;if(!c)c=this.bends;f=0;for(g=c.length;f<g;f++)e=this.getWrapPoints(e,c[f]);return e};
-THREE.CurvePath.prototype.getWrapPoints=function(b,c){var e=this.getBoundingBox(),f,g,j,h,m,n;f=0;for(g=b.length;f<g;f++)j=b[f],h=j.x,m=j.y,n=h/e.maxX,n=c.getUtoTmapping(n,h),h=c.getPoint(n),m=c.getNormalVector(n).multiplyScalar(m),j.x=h.x+m.x,j.y=h.y+m.y;return b};THREE.Path=function(b){THREE.CurvePath.call(this);this.actions=[];b&&this.fromPoints(b)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;
+THREE.CurvePath.prototype.getWrapPoints=function(b,c){var e=this.getBoundingBox(),f,g,j,h,k,o;f=0;for(g=b.length;f<g;f++)j=b[f],h=j.x,k=j.y,o=h/e.maxX,o=c.getUtoTmapping(o,h),h=c.getPoint(o),k=c.getNormalVector(o).multiplyScalar(k),j.x=h.x+k.x,j.y=h.y+k.y;return b};THREE.Path=function(b){THREE.CurvePath.call(this);this.actions=[];b&&this.fromPoints(b)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;
 THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"};THREE.Path.prototype.fromPoints=function(b){this.moveTo(b[0].x,b[0].y);var c,e=b.length;for(c=1;c<e;c++)this.lineTo(b[c].x,b[c].y)};THREE.Path.prototype.moveTo=function(){var b=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:b})};
 THREE.Path.prototype.lineTo=function(b,c){var e=Array.prototype.slice.call(arguments),f=this.actions[this.actions.length-1].args;this.curves.push(new THREE.LineCurve(new THREE.Vector2(f[f.length-2],f[f.length-1]),new THREE.Vector2(b,c)));this.actions.push({action:THREE.PathActions.LINE_TO,args:e})};
 THREE.Path.prototype.quadraticCurveTo=function(b,c,e,f){var g=Array.prototype.slice.call(arguments),j=this.actions[this.actions.length-1].args;this.curves.push(new THREE.QuadraticBezierCurve(new THREE.Vector2(j[j.length-2],j[j.length-1]),new THREE.Vector2(b,c),new THREE.Vector2(e,f)));this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:g})};
-THREE.Path.prototype.bezierCurveTo=function(b,c,e,f,g,j){var h=Array.prototype.slice.call(arguments),m=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(m[m.length-2],m[m.length-1]),new THREE.Vector2(b,c),new THREE.Vector2(e,f),new THREE.Vector2(g,j)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:h})};
+THREE.Path.prototype.bezierCurveTo=function(b,c,e,f,g,j){var h=Array.prototype.slice.call(arguments),k=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(k[k.length-2],k[k.length-1]),new THREE.Vector2(b,c),new THREE.Vector2(e,f),new THREE.Vector2(g,j)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:h})};
 THREE.Path.prototype.splineThru=function(b){var c=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args,e=[new THREE.Vector2(e[e.length-2],e[e.length-1])],e=e.concat(b);this.curves.push(new THREE.SplineCurve(e));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c})};THREE.Path.prototype.arc=function(b,c,e,f,g,j){var h=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(b,c,e,f,g,j));this.actions.push({action:THREE.PathActions.ARC,args:h})};
 THREE.Path.prototype.getSpacedPoints=function(b){b||(b=40);for(var c=[],e=0;e<b;e++)c.push(this.getPoint(e/b));return c};
-THREE.Path.prototype.getPoints=function(b,c){var b=b||12,e=[],f,g,j,h,m,n,p,o,t,v,u,y,z;f=0;for(g=this.actions.length;f<g;f++)switch(j=this.actions[f],h=j.action,j=j.args,h){case THREE.PathActions.LINE_TO:e.push(new THREE.Vector2(j[0],j[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:m=j[2];n=j[3];t=j[0];v=j[1];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.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;m<n;m++)p=h[m],o=p.x,t=p.y,p.x=b*o+c*t+e,p.y=f*t+g*o+j;return h};
+THREE.Path.prototype.getPoints=function(b,c){var b=b||12,e=[],f,g,j,h,k,o,m,p,u,v,t,w,x;f=0;for(g=this.actions.length;f<g;f++)switch(j=this.actions[f],h=j.action,j=j.args,h){case THREE.PathActions.LINE_TO:e.push(new THREE.Vector2(j[0],j[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:k=j[2];o=j[3];u=j[0];v=j[1];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.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<o;k++)m=h[k],p=m.x,u=m.y,m.x=b*p+c*u+e,m.y=f*u+g*p+j;return h};
 THREE.Path.prototype.debug=function(b){var c=this.getBoundingBox();b||(b=document.createElement("canvas"),b.setAttribute("width",c.maxX+100),b.setAttribute("height",c.maxY+100),document.body.appendChild(b));c=b.getContext("2d");c.fillStyle="white";c.fillRect(0,0,b.width,b.height);c.strokeStyle="black";c.beginPath();var e,f,g,b=0;for(e=this.actions.length;b<e;b++)f=this.actions[b],g=f.args,f=f.action,f!=THREE.PathActions.CSPLINE_THRU&&c[f].apply(c,g);c.stroke();c.closePath();c.strokeStyle="red";f=
 this.getPoints();b=0;for(e=f.length;b<e;b++)g=f[b],c.beginPath(),c.arc(g.x,g.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
 THREE.Path.prototype.toShapes=function(){var b,c,e,f,g=[],j=new THREE.Path;b=0;for(c=this.actions.length;b<c;b++)e=this.actions[b],f=e.args,e=e.action,e==THREE.PathActions.MOVE_TO&&j.actions.length!=0&&(g.push(j),j=new THREE.Path),j[e].apply(j,f);j.actions.length!=0&&g.push(j);if(g.length==0)return[];var h,j=[];if(THREE.Shape.Utils.isClockWise(g[0].getPoints())){b=0;for(c=g.length;b<c;b++)f=g[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(h&&j.push(h),h=new THREE.Shape,h.actions=f.actions,h.curves=
 f.curves):h.holes.push(f);j.push(h)}else{h=new THREE.Shape;b=0;for(c=g.length;b<c;b++)f=g[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(h.actions=f.actions,h.curves=f.curves,j.push(h),h=new THREE.Shape):h.holes.push(f)}return j};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(b){return new THREE.ExtrudeGeometry(this,b)};
 THREE.Shape.prototype.getPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getTransformedPoints(b,this.bends);return f};THREE.Shape.prototype.getSpacedPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getTransformedSpacedPoints(b,this.bends);return f};THREE.Shape.prototype.extractAllPoints=function(b){return{shape:this.getTransformedPoints(b),holes:this.getPointsHoles(b)}};
 THREE.Shape.prototype.extractAllSpacedPoints=function(b){return{shape:this.getTransformedSpacedPoints(b),holes:this.getSpacedPointsHoles(b)}};
-THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),g,j,h,m,n,p,o,t,v,u,y=[];for(n=0;n<c.length;n++){p=c[n];f=f.concat(p);j=Number.POSITIVE_INFINITY;for(g=0;g<p.length;g++){v=p[g];u=[];for(t=0;t<e.length;t++)o=e[t],o=v.distanceToSquared(o),u.push(o),o<j&&(j=o,h=g,m=t)}g=m-1>=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<h;j++)n=f[j].x+":"+f[j].y,p[n]!==void 0&&console.log("Duplicate point",n),p[n]=j;j=0;for(h=e.length;j<h;j++){m=e[j];for(f=0;f<3;f++)n=m[f].x+":"+m[f].y,n=p[n],n!==void 0&&(m[f]=n)}j=0;for(h=g.length;j<h;j++){m=g[j];for(f=0;f<3;f++)n=m[f].x+":"+m[f].y,n=p[n],n!==void 0&&(m[f]=n)}return e.concat(g)},isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<
+THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),g,j,h,k,o,m,p,u,v,t,w=[];for(o=0;o<c.length;o++){m=c[o];f=f.concat(m);j=Number.POSITIVE_INFINITY;for(g=0;g<m.length;g++){v=m[g];t=[];for(u=0;u<e.length;u++)p=e[u],p=v.distanceToSquared(p),t.push(p),p<j&&(j=p,h=g,k=u)}g=k-1>=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;j<h;j++)o=f[j].x+":"+f[j].y,m[o]!==void 0&&console.log("Duplicate point",o),m[o]=j;j=0;for(h=e.length;j<h;j++){k=e[j];for(f=0;f<3;f++)o=k[f].x+":"+k[f].y,o=m[o],o!==void 0&&(k[f]=o)}j=0;for(h=g.length;j<h;j++){k=g[j];for(f=0;f<3;f++)o=k[f].x+":"+k[f].y,o=m[o],o!==void 0&&(k[f]=o)}return e.concat(g)},isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<
 0},b2p0:function(b,c){var e=1-b;return e*e*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,e,f){return this.b2p0(b,c)+this.b2p1(b,e)+this.b2p2(b,f)},b3p0:function(b,c){var e=1-b;return e*e*e*c},b3p1:function(b,c){var e=1-b;return 3*e*e*b*c},b3p2:function(b,c){return 3*(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,g){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,g)}};
 THREE.TextPath=function(b,c){THREE.Path.call(this);this.parameters=c||{};this.set(b)};THREE.TextPath.prototype.set=function(b,c){this.text=b;var c=c||this.parameters,e=c.curveSegments!==void 0?c.curveSegments:4,f=c.font!==void 0?c.font:"helvetiker",g=c.weight!==void 0?c.weight:"normal",j=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=e;THREE.FontUtils.face=f;THREE.FontUtils.weight=g;THREE.FontUtils.style=j};
 THREE.TextPath.prototype.toShapes=function(){for(var b=THREE.FontUtils.drawText(this.text).paths,c=[],e=0,f=b.length;e<f;e++)c=c.concat(b[e].toShapes());return c};
-THREE.CubeGeometry=function(b,c,e,f,g,j,h,m,n){function p(b,c,e,h,m,n,p,u){var t,v,y=f||1,z=g||1,T=m/2,C=n/2,ea=o.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")t="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")t="y",z=j||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")t="x",y=j||1;var S=y+1,P=z+1;m/=y;var k=n/z;for(v=0;v<P;v++)for(n=0;n<S;n++){var M=new THREE.Vector3;M[b]=(n*m-T)*e;M[c]=(v*k-C)*h;M[t]=p;o.vertices.push(new THREE.Vertex(M))}for(v=0;v<z;v++)for(n=0;n<y;n++)o.faces.push(new THREE.Face4(n+S*
-v+ea,n+S*(v+1)+ea,n+1+S*(v+1)+ea,n+1+S*v+ea,null,null,u)),o.faceVertexUvs[0].push([new THREE.UV(n/y,v/z),new THREE.UV(n/y,(v+1)/z),new THREE.UV((n+1)/y,(v+1)/z),new THREE.UV((n+1)/y,v/z)])}THREE.Geometry.call(this);var o=this,t=b/2,v=c/2,u=e/2,m=m?-1:1;if(h!==void 0)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=void 0)for(var z in n)this.sides[z]!=void 0&&(this.sides[z]=
-n[z]);this.sides.px&&p("z","y",1*m,-1,e,c,-t,this.materials[0]);this.sides.nx&&p("z","y",-1*m,-1,e,c,t,this.materials[1]);this.sides.py&&p("x","z",1*m,1,b,e,v,this.materials[2]);this.sides.ny&&p("x","z",1*m,-1,b,e,-v,this.materials[3]);this.sides.pz&&p("x","y",1*m,-1,b,c,u,this.materials[4]);this.sides.nz&&p("x","y",-1*m,-1,b,c,-u,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=o.vertices.length;e<f;e++){for(var h=o.vertices[e],g=!1,j=0,m=b.length;j<m;j++){var n=b[j];if(h.position.x==n.position.x&&
-h.position.y==n.position.y&&h.position.z==n.position.z){c[e]=j;g=!0;break}}if(!g)c[e]=b.length,b.push(new THREE.Vertex(h.position.clone()))}e=0;for(f=o.faces.length;e<f;e++)h=o.faces[e],h.a=c[h.a],h.b=c[h.b],h.c=c[h.c],h.d=c[h.d];o.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
-THREE.CylinderGeometry=function(b,c,e,f,g,j){function h(b,c,e){m.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}THREE.Geometry.call(this);var m=this,n,p=Math.PI*2,o=f/2;for(n=0;n<b;n++)h(Math.sin(p*n/b)*c,Math.cos(p*n/b)*c,-o);for(n=0;n<b;n++)h(Math.sin(p*n/b)*e,Math.cos(p*n/b)*e,o);for(n=0;n<b;n++)m.faces.push(new THREE.Face4(n,n+b,b+(n+1)%b,(n+1)%b));if(e>0){h(0,0,-o-(j||0));for(n=b;n<b+b/2;n++)m.faces.push(new THREE.Face4(2*b,(2*n-2*b)%b,(2*n-2*b+1)%b,(2*n-2*b+2)%b))}if(c>0){h(0,0,o+
-(g||0));for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n<b;n++){var c=[],e=this.faces[n],g=this.vertices[e.a],j=this.vertices[e.b],o=this.vertices[e.c],t=this.vertices[e.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/p,0.5+g.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(j.position.x,j.position.y)/p,0.5+j.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/p,0.5+o.position.z/
-f));e instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(t.position.x,t.position.y)/p,0.5+t.position.z/f));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,g;for(e=0;e<f;e++)g=b[e],this.addShape(g,c)}};
+THREE.CubeGeometry=function(b,c,e,f,g,j,h,k,o){function m(b,c,e,h,k,m,o,t){var u,v,w=f||1,x=g||1,R=k/2,C=m/2,n=p.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")u="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")u="y",x=j||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")u="x",w=j||1;var W=w+1,V=x+1;k/=w;var fa=m/x;for(v=0;v<V;v++)for(m=0;m<W;m++){var L=new THREE.Vector3;L[b]=(m*k-R)*e;L[c]=(v*fa-C)*h;L[u]=o;p.vertices.push(new THREE.Vertex(L))}for(v=0;v<x;v++)for(m=0;m<w;m++)p.faces.push(new THREE.Face4(m+W*
+v+n,m+W*(v+1)+n,m+1+W*(v+1)+n,m+1+W*v+n,null,null,t)),p.faceVertexUvs[0].push([new THREE.UV(m/w,v/x),new THREE.UV(m/w,(v+1)/x),new THREE.UV((m+1)/w,(v+1)/x),new THREE.UV((m+1)/w,v/x)])}THREE.Geometry.call(this);var p=this,u=b/2,v=c/2,t=e/2,k=k?-1:1;if(h!==void 0)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(o!=void 0)for(var x in o)this.sides[x]!=void 0&&(this.sides[x]=
+o[x]);this.sides.px&&m("z","y",1*k,-1,e,c,-u,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,e,c,u,this.materials[1]);this.sides.py&&m("x","z",1*k,1,b,e,v,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,b,e,-v,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,b,c,t,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,b,c,-t,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=p.vertices.length;e<f;e++){for(var g=p.vertices[e],h=!1,j=0,k=b.length;j<k;j++){var m=b[j];if(g.position.x==m.position.x&&
+g.position.y==m.position.y&&g.position.z==m.position.z){c[e]=j;h=!0;break}}if(!h)c[e]=b.length,b.push(new THREE.Vertex(g.position.clone()))}e=0;for(f=p.faces.length;e<f;e++)g=p.faces[e],g.a=c[g.a],g.b=c[g.b],g.c=c[g.c],g.d=c[g.d];p.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
+THREE.CylinderGeometry=function(b,c,e,f,g,j){function h(b,c,e){k.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}THREE.Geometry.call(this);var k=this,o,m=Math.PI*2,p=f/2;for(o=0;o<b;o++)h(Math.sin(m*o/b)*c,Math.cos(m*o/b)*c,-p);for(o=0;o<b;o++)h(Math.sin(m*o/b)*e,Math.cos(m*o/b)*e,p);for(o=0;o<b;o++)k.faces.push(new THREE.Face4(o,o+b,b+(o+1)%b,(o+1)%b));if(e>0){h(0,0,-p-(j||0));for(o=b;o<b+b/2;o++)k.faces.push(new THREE.Face4(2*b,(2*o-2*b)%b,(2*o-2*b+1)%b,(2*o-2*b+2)%b))}if(c>0){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;o<b;o++){var c=[],e=this.faces[o],g=this.vertices[e.a],j=this.vertices[e.b],p=this.vertices[e.c],u=this.vertices[e.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/m,0.5+g.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(j.position.x,j.position.y)/m,0.5+j.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(p.position.x,p.position.y)/m,0.5+p.position.z/
+f));e instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(u.position.x,u.position.y)/m,0.5+u.position.z/f));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,g;for(e=0;e<f;e++)g=b[e],this.addShape(g,c)}};
 THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
-THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,h=THREE.ExtrudeGeometry.__v2,g=THREE.ExtrudeGeometry.__v3,j=THREE.ExtrudeGeometry.__v4,k=THREE.ExtrudeGeometry.__v5,m=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);h.set(b.x-e.x,b.y-e.y);f=f.normalize();h=h.normalize();g.set(-f.y,f.x);j.set(h.y,-h.x);k.copy(b).addSelf(g);m.copy(b).addSelf(j);if(k.equals(m))return j.clone();
-k.copy(c).addSelf(g);m.copy(e).addSelf(j);g=f.dot(j);j=m.subSelf(k).dot(j);g==0&&(console.log("Either infinite or no solutions!"),j==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));j/=g;if(j<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(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<u+o*2;c++){var e=ea*c,f=ea*(c+1),h=ha+aa+e,e=ha+Z+e,g=ha+Z+f,f=ha+aa+f;h+=L;e+=L;g+=L;f+=L;D.faces.push(new THREE.Face4(h,e,g,f))}}}function j(b,c,e){D.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function h(b,c,e){b+=L;c+=L;e+=L;D.faces.push(new THREE.Face3(b,c,e))}var m=c.amount!==void 0?c.amount:100,n=c.bevelThickness!==void 0?c.bevelThickness:6,p=c.bevelSize!==void 0?c.bevelSize:n-2,o=c.bevelSegments!==void 0?c.bevelSegments:3,t=c.bevelEnabled!==void 0?c.bevelEnabled:
-!0,v=c.curveSegments!==void 0?c.curveSegments:12,u=c.steps!==void 0?c.steps:1,y=c.bendPath,z=c.extrudePath,x,w=!1,H=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1;if(z)x=z.getPoints(v),u=x.length,w=!0,t=!1;t||(p=n=o=0);var B,F,J,D=this,L=this.vertices.length;y&&b.addWrapPath(y);v=H?b.extractAllSpacedPoints(v):b.extractAllPoints(v);y=v.shape;v=v.holes;if(z=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();F=0;for(J=v.length;F<J;F++)B=v[F],THREE.Shape.Utils.isClockWise(B)&&(v[F]=B.reverse());z=!1}z=
-THREE.Shape.Utils.triangulateShape(y,v);H=y;F=0;for(J=v.length;F<J;F++)B=v[F],y=y.concat(B);var G,I,R,da,T,C,ea=y.length,S=z.length,P=[];G=0;I=H.length;aa=I-1;for(Z=G+1;G<I;G++,aa++,Z++)aa==I&&(aa=0),Z==I&&(Z=0),P[G]=f(H[G],H[aa],H[Z]);var k=[],M,Y=P.concat();F=0;for(J=v.length;F<J;F++){B=v[F];M=[];G=0;I=B.length;aa=I-1;for(Z=G+1;G<I;G++,aa++,Z++)aa==I&&(aa=0),Z==I&&(Z=0),M[G]=f(B[G],B[aa],B[Z]);k.push(M);Y=Y.concat(M)}for(R=0;R<o;R++){da=R/o;T=n*(1-da);da=p*Math.sin(da*Math.PI/2);G=0;for(I=H.length;G<
-I;G++)C=e(H[G],P[G],da),j(C.x,C.y,-T);F=0;for(J=v.length;F<J;F++){B=v[F];M=k[F];G=0;for(I=B.length;G<I;G++)C=e(B[G],M[G],da),j(C.x,C.y,-T)}}da=p;for(G=0;G<ea;G++)C=t?e(y[G],Y[G],da):y[G],w?j(C.x,C.y+x[0].y,x[0].x):j(C.x,C.y,0);for(R=1;R<=u;R++)for(G=0;G<ea;G++)C=t?e(y[G],Y[G],da):y[G],w?j(C.x,C.y+x[R-1].y,x[R-1].x):j(C.x,C.y,m/u*R);for(R=o-1;R>=0;R--){da=R/o;T=n*(1-da);da=p*Math.sin(da*Math.PI/2);G=0;for(I=H.length;G<I;G++)C=e(H[G],P[G],da),j(C.x,C.y,m+T);F=0;for(J=v.length;F<J;F++){B=v[F];M=k[F];
-G=0;for(I=B.length;G<I;G++)C=e(B[G],M[G],da),w?j(C.x,C.y+x[u-1].y,x[u-1].x+T):j(C.x,C.y,m+T)}}if(t){n=ea*0;for(G=0;G<S;G++)m=z[G],h(m[2]+n,m[1]+n,m[0]+n);n=ea*(u+o*2);for(G=0;G<S;G++)m=z[G],h(m[0]+n,m[1]+n,m[2]+n)}else{for(G=0;G<S;G++)m=z[G],h(m[2],m[1],m[0]);for(G=0;G<S;G++)m=z[G],h(m[0]+ea*u,m[1]+ea*u,m[2]+ea*u)}var aa,Z,ha=0;g(H);ha+=H.length;F=0;for(J=v.length;F<J;F++)B=v[F],g(B),ha+=B.length;this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
-THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
-THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=g.vertices[b].position,h=g.vertices[e].position;return c((f.x+h.x)/2,(f.y+h.y)/2,(f.z+h.z)/2)}var g=this,j=new THREE.Geometry,h;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,
--b);c(0,1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,j);e(0,5,1,j);e(0,1,7,j);e(0,7,10,j);e(0,10,11,j);e(1,5,9,j);e(5,11,4,j);e(11,10,2,j);e(10,7,6,j);e(7,1,8,j);e(3,9,4,j);e(3,4,2,j);e(3,2,6,j);e(3,6,8,j);e(3,8,9,j);e(4,9,5,j);e(2,4,11,j);e(6,2,10,j);e(8,6,7,j);e(9,8,1,j);for(b=0;b<this.subdivisions;b++){h=new THREE.Geometry;for(var m in j.faces){var n=f(j.faces[m].a,j.faces[m].b),p=f(j.faces[m].b,j.faces[m].c),o=f(j.faces[m].c,j.faces[m].a);e(j.faces[m].a,n,o,h);e(j.faces[m].b,p,n,h);
-e(j.faces[m].c,o,p,h);e(n,p,o,h)}j.faces=h.faces}g.faces=j.faces;delete j;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
-THREE.LatheGeometry=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],g=[],j=[],h=(new THREE.Matrix4).setRotationZ(c),m=0;m<b.length;m++)this.vertices.push(new THREE.Vertex(b[m])),e[m]=b[m].clone(),f[m]=this.vertices.length-1;for(var n=0;n<=this.angle+0.001;n+=c){for(m=0;m<e.length;m++)n<this.angle?(e[m]=h.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),g[m]=this.vertices.length-1):g=j;n==0&&(j=f);
-for(m=0;m<f.length-1;m++)this.faces.push(new THREE.Face4(g[m],g[m+1],f[m+1],f[m])),this.faceVertexUvs[0].push([new THREE.UV(1-n/this.angle,m/b.length),new THREE.UV(1-n/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,m/b.length)]);f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
-THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var g,j=b/2,h=c/2,e=e||1,f=f||1,m=e+1,n=f+1;b/=e;var p=c/f;for(g=0;g<n;g++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-j,-(g*p-h),0)));for(g=0;g<f;g++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*g,c+m*(g+1),c+1+m*(g+1),c+1+m*g)),this.faceVertexUvs[0].push([new THREE.UV(c/e,g/f),new THREE.UV(c/e,(g+1)/f),new THREE.UV((c+1)/e,(g+1)/f),new THREE.UV((c+1)/e,g/f)]);this.computeCentroids();this.computeFaceNormals()};
+THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,g=THREE.ExtrudeGeometry.__v2,h=THREE.ExtrudeGeometry.__v3,j=THREE.ExtrudeGeometry.__v4,k=THREE.ExtrudeGeometry.__v5,m=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);g.set(b.x-e.x,b.y-e.y);f=f.normalize();g=g.normalize();h.set(-f.y,f.x);j.set(g.y,-g.x);k.copy(b).addSelf(h);m.copy(b).addSelf(j);if(k.equals(m))return j.clone();
+k.copy(c).addSelf(h);m.copy(e).addSelf(j);h=f.dot(j);j=m.subSelf(k).dot(j);h==0&&(console.log("Either infinite or no solutions!"),j==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));j/=h;if(j<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(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<t+p*2;c++){var e=n*c,f=n*(c+1),g=da+T+e,e=da+U+e,h=da+U+f,f=da+T+f;g+=K;e+=K;h+=K;f+=K;E.faces.push(new THREE.Face4(g,e,h,f))}}}function j(b,c,e){E.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function h(b,c,e){b+=K;c+=K;e+=K;E.faces.push(new THREE.Face3(b,c,e))}var k=c.amount!==void 0?c.amount:100,o=c.bevelThickness!==void 0?c.bevelThickness:6,m=c.bevelSize!==void 0?c.bevelSize:o-2,p=c.bevelSegments!==void 0?c.bevelSegments:3,u=c.bevelEnabled!==void 0?c.bevelEnabled:
+!0,v=c.curveSegments!==void 0?c.curveSegments:12,t=c.steps!==void 0?c.steps:1,w=c.bendPath,x=c.extrudePath,B,A=!1,H=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1;if(x)B=x.getPoints(v),t=B.length,A=!0,u=!1;u||(m=o=p=0);var y,G,I,E=this,K=this.vertices.length;w&&b.addWrapPath(w);v=H?b.extractAllSpacedPoints(v):b.extractAllPoints(v);w=v.shape;v=v.holes;if(x=!THREE.Shape.Utils.isClockWise(w)){w=w.reverse();G=0;for(I=v.length;G<I;G++)y=v[G],THREE.Shape.Utils.isClockWise(y)&&(v[G]=y.reverse());x=!1}x=
+THREE.Shape.Utils.triangulateShape(w,v);H=w;G=0;for(I=v.length;G<I;G++)y=v[G],w=w.concat(y);var D,J,S,X,R,C,n=w.length,W=x.length,V=[];D=0;J=H.length;T=J-1;for(U=D+1;D<J;D++,T++,U++)T==J&&(T=0),U==J&&(U=0),V[D]=f(H[D],H[T],H[U]);var fa=[],L,ea=V.concat();G=0;for(I=v.length;G<I;G++){y=v[G];L=[];D=0;J=y.length;T=J-1;for(U=D+1;D<J;D++,T++,U++)T==J&&(T=0),U==J&&(U=0),L[D]=f(y[D],y[T],y[U]);fa.push(L);ea=ea.concat(L)}for(S=0;S<p;S++){X=S/p;R=o*(1-X);X=m*Math.sin(X*Math.PI/2);D=0;for(J=H.length;D<J;D++)C=
+e(H[D],V[D],X),j(C.x,C.y,-R);G=0;for(I=v.length;G<I;G++){y=v[G];L=fa[G];D=0;for(J=y.length;D<J;D++)C=e(y[D],L[D],X),j(C.x,C.y,-R)}}X=m;for(D=0;D<n;D++)C=u?e(w[D],ea[D],X):w[D],A?j(C.x,C.y+B[0].y,B[0].x):j(C.x,C.y,0);for(S=1;S<=t;S++)for(D=0;D<n;D++)C=u?e(w[D],ea[D],X):w[D],A?j(C.x,C.y+B[S-1].y,B[S-1].x):j(C.x,C.y,k/t*S);for(S=p-1;S>=0;S--){X=S/p;R=o*(1-X);X=m*Math.sin(X*Math.PI/2);D=0;for(J=H.length;D<J;D++)C=e(H[D],V[D],X),j(C.x,C.y,k+R);G=0;for(I=v.length;G<I;G++){y=v[G];L=fa[G];D=0;for(J=y.length;D<
+J;D++)C=e(y[D],L[D],X),A?j(C.x,C.y+B[t-1].y,B[t-1].x+R):j(C.x,C.y,k+R)}}if(u){o=n*0;for(D=0;D<W;D++)k=x[D],h(k[2]+o,k[1]+o,k[0]+o);o=n*(t+p*2);for(D=0;D<W;D++)k=x[D],h(k[0]+o,k[1]+o,k[2]+o)}else{for(D=0;D<W;D++)k=x[D],h(k[2],k[1],k[0]);for(D=0;D<W;D++)k=x[D],h(k[0]+n*t,k[1]+n*t,k[2]+n*t)}var T,U,da=0;g(H);da+=H.length;G=0;for(I=v.length;G<I;G++)y=v[G],g(y),da+=y.length;this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
+THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
+THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=g.vertices[b].position,h=g.vertices[e].position;return c((f.x+h.x)/2,(f.y+h.y)/2,(f.z+h.z)/2)}var g=this,j=new THREE.Geometry;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,
+-b);c(0,1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,j);e(0,5,1,j);e(0,1,7,j);e(0,7,10,j);e(0,10,11,j);e(1,5,9,j);e(5,11,4,j);e(11,10,2,j);e(10,7,6,j);e(7,1,8,j);e(3,9,4,j);e(3,4,2,j);e(3,2,6,j);e(3,6,8,j);e(3,8,9,j);e(4,9,5,j);e(2,4,11,j);e(6,2,10,j);e(8,6,7,j);e(9,8,1,j);for(var h=0;h<this.subdivisions;h++){var b=new THREE.Geometry,k;for(k in j.faces){var o=f(j.faces[k].a,j.faces[k].b),m=f(j.faces[k].b,j.faces[k].c),p=f(j.faces[k].c,j.faces[k].a);e(j.faces[k].a,o,p,b);e(j.faces[k].b,m,
+o,b);e(j.faces[k].c,p,m,b);e(o,m,p,b)}j.faces=b.faces}g.faces=j.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
+THREE.LatheGeometry=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],g=[],j=[],h=(new THREE.Matrix4).setRotationZ(c),k=0;k<b.length;k++)this.vertices.push(new THREE.Vertex(b[k])),e[k]=b[k].clone(),f[k]=this.vertices.length-1;for(var o=0;o<=this.angle+0.001;o+=c){for(k=0;k<e.length;k++)o<this.angle?(e[k]=h.multiplyVector3(e[k].clone()),this.vertices.push(new THREE.Vertex(e[k])),g[k]=this.vertices.length-1):g=j;o==0&&(j=f);
+for(k=0;k<f.length-1;k++)this.faces.push(new THREE.Face4(g[k],g[k+1],f[k+1],f[k])),this.faceVertexUvs[0].push([new THREE.UV(1-o/this.angle,k/b.length),new THREE.UV(1-o/this.angle,(k+1)/b.length),new THREE.UV(1-(o-c)/this.angle,(k+1)/b.length),new THREE.UV(1-(o-c)/this.angle,k/b.length)]);f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
+THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var g,j=b/2,h=c/2,e=e||1,f=f||1,k=e+1,o=f+1;b/=e;var m=c/f;for(g=0;g<o;g++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-j,-(g*m-h),0)));for(g=0;g<f;g++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+k*g,c+k*(g+1),c+1+k*(g+1),c+1+k*g)),this.faceVertexUvs[0].push([new THREE.UV(c/e,g/f),new THREE.UV(c/e,(g+1)/f),new THREE.UV((c+1)/e,(g+1)/f),new THREE.UV((c+1)/e,g/f)]);this.computeCentroids();this.computeFaceNormals()};
 THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
-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;e<h+1;e++){f=e/h;var m=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<j;f++){var t=2*f/j,v=n*Math.sin(t*g),t=n*Math.cos(t*g);(e==0||e==h)&&f>0||(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;e<g;e++)if(j=c[e].length,e>0)for(f=0;f<j;f++){p=f==j-1;h=c[e][p?0:f+1];m=c[e][p?j-1:f];n=c[e-1][p?
-j-1:f];p=c[e-1][p?0:f+1];v=e/(g-1);u=(e-1)/(g-1);y=(f+1)/j;var t=f/j,o=new THREE.UV(1-y,v),v=new THREE.UV(1-t,v),t=new THREE.UV(1-t,u),x=new THREE.UV(1-y,u);e<c.length-1&&(u=this.vertices[h].position.clone(),y=this.vertices[m].position.clone(),z=this.vertices[n].position.clone(),u.normalize(),y.normalize(),z.normalize(),this.faces.push(new THREE.Face3(h,m,n,[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,v,t]));e>1&&(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;e<h+1;e++){f=e/h;var k=b*Math.cos(f*g),o=b*Math.sin(f*g),m=[],p=0;for(f=0;f<j;f++){var u=2*f/j,v=o*Math.sin(u*g),u=o*Math.cos(u*g);(e==0||e==h)&&f>0||(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;e<g;e++)if(j=c[e].length,e>0)for(f=0;f<j;f++){m=f==j-1;h=c[e][m?0:f+1];k=c[e][m?j-1:f];o=c[e-1][m?
+j-1:f];m=c[e-1][m?0:f+1];v=e/(g-1);t=(e-1)/(g-1);w=(f+1)/j;var u=f/j,p=new THREE.UV(1-w,v),v=new THREE.UV(1-u,v),u=new THREE.UV(1-u,t),B=new THREE.UV(1-w,t);e<c.length-1&&(t=this.vertices[h].position.clone(),w=this.vertices[k].position.clone(),x=this.vertices[o].position.clone(),t.normalize(),w.normalize(),x.normalize(),this.faces.push(new THREE.Face3(h,k,o,[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,v,u]));e>1&&(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;b<j;b++){var m=new THREE.Path,m=this.extractGlyphPoints(g[b],c,e,f,m);f+=m.offset;h.push(m.path)}return{paths:h,offset:f/2}},extractGlyphPoints:function(b,c,e,f,g){var j=[],h,m,n,p,o,t,v,u,y,z,x=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(x){if(x.o){c=x._cachedOutline||(x._cachedOutline=x.o.split(" "));n=c.length;for(b=0;b<n;)switch(m=c[b++],m){case "m":m=c[b++]*e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,
-p));g.moveTo(m,p);break;case "l":m=c[b++]*e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,p));g.lineTo(m,p);break;case "q":m=c[b++]*e+f;p=c[b++]*e;v=c[b++]*e+f;u=c[b++]*e;g.quadraticCurveTo(v,u,m,p);if(h=j[j.length-1]){o=h.x;t=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++){var w=h/divisions,H=THREE.Shape.Utils.b2(w,o,v,m),w=THREE.Shape.Utils.b2(w,t,u,p);j.push(new THREE.Vector2(H,w))}}break;case "b":if(m=c[b++]*e+f,p=c[b++]*e,v=c[b++]*e+f,u=c[b++]*-e,y=c[b++]*e+f,z=c[b++]*-e,g.bezierCurveTo(m,p,
-v,u,y,z),h=j[j.length-1]){o=h.x;t=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++)w=h/divisions,H=THREE.Shape.Utils.b3(w,o,v,y,m),w=THREE.Shape.Utils.b3(w,t,u,z,p),j.push(new THREE.Vector2(H,w))}}}return{offset:x.ha*e,points:j,path:g}}}};
-(function(b){var c=function(b){for(var c=b.length,g=0,j=c-1,h=0;h<c;j=h++)g+=b[j].x*b[h].y-b[h].x*b[j].y;return g*0.5};b.Triangulate=function(b,f){var g=b.length;if(g<3)return null;var j=[],h=[],m=[],n,p,o;if(c(b)>0)for(p=0;p<g;p++)h[p]=p;else for(p=0;p<g;p++)h[p]=g-1-p;var t=2*g;for(p=g-1;g>2;){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<x;H++)if(!(H==u||H==y||H==z)){var I=v[w[H]].x,R=v[w[H]].y,da=void 0,T=void 0,C=void 0,ea=void 0,S=void 0,P=void 0,k=void 0,M=void 0,Y=void 0,aa=void 0,Z=void 0,ha=void 0,da=C=S=void 0,da=L-J,T=G-D,C=B-L,ea=F-G,S=J-B,P=D-F,k=I-B,M=R-F,Y=I-J,aa=R-D,Z=I-L,ha=R-G,da=da*aa-T*Y,S=S*M-P*k,C=C*ha-ea*Z;if(da>=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;o<g;n++,o++)h[n]=h[o];g--;t=2*g}}if(f)return m;return j};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
+this.getFace(),e=this.size/c.resolution,f=0,g=String(b).split(""),j=g.length,h=[],b=0;b<j;b++){var k=new THREE.Path,k=this.extractGlyphPoints(g[b],c,e,f,k);f+=k.offset;h.push(k.path)}return{paths:h,offset:f/2}},extractGlyphPoints:function(b,c,e,f,g){var j=[],h,k,o,m,p,u,v,t,w,x,B=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(B){if(B.o){c=B._cachedOutline||(B._cachedOutline=B.o.split(" "));o=c.length;for(b=0;b<o;)switch(k=c[b++],k){case "m":k=c[b++]*e+f;m=c[b++]*e;j.push(new THREE.Vector2(k,
+m));g.moveTo(k,m);break;case "l":k=c[b++]*e+f;m=c[b++]*e;j.push(new THREE.Vector2(k,m));g.lineTo(k,m);break;case "q":k=c[b++]*e+f;m=c[b++]*e;v=c[b++]*e+f;t=c[b++]*e;g.quadraticCurveTo(v,t,k,m);if(h=j[j.length-1]){p=h.x;u=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++){var A=h/divisions,H=THREE.Shape.Utils.b2(A,p,v,k),A=THREE.Shape.Utils.b2(A,u,t,m);j.push(new THREE.Vector2(H,A))}}break;case "b":if(k=c[b++]*e+f,m=c[b++]*e,v=c[b++]*e+f,t=c[b++]*-e,w=c[b++]*e+f,x=c[b++]*-e,g.bezierCurveTo(k,m,
+v,t,w,x),h=j[j.length-1]){p=h.x;u=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++)A=h/divisions,H=THREE.Shape.Utils.b3(A,p,v,w,k),A=THREE.Shape.Utils.b3(A,u,t,x,m),j.push(new THREE.Vector2(H,A))}}}return{offset:B.ha*e,points:j,path:g}}}};
+(function(b){var c=function(b){for(var c=b.length,g=0,j=c-1,h=0;h<c;j=h++)g+=b[j].x*b[h].y-b[h].x*b[j].y;return g*0.5};b.Triangulate=function(b,f){var g=b.length;if(g<3)return null;var j=[],h=[],k=[],o,m,p;if(c(b)>0)for(m=0;m<g;m++)h[m]=m;else for(m=0;m<g;m++)h[m]=g-1-m;var u=2*g;for(m=g-1;g>2;){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<B;H++)if(!(H==t||H==w||H==x)){var J=v[A[H]].x,S=v[A[H]].y,X=void 0,R=void 0,C=void 0,n=void 0,W=void 0,V=void 0,fa=void 0,L=void 0,ea=void 0,T=void 0,U=void 0,da=void 0,X=C=W=void 0,X=K-I,R=D-E,C=y-K,n=G-D,W=I-y,V=E-G,fa=J-y,L=S-G,ea=J-I,T=S-E,U=J-K,da=S-D,X=X*T-R*ea,W=W*L-V*fa,C=C*da-n*U;if(X>=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<g;o++,p++)h[o]=h[p];g--;u=2*g}}if(f)return k;return j};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(b,c,e,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;b=[];for(c=0;c<=this.segmentsR;++c)for(e=0;e<=this.segmentsT;++e){var f=e/this.segmentsT*2*Math.PI,g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([e/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(e=
-1;e<=this.segmentsT;++e){var f=(this.segmentsT+1)*c+e,g=(this.segmentsT+1)*c+e-1,j=(this.segmentsT+1)*(c-1)+e-1,h=(this.segmentsT+1)*(c-1)+e;this.faces.push(new THREE.Face4(f,g,j,h));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[j][0],b[j][1]),new THREE.UV(b[h][0],b[h][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
+1;e<=this.segmentsT;++e){var f=(this.segmentsT+1)*c+e,g=(this.segmentsT+1)*c+e-1,j=(this.segmentsT+1)*(c-1)+e-1,h=(this.segmentsT+1)*(c-1)+e;this.faces.push(new THREE.Face4(f,g,j,h));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[j][0],b[j][1]),new THREE.UV(b[h][0],b[h][1])])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
 THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
-THREE.TorusKnotGeometry=function(b,c,e,f,g,j,h){function m(b,c,e,f,h,g){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(h*(2+e)*0.5*Math.cos(b),h*(2+e)*Math.sin(b)*0.5,g*h*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=g||2;this.q=j||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;j=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
-this.segmentsT;++c){var n=b/this.segmentsR*2*this.p*Math.PI,h=c/this.segmentsT*2*Math.PI,g=m(n,h,this.q,this.p,this.radius,this.heightScale),n=m(n+0.01,h,this.q,this.p,this.radius,this.heightScale);e.x=n.x-g.x;e.y=n.y-g.y;e.z=n.z-g.z;f.x=n.x+g.x;f.y=n.y+g.y;f.z=n.z+g.z;j.cross(e,f);f.cross(j,e);j.normalize();f.normalize();n=-this.tube*Math.cos(h);h=this.tube*Math.sin(h);g.x+=n*f.x+h*j.x;g.y+=n*f.y+h*j.y;g.z+=n*f.z+h*j.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,
-g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,j=(c+1)%this.segmentsT,g=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][j],j=this.grid[b][j],h=new THREE.UV(b/this.segmentsR,c/this.segmentsT),n=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),p=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),o=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,e,f,j));this.faceVertexUvs[0].push([h,n,p,o])}this.computeCentroids();
+THREE.TorusKnotGeometry=function(b,c,e,f,g,j,h){function k(b,c,e,f,g,h){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(g*(2+e)*0.5*Math.cos(b),g*(2+e)*Math.sin(b)*0.5,h*g*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=g||2;this.q=j||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;j=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
+this.segmentsT;++c){var o=b/this.segmentsR*2*this.p*Math.PI,h=c/this.segmentsT*2*Math.PI,g=k(o,h,this.q,this.p,this.radius,this.heightScale),o=k(o+0.01,h,this.q,this.p,this.radius,this.heightScale);e.x=o.x-g.x;e.y=o.y-g.y;e.z=o.z-g.z;f.x=o.x+g.x;f.y=o.y+g.y;f.z=o.z+g.z;j.cross(e,f);f.cross(j,e);j.normalize();f.normalize();o=-this.tube*Math.cos(h);h=this.tube*Math.sin(h);g.x+=o*f.x+h*j.x;g.y+=o*f.y+h*j.y;g.z+=o*f.z+h*j.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,
+g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,j=(c+1)%this.segmentsT,g=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][j],j=this.grid[b][j],h=new THREE.UV(b/this.segmentsR,c/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),m=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),p=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,e,f,j));this.faceVertexUvs[0].push([h,o,m,p])}this.computeCentroids();
 this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={addStatusElement:function(){var b=document.createElement("div");b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="rgba(0,0,0,0.25)";b.style.color="#fff";b.style.width="120px";b.style.padding="0.5em 0.5em 0.5em 0.5em";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var c="Loaded ";c+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/1E3).toFixed(2)+" KB";
 this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,c,e){b.materials=[];for(var f=0;f<c.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(c[f],e)]},hasNormals:function(b){var c,e,f=b.materials.length;for(e=0;e<f;e++)if(c=b.materials[e][0],c instanceof THREE.MeshShaderMaterial)return!0;return!1},createMaterial:function(b,c){function e(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function f(b,c){var f=
-new Image;f.onload=function(){if(!e(this.width)||!e(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=c;b.image.height=f;b.image.getContext("2d").drawImage(this,0,0,c,f)}else b.image=this;b.needsUpdate=!0};f.src=c}function g(b,e,h,g,j,m){var n=document.createElement("canvas");b[e]=new THREE.Texture(n);b[e].sourceFile=h;if(g){b[e].repeat.set(g[0],g[1]);if(g[0]!=1)b[e].wrapS=THREE.RepeatWrapping;if(g[1]!=
-1)b[e].wrapT=THREE.RepeatWrapping}j&&b[e].offset.set(j[0],j[1]);if(m){g={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(g[m[0]]!==void 0)b[e].wrapS=g[m[0]];if(g[m[1]]!==void 0)b[e].wrapT=g[m[1]]}f(b[e],c+"/"+h)}function j(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var h,m,n;m="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?m="MeshPhongMaterial":b.shading=="Basic"&&(m="MeshBasicMaterial"));
+new Image;f.onload=function(){if(!e(this.width)||!e(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=c;b.image.height=f;b.image.getContext("2d").drawImage(this,0,0,c,f)}else b.image=this;b.needsUpdate=!0};f.src=c}function g(b,e,g,h,j,k){var m=document.createElement("canvas");b[e]=new THREE.Texture(m);b[e].sourceFile=g;if(h){b[e].repeat.set(h[0],h[1]);if(h[0]!=1)b[e].wrapS=THREE.RepeatWrapping;if(h[1]!=
+1)b[e].wrapT=THREE.RepeatWrapping}j&&b[e].offset.set(j[0],j[1]);if(k){h={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(h[k[0]]!==void 0)b[e].wrapS=h[k[0]];if(h[k[1]]!==void 0)b[e].wrapT=h[k[1]]}f(b[e],c+"/"+g)}function j(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var h,k,o;k="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?k="MeshPhongMaterial":b.shading=="Basic"&&(k="MeshBasicMaterial"));
 if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(b.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)h.transparent=b.transparent;if(b.depthTest!==void 0)h.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(b.vertexColors)h.vertexColors=THREE.VertexColors;if(b.colorDiffuse)h.color=j(b.colorDiffuse);
 else if(b.DbgColor)h.color=b.DbgColor;if(b.colorSpecular)h.specular=j(b.colorSpecular);if(b.colorAmbient)h.ambient=j(b.colorAmbient);if(b.transparency)h.opacity=b.transparency;if(b.specularCoef)h.shininess=b.specularCoef;b.mapDiffuse&&c&&g(h,"map",b.mapDiffuse,b.mapDiffuseRepeat,b.mapDiffuseOffset,b.mapDiffuseWrap);b.mapLight&&c&&g(h,"lightMap",b.mapLight,b.mapLightRepeat,b.mapLightOffset,b.mapLightWrap);b.mapNormal&&c&&g(h,"normalMap",b.mapNormal,b.mapNormalRepeat,b.mapNormalOffset,b.mapNormalWrap);
-b.mapSpecular&&c&&g(h,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var p=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(p.uniforms),t=h.color;m=h.specular;n=h.ambient;var v=h.shininess;o.tNormal.texture=h.normalMap;if(b.mapNormalFactor)o.uNormalScale.value=b.mapNormalFactor;if(h.map)o.tDiffuse.texture=h.map,o.enableDiffuse.value=!0;if(h.specularMap)o.tSpecular.texture=h.specularMap,o.enableSpecular.value=!0;if(h.lightMap)o.tAO.texture=
-h.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(t);o.uSpecularColor.value.setHex(m);o.uAmbientColor.value.setHex(n);o.uShininess.value=v;if(h.opacity)o.uOpacity.value=h.opacity;h=new THREE.MeshShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:o,lights:!0,fog:!0})}else h=new THREE[m](h);return h},constructor:THREE.Loader};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;
+b.mapSpecular&&c&&g(h,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var m=THREE.ShaderUtils.lib.normal,p=THREE.UniformsUtils.clone(m.uniforms),u=h.color;k=h.specular;o=h.ambient;var v=h.shininess;p.tNormal.texture=h.normalMap;if(b.mapNormalFactor)p.uNormalScale.value=b.mapNormalFactor;if(h.map)p.tDiffuse.texture=h.map,p.enableDiffuse.value=!0;if(h.specularMap)p.tSpecular.texture=h.specularMap,p.enableSpecular.value=!0;if(h.lightMap)p.tAO.texture=
+h.lightMap,p.enableAO.value=!0;p.uDiffuseColor.value.setHex(u);p.uSpecularColor.value.setHex(k);p.uAmbientColor.value.setHex(o);p.uShininess.value=v;if(h.opacity)p.uOpacity.value=h.opacity;h=new THREE.MeshShaderMaterial({fragmentShader:m.fragmentShader,vertexShader:m.vertexShader,uniforms:p,lights:!0,fog:!0})}else h=new THREE[k](h);return h},constructor:THREE.Loader};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;
 THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(b){var c=this,e=b.model,f=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,g);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,g=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,g,n,p,o,t,v,u,y,z,x,w,H,B,F=b.faces;t=b.vertices;var J=b.normals,D=b.colors,L=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&L++;for(e=0;e<L;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];p=0;for(o=t.length;p<o;)v=new THREE.Vertex,v.position.x=t[p++]*c,v.position.y=
-t[p++]*c,v.position.z=t[p++]*c,f.vertices.push(v);p=0;for(o=F.length;p<o;){c=F[p++];t=c&1;n=c&2;e=c&4;g=c&8;u=c&16;v=c&32;z=c&64;c&=128;t?(x=new THREE.Face4,x.a=F[p++],x.b=F[p++],x.c=F[p++],x.d=F[p++],t=4):(x=new THREE.Face3,x.a=F[p++],x.b=F[p++],x.c=F[p++],t=3);if(n)n=F[p++],x.materials=f.materials[n];n=f.faces.length;if(e)for(e=0;e<L;e++)w=b.uvs[e],y=F[p++],B=w[y*2],y=w[y*2+1],f.faceUvs[e][n]=new THREE.UV(B,y);if(g)for(e=0;e<L;e++){w=b.uvs[e];H=[];for(g=0;g<t;g++)y=F[p++],B=w[y*2],y=w[y*2+1],H[g]=
-new THREE.UV(B,y);f.faceVertexUvs[e][n]=H}if(u)u=F[p++]*3,g=new THREE.Vector3,g.x=J[u++],g.y=J[u++],g.z=J[u],x.normal=g;if(v)for(e=0;e<t;e++)u=F[p++]*3,g=new THREE.Vector3,g.x=J[u++],g.y=J[u++],g.z=J[u],x.vertexNormals.push(g);if(z)v=F[p++],v=new THREE.Color(D[v]),x.color=v;if(c)for(e=0;e<t;e++)v=F[p++],v=new THREE.Color(D[v]),x.vertexColors.push(v);f.faces.push(x)}}})(g);(function(){var c,e,g,n;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)g=b.skinWeights[c],n=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(g,
-n,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)g=b.skinIndices[c],n=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(g,n,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,g,n,p,o,t,v,u,y;e=0;for(g=b.morphTargets.length;e<g;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];u=f.morphTargets[e].vertices;y=b.morphTargets[e].vertices;n=0;for(p=y.length;n<p;n+=3)o=y[n]*c,t=y[n+1]*
-c,v=y[n+2]*c,u.push(new THREE.Vertex(new THREE.Vector3(o,t,v)))}}if(b.morphColors!==void 0){e=0;for(g=b.morphColors.length;e<g;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];p=f.morphColors[e].colors;o=b.morphColors[e].colors;c=0;for(n=o.length;c<n;c+=3)t=new THREE.Color(16755200),t.setRGB(o[c],o[c+1],o[c+2]),p.push(t)}}})(g);(function(){if(b.edges!==void 0){var c,e,g;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],g=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
+THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,g=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,g,o,m,p,u,v,t,w,x,B,A,H,y,G=b.faces;u=b.vertices;var I=b.normals,E=b.colors,K=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&K++;for(e=0;e<K;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];m=0;for(p=u.length;m<p;)v=new THREE.Vertex,v.position.x=u[m++]*c,v.position.y=
+u[m++]*c,v.position.z=u[m++]*c,f.vertices.push(v);m=0;for(p=G.length;m<p;){c=G[m++];u=c&1;o=c&2;e=c&4;g=c&8;t=c&16;v=c&32;x=c&64;c&=128;u?(B=new THREE.Face4,B.a=G[m++],B.b=G[m++],B.c=G[m++],B.d=G[m++],u=4):(B=new THREE.Face3,B.a=G[m++],B.b=G[m++],B.c=G[m++],u=3);if(o)o=G[m++],B.materials=f.materials[o];o=f.faces.length;if(e)for(e=0;e<K;e++)A=b.uvs[e],w=G[m++],y=A[w*2],w=A[w*2+1],f.faceUvs[e][o]=new THREE.UV(y,w);if(g)for(e=0;e<K;e++){A=b.uvs[e];H=[];for(g=0;g<u;g++)w=G[m++],y=A[w*2],w=A[w*2+1],H[g]=
+new THREE.UV(y,w);f.faceVertexUvs[e][o]=H}if(t)t=G[m++]*3,g=new THREE.Vector3,g.x=I[t++],g.y=I[t++],g.z=I[t],B.normal=g;if(v)for(e=0;e<u;e++)t=G[m++]*3,g=new THREE.Vector3,g.x=I[t++],g.y=I[t++],g.z=I[t],B.vertexNormals.push(g);if(x)v=G[m++],v=new THREE.Color(E[v]),B.color=v;if(c)for(e=0;e<u;e++)v=G[m++],v=new THREE.Color(E[v]),B.vertexColors.push(v);f.faces.push(B)}}})(g);(function(){var c,e,g,o;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)g=b.skinWeights[c],o=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(g,
+o,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)g=b.skinIndices[c],o=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(g,o,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,g,o,m,p,u,v,t,w;e=0;for(g=b.morphTargets.length;e<g;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];t=f.morphTargets[e].vertices;w=b.morphTargets[e].vertices;o=0;for(m=w.length;o<m;o+=3)p=w[o]*c,u=w[o+1]*
+c,v=w[o+2]*c,t.push(new THREE.Vertex(new THREE.Vector3(p,u,v)))}}if(b.morphColors!==void 0){e=0;for(g=b.morphColors.length;e<g;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];m=f.morphColors[e].colors;p=b.morphColors[e].colors;c=0;for(o=p.length;c<o;c+=3)u=new THREE.Color(16755200),u.setRGB(p[c],p[c+1],p[c+2]),m.push(u)}}})(g);(function(){if(b.edges!==void 0){var c,e,g;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],g=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
 f.vertices[g],e,g))}})();f.computeCentroids();f.computeFaceNormals();this.hasNormals(f)&&f.computeTangents();c(f)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(b){var c=b.model,e=b.callback,f=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(c),g=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),j=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,e,g,f,j)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
-c.postMessage(b)},loadAjaxBuffers:function(b,c,e,f,g,j){var h=new XMLHttpRequest,m=f+"/"+b,n=0;h.onreadystatechange=function(){h.readyState==4?h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,e,g,c):alert("Couldn't load ["+m+"] ["+h.status+"]"):h.readyState==3?j&&(n==0&&(n=h.getResponseHeader("Content-Length")),j({total:n,loaded:h.responseText.length})):h.readyState==2&&(n=h.getResponseHeader("Content-Length"))};h.open("GET",m,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
-h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(b,c,e,f){var g=function(c){function e(b,c){var f=o(b,c),g=o(b,c+1),h=o(b,c+2),j=o(b,c+3),k=(j<<1&255|h>>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<m;c+=k)f=e(b,c),g=e(b,c+B.vertex_coordinate_bytes),j=e(b,c+B.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(w,f,g,j);return B.nvertices*k}(H);H+=function(c){for(var e,f,g,h=B.normal_coordinate_bytes*3,j=c+B.nnormals*
-h;c<j;c+=h)e=p(b,c),f=p(b,c+B.normal_coordinate_bytes),g=p(b,c+B.normal_coordinate_bytes*2),F.push(e/127,f/127,g/127);return B.nnormals*h}(H);H+=function(c){for(var f,g,j=B.uv_coordinate_bytes*2,k=c+B.nuvs*j;c<k;c+=j)f=e(b,c),g=e(b,c+B.uv_coordinate_bytes),J.push(f,g);return B.nuvs*j}(H);U=H+U;X=U+X;ca=X+ca;ma=ca+ma;la=ma+la;c=la+c;sa=c+sa;(function(b){var c,e=B.vertex_index_bytes*3+B.material_index_bytes,f=e+B.uv_index_bytes*3,g=b+B.ntri_flat_uv*f;for(c=b;c<g;c+=f)t(c),z(c+e);return g-b})(X);(function(b){var c,
-e=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,f=e+B.uv_index_bytes*3,g=b+B.ntri_smooth_uv*f;for(c=b;c<g;c+=f)v(c),z(c+e);return g-b})(ca);(function(b){var c,e=B.vertex_index_bytes*4+B.material_index_bytes,f=e+B.uv_index_bytes*4,g=b+B.nquad_flat_uv*f;for(c=b;c<g;c+=f)u(c),x(c+e);return g-b})(c);(function(b){var c,e=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*4,f=e+B.uv_index_bytes*4,g=b+B.nquad_smooth_uv*f;for(c=b;c<g;c+=f)y(c),x(c+e);return g-b})(sa);
-(function(b){var c,e=B.vertex_index_bytes*3+B.material_index_bytes,f=b+B.ntri_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(H);(function(b){var c,e=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,f=b+B.ntri_smooth*e;for(c=b;c<f;c+=e)v(c);return f-b})(U);(function(b){var c,e=B.vertex_index_bytes*4+B.material_index_bytes,f=b+B.nquad_flat*e;for(c=b;c<f;c+=e)u(c);return f-b})(ma);(function(b){var c,e=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*4,f=b+B.nquad_smooth*
-e;for(c=b;c<f;c+=e)y(c);return f-b})(la);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(e))},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3:function(b,c,e,f,g){b.faces.push(new THREE.Face3(c,e,f,null,null,b.materials[g]))},f4:function(b,c,e,f,g,j){b.faces.push(new THREE.Face4(c,e,f,g,null,null,b.materials[j]))},f3n:function(b,c,e,
-f,g,j,h,m,n){var j=b.materials[j],p=c[m*3],o=c[m*3+1],m=c[m*3+2],t=c[n*3],v=c[n*3+1],n=c[n*3+2];b.faces.push(new THREE.Face3(e,f,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(p,o,m),new THREE.Vector3(t,v,n)],null,j))},f4n:function(b,c,e,f,g,j,h,m,n,p,o){var h=b.materials[h],t=c[n*3],v=c[n*3+1],n=c[n*3+2],u=c[p*3],y=c[p*3+1],p=c[p*3+2],z=c[o*3],x=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face4(e,f,g,j,[new THREE.Vector3(c[m*3],c[m*3+1],c[m*3+2]),new THREE.Vector3(t,v,n),new THREE.Vector3(u,
-y,p),new THREE.Vector3(z,x,o)],null,h))},uv3:function(b,c,e,f,g,j,h){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,g));m.push(new THREE.UV(j,h));b.push(m)},uv4:function(b,c,e,f,g,j,h,m,n){var p=[];p.push(new THREE.UV(c,e));p.push(new THREE.UV(f,g));p.push(new THREE.UV(j,h));p.push(new THREE.UV(m,n));b.push(p)},constructor:THREE.BinaryLoader};
+c.postMessage(b)},loadAjaxBuffers:function(b,c,e,f,g,j){var h=new XMLHttpRequest,k=f+"/"+b,o=0;h.onreadystatechange=function(){h.readyState==4?h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,e,g,c):alert("Couldn't load ["+k+"] ["+h.status+"]"):h.readyState==3?j&&(o==0&&(o=h.getResponseHeader("Content-Length")),j({total:o,loaded:h.responseText.length})):h.readyState==2&&(o=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
+h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(b,c,e,f){var g=function(c){function e(b,c){var f=p(b,c),g=p(b,c+1),h=p(b,c+2),j=p(b,c+3),k=(j<<1&255|h>>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;c<m;c+=k)f=e(b,c),g=e(b,c+y.vertex_coordinate_bytes),j=e(b,c+y.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(A,f,g,j);return y.nvertices*k}(H);H+=function(c){for(var e,f,g,h=y.normal_coordinate_bytes*3,j=
+c+y.nnormals*h;c<j;c+=h)e=m(b,c),f=m(b,c+y.normal_coordinate_bytes),g=m(b,c+y.normal_coordinate_bytes*2),G.push(e/127,f/127,g/127);return y.nnormals*h}(H);H+=function(c){for(var f,g,j=y.uv_coordinate_bytes*2,k=c+y.nuvs*j;c<k;c+=j)f=e(b,c),g=e(b,c+y.uv_coordinate_bytes),I.push(f,g);return y.nuvs*j}(H);M=H+M;P=M+P;aa=P+aa;Y=aa+Y;Z=Y+Z;c=Z+c;ca=c+ca;(function(b){var c,e=y.vertex_index_bytes*3+y.material_index_bytes,f=e+y.uv_index_bytes*3,g=b+y.ntri_flat_uv*f;for(c=b;c<g;c+=f)u(c),x(c+e);return g-b})(P);
+(function(b){var c,e=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*3,f=e+y.uv_index_bytes*3,g=b+y.ntri_smooth_uv*f;for(c=b;c<g;c+=f)v(c),x(c+e);return g-b})(aa);(function(b){var c,e=y.vertex_index_bytes*4+y.material_index_bytes,f=e+y.uv_index_bytes*4,g=b+y.nquad_flat_uv*f;for(c=b;c<g;c+=f)t(c),B(c+e);return g-b})(c);(function(b){var c,e=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*4,f=e+y.uv_index_bytes*4,g=b+y.nquad_smooth_uv*f;for(c=b;c<g;c+=f)w(c),B(c+
+e);return g-b})(ca);(function(b){var c,e=y.vertex_index_bytes*3+y.material_index_bytes,f=b+y.ntri_flat*e;for(c=b;c<f;c+=e)u(c);return f-b})(H);(function(b){var c,e=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*3,f=b+y.ntri_smooth*e;for(c=b;c<f;c+=e)v(c);return f-b})(M);(function(b){var c,e=y.vertex_index_bytes*4+y.material_index_bytes,f=b+y.nquad_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(Y);(function(b){var c,e=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*
+4,f=b+y.nquad_smooth*e;for(c=b;c<f;c+=e)w(c);return f-b})(Z);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(e))},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3:function(b,c,e,f,g){b.faces.push(new THREE.Face3(c,e,f,null,null,b.materials[g]))},f4:function(b,c,e,f,g,j){b.faces.push(new THREE.Face4(c,e,f,g,null,null,b.materials[j]))},
+f3n:function(b,c,e,f,g,j,h,k,o){var j=b.materials[j],m=c[k*3],p=c[k*3+1],k=c[k*3+2],u=c[o*3],v=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face3(e,f,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,p,k),new THREE.Vector3(u,v,o)],null,j))},f4n:function(b,c,e,f,g,j,h,k,o,m,p){var h=b.materials[h],u=c[o*3],v=c[o*3+1],o=c[o*3+2],t=c[m*3],w=c[m*3+1],m=c[m*3+2],x=c[p*3],B=c[p*3+1],p=c[p*3+2];b.faces.push(new THREE.Face4(e,f,g,j,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(u,
+v,o),new THREE.Vector3(t,w,m),new THREE.Vector3(x,B,p)],null,h))},uv3:function(b,c,e,f,g,j,h){var k=[];k.push(new THREE.UV(c,e));k.push(new THREE.UV(f,g));k.push(new THREE.UV(j,h));b.push(k)},uv4:function(b,c,e,f,g,j,h,k,o){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,g));m.push(new THREE.UV(j,h));m.push(new THREE.UV(k,o));b.push(m)},constructor:THREE.BinaryLoader};
 THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
-THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:g+"/"+b}function m(){for(u in T.objects)if(!M.objects[u])if(H=T.objects[u],H.geometry!==void 0){if(D=M.geometries[H.geometry]){var b=!1;R=[];for(aa=0;aa<H.materials.length;aa++)R[aa]=M.materials[H.materials[aa]],b=R[aa]instanceof THREE.MeshShaderMaterial;b&&D.computeTangents();B=H.position;r=
-H.rotation;q=H.quaternion;s=H.scale;q=0;R.length==0&&(R[0]=new THREE.MeshFaceMaterial);R.length>1&&(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;I<t.url.length;I++)e.onLoadStart()}else S+=1,e.onLoadStart();
-k=S;for(w in T.textures){t=T.textures[w];if(t.mapping!=void 0&&THREE[t.mapping]!=void 0)t.mapping=new THREE[t.mapping];if(t.url instanceof Array){I=[];for(var aa=0;aa<t.url.length;aa++)I[aa]=f(t.url[aa],T.urlBaseType);I=THREE.ImageUtils.loadTextureCube(I,t.mapping,b)}else{I=THREE.ImageUtils.loadTexture(f(t.url,T.urlBaseType),t.mapping,b);if(THREE[t.minFilter]!=void 0)I.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=void 0)I.magFilter=THREE[t.magFilter];if(t.repeat){I.repeat.set(t.repeat[0],t.repeat[1]);
-if(t.repeat[0]!=1)I.wrapS=THREE.RepeatWrapping;if(t.repeat[1]!=1)I.wrapT=THREE.RepeatWrapping}t.offset&&I.offset.set(t.offset[0],t.offset[1]);if(t.wrap){C={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(C[t.wrap[0]]!==void 0)I.wrapS=C[t.wrap[0]];if(C[t.wrap[1]]!==void 0)I.wrapT=C[t.wrap[1]]}}M.textures[w]=I}for(v in T.materials){w=T.materials[v];for(J in w.parameters)if(J=="envMap"||J=="map"||J=="lightMap")w.parameters[J]=M.textures[w.parameters[J]];else if(J=="shading")w.parameters[J]=
-w.parameters[J]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(J=="blending")w.parameters[J]=THREE[w.parameters[J]]?THREE[w.parameters[J]]:THREE.NormalBlending;else if(J=="combine")w.parameters[J]=w.parameters[J]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(J=="vertexColors")if(w.parameters[J]=="face")w.parameters[J]=THREE.FaceColors;else if(w.parameters[J])w.parameters[J]=THREE.VertexColors;if(w.parameters.opacity!==void 0&&w.parameters.opacity<1)w.parameters.transparent=
-!0;if(w.parameters.normalMap){t=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(t.uniforms);I=w.parameters.color;C=w.parameters.specular;x=w.parameters.ambient;G=w.parameters.shininess;b.tNormal.texture=M.textures[w.parameters.normalMap];if(w.parameters.normalMapFactor)b.uNormalScale.value=w.parameters.normalMapFactor;if(w.parameters.map)b.tDiffuse.texture=w.parameters.map,b.enableDiffuse.value=!0;if(w.parameters.lightMap)b.tAO.texture=w.parameters.lightMap,b.enableAO.value=!0;if(w.parameters.specularMap)b.tSpecular.texture=
-M.textures[w.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(I);b.uSpecularColor.value.setHex(C);b.uAmbientColor.value.setHex(x);b.uShininess.value=G;if(w.parameters.opacity)b.uOpacity.value=w.parameters.opacity;w=new THREE.MeshShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:b,lights:!0,fog:!0})}else w=new THREE[w.type](w.parameters);M.materials[v]=w}m();e.callbackSync(M)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
+THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:g+"/"+b}function k(){for(t in R.objects)if(!L.objects[t])if(H=R.objects[t],H.geometry!==void 0){if(E=L.geometries[H.geometry]){var b=!1;S=[];for(T=0;T<H.materials.length;T++)S[T]=L.materials[H.materials[T]],b=S[T]instanceof THREE.MeshShaderMaterial;b&&E.computeTangents();y=H.position;r=H.rotation;
+q=H.quaternion;s=H.scale;q=0;S.length==0&&(S[0]=new THREE.MeshFaceMaterial);S.length>1&&(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<u.url.length;J++)e.onLoadStart()}else W+=1,e.onLoadStart();
+fa=W;for(A in R.textures){u=R.textures[A];if(u.mapping!=void 0&&THREE[u.mapping]!=void 0)u.mapping=new THREE[u.mapping];if(u.url instanceof Array){J=[];for(var T=0;T<u.url.length;T++)J[T]=f(u.url[T],R.urlBaseType);J=THREE.ImageUtils.loadTextureCube(J,u.mapping,b)}else{J=THREE.ImageUtils.loadTexture(f(u.url,R.urlBaseType),u.mapping,b);if(THREE[u.minFilter]!=void 0)J.minFilter=THREE[u.minFilter];if(THREE[u.magFilter]!=void 0)J.magFilter=THREE[u.magFilter];if(u.repeat){J.repeat.set(u.repeat[0],u.repeat[1]);
+if(u.repeat[0]!=1)J.wrapS=THREE.RepeatWrapping;if(u.repeat[1]!=1)J.wrapT=THREE.RepeatWrapping}u.offset&&J.offset.set(u.offset[0],u.offset[1]);if(u.wrap){C={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(C[u.wrap[0]]!==void 0)J.wrapS=C[u.wrap[0]];if(C[u.wrap[1]]!==void 0)J.wrapT=C[u.wrap[1]]}}L.textures[A]=J}for(v in R.materials){A=R.materials[v];for(I in A.parameters)if(I=="envMap"||I=="map"||I=="lightMap")A.parameters[I]=L.textures[A.parameters[I]];else if(I=="shading")A.parameters[I]=
+A.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")A.parameters[I]=THREE[A.parameters[I]]?THREE[A.parameters[I]]:THREE.NormalBlending;else if(I=="combine")A.parameters[I]=A.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(I=="vertexColors")if(A.parameters[I]=="face")A.parameters[I]=THREE.FaceColors;else if(A.parameters[I])A.parameters[I]=THREE.VertexColors;if(A.parameters.opacity!==void 0&&A.parameters.opacity<1)A.parameters.transparent=
+!0;if(A.parameters.normalMap){u=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(u.uniforms);J=A.parameters.color;C=A.parameters.specular;B=A.parameters.ambient;D=A.parameters.shininess;b.tNormal.texture=L.textures[A.parameters.normalMap];if(A.parameters.normalMapFactor)b.uNormalScale.value=A.parameters.normalMapFactor;if(A.parameters.map)b.tDiffuse.texture=A.parameters.map,b.enableDiffuse.value=!0;if(A.parameters.lightMap)b.tAO.texture=A.parameters.lightMap,b.enableAO.value=!0;if(A.parameters.specularMap)b.tSpecular.texture=
+L.textures[A.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(J);b.uSpecularColor.value.setHex(C);b.uAmbientColor.value.setHex(B);b.uShininess.value=D;if(A.parameters.opacity)b.uOpacity.value=A.parameters.opacity;A=new THREE.MeshShaderMaterial({fragmentShader:u.fragmentShader,vertexShader:u.vertexShader,uniforms:b,lights:!0,fog:!0})}else A=new THREE[A.type](A.parameters);L.materials[v]=A}k();e.callbackSync(L)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
 THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
-THREE.UTF8Loader.prototype={load:function(b){var c=new XMLHttpRequest,e=b.model,f=b.callback,g=b.scale!==void 0?b.scale:1,j=b.offsetX!==void 0?b.offsetX:0,h=b.offsetY!==void 0?b.offsetY:0,m=b.offsetZ!==void 0?b.offsetZ:0;c.onreadystatechange=function(){c.readyState==4?c.status==200||c.status==0?THREE.UTF8Loader.prototype.createModel(c.responseText,f,g,j,h,m):alert("Couldn't load ["+e+"] ["+c.status+"]"):c.readyState!=3&&c.readyState==2&&c.getResponseHeader("Content-Length")};c.open("GET",e,!0);c.send(null)},
-decompressMesh:function(b){var c=b.charCodeAt(0);c>=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<c;++h){var m=b.charCodeAt(h+f);j+=m>>1^-(m&1);e[8*h+g]=j}f+=c}c=b.length-f;j=new Uint16Array(c);for(g=h=0;g<c;g++)m=b.charCodeAt(g+f),j[g]=h-m,m==0&&h++;return[e,j]},createModel:function(b,c,e,f,g,j){var h=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var h=THREE.UTF8Loader.prototype.decompressMesh(b),p=[],o=[];(function(b,h,n){for(var o,p,x,
-w=b.length;n<w;n+=h)o=b[n],p=b[n+1],x=b[n+2],o=o/16383*e,p=p/16383*e,x=x/16383*e,o+=f,p+=g,x+=j,THREE.UTF8Loader.prototype.v(c,o,p,x)})(h[0],8,0);(function(b,c,e){for(var f,g,h=b.length;e<h;e+=c)f=b[e],g=b[e+1],f/=1023,g/=1023,o.push(f,g)})(h[0],8,3);(function(b,c,e){for(var f,g,h,j=b.length;e<j;e+=c)f=b[e],g=b[e+1],h=b[e+2],f=(f-512)/511,g=(g-512)/511,h=(h-512)/511,p.push(f,g,h)})(h[0],8,5);(function(b){var e,f,g,h,j,n,H,B=b.length;for(e=0;e<B;e+=3)f=b[e],g=b[e+1],h=b[e+2],THREE.UTF8Loader.prototype.f3n(c,
-p,f,g,h,0,f,g,h),j=o[f*2],f=o[f*2+1],n=o[g*2],g=o[g*2+1],H=o[h*2],h=o[h*2+1],THREE.UTF8Loader.prototype.uv3(c.faceVertexUvs[0],j,f,n,g,H,h)})(h[1]);this.computeCentroids();this.computeFaceNormals()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h)},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3n:function(b,c,e,f,g,j,h,m,n){var j=b.materials[j],p=c[m*3],o=c[m*3+1],m=c[m*3+2],t=c[n*3],v=c[n*3+1],n=c[n*3+2],h=new THREE.Vector3(c[h*3],c[h*3+1],c[h*
-3+2]),m=new THREE.Vector3(p,o,m),n=new THREE.Vector3(t,v,n);b.faces.push(new THREE.Face3(e,f,g,[h,m,n],null,j))},uv3:function(b,c,e,f,g,j,h){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,g));m.push(new THREE.UV(j,h));b.push(m)},constructor:THREE.UTF8Loader};
+THREE.UTF8Loader.prototype={load:function(b){var c=new XMLHttpRequest,e=b.model,f=b.callback,g=b.scale!==void 0?b.scale:1,j=b.offsetX!==void 0?b.offsetX:0,h=b.offsetY!==void 0?b.offsetY:0,k=b.offsetZ!==void 0?b.offsetZ:0;c.onreadystatechange=function(){c.readyState==4?c.status==200||c.status==0?THREE.UTF8Loader.prototype.createModel(c.responseText,f,g,j,h,k):alert("Couldn't load ["+e+"] ["+c.status+"]"):c.readyState!=3&&c.readyState==2&&c.getResponseHeader("Content-Length")};c.open("GET",e,!0);c.send(null)},
+decompressMesh:function(b){var c=b.charCodeAt(0);c>=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<c;++h){var k=b.charCodeAt(h+f);j+=k>>1^-(k&1);e[8*h+g]=j}f+=c}c=b.length-f;j=new Uint16Array(c);for(g=h=0;g<c;g++)k=b.charCodeAt(g+f),j[g]=h-k,k==0&&h++;return[e,j]},createModel:function(b,c,e,f,g,j){var h=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var h=THREE.UTF8Loader.prototype.decompressMesh(b),m=[],p=[];(function(b,h,m){for(var o,p,B,
+A=b.length;m<A;m+=h)o=b[m],p=b[m+1],B=b[m+2],o=o/16383*e,p=p/16383*e,B=B/16383*e,o+=f,p+=g,B+=j,THREE.UTF8Loader.prototype.v(c,o,p,B)})(h[0],8,0);(function(b,c,e){for(var f,g,h=b.length;e<h;e+=c)f=b[e],g=b[e+1],f/=1023,g/=1023,p.push(f,g)})(h[0],8,3);(function(b,c,e){for(var f,g,h,j=b.length;e<j;e+=c)f=b[e],g=b[e+1],h=b[e+2],f=(f-512)/511,g=(g-512)/511,h=(h-512)/511,m.push(f,g,h)})(h[0],8,5);(function(b){var e,f,g,h,j,o,H,y=b.length;for(e=0;e<y;e+=3)f=b[e],g=b[e+1],h=b[e+2],THREE.UTF8Loader.prototype.f3n(c,
+m,f,g,h,0,f,g,h),j=p[f*2],f=p[f*2+1],o=p[g*2],g=p[g*2+1],H=p[h*2],h=p[h*2+1],THREE.UTF8Loader.prototype.uv3(c.faceVertexUvs[0],j,f,o,g,H,h)})(h[1]);this.computeCentroids();this.computeFaceNormals()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h)},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3n:function(b,c,e,f,g,j,h,k,o){var j=b.materials[j],m=c[k*3],p=c[k*3+1],k=c[k*3+2],u=c[o*3],v=c[o*3+1],o=c[o*3+2],h=new THREE.Vector3(c[h*3],c[h*3+1],c[h*
+3+2]),k=new THREE.Vector3(m,p,k),o=new THREE.Vector3(u,v,o);b.faces.push(new THREE.Face3(e,f,g,[h,k,o],null,j))},uv3:function(b,c,e,f,g,j,h){var k=[];k.push(new THREE.UV(c,e));k.push(new THREE.UV(f,g));k.push(new THREE.UV(j,h));b.push(k)},constructor:THREE.UTF8Loader};
 THREE.MarchingCubes=function(b,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
-0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,g){return b+(c-b)*g};this.VIntX=function(b,c,g,j,h,m,n,p,o,t){h=(h-o)/(t-o);o=this.normal_cache;c[j]=m+h*this.delta;c[j+1]=n;c[j+2]=p;g[j]=this.lerp(o[b],o[b+3],h);g[j+1]=this.lerp(o[b+1],o[b+4],h);g[j+2]=this.lerp(o[b+2],o[b+5],h)};this.VIntY=function(b,c,g,j,h,m,n,p,o,t){h=(h-o)/(t-o);o=this.normal_cache;c[j]=m;c[j+1]=n+h*this.delta;c[j+
-2]=p;c=b+this.yd*3;g[j]=this.lerp(o[b],o[c],h);g[j+1]=this.lerp(o[b+1],o[c+1],h);g[j+2]=this.lerp(o[b+2],o[c+2],h)};this.VIntZ=function(b,c,g,j,h,m,n,p,o,t){h=(h-o)/(t-o);o=this.normal_cache;c[j]=m;c[j+1]=n;c[j+2]=p+h*this.delta;c=b+this.zd*3;g[j]=this.lerp(o[b],o[c],h);g[j+1]=this.lerp(o[b+1],o[c+1],h);g[j+2]=this.lerp(o[b+2],o[c+2],h)};this.compNorm=function(b){var c=b*3;this.normal_cache[c]==0&&(this.normal_cache[c]=this.field[b-1]-this.field[b+1],this.normal_cache[c+1]=this.field[b-this.yd]-this.field[b+
-this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,g,j,h,m){var n=j+1,p=j+this.yd,o=j+this.zd,t=n+this.yd,v=n+this.zd,u=j+this.yd+this.zd,y=n+this.yd+this.zd,z=0,x=this.field[j],w=this.field[n],H=this.field[p],B=this.field[t],F=this.field[o],J=this.field[v],D=this.field[u],L=this.field[y];x<h&&(z|=1);w<h&&(z|=2);H<h&&(z|=8);B<h&&(z|=4);F<h&&(z|=16);J<h&&(z|=32);D<h&&(z|=128);L<h&&(z|=64);var G=THREE.edgeTable[z];if(G==0)return 0;var I=this.delta,
-R=b+I,da=c+I,I=g+I;G&1&&(this.compNorm(j),this.compNorm(n),this.VIntX(j*3,this.vlist,this.nlist,0,h,b,c,g,x,w));G&2&&(this.compNorm(n),this.compNorm(t),this.VIntY(n*3,this.vlist,this.nlist,3,h,R,c,g,w,B));G&4&&(this.compNorm(p),this.compNorm(t),this.VIntX(p*3,this.vlist,this.nlist,6,h,b,da,g,H,B));G&8&&(this.compNorm(j),this.compNorm(p),this.VIntY(j*3,this.vlist,this.nlist,9,h,b,c,g,x,H));G&16&&(this.compNorm(o),this.compNorm(v),this.VIntX(o*3,this.vlist,this.nlist,12,h,b,c,I,F,J));G&32&&(this.compNorm(v),
-this.compNorm(y),this.VIntY(v*3,this.vlist,this.nlist,15,h,R,c,I,J,L));G&64&&(this.compNorm(u),this.compNorm(y),this.VIntX(u*3,this.vlist,this.nlist,18,h,b,da,I,D,L));G&128&&(this.compNorm(o),this.compNorm(u),this.VIntY(o*3,this.vlist,this.nlist,21,h,b,c,I,F,D));G&256&&(this.compNorm(j),this.compNorm(o),this.VIntZ(j*3,this.vlist,this.nlist,24,h,b,c,g,x,F));G&512&&(this.compNorm(n),this.compNorm(v),this.VIntZ(n*3,this.vlist,this.nlist,27,h,R,c,g,w,J));G&1024&&(this.compNorm(t),this.compNorm(y),this.VIntZ(t*
-3,this.vlist,this.nlist,30,h,R,da,g,B,L));G&2048&&(this.compNorm(p),this.compNorm(u),this.VIntZ(p*3,this.vlist,this.nlist,33,h,b,da,g,H,D));z<<=4;for(h=j=0;THREE.triTable[z+h]!=-1;)b=z+h,c=b+1,g=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],m),h+=3,j++;return j};this.posnormtriv=function(b,c,g,j,h,m){var n=this.count*3;this.positionArray[n]=b[g];this.positionArray[n+1]=b[g+1];this.positionArray[n+2]=b[g+2];this.positionArray[n+3]=b[j];this.positionArray[n+
-4]=b[j+1];this.positionArray[n+5]=b[j+2];this.positionArray[n+6]=b[h];this.positionArray[n+7]=b[h+1];this.positionArray[n+8]=b[h+2];this.normalArray[n]=c[g];this.normalArray[n+1]=c[g+1];this.normalArray[n+2]=c[g+2];this.normalArray[n+3]=c[j];this.normalArray[n+4]=c[j+1];this.normalArray[n+5]=c[j+2];this.normalArray[n+6]=c[h];this.normalArray[n+7]=c[h+1];this.normalArray[n+8]=c[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=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;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,g,j,h){var m=this.size*Math.sqrt(j/h),n=g*this.size,p=c*this.size,o=b*this.size,t=Math.floor(n-m);t<1&&(t=1);n=Math.floor(n+m);n>this.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;t<n;t++){o=this.size2*t;z=t/this.size-g;H=z*z;for(z=v;z<p;z++){x=o+this.size*z;y=z/this.size-c;B=y*y;for(y=u;y<m;y++)w=y/this.size-b,w=j/(1.0E-6+w*w+B+H)-h,w>0&&(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;g<u;g++)if(j=g/p,j*=j,m=b/(1.0E-4+j)-c,m>0)for(j=0;j<p;j++){n=g+j*o;for(h=0;h<p;h++)v[t*h+n]+=m}};this.addPlaneY=function(b,c){var g,j,h,m,n,p,o=this.size,t=this.yd,v=
-this.zd,u=this.field,y=o*Math.sqrt(b/c);y>o&&(y=o);for(j=0;j<y;j++)if(g=j/o,g*=g,m=b/(1.0E-4+g)-c,m>0){n=j*t;for(g=0;g<o;g++){p=n+g;for(h=0;h<o;h++)u[v*h+p]+=m}}};this.addPlaneZ=function(b,c){var g,j,h,m,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(h=0;h<dist;h++)if(g=h/size,g*=g,m=b/(1.0E-4+g)-c,m>0){n=zd*h;for(j=0;j<size;j++){p=n+j*yd;for(g=0;g<size;g++)field[p+g]+=m}}};this.reset=function(){var b;for(b=0;b<this.size3;b++)this.normal_cache[b*
-3]=0,this.field[b]=0};this.render=function(b){this.begin();var c,g,j,h,m,n,p,o,t,v=this.size-2;for(h=1;h<v;h++){t=this.size2*h;p=(h-this.halfsize)/this.halfsize;for(j=1;j<v;j++){o=t+this.size*j;n=(j-this.halfsize)/this.halfsize;for(g=1;g<v;g++)m=(g-this.halfsize)/this.halfsize,c=o+g,this.polygonize(m,n,p,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,g=[];this.render(function(j){var h,m,n,p,o,t,v,u;for(h=0;h<j.count;h++)v=h*3,o=v+1,u=v+2,m=j.positionArray[v],
-n=j.positionArray[o],p=j.positionArray[u],t=new THREE.Vector3(m,n,p),m=j.normalArray[v],n=j.normalArray[o],p=j.normalArray[u],v=new THREE.Vector3(m,n,p),v.normalize(),o=new THREE.Vertex(t),c.vertices.push(o),g.push(v);nfaces=j.count/3;for(h=0;h<nfaces;h++)v=(b+h)*3,o=v+1,u=v+2,t=g[v],m=g[o],n=g[u],v=new THREE.Face3(v,o,u,[t,m,n]),c.faces.push(v);b+=nfaces;j.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,g){return b+(c-b)*g};this.VIntX=function(b,c,g,j,h,k,o,m,p,u){h=(h-p)/(u-p);p=this.normal_cache;c[j]=k+h*this.delta;c[j+1]=o;c[j+2]=m;g[j]=this.lerp(p[b],p[b+3],h);g[j+1]=this.lerp(p[b+1],p[b+4],h);g[j+2]=this.lerp(p[b+2],p[b+5],h)};this.VIntY=function(b,c,g,j,h,k,o,m,p,u){h=(h-p)/(u-p);p=this.normal_cache;c[j]=k;c[j+1]=o+h*this.delta;c[j+
+2]=m;c=b+this.yd*3;g[j]=this.lerp(p[b],p[c],h);g[j+1]=this.lerp(p[b+1],p[c+1],h);g[j+2]=this.lerp(p[b+2],p[c+2],h)};this.VIntZ=function(b,c,g,j,h,k,o,m,p,u){h=(h-p)/(u-p);p=this.normal_cache;c[j]=k;c[j+1]=o;c[j+2]=m+h*this.delta;c=b+this.zd*3;g[j]=this.lerp(p[b],p[c],h);g[j+1]=this.lerp(p[b+1],p[c+1],h);g[j+2]=this.lerp(p[b+2],p[c+2],h)};this.compNorm=function(b){var c=b*3;this.normal_cache[c]==0&&(this.normal_cache[c]=this.field[b-1]-this.field[b+1],this.normal_cache[c+1]=this.field[b-this.yd]-this.field[b+
+this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,g,j,h,k){var o=j+1,m=j+this.yd,p=j+this.zd,u=o+this.yd,v=o+this.zd,t=j+this.yd+this.zd,w=o+this.yd+this.zd,x=0,B=this.field[j],A=this.field[o],H=this.field[m],y=this.field[u],G=this.field[p],I=this.field[v],E=this.field[t],K=this.field[w];B<h&&(x|=1);A<h&&(x|=2);H<h&&(x|=8);y<h&&(x|=4);G<h&&(x|=16);I<h&&(x|=32);E<h&&(x|=128);K<h&&(x|=64);var D=THREE.edgeTable[x];if(D==0)return 0;var J=this.delta,
+S=b+J,X=c+J,J=g+J;D&1&&(this.compNorm(j),this.compNorm(o),this.VIntX(j*3,this.vlist,this.nlist,0,h,b,c,g,B,A));D&2&&(this.compNorm(o),this.compNorm(u),this.VIntY(o*3,this.vlist,this.nlist,3,h,S,c,g,A,y));D&4&&(this.compNorm(m),this.compNorm(u),this.VIntX(m*3,this.vlist,this.nlist,6,h,b,X,g,H,y));D&8&&(this.compNorm(j),this.compNorm(m),this.VIntY(j*3,this.vlist,this.nlist,9,h,b,c,g,B,H));D&16&&(this.compNorm(p),this.compNorm(v),this.VIntX(p*3,this.vlist,this.nlist,12,h,b,c,J,G,I));D&32&&(this.compNorm(v),
+this.compNorm(w),this.VIntY(v*3,this.vlist,this.nlist,15,h,S,c,J,I,K));D&64&&(this.compNorm(t),this.compNorm(w),this.VIntX(t*3,this.vlist,this.nlist,18,h,b,X,J,E,K));D&128&&(this.compNorm(p),this.compNorm(t),this.VIntY(p*3,this.vlist,this.nlist,21,h,b,c,J,G,E));D&256&&(this.compNorm(j),this.compNorm(p),this.VIntZ(j*3,this.vlist,this.nlist,24,h,b,c,g,B,G));D&512&&(this.compNorm(o),this.compNorm(v),this.VIntZ(o*3,this.vlist,this.nlist,27,h,S,c,g,A,I));D&1024&&(this.compNorm(u),this.compNorm(w),this.VIntZ(u*
+3,this.vlist,this.nlist,30,h,S,X,g,y,K));D&2048&&(this.compNorm(m),this.compNorm(t),this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,X,g,H,E));x<<=4;for(h=j=0;THREE.triTable[x+h]!=-1;)b=x+h,c=b+1,g=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],k),h+=3,j++;return j};this.posnormtriv=function(b,c,g,j,h,k){var o=this.count*3;this.positionArray[o]=b[g];this.positionArray[o+1]=b[g+1];this.positionArray[o+2]=b[g+2];this.positionArray[o+3]=b[j];this.positionArray[o+
+4]=b[j+1];this.positionArray[o+5]=b[j+2];this.positionArray[o+6]=b[h];this.positionArray[o+7]=b[h+1];this.positionArray[o+8]=b[h+2];this.normalArray[o]=c[g];this.normalArray[o+1]=c[g+1];this.normalArray[o+2]=c[g+2];this.normalArray[o+3]=c[j];this.normalArray[o+4]=c[j+1];this.normalArray[o+5]=c[j+2];this.normalArray[o+6]=c[h];this.normalArray[o+7]=c[h+1];this.normalArray[o+8]=c[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=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;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,g,j,h){var k=this.size*Math.sqrt(j/h),o=g*this.size,m=c*this.size,p=b*this.size,u=Math.floor(o-k);u<1&&(u=1);o=Math.floor(o+k);o>this.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;u<o;u++){p=this.size2*u;x=u/this.size-g;H=x*x;for(x=v;x<m;x++){B=p+this.size*x;w=x/this.size-c;y=w*w;for(w=t;w<k;w++)A=w/this.size-b,A=j/(1.0E-6+A*A+y+H)-h,A>0&&(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;g<t;g++)if(j=g/m,j*=j,k=b/(1.0E-4+j)-c,k>0)for(j=0;j<m;j++){o=g+j*p;for(h=0;h<m;h++)v[u*h+o]+=k}};this.addPlaneY=function(b,c){var g,j,h,k,o,m,p=this.size,u=this.yd,v=
+this.zd,t=this.field,w=p*Math.sqrt(b/c);w>p&&(w=p);for(j=0;j<w;j++)if(g=j/p,g*=g,k=b/(1.0E-4+g)-c,k>0){o=j*u;for(g=0;g<p;g++){m=o+g;for(h=0;h<p;h++)t[v*h+m]+=k}}};this.addPlaneZ=function(b,c){var g,j,h,k,o,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(h=0;h<dist;h++)if(g=h/size,g*=g,k=b/(1.0E-4+g)-c,k>0){o=zd*h;for(j=0;j<size;j++){m=o+j*yd;for(g=0;g<size;g++)field[m+g]+=k}}};this.reset=function(){var b;for(b=0;b<this.size3;b++)this.normal_cache[b*
+3]=0,this.field[b]=0};this.render=function(b){this.begin();var c,g,j,h,k,o,m,p,u,v=this.size-2;for(h=1;h<v;h++){u=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(j=1;j<v;j++){p=u+this.size*j;o=(j-this.halfsize)/this.halfsize;for(g=1;g<v;g++)k=(g-this.halfsize)/this.halfsize,c=p+g,this.polygonize(k,o,m,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,g=[];this.render(function(j){var h,k,o,m,p,u,v,t;for(h=0;h<j.count;h++)v=h*3,p=v+1,t=v+2,k=j.positionArray[v],
+o=j.positionArray[p],m=j.positionArray[t],u=new THREE.Vector3(k,o,m),k=j.normalArray[v],o=j.normalArray[p],m=j.normalArray[t],v=new THREE.Vector3(k,o,m),v.normalize(),p=new THREE.Vertex(u),c.vertices.push(p),g.push(v);nfaces=j.count/3;for(h=0;h<nfaces;h++)v=(b+h)*3,p=v+1,t=v+2,u=g[v],k=g[p],o=g[t],v=new THREE.Face3(v,p,t,[u,k,o]),c.faces.push(v);b+=nfaces;j.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
@@ -627,20 +595,20 @@ THREE.MeshCollider=function(b,c){this.mesh=b;this.box=c;this.numFaces=this.mesh.
 THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,g,j=0;c=0;for(e=this.colliders.length;c<e;c++)if(g=this.colliders[c],f=this.rayCast(b,g),f<Number.MAX_VALUE)g.distance=f,f>j?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.dist<Number.MAX_VALUE){c[e].distance=f.dist;c[e].faceIndex=f.faceIndex;break}e++}if(e>c.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<c.numFaces;j++){var h=c.mesh.geometry.faces[j],m=c.mesh.geometry.vertices[h.a].position,n=c.mesh.geometry.vertices[h.b].position,p=c.mesh.geometry.vertices[h.c].position,o=h instanceof THREE.Face4?c.mesh.geometry.vertices[h.d].position:null;h instanceof THREE.Face3?(h=this.rayTriangle(e,m,n,p,f,this.collisionNormal,c.mesh),h<f&&(f=h,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize())):
-h instanceof THREE.Face4&&(h=this.rayTriangle(e,m,n,o,f,this.collisionNormal,c.mesh),h<f&&(f=h,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize()),h=this.rayTriangle(e,n,p,o,f,this.collisionNormal,c.mesh),h<f&&(f=h,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:g}};
-THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,g,j,h){var m=THREE.CollisionSystem.__v1,n=THREE.CollisionSystem.__v2;j.set(0,0,0);m.sub(e,c);n.sub(f,e);j.cross(m,n);m=j.dot(b.direction);if(!(m<0))if(h.doubleSided||h.flipSided)j.multiplyScalar(-1),m*=-1;else return Number.MAX_VALUE;h=j.dot(c)-j.dot(b.origin);if(!(h<=0))return Number.MAX_VALUE;if(!(h>=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<c.numFaces;j++){var h=c.mesh.geometry.faces[j],k=c.mesh.geometry.vertices[h.a].position,o=c.mesh.geometry.vertices[h.b].position,m=c.mesh.geometry.vertices[h.c].position,p=h instanceof THREE.Face4?c.mesh.geometry.vertices[h.d].position:null;h instanceof THREE.Face3?(h=this.rayTriangle(e,k,o,m,f,this.collisionNormal,c.mesh),h<f&&(f=h,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize())):
+h instanceof THREE.Face4&&(h=this.rayTriangle(e,k,o,p,f,this.collisionNormal,c.mesh),h<f&&(f=h,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize()),h=this.rayTriangle(e,o,m,p,f,this.collisionNormal,c.mesh),h<f&&(f=h,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:g}};
+THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,g,j,h){var k=THREE.CollisionSystem.__v1,o=THREE.CollisionSystem.__v2;j.set(0,0,0);k.sub(e,c);o.sub(f,e);j.cross(k,o);k=j.dot(b.direction);if(!(k<0))if(h.doubleSided||h.flipSided)j.multiplyScalar(-1),k*=-1;else return Number.MAX_VALUE;h=j.dot(c)-j.dot(b.origin);if(!(h<=0))return Number.MAX_VALUE;if(!(h>=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.x<c.min.x?(f=c.min.x-e.origin.x,f/=e.direction.x,p=!1,h=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,h=1);e.origin.y<c.min.y?(g=c.min.y-e.origin.y,g/=e.direction.y,p=!1,m=-1):e.origin.y>c.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y,
-p=!1,m=1);e.origin.z<c.min.z?(j=c.min.z-e.origin.z,j/=e.direction.z,p=!1,n=-1):e.origin.z>c.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(m<c.min.y||m>c.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*
-f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:h=e.origin.x+e.direction.x*f;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(m<c.min.y||m>c.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.x<c.min.x?(f=c.min.x-e.origin.x,f/=e.direction.x,m=!1,h=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,m=!1,h=1);e.origin.y<c.min.y?(g=c.min.y-e.origin.y,g/=e.direction.y,m=!1,k=-1):e.origin.y>c.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y,
+m=!1,k=1);e.origin.z<c.min.z?(j=c.min.z-e.origin.z,j/=e.direction.z,m=!1,o=-1):e.origin.z>c.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(k<c.min.y||k>c.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*
+f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:h=e.origin.x+e.direction.x*f;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;k=e.origin.y+e.direction.y*f;if(k<c.min.y||k>c.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<c.radiusSq)return-1;var f=e.dot(b.direction.clone());if(f<=0)return Number.MAX_VALUE;e=c.radiusSq-(e.lengthSq()-f*f);if(e>=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)}};

+ 56 - 56
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;b<c;b++)d=d.concat(this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function b(a,b,c){var d,c=c.matrixWorld.getPosition();d=c.clone().subSelf(a).dot(b);a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function c(a,b,c,d){var d=d.clone().subSelf(b),
 c=c.clone().subSelf(b),f=a.clone().subSelf(b),a=d.dot(d),b=d.dot(c),d=d.dot(f),e=c.dot(c),c=c.dot(f),f=1/(a*e-b*b),e=(e*d-b*c)*f,a=(a*c-b*d)*f;return e>0&&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;d<f;d++)if(g=p.faces[d],n=this.origin.clone(),j=this.direction.clone(),l=a.matrixWorld,e=l.multiplyVector3(q[g.a].position.clone()),h=l.multiplyVector3(q[g.b].position.clone()),k=l.multiplyVector3(q[g.c].position.clone()),l=g instanceof THREE.Face4?l.multiplyVector3(q[g.d].position.clone()):null,m=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),i=j.dot(m),a.doubleSided||(a.flipSided?i>0: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;d<f;d++)if(g=p.faces[d],n=this.origin.clone(),k=this.direction.clone(),l=a.matrixWorld,e=l.multiplyVector3(q[g.a].position.clone()),h=l.multiplyVector3(q[g.b].position.clone()),j=l.multiplyVector3(q[g.c].position.clone()),l=g instanceof THREE.Face4?l.multiplyVector3(q[g.d].position.clone()):null,m=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),i=k.dot(m),a.doubleSided||(a.flipSided?i>0: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=b<e?b:e,c=c<g?c:g,d=d>e?d:e,f=f>g?f:g);a()};this.add3Points=
-function(e,g,m,i,n,j){h?(h=!1,b=e<m?e<n?e:n:m<n?m:n,c=g<i?g<j?g:j:i<j?i:j,d=e>m?e>n?e:n:m>n?m:n,f=g>i?g>j?g:j:i>j?i:j):(b=e<m?e<n?e<b?e:b:n<b?n:b:m<n?m<b?m:b:n<b?n:b,c=g<i?g<j?g<c?g:c:j<c?j:c:i<j?i<c?i:c:j<c?j:c,d=e>m?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=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.getRight()?d:e.getRight(),f=f>
+function(e,g,m,i,n,k){h?(h=!1,b=e<m?e<n?e:n:m<n?m:n,c=g<i?g<k?g:k:i<k?i:k,d=e>m?e>n?e:n:m>n?m:n,f=g>i?g>k?g:k:i>k?i:k):(b=e<m?e<n?e<b?e:b:n<b?n:b:m<n?m<b?m:b:n<b?n:b,c=g<i?g<k?g<c?g:c:k<c?k:c:i<k?i<c?i:c:k<c?k:c,d=e>m?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=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.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<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.instersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=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;a<b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),
-c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,f,g,e,h=new THREE.Vector3,k=new THREE.Vector3;d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],e=this.vertices[g.c],h.sub(e.position,c.position),k.sub(b.position,c.position),h.crossSelf(k);h.isZero()||
+c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,f,g,e,h=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],e=this.vertices[g.c],h.sub(e.position,c.position),j.sub(b.position,c.position),h.crossSelf(j);h.isZero()||
 h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),
-c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,f,g,r){h=a.vertices[b].position;k=a.vertices[c].position;l=a.vertices[d].position;m=e[f];i=e[g];n=e[r];j=k.x-h.x;p=l.x-h.x;q=k.y-h.y;v=l.y-h.y;s=k.z-h.z;O=l.z-h.z;P=i.u-m.u;y=n.u-m.u;B=i.v-m.v;o=n.v-m.v;t=1/(P*o-y*B);Z.set((o*j-B*p)*
-t,(o*q-B*v)*t,(o*s-B*O)*t);$.set((P*p-y*j)*t,(P*v-y*q)*t,(P*O-y*s)*t);x[b].addSelf(Z);x[c].addSelf(Z);x[d].addSelf(Z);E[b].addSelf($);E[c].addSelf($);E[d].addSelf($)}var b,c,d,f,g,e,h,k,l,m,i,n,j,p,q,v,s,O,P,y,B,o,t,r,x=[],E=[],Z=new THREE.Vector3,$=new THREE.Vector3,I=new THREE.Vector3,D=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)x[b]=new THREE.Vector3,E[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],e=this.faceVertexUvs[0][b],g instanceof
+c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,f,g,r){h=a.vertices[b].position;j=a.vertices[c].position;l=a.vertices[d].position;m=e[f];i=e[g];n=e[r];k=j.x-h.x;p=l.x-h.x;q=j.y-h.y;v=l.y-h.y;s=j.z-h.z;O=l.z-h.z;P=i.u-m.u;y=n.u-m.u;B=i.v-m.v;o=n.v-m.v;t=1/(P*o-y*B);Z.set((o*k-B*p)*
+t,(o*q-B*v)*t,(o*s-B*O)*t);$.set((P*p-y*k)*t,(P*v-y*q)*t,(P*O-y*s)*t);x[b].addSelf(Z);x[c].addSelf(Z);x[d].addSelf(Z);E[b].addSelf($);E[c].addSelf($);E[d].addSelf($)}var b,c,d,f,g,e,h,j,l,m,i,n,k,p,q,v,s,O,P,y,B,o,t,r,x=[],E=[],Z=new THREE.Vector3,$=new THREE.Vector3,I=new THREE.Vector3,D=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)x[b]=new THREE.Vector3,E[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],e=this.faceVertexUvs[0][b],g instanceof
 THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var M=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)J.copy(g.vertexNormals[d]),f=g[M[d]],r=x[f],I.copy(r),I.subSelf(J.multiplyScalar(J.dot(r))).normalize(),D.cross(g.vertexNormals[d],r),f=D.dot(E[f]),f=f<0?-1:1,g.vertexTangents[d]=new THREE.Vector4(I.x,I.y,I.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){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;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}function b(a,b,c){a[b]===
@@ -105,44 +105,44 @@ b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var a=k[h]=k[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=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<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,g=[],e,h,k=[],l,m,i=[],n,j=[],p,q,v=[],s,O,P=[],y=new THREE.Vector4,B=new THREE.Vector4,
-o=new THREE.Matrix4,t=new THREE.Matrix4,r=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],x=new THREE.Vector4,E=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,e){var c=[],h,j,l;f=0;j=
-a.objects;a=0;for(h=j.length;a<h;a++){l=j[a];var i;if(!(i=!l.visible))if(i=l instanceof THREE.Mesh){a:{i=void 0;for(var k=l.matrixWorld,n=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),m=0;m<6;m++)if(i=r[m].x*k.n14+r[m].y*k.n24+r[m].z*k.n34+r[m].w,i<=n){i=!1;break a}i=!0}i=!i}if(!i)i=g[f]=g[f]||new THREE.RenderableObject,f++,d=i,y.copy(l.position),o.multiplyVector3(y),d.object=l,d.z=y.z,c.push(d)}e&&c.sort(b);return c};this.projectScene=function(d,f,g){var D=[],
+THREE.Projector=function(){function a(){var a=j[h]=j[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=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<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,g=[],e,h,j=[],l,m,i=[],n,k=[],p,q,v=[],s,O,P=[],y=new THREE.Vector4,B=new THREE.Vector4,
+o=new THREE.Matrix4,t=new THREE.Matrix4,r=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],x=new THREE.Vector4,E=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,e){var c=[],h,k,l;f=0;k=
+a.objects;a=0;for(h=k.length;a<h;a++){l=k[a];var i;if(!(i=!l.visible))if(i=l instanceof THREE.Mesh){a:{i=void 0;for(var j=l.matrixWorld,n=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),m=0;m<6;m++)if(i=r[m].x*j.n14+r[m].y*j.n24+r[m].z*j.n34+r[m].w,i<=n){i=!1;break a}i=!0}i=!i}if(!i)i=g[f]=g[f]||new THREE.RenderableObject,f++,d=i,y.copy(l.position),o.multiplyVector3(y),d.object=l,d.z=y.z,c.push(d)}e&&c.sort(b);return c};this.projectScene=function(d,f,g){var D=[],
 J=f.near,M=f.far,F,K,G,Q,w,N,L,y,C,u,A,H,S,la,V,ca,W;O=q=n=m=0;f.matrixAutoUpdate&&f.update(void 0,!0);d.update(void 0,!1,f);o.multiply(f.projectionMatrix,f.matrixWorldInverse);r[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);r[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);r[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);r[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);r[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);r[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+
 o.n33,o.n44+o.n34);for(F=0;F<6;F++)C=r[F],C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z));C=this.projectObjects(d,f,!0);d=0;for(F=C.length;d<F;d++)if(u=C[d].object,u.visible)if(A=u.matrixWorld,H=u.matrixRotationWorld,S=u.materials,la=u.overdraw,h=0,u instanceof THREE.Mesh){V=u.geometry;Q=V.vertices;ca=V.faces;V=V.faceVertexUvs;K=0;for(G=Q.length;K<G;K++)e=a(),e.positionWorld.copy(Q[K].position),A.multiplyVector3(e.positionWorld),e.positionScreen.copy(e.positionWorld),o.multiplyVector4(e.positionScreen),
-e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>J&&e.positionScreen.z<M;Q=0;for(K=ca.length;Q<K;Q++){G=ca[Q];if(G instanceof THREE.Face3)if(w=k[G.a],N=k[G.b],L=k[G.c],w.visible&&N.visible&&L.visible&&(u.doubleSided||u.flipSided!=(L.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(L.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0))y=i[m]=i[m]||new THREE.RenderableFace3,m++,l=y,l.v1.copy(w),
-l.v2.copy(N),l.v3.copy(L);else continue;else if(G instanceof THREE.Face4)if(w=k[G.a],N=k[G.b],L=k[G.c],y=k[G.d],w.visible&&N.visible&&L.visible&&y.visible&&(u.doubleSided||u.flipSided!=((y.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0||(N.positionScreen.x-L.positionScreen.x)*(y.positionScreen.y-L.positionScreen.y)-(N.positionScreen.y-L.positionScreen.y)*(y.positionScreen.x-L.positionScreen.x)<
-0)))W=j[n]=j[n]||new THREE.RenderableFace4,n++,l=W,l.v1.copy(w),l.v2.copy(N),l.v3.copy(L),l.v4.copy(y);else continue;l.normalWorld.copy(G.normal);H.multiplyVector3(l.normalWorld);l.centroidWorld.copy(G.centroid);A.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);o.multiplyVector3(l.centroidScreen);L=G.vertexNormals;w=0;for(N=L.length;w<N;w++)y=l.vertexNormalsWorld[w],y.copy(L[w]),H.multiplyVector3(y);w=0;for(N=V.length;w<N;w++)if(W=V[w][Q]){L=0;for(y=W.length;L<y;L++)l.uvs[w][L]=
-W[L]}l.meshMaterials=S;l.faceMaterials=G.materials;l.overdraw=la;l.z=l.centroidScreen.z;D.push(l)}}else if(u instanceof THREE.Line){t.multiply(o,A);Q=u.geometry.vertices;w=a();w.positionScreen.copy(Q[0].position);t.multiplyVector4(w.positionScreen);K=1;for(G=Q.length;K<G;K++)if(w=a(),w.positionScreen.copy(Q[K].position),t.multiplyVector4(w.positionScreen),N=k[h-2],x.copy(w.positionScreen),E.copy(N.positionScreen),c(x,E))x.multiplyScalar(1/x.w),E.multiplyScalar(1/E.w),A=v[q]=v[q]||new THREE.RenderableLine,
+e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>J&&e.positionScreen.z<M;Q=0;for(K=ca.length;Q<K;Q++){G=ca[Q];if(G instanceof THREE.Face3)if(w=j[G.a],N=j[G.b],L=j[G.c],w.visible&&N.visible&&L.visible&&(u.doubleSided||u.flipSided!=(L.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(L.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0))y=i[m]=i[m]||new THREE.RenderableFace3,m++,l=y,l.v1.copy(w),
+l.v2.copy(N),l.v3.copy(L);else continue;else if(G instanceof THREE.Face4)if(w=j[G.a],N=j[G.b],L=j[G.c],y=j[G.d],w.visible&&N.visible&&L.visible&&y.visible&&(u.doubleSided||u.flipSided!=((y.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0||(N.positionScreen.x-L.positionScreen.x)*(y.positionScreen.y-L.positionScreen.y)-(N.positionScreen.y-L.positionScreen.y)*(y.positionScreen.x-L.positionScreen.x)<
+0)))W=k[n]=k[n]||new THREE.RenderableFace4,n++,l=W,l.v1.copy(w),l.v2.copy(N),l.v3.copy(L),l.v4.copy(y);else continue;l.normalWorld.copy(G.normal);H.multiplyVector3(l.normalWorld);l.centroidWorld.copy(G.centroid);A.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);o.multiplyVector3(l.centroidScreen);L=G.vertexNormals;w=0;for(N=L.length;w<N;w++)y=l.vertexNormalsWorld[w],y.copy(L[w]),H.multiplyVector3(y);w=0;for(N=V.length;w<N;w++)if(W=V[w][Q]){L=0;for(y=W.length;L<y;L++)l.uvs[w][L]=
+W[L]}l.meshMaterials=S;l.faceMaterials=G.materials;l.overdraw=la;l.z=l.centroidScreen.z;D.push(l)}}else if(u instanceof THREE.Line){t.multiply(o,A);Q=u.geometry.vertices;w=a();w.positionScreen.copy(Q[0].position);t.multiplyVector4(w.positionScreen);K=1;for(G=Q.length;K<G;K++)if(w=a(),w.positionScreen.copy(Q[K].position),t.multiplyVector4(w.positionScreen),N=j[h-2],x.copy(w.positionScreen),E.copy(N.positionScreen),c(x,E))x.multiplyScalar(1/x.w),E.multiplyScalar(1/E.w),A=v[q]=v[q]||new THREE.RenderableLine,
 q++,p=A,p.v1.positionScreen.copy(x),p.v2.positionScreen.copy(E),p.z=Math.max(x.z,E.z),p.materials=u.materials,D.push(p)}else if(u instanceof THREE.Particle&&(B.set(u.matrixWorld.n14,u.matrixWorld.n24,u.matrixWorld.n34,1),o.multiplyVector4(B),B.z/=B.w,B.z>0&&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<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?(Y.r+=d.r,Y.g+=d.g,Y.b+=d.b):c instanceof THREE.DirectionalLight?(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b):c instanceof THREE.PointLight&&(ua.r+=d.r,ua.g+=d.g,ua.b+=d.b)}function m(a,b,c,d){var f,
-e,g,h,l=a.lights,a=0;for(f=l.length;a<f;a++)e=l[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(R.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function p(a,e,g){b(g.opacity);c(g.blending);var h,l,m,k,Ba,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)k=g.map.image,
-Ba=k.width>>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;xa<Ja;xa++){z=e[xa];U.empty();if(z instanceof THREE.RenderableParticle){t=z;t.x*=i;t.y*=n;ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&p(t,z,T,a)}else if(z instanceof THREE.RenderableLine){if(t=z.v1,r=z.v2,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),ja.instersects(U)){ea=0;for(ia=
-z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&q(t,r,z,T,a)}}else if(z instanceof THREE.RenderableFace3){if(t=z.v1,r=z.v2,x=z.v3,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,x.positionScreen),ha(x.positionScreen,t.positionScreen)),U.add3Points(t.positionScreen.x,t.positionScreen.y,r.positionScreen.x,r.positionScreen.y,x.positionScreen.x,
-x.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}else T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}}else if(z instanceof THREE.RenderableFace4&&(t=z.v1,r=z.v2,x=z.v3,E=z.v4,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,E.positionScreen.x*=
-i,E.positionScreen.y*=n,Z.positionScreen.copy(r.positionScreen),$.positionScreen.copy(E.positionScreen),z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,E.positionScreen),ha(E.positionScreen,t.positionScreen),ha(x.positionScreen,Z.positionScreen),ha(x.positionScreen,$.positionScreen)),U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(x.positionScreen.x,x.positionScreen.y),U.addPoint(E.positionScreen.x,E.positionScreen.y),
-ja.instersects(U))){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}else T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}X.addRectangle(U)}j.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
-THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+THREE.CanvasRenderer=function(a){function b(a){if(v!=a)k.globalAlpha=v=a}function c(a){if(s!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}s=a}}function d(a){if(O!=a)k.strokeStyle=O=a}function f(a){if(P!=a)k.fillStyle=P=a}var g=this,e=null,h=new THREE.Projector,a=a||{},j=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
+l,m,i,n,k=j.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=j;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);j.width=l;j.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(){k.setTransform(1,0,0,-1,i,n);X.isEmpty()||(X.minSelf(ja),X.inflate(2),q<1&&k.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+")"),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<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?(Y.r+=d.r,Y.g+=d.g,Y.b+=d.b):c instanceof THREE.DirectionalLight?(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b):c instanceof THREE.PointLight&&(ua.r+=d.r,ua.g+=d.g,ua.b+=d.b)}function m(a,b,c,d){var f,
+e,g,h,l=a.lights,a=0;for(f=l.length;a<f;a++)e=l[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(R.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function p(a,e,g){b(g.opacity);c(g.blending);var h,l,m,j,Ba,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)j=g.map.image,
+Ba=j.width>>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<Ja;xa++){z=e[xa];U.empty();if(z instanceof THREE.RenderableParticle){t=z;t.x*=i;t.y*=n;ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&p(t,z,T,a)}else if(z instanceof THREE.RenderableLine){if(t=z.v1,r=z.v2,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,U.addPoint(t.positionScreen.x,t.positionScreen.y),
+U.addPoint(r.positionScreen.x,r.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&q(t,r,z,T,a)}}else if(z instanceof THREE.RenderableFace3){if(t=z.v1,r=z.v2,x=z.v3,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,x.positionScreen),ha(x.positionScreen,t.positionScreen)),U.add3Points(t.positionScreen.x,
+t.positionScreen.y,r.positionScreen.x,r.positionScreen.y,x.positionScreen.x,x.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}else T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}}else if(z instanceof THREE.RenderableFace4&&(t=z.v1,r=z.v2,x=z.v3,E=z.v4,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=
+i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,E.positionScreen.x*=i,E.positionScreen.y*=n,Z.positionScreen.copy(r.positionScreen),$.positionScreen.copy(E.positionScreen),z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,E.positionScreen),ha(E.positionScreen,t.positionScreen),ha(x.positionScreen,Z.positionScreen),ha(x.positionScreen,$.positionScreen)),U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(x.positionScreen.x,
+x.positionScreen.y),U.addPoint(E.positionScreen.x,E.positionScreen.y),ja.instersects(U))){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}else T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}X.addRectangle(U)}k.setTransform(1,0,0,1,0,0)}};
+THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};

+ 1 - 1
build/custom/ThreeDOM.js

@@ -1,4 +1,4 @@
-// ThreeDOM.js r42 - http://github.com/mrdoob/three.js
+// ThreeDOM.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,e,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),e=a*6-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),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)}};

+ 5 - 5
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 a<b?b:a>c?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<n;m++){var o=new THREE.Vertex(g[m].position.clone());c&&b.matrix.multiplyVector3(o.position);h.push(o)}m=0;for(n=k.length;m<n;m++){var g=k[m],t,v,u=g.vertexNormals,o=g.vertexColors;g instanceof THREE.Face3?t=new THREE.Face3(g.a+e,g.b+e,g.c+
@@ -145,9 +145,9 @@ THREE.Shape.Utils.triangulateShape(v,o);x=v;z=0;for(B=o.length;z<B;z++)p=o[z],v=
 O[A],I),h(F.x,F.y,-E);z=0;for(B=o.length;z<B;z++){p=o[z];C=Q[z];A=0;for(D=p.length;A<D;A++)F=c(p[A],C[A],I),h(F.x,F.y,-E)}}I=l;for(A=0;A<L;A++)F=n?c(v[A],P[A],I):v[A],y?h(F.x,F.y+w[0].y,w[0].x):h(F.x,F.y,0);for(J=1;J<=t;J++)for(A=0;A<L;A++)F=n?c(v[A],P[A],I):v[A],y?h(F.x,F.y+w[J-1].y,w[J-1].x):h(F.x,F.y,j/t*J);for(J=m-1;J>=0;J--){I=J/m;E=k*(1-I);I=l*Math.sin(I*Math.PI/2);A=0;for(D=x.length;A<D;A++)F=c(x[A],O[A],I),h(F.x,F.y,j+E);z=0;for(B=o.length;z<B;z++){p=o[z];C=Q[z];A=0;for(D=p.length;A<D;A++)F=
 c(p[A],C[A],I),y?h(F.x,F.y+w[t-1].y,w[t-1].x+E):h(F.x,F.y,j+E)}}if(n){k=L*0;for(A=0;A<M;A++)j=u[A],g(j[2]+k,j[1]+k,j[0]+k);k=L*(t+m*2);for(A=0;A<M;A++)j=u[A],g(j[0]+k,j[1]+k,j[2]+k)}else{for(A=0;A<M;A++)j=u[A],g(j[2],j[1],j[0]);for(A=0;A<M;A++)j=u[A],g(j[0]+L*t,j[1]+L*t,j[2]+L*t)}var K,N,R=0;f(x);R+=x.length;z=0;for(B=o.length;z<B;z++)p=o[z],f(p),R+=p.length;this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
 THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
-THREE.IcosahedronGeometry=function(a){function b(a,b,c){var e=Math.sqrt(a*a+b*b+c*c);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function c(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function e(a,c){var e=f.vertices[a].position,g=f.vertices[c].position;return b((e.x+g.x)/2,(e.y+g.y)/2,(e.z+g.z)/2)}var f=this,h=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,
--a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var j in h.faces){var k=e(h.faces[j].a,h.faces[j].b),l=e(h.faces[j].b,h.faces[j].c),m=e(h.faces[j].c,h.faces[j].a);c(h.faces[j].a,k,m,g);c(h.faces[j].b,l,k,g);
-c(h.faces[j].c,m,l,g);c(k,l,m,g)}h.faces=g.faces}f.faces=h.faces;delete h;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
+THREE.IcosahedronGeometry=function(a){function b(a,b,c){var e=Math.sqrt(a*a+b*b+c*c);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function c(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function e(a,c){var e=f.vertices[a].position,g=f.vertices[c].position;return b((e.x+g.x)/2,(e.y+g.y)/2,(e.z+g.z)/2)}var f=this,h=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,
+-a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(var g=0;g<this.subdivisions;g++){var a=new THREE.Geometry,j;for(j in h.faces){var k=e(h.faces[j].a,h.faces[j].b),l=e(h.faces[j].b,h.faces[j].c),m=e(h.faces[j].c,h.faces[j].a);c(h.faces[j].a,k,m,a);c(h.faces[j].b,l,
+k,a);c(h.faces[j].c,m,l,a);c(k,l,m,a)}h.faces=a.faces}f.faces=h.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
 THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],e=[],f=[],h=[],g=(new THREE.Matrix4).setRotationZ(b),j=0;j<a.length;j++)this.vertices.push(new THREE.Vertex(a[j])),c[j]=a[j].clone(),e[j]=this.vertices.length-1;for(var k=0;k<=this.angle+0.001;k+=b){for(j=0;j<c.length;j++)k<this.angle?(c[j]=g.multiplyVector3(c[j].clone()),this.vertices.push(new THREE.Vertex(c[j])),f[j]=this.vertices.length-1):f=h;k==0&&(h=e);
 for(j=0;j<e.length-1;j++)this.faces.push(new THREE.Face4(f[j],f[j+1],e[j+1],e[j])),this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,j/a.length)]);e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.PlaneGeometry=function(a,b,c,e){THREE.Geometry.call(this);var f,h=a/2,g=b/2,c=c||1,e=e||1,j=c+1,k=e+1;a/=c;var l=b/e;for(f=0;f<k;f++)for(b=0;b<j;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(f*l-g),0)));for(f=0;f<e;f++)for(b=0;b<c;b++)this.faces.push(new THREE.Face4(b+j*f,b+j*(f+1),b+1+j*(f+1),b+1+j*f)),this.faceVertexUvs[0].push([new THREE.UV(b/c,f/e),new THREE.UV(b/c,(f+1)/e),new THREE.UV((b+1)/c,(f+1)/e),new THREE.UV((b+1)/c,f/e)]);this.computeCentroids();this.computeFaceNormals()};
@@ -166,7 +166,7 @@ o,t,v,u),g=h[h.length-1]){m=g.x;n=g.y;g=1;for(divisions=this.divisions;g<=divisi
 B=void 0,G=void 0,H=void 0,A=void 0,D=void 0,J=void 0,p=o[y[t]].x,z=o[y[t]].y,B=o[y[v]].x,G=o[y[v]].y,H=o[y[u]].x,A=o[y[u]].y;if(1.0E-10>(B-p)*(A-z)-(G-z)*(H-p))o=!1;else{for(x=0;x<w;x++)if(!(x==t||x==v||x==u)){var D=o[y[x]].x,J=o[y[x]].y,I=void 0,E=void 0,F=void 0,L=void 0,M=void 0,O=void 0,Q=void 0,C=void 0,P=void 0,K=void 0,N=void 0,R=void 0,I=F=M=void 0,I=H-B,E=A-G,F=p-H,L=z-A,M=B-p,O=G-z,Q=D-p,C=J-z,P=D-B,K=J-G,N=D-H,R=J-A,I=I*K-E*P,M=M*C-O*Q,F=F*R-L*N;if(I>=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<f;k++,m++)g[k]=g[m];f--;n=2*f}}if(e)return j;return h};a.Triangulate.area=b;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(a,b,c,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){var e=c/this.segmentsT*2*Math.PI,f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
-1;c<=this.segmentsT;++c){var e=(this.segmentsT+1)*b+c,f=(this.segmentsT+1)*b+c-1,h=(this.segmentsT+1)*(b-1)+c-1,g=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,f,h,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
+1;c<=this.segmentsT;++c){var e=(this.segmentsT+1)*b+c,f=(this.segmentsT+1)*b+c-1,h=(this.segmentsT+1)*(b-1)+c-1,g=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,f,h,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[g][0],a[g][1])])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
 THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
 THREE.TorusKnotGeometry=function(a,b,c,e,f,h,g){function j(a,b,c,e,g,h){b=c/e*a;c=Math.cos(b);return new THREE.Vector3(g*(2+c)*0.5*Math.cos(a),g*(2+c)*Math.sin(a)*0.5,h*g*Math.sin(b)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=e||8;this.p=f||2;this.q=h||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;e=new THREE.Vector3;h=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(b=0;b<
 this.segmentsT;++b){var k=a/this.segmentsR*2*this.p*Math.PI,g=b/this.segmentsT*2*Math.PI,f=j(k,g,this.q,this.p,this.radius,this.heightScale),k=j(k+0.01,g,this.q,this.p,this.radius,this.heightScale);c.x=k.x-f.x;c.y=k.y-f.y;c.z=k.z-f.z;e.x=k.x+f.x;e.y=k.y+f.y;e.z=k.z+f.z;h.cross(c,e);e.cross(h,c);h.normalize();e.normalize();k=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=k*e.x+g*h.x;f.y+=k*e.y+g*h.y;f.z+=k*e.z+g*h.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,

+ 1 - 1
build/custom/ThreeSVG.js

@@ -1,4 +1,4 @@
-// ThreeSVG.js r42 - http://github.com/mrdoob/three.js
+// ThreeSVG.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)}};

+ 216 - 248
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;d<e;d++)f=f.concat(this.intersectObject(b[d]));f.sort(function(b,d){return b.distance-d.distance});return f},intersectObject:function(b){function d(b,d,e){var f,e=e.matrixWorld.getPosition();f=e.clone().subSelf(b).dot(d);b=b.clone().addSelf(d.clone().multiplyScalar(f));return e.distanceTo(b)}function e(b,d,e,f){var f=f.clone().subSelf(d),
-e=e.clone().subSelf(d),h=b.clone().subSelf(d),b=f.dot(f),d=f.dot(e),f=f.dot(h),g=e.dot(e),e=e.dot(h),h=1/(b*g-d*d),g=(g*f-d*e)*h,b=(b*e-d*f)*h;return g>0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var f=d(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=d(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var h,i,g,j,
-k,q,n,r,t,o,F=b.geometry,x=F.vertices,G=[],f=0;for(h=F.faces.length;f<h;f++)if(i=F.faces[f],t=this.origin.clone(),o=this.direction.clone(),q=b.matrixWorld,g=q.multiplyVector3(x[i.a].position.clone()),j=q.multiplyVector3(x[i.b].position.clone()),k=q.multiplyVector3(x[i.c].position.clone()),q=i instanceof THREE.Face4?q.multiplyVector3(x[i.d].position.clone()):null,n=b.matrixRotationWorld.multiplyVector3(i.normal.clone()),r=o.dot(n),b.doubleSided||(b.flipSided?r>0: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=d<g?d:g,e=e<i?e:i,f=f>g?f:g,h=h>i?h:i);b()};this.add3Points=
-function(g,i,n,r,t,o){j?(j=!1,d=g<n?g<t?g:t:n<t?n:t,e=i<r?i<o?i:o:r<o?r:o,f=g>n?g>t?g:t:n>t?n:t,h=i>r?i>o?i:o:r>o?r:o):(d=g<n?g<t?g<d?g:d:t<d?t:d:n<t?n<d?n:d:t<d?t:d,e=i<r?i<o?i<e?i:e:o<e?o:e:r<o?r<e?r:e:o<e?o:e,f=g>n?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=d<g.getLeft()?d:g.getLeft(),e=e<g.getTop()?e:g.getTop(),f=f>g.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<g.getRight()?f:g.getRight();h=h<g.getBottom()?h:g.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(d,b.getLeft())>=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;c<d;c++)e=e.concat(this.intersectObject(b[c]));e.sort(function(b,c){return b.distance-c.distance});return e},intersectObject:function(b){function c(b,c,d){var e,d=d.matrixWorld.getPosition();e=d.clone().subSelf(b).dot(c);b=b.clone().addSelf(c.clone().multiplyScalar(e));return d.distanceTo(b)}function d(b,c,d,e){var e=e.clone().subSelf(c),
+d=d.clone().subSelf(c),h=b.clone().subSelf(c),b=e.dot(e),c=e.dot(d),e=e.dot(h),g=d.dot(d),d=d.dot(h),h=1/(b*g-c*c),g=(g*e-c*d)*h,b=(b*d-c*e)*h;return g>0&&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;e<h;e++)if(j=C.faces[e],r=this.origin.clone(),v=this.direction.clone(),m=b.matrixWorld,g=m.multiplyVector3(x[j.a].position.clone()),k=m.multiplyVector3(x[j.b].position.clone()),q=m.multiplyVector3(x[j.c].position.clone()),m=j instanceof THREE.Face4?m.multiplyVector3(x[j.d].position.clone()):null,o=b.matrixRotationWorld.multiplyVector3(j.normal.clone()),p=v.dot(o),b.doubleSided||(b.flipSided?p>0: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=c<g?c:g,d=d<j?d:j,e=e>g?e:g,h=h>j?h:j);b()};this.add3Points=
+function(g,j,o,p,r,v){k?(k=!1,c=g<o?g<r?g:r:o<r?o:r,d=j<p?j<v?j:v:p<v?p:v,e=g>o?g>r?g:r:o>r?o:r,h=j>p?j>v?j:v:p>v?p:v):(c=g<o?g<r?g<c?g:c:r<c?r:c:o<r?o<c?o:c:r<c?r:c,d=j<p?j<v?j<d?j:d:v<d?v:d:p<v?p<d?p:d:v<d?v:d,e=g>o?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=c<g.getLeft()?c:g.getLeft(),d=d<g.getTop()?d:g.getTop(),e=e>g.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<g.getRight()?e:g.getRight();h=h<g.getBottom()?h:g.getBottom();b()};this.instersects=function(b){return Math.min(e,b.getRight())-Math.max(c,b.getLeft())>=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<f;e++){h=this.children[e];if(h.name===b)return h;if(d&&(h=h.getChildByName(b,d),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);
-this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,d,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),
-this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,d=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,d,e)}};THREE.Quaternion=function(b,d,e,f){this.set(b||0,d||0,e||0,f!==void 0?f:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,f=b.y*d,h=b.z*d,b=Math.cos(f),f=Math.sin(f),d=Math.cos(-h),h=Math.sin(-h),i=Math.cos(e),e=Math.sin(e),g=b*d,j=f*h;this.w=g*i-j*e;this.x=g*e+j*i;this.y=f*d*i+b*h*e;this.z=b*h*i-f*d*e;return this},setFromAxisAngle:function(b,d){var e=d/2,f=Math.sin(e);
-this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=
-b,this.w*=b);return this},multiplySelf:function(b){var d=this.x,e=this.y,f=this.z,h=this.w,i=b.x,g=b.y,j=b.z,b=b.w;this.x=d*b+h*i+e*j-f*g;this.y=e*b+h*g+f*i-d*j;this.z=f*b+h*j+d*g-e*i;this.w=h*b-d*i-e*g-f*j;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,f=b.y,h=b.z,i=this.x,g=this.y,j=this.z,
-k=this.w,q=k*e+g*h-j*f,n=k*f+j*e-i*h,r=k*h+i*f-g*e,e=-i*e-g*f-j*h;d.x=q*k+e*-i+n*-j-r*-g;d.y=n*k+e*-g+r*-i-q*-j;d.z=r*k+e*-j+q*-g-n*-i;return d}};
-THREE.Quaternion.slerp=function(b,d,e,f){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.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;b<d;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),e.centroid.divideScalar(3)):e instanceof THREE.Face4&&(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),
-e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var d,e,f,h,i,g,j=new THREE.Vector3,k=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];if(b&&i.vertexNormals.length){j.set(0,0,0);d=0;for(e=i.vertexNormals.length;d<e;d++)j.addSelf(i.vertexNormals[d]);j.divideScalar(3)}else d=this.vertices[i.a],e=this.vertices[i.b],g=this.vertices[i.c],j.sub(g.position,e.position),k.sub(d.position,e.position),j.crossSelf(k);j.isZero()||
-j.normalize();i.normal.copy(j)}},computeVertexNormals:function(){var b,d,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)f[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=
-this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)f[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++)e=this.faces[b],e instanceof THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(d=this.vertices.length;b<d;b++)f[b].normalize();b=0;for(d=this.faces.length;b<d;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),
-e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,d,e,f,h,i,K){j=b.vertices[d].position;k=b.vertices[e].position;q=b.vertices[f].position;n=g[h];r=g[i];t=g[K];o=k.x-j.x;F=q.x-j.x;x=k.y-j.y;G=q.y-j.y;E=k.z-j.z;U=q.z-j.z;ta=r.u-n.u;fa=t.u-n.u;I=r.v-n.v;w=t.v-n.v;P=1/(ta*w-fa*I);ra.set((w*o-
-I*F)*P,(w*x-I*G)*P,(w*E-I*U)*P);ka.set((ta*F-fa*o)*P,(ta*G-fa*x)*P,(ta*U-fa*E)*P);M[d].addSelf(ra);M[e].addSelf(ra);M[f].addSelf(ra);Q[d].addSelf(ka);Q[e].addSelf(ka);Q[f].addSelf(ka)}var d,e,f,h,i,g,j,k,q,n,r,t,o,F,x,G,E,U,ta,fa,I,w,P,J,M=[],Q=[],ra=new THREE.Vector3,ka=new THREE.Vector3,aa=new THREE.Vector3,va=new THREE.Vector3,N=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++)M[d]=new THREE.Vector3,Q[d]=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++)i=this.faces[d],g=this.faceVertexUvs[0][d],
-i instanceof THREE.Face3?b(this,i.a,i.b,i.c,0,1,2):i instanceof THREE.Face4&&(b(this,i.a,i.b,i.c,0,1,2),b(this,i.a,i.b,i.d,0,1,3));var K=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){i=this.faces[d];for(f=0;f<i.vertexNormals.length;f++)N.copy(i.vertexNormals[f]),h=i[K[f]],J=M[h],aa.copy(J),aa.subSelf(N.multiplyScalar(N.dot(J))).normalize(),va.cross(i.vertexNormals[f],J),h=va.dot(Q[h]),h=h<0?-1:1,i.vertexTangents[f]=new THREE.Vector4(aa.x,aa.y,aa.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var b;
-if(this.vertices.length>0){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;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;
-else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,d=0,e=this.vertices.length;d<e;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,d){return Math.min(b,d)+"_"+Math.max(b,d)}function d(b,d,e){b[d]===
-void 0?(b[d]={set:{},array:[]},b[d].set[e]=1,b[d].array.push(e)):b[d].set[e]===void 0&&(b[d].set[e]=1,b[d].array.push(e))}var e,f,h,i,g,j={};e=0;for(f=this.faces.length;e<f;e++)g=this.faces[e],g instanceof THREE.Face3?(h=b(g.a,g.b),d(j,h,e),h=b(g.b,g.c),d(j,h,e),h=b(g.a,g.c),d(j,h,e)):g instanceof THREE.Face4&&(h=b(g.b,g.d),d(j,h,e),h=b(g.a,g.b),d(j,h,e),h=b(g.a,g.d),d(j,h,e),h=b(g.b,g.c),d(j,h,e),h=b(g.c,g.d),d(j,h,e));e=0;for(f=this.edges.length;e<f;e++){g=this.edges[e];h=g.vertexIndices[0];i=g.vertexIndices[1];
-g.faceIndices=j[b(h,i)].array;for(h=0;h<g.faceIndices.length;h++)i=g.faceIndices[h],g.faces.push(this.faces[i])}}};THREE.GeometryIdCounter=0;
-THREE.Spline=function(b){function d(b,d,e,f,h,g,i){b=(e-b)*0.5;f=(f-d)*0.5;return(2*(d-e)+b+f)*i+(-3*(d-e)-2*b-f)*g+b*h+d}this.points=b;var e=[],f={x:0,y:0,z:0},h,i,g,j,k,q,n,r,t;this.initFromArray=function(b){this.points=[];for(var d=0;d<b.length;d++)this.points[d]={x:b[d][0],y:b[d][1],z:b[d][2]}};this.getPoint=function(b){h=(this.points.length-1)*b;i=Math.floor(h);g=h-i;e[0]=i==0?i:i-1;e[1]=i;e[2]=i>this.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<e;b++)d=this.points[b],f[b]=[d.x,d.y,d.z];return f};this.getLength=function(b){var d,e,f=d=d=0,h=new THREE.Vector3,g=new THREE.Vector3,i=[],j=0;i[0]=0;b||(b=100);e=this.points.length*b;h.copy(this.points[0]);for(b=1;b<e;b++)d=b/e,position=this.getPoint(d),g.copy(position),
-j+=g.distanceTo(h),h.copy(position),d*=this.points.length-1,d=Math.floor(d),d!=f&&(i[d]=j,f=d);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(b){var d,e,f,h,g,i,j=[],q=new THREE.Vector3,k=this.getLength();j.push(q.copy(this.points[0]).clone());for(d=1;d<this.points.length;d++){e=k.chunks[d]-k.chunks[d-1];i=Math.ceil(b*e/k.total);h=(d-1)/(this.points.length-1);g=d/(this.points.length-1);for(e=1;e<i-1;e++)f=h+e*(1/i)*(g-h),position=this.getPoint(f),j.push(q.copy(position).clone());
-j.push(q.copy(this.points[d]).clone())}this.points=j}};THREE.Edge=function(b,d,e,f){this.vertices=[b,d];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,d,e,f,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=e||0.1;this.far=f||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
-THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);d.multiplyScalar(b);this.position.addSelf(d);this.target.position.addSelf(d)};
-THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,d=Math.tan(this.fov*Math.PI/360)*this.near,e=-d,f=b*e,b=Math.abs(b*d-f),e=Math.abs(d-e);this.projectionMatrix=THREE.Matrix4.makeFrustum(f+this.x*b/this.fullWidth,f+(this.x+this.width)*b/this.fullWidth,d-(this.y+this.height)*e/this.fullHeight,d-this.y*e/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.setViewOffset=function(b,d,e,f,h,i){this.fullWidth=b;this.fullHeight=d;this.x=e;this.y=f;this.width=h;this.height=i;this.updateProjectionMatrix()};
-THREE.Camera.prototype.update=function(b,d,e){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),d=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
-!1,d=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
-THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,d,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=d||1;this.distance=e||0};
-THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(b,d,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=d||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
-THREE.LensFlare=function(b,d,e,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,d,e,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
-THREE.LensFlare.prototype.add=function(b,d,e,f){d===void 0&&(d=-1);e===void 0&&(e=0);if(f===void 0)f=THREE.BillboardBlending;e=Math.min(e,Math.max(0,e));this.lensFlares.push({texture:b,size:d,distance:e,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:f})};
-THREE.LensFlare.prototype.updateLensFlares=function(){var b,d=this.lensFlares.length,e,f=-this.positionScreen.x*2,h=-this.positionScreen.y*2;for(b=0;b<d;b++)e=this.lensFlares[b],e.x=this.positionScreen.x+f*e.distance,e.y=this.positionScreen.y+h*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
+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 d,e,h;d=0;for(e=this.children.length;d<e;d++){h=this.children[d];if(h.name===b)return h;if(c&&(h=h.getChildByName(b,c),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);
+this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,d){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),
+this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,e=this.children.length;b<e;b++)this.children[b].update(this.matrixWorld,c,d)}};THREE.Quaternion=function(b,c,d,e){this.set(b||0,c||0,d||0,e!==void 0?e:1)};
+THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,e=b.y*c,h=b.z*c,b=Math.cos(e),e=Math.sin(e),c=Math.cos(-h),h=Math.sin(-h),j=Math.cos(d),d=Math.sin(d),g=b*c,k=e*h;this.w=g*j-k*d;this.x=g*d+k*j;this.y=e*c*j+b*h*d;this.z=b*h*j-e*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,e=Math.sin(d);
+this.x=b.x*e;this.y=b.y*e;this.z=b.z*e;this.w=Math.cos(d);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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=
+b,this.w*=b);return this},multiplySelf:function(b){var c=this.x,d=this.y,e=this.z,h=this.w,j=b.x,g=b.y,k=b.z,b=b.w;this.x=c*b+h*j+d*k-e*g;this.y=d*b+h*g+e*j-c*k;this.z=e*b+h*k+c*g-d*j;this.w=h*b-c*j-d*g-e*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,e=b.y,h=b.z,j=this.x,g=this.y,k=this.z,
+q=this.w,m=q*d+g*h-k*e,o=q*e+k*d-j*h,p=q*h+j*e-g*d,d=-j*d-g*e-k*h;c.x=m*q+d*-j+o*-k-p*-g;c.y=o*q+d*-g+p*-j-m*-k;c.z=p*q+d*-k+m*-g-o*-j;return c}};
+THREE.Quaternion.slerp=function(b,c,d,e){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=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;b<c;b++)d=this.faces[b],d.centroid.set(0,0,0),d instanceof THREE.Face3?(d.centroid.addSelf(this.vertices[d.a].position),d.centroid.addSelf(this.vertices[d.b].position),d.centroid.addSelf(this.vertices[d.c].position),d.centroid.divideScalar(3)):d instanceof THREE.Face4&&(d.centroid.addSelf(this.vertices[d.a].position),d.centroid.addSelf(this.vertices[d.b].position),d.centroid.addSelf(this.vertices[d.c].position),
+d.centroid.addSelf(this.vertices[d.d].position),d.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,d,e,h,j,g,k=new THREE.Vector3,q=new THREE.Vector3;e=0;for(h=this.faces.length;e<h;e++){j=this.faces[e];if(b&&j.vertexNormals.length){k.set(0,0,0);c=0;for(d=j.vertexNormals.length;c<d;c++)k.addSelf(j.vertexNormals[c]);k.divideScalar(3)}else c=this.vertices[j.a],d=this.vertices[j.b],g=this.vertices[j.c],k.sub(g.position,d.position),q.sub(c.position,d.position),k.crossSelf(q);k.isZero()||
+k.normalize();j.normal.copy(k)}},computeVertexNormals:function(){var b,c,d,e;if(this.__tmpVertices==void 0){e=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)e[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(d=this.faces[b],d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{e=
+this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)e[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal)):d instanceof THREE.Face4&&(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal),e[d.d].addSelf(d.normal));b=0;for(c=this.vertices.length;b<c;b++)e[b].normalize();b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(d.vertexNormals[0].copy(e[d.a]),
+d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c])):d instanceof THREE.Face4&&(d.vertexNormals[0].copy(e[d.a]),d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c]),d.vertexNormals[3].copy(e[d.d]))},computeTangents:function(){function b(b,f,c,d,e,h,j){k=b.vertices[f].position;q=b.vertices[c].position;m=b.vertices[d].position;o=g[e];p=g[h];r=g[j];v=q.x-k.x;C=m.x-k.x;x=q.y-k.y;E=m.y-k.y;J=q.z-k.z;ya=m.z-k.z;za=p.u-o.u;sa=r.u-o.u;V=p.v-o.v;u=r.v-o.v;Q=1/(za*u-sa*V);qa.set((u*v-
+V*C)*Q,(u*x-V*E)*Q,(u*J-V*ya)*Q);N.set((za*C-sa*v)*Q,(za*E-sa*x)*Q,(za*ya-sa*J)*Q);T[f].addSelf(qa);T[c].addSelf(qa);T[d].addSelf(qa);U[f].addSelf(N);U[c].addSelf(N);U[d].addSelf(N)}var c,d,e,h,j,g,k,q,m,o,p,r,v,C,x,E,J,ya,za,sa,V,u,Q,O,T=[],U=[],qa=new THREE.Vector3,N=new THREE.Vector3,L=new THREE.Vector3,f=new THREE.Vector3,ua=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++)T[c]=new THREE.Vector3,U[c]=new THREE.Vector3;c=0;for(d=this.faces.length;c<d;c++)j=this.faces[c],g=this.faceVertexUvs[0][c],
+j instanceof THREE.Face3?b(this,j.a,j.b,j.c,0,1,2):j instanceof THREE.Face4&&(b(this,j.a,j.b,j.c,0,1,2),b(this,j.a,j.b,j.d,0,1,3));var Aa=["a","b","c","d"];c=0;for(d=this.faces.length;c<d;c++){j=this.faces[c];for(e=0;e<j.vertexNormals.length;e++)ua.copy(j.vertexNormals[e]),h=j[Aa[e]],O=T[h],L.copy(O),L.subSelf(ua.multiplyScalar(ua.dot(O))).normalize(),f.cross(j.vertexNormals[e],O),h=f.dot(U[h]),h=h<0?-1:1,j.vertexTangents[e]=new THREE.Vector4(L.x,L.y,L.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var b;
+if(this.vertices.length>0){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;c<d;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;
+else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,d=this.vertices.length;c<d;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,c){return Math.min(b,c)+"_"+Math.max(b,c)}function c(b,c,d){b[c]===
+void 0?(b[c]={set:{},array:[]},b[c].set[d]=1,b[c].array.push(d)):b[c].set[d]===void 0&&(b[c].set[d]=1,b[c].array.push(d))}var d,e,h,j,g,k={};d=0;for(e=this.faces.length;d<e;d++)g=this.faces[d],g instanceof THREE.Face3?(h=b(g.a,g.b),c(k,h,d),h=b(g.b,g.c),c(k,h,d),h=b(g.a,g.c),c(k,h,d)):g instanceof THREE.Face4&&(h=b(g.b,g.d),c(k,h,d),h=b(g.a,g.b),c(k,h,d),h=b(g.a,g.d),c(k,h,d),h=b(g.b,g.c),c(k,h,d),h=b(g.c,g.d),c(k,h,d));d=0;for(e=this.edges.length;d<e;d++){g=this.edges[d];h=g.vertexIndices[0];j=g.vertexIndices[1];
+g.faceIndices=k[b(h,j)].array;for(h=0;h<g.faceIndices.length;h++)j=g.faceIndices[h],g.faces.push(this.faces[j])}}};THREE.GeometryIdCounter=0;
+THREE.Spline=function(b){function c(b,c,d,e,h,g,j){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*j+(-3*(c-d)-2*b-e)*g+b*h+c}this.points=b;var d=[],e={x:0,y:0,z:0},h,j,g,k,q,m,o,p,r;this.initFromArray=function(b){this.points=[];for(var c=0;c<b.length;c++)this.points[c]={x:b[c][0],y:b[c][1],z:b[c][2]}};this.getPoint=function(b){h=(this.points.length-1)*b;j=Math.floor(h);g=h-j;d[0]=j==0?j:j-1;d[1]=j;d[2]=j>this.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;b<d;b++)c=this.points[b],e[b]=[c.x,c.y,c.z];return e};this.getLength=function(b){var c,d,e=c=c=0,h=new THREE.Vector3,g=new THREE.Vector3,j=[],k=0;j[0]=0;b||(b=100);d=this.points.length*b;h.copy(this.points[0]);for(b=1;b<d;b++)c=b/d,position=this.getPoint(c),g.copy(position),
+k+=g.distanceTo(h),h.copy(position),c*=this.points.length-1,c=Math.floor(c),c!=e&&(j[c]=k,e=c);j[j.length]=k;return{chunks:j,total:k}};this.reparametrizeByArcLength=function(b){var c,d,e,h,g,j,k=[],m=new THREE.Vector3,q=this.getLength();k.push(m.copy(this.points[0]).clone());for(c=1;c<this.points.length;c++){d=q.chunks[c]-q.chunks[c-1];j=Math.ceil(b*d/q.total);h=(c-1)/(this.points.length-1);g=c/(this.points.length-1);for(d=1;d<j-1;d++)e=h+d*(1/j)*(g-h),position=this.getPoint(e),k.push(m.copy(position).clone());
+k.push(m.copy(this.points[c]).clone())}this.points=k}};THREE.Edge=function(b,c,d,e){this.vertices=[b,c];this.vertexIndices=[d,e];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,d,e,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=d||0.1;this.far=e||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
+THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);c.multiplyScalar(b);this.position.addSelf(c);this.target.position.addSelf(c)};
+THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,d=-c,e=b*d,b=Math.abs(b*c-e),d=Math.abs(c-d);this.projectionMatrix=THREE.Matrix4.makeFrustum(e+this.x*b/this.fullWidth,e+(this.x+this.width)*b/this.fullWidth,c-(this.y+this.height)*d/this.fullHeight,c-this.y*d/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.setViewOffset=function(b,c,d,e,h,j){this.fullWidth=b;this.fullHeight=c;this.x=d;this.y=e;this.width=h;this.height=j;this.updateProjectionMatrix()};
+THREE.Camera.prototype.update=function(b,c,d){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),c=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
+!1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
+THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=d||0;this.castShadow=e!==void 0?e:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,d){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=d||0};
+THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(b,c,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=c||1;this.distance=d||0;this.castShadow=e!==void 0?e:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
 THREE.Material=function(b){this.id=THREE.MaterialCount++;b=b||{};this.opacity=b.opacity!==void 0?b.opacity:1;this.transparent=b.transparent!==void 0?b.transparent:!1;this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==void 0?b.depthTest:!0;this.polygonOffset=b.polygonOffset!==void 0?b.polygonOffset:!1;this.polygonOffsetFactor=b.polygonOffsetFactor!==void 0?b.polygonOffsetFactor:0;this.polygonOffsetUnits=b.polygonOffsetUnits!==void 0?b.polygonOffsetUnits:
 0;this.alphaTest=b.alphaTest!==void 0?b.alphaTest:0};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.LineBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.linewidth=b.linewidth!==void 0?b.linewidth:1;this.linecap=b.linecap!==void 0?b.linecap:"round";this.linejoin=b.linejoin!==void 0?b.linejoin:"round";this.vertexColors=b.vertexColors?b.vertexColors:!1};
@@ -101,55 +98,44 @@ THREE.MeshNormalMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.sh
 THREE.MeshShaderMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.fragmentShader=b.fragmentShader!==void 0?b.fragmentShader:"void main() {}";this.vertexShader=b.vertexShader!==void 0?b.vertexShader:"void main() {}";this.uniforms=b.uniforms!==void 0?b.uniforms:{};this.attributes=b.attributes;this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.fog=
 b.fog!==void 0?b.fog:!1;this.lights=b.lights!==void 0?b.lights:!1;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};THREE.MeshShaderMaterial.prototype=new THREE.Material;THREE.MeshShaderMaterial.prototype.constructor=THREE.MeshShaderMaterial;
 THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.size=b.size!==void 0?b.size:1;this.sizeAttenuation=b.sizeAttenuation!==void 0?b.sizeAttenuation:!0;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
-THREE.ShadowVolumeDynamicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
-void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
-THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
-THREE.Texture=function(b,d,e,f,h,i){this.id=THREE.TextureCount++;this.image=b;this.mapping=d!==void 0?d:new THREE.UVMapping;this.wrapS=e!==void 0?e:THREE.ClampToEdgeWrapping;this.wrapT=f!==void 0?f:THREE.ClampToEdgeWrapping;this.magFilter=h!==void 0?h:THREE.LinearFilter;this.minFilter=i!==void 0?i:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
+THREE.Texture=function(b,c,d,e,h,j){this.id=THREE.TextureCount++;this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=d!==void 0?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==void 0?e:THREE.ClampToEdgeWrapping;this.magFilter=h!==void 0?h:THREE.LinearFilter;this.minFilter=j!==void 0?j:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
 THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var b=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;
 THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b]};THREE.Particle.prototype=new THREE.Object3D;
-THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,d,e){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d];this.type=e!=void 0?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
+THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,c,d){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=d!=void 0?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
 THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
-THREE.Mesh=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d&&d.length?d:[d];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=b.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var e=0;e<this.geometry.morphTargets.length;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=
-e}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(b){if(this.morphTargetDictionary[b]!==void 0)return this.morphTargetDictionary[b];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+b+" does not exist. Returning 0.");return 0};
+THREE.Mesh=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c&&c.length?c:[c];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=b.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var d=0;d<this.geometry.morphTargets.length;d++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[d].name]=
+d}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(b){if(this.morphTargetDictionary[b]!==void 0)return this.morphTargetDictionary[b];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+b+" does not exist. Returning 0.");return 0};
 THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
-THREE.Bone.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;var f,h=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<h;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.skinMatrix,d,e):b.update(this.matrixWorld,!0,e)}else for(f=0;f<h;f++)this.children[f].update(this.skinMatrix,
-d,e)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
-THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,h,i,g,j;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)h=this.geometry.bones[e],i=h.pos,g=h.rotq,j=h.scl,f=this.addBone(),f.name=h.name,f.position.set(i[0],i[1],i[2]),f.quaternion.set(g[0],g[1],g[2],g[3]),f.useQuaternion=!0,j!==void 0?f.scale.set(j[0],j[1],j[2]):f.scale.set(1,1,1);for(e=0;e<this.bones.length;e++)h=this.geometry.bones[e],
-f=this.bones[e],h.parent===-1?this.addChild(f):this.bones[h.parent].addChild(f);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.update=function(b,d,e){if(this.visible){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;var f,h=this.children.length;for(f=0;f<h;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,d,e);e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(d=0;d<e;d++)ba[d].skinMatrix.flattenToArrayOffset(bm,
-d*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
-THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,d=[],e=0;e<this.bones.length;e++)b=this.bones[e],d.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var f;for(b=0;b<this.geometry.skinIndices.length;b++){var e=this.geometry.vertices[b].position,h=this.geometry.skinIndices[b].x,i=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
-e.y,e.z);this.geometry.skinVerticesA.push(d[h].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(d[i].multiplyVector3(f));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=e,this.geometry.skinWeights[b].y+=e)}}};THREE.Ribbon=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d]};
-THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(b,d){d===void 0&&(d=0);for(var d=Math.abs(d),e=0;e<this.LODs.length;e++)if(d<this.LODs[e].visibleAtDistance)break;this.LODs.splice(e,0,{visibleAtDistance:d,object3D:b});this.addChild(b)};
-THREE.LOD.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;if(this.LODs.length>1){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.length;f++)if(b>=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1,
-this.LODs[f].object3D.visible=!0;else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.ShadowVolume=function(b,d){b instanceof THREE.Mesh?(THREE.Mesh.call(this,b.geometry,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]),b.addChild(this)):THREE.Mesh.call(this,b,d?[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;
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,e,f,h,i,g,j,k,q,n,r,t,o,F=new THREE.Geometry;F.vertices=this.geometry.vertices;f=F.faces=this.geometry.faces;var x=F.egdes=this.geometry.edges,G=F.edgeFaces=[];h=0;var E=[];b=0;for(d=f.length;b<d;b++)if(e=f[b],E.push(h),h+=e instanceof THREE.Face3?3:4,e.vertexNormals[0]=e.normal,e.vertexNormals[1]=e.normal,e.vertexNormals[2]=e.normal,e instanceof THREE.Face4)e.vertexNormals[3]=
-e.normal;b=0;for(d=x.length;b<d;b++)j=x[b],e=j.faces[0],f=j.faces[1],h=j.faceIndices[0],i=j.faceIndices[1],g=j.vertexIndices[0],j=j.vertexIndices[1],e.a===g?(k="a",n=E[h]+0):e.b===g?(k="b",n=E[h]+1):e.c===g?(k="c",n=E[h]+2):e.d===g&&(k="d",n=E[h]+3),e.a===j?(k+="a",r=E[h]+0):e.b===j?(k+="b",r=E[h]+1):e.c===j?(k+="c",r=E[h]+2):e.d===j&&(k+="d",r=E[h]+3),f.a===g?(q="a",t=E[i]+0):f.b===g?(q="b",t=E[i]+1):f.c===g?(q="c",t=E[i]+2):f.d===g&&(q="d",t=E[i]+3),f.a===j?(q+="a",o=E[i]+0):f.b===j?(q+="b",o=E[i]+
-1):f.c===j?(q+="c",o=E[i]+2):f.d===j&&(q+="d",o=E[i]+3),k==="ac"||k==="ad"||k==="ca"||k==="da"?n>r&&(e=n,n=r,r=e):n<r&&(e=n,n=r,r=e),q==="ac"||q==="ad"||q==="ca"||q==="da"?t>o&&(e=t,t=o,o=e):t<o&&(e=t,t=o,o=e),e=new THREE.Face4(n,r,t,o),e.normal.set(1,0,0),G.push(e);this.geometry=F}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,f=this.geometry.edgeFaces,h=b.faces,b=b.vertices,i=h.length,g,j,k,q,n,r=["a","b","c","d"];for(k=0;k<i;k++){j=d.length;g=h[k];g instanceof THREE.Face4?(q=4,j=new THREE.Face4(j,j+1,j+2,j+3)):(q=3,j=new THREE.Face3(j,j+1,j+2));j.normal.copy(g.normal);e.push(j);
-for(j=0;j<q;j++)n=b[g[r[j]]],d.push(new THREE.Vertex(n.position.clone()))}for(i=0;i<h.length-1;i++){b=e[i];for(g=i+1;g<h.length;g++)j=e[g],j=this.facesShareEdge(d,b,j),j!==void 0&&(j=new THREE.Face4(j.indices[0],j.indices[3],j.indices[2],j.indices[1]),j.normal.set(1,0,0),f.push(j))}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var f,h,i,g,j,k,q,n,r,t,o,F,x,G=0,E=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;h=e instanceof THREE.Face4?4:3;for(F=0;F<f;F++){i=d[E[F]];j=b[i];for(x=0;x<h;x++)if(g=e[E[x]],k=b[g],Math.abs(j.position.x-k.position.x)<1.0E-4&&Math.abs(j.position.y-k.position.y)<1.0E-4&&Math.abs(j.position.z-k.position.z)<1.0E-4&&(G++,G===1&&(q=j,n=k,r=i,t=g,o=E[F]),G===2))return o+=E[F],o==="ad"||o==="ac"?{faces:[d,e],vertices:[q,n,k,j],indices:[r,t,
-g,i],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[q,j,k,n],indices:[r,i,g,t],vertexTypes:[1,1,2,2],extrudable:!0}}};
+THREE.Bone.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,h=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<h;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.skinMatrix,c,d):b.update(this.matrixWorld,!0,d)}else for(e=0;e<h;e++)this.children[e].update(this.skinMatrix,
+c,d)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
+THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,h,j,g,k;if(this.geometry.bones!==void 0){for(d=0;d<this.geometry.bones.length;d++)h=this.geometry.bones[d],j=h.pos,g=h.rotq,k=h.scl,e=this.addBone(),e.name=h.name,e.position.set(j[0],j[1],j[2]),e.quaternion.set(g[0],g[1],g[2],g[3]),e.useQuaternion=!0,k!==void 0?e.scale.set(k[0],k[1],k[2]):e.scale.set(1,1,1);for(d=0;d<this.bones.length;d++)h=this.geometry.bones[d],
+e=this.bones[d],h.parent===-1?this.addChild(e):this.bones[h.parent].addChild(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
+THREE.SkinnedMesh.prototype.update=function(b,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,h=this.children.length;for(e=0;e<h;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,d):b.update(this.matrixWorld,c,d);d=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<d;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
+c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
+THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],d=0;d<this.bones.length;d++)b=this.bones[d],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,d*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(b=0;b<this.geometry.skinIndices.length;b++){var d=this.geometry.vertices[b].position,h=this.geometry.skinIndices[b].x,j=this.geometry.skinIndices[b].y;e=new THREE.Vector3(d.x,
+d.y,d.z);this.geometry.skinVerticesA.push(c[h].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(c[j].multiplyVector3(e));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(d=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=d,this.geometry.skinWeights[b].y+=d)}}};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};
+THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),d=0;d<this.LODs.length;d++)if(c<this.LODs[d].visibleAtDistance)break;this.LODs.splice(d,0,{visibleAtDistance:c,object3D:b});this.addChild(b)};
+THREE.LOD.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){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.length;e++)if(b>=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1,
+this.LODs[e].object3D.visible=!0;else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};
 THREE.Sprite=function(b){THREE.Object3D.call(this);if(b.material!==void 0)this.material=b.material,this.map=void 0,this.blending=material.blending;else if(b.map!==void 0)this.map=b.map instanceof THREE.Texture?b.map:THREE.ImageUtils.loadTexture(b.map),this.material=void 0,this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.useScreenCoordinates=b.useScreenCoordinates!==void 0?b.useScreenCoordinates:!0;this.mergeWith3D=b.mergeWith3D!==void 0?b.mergeWith3D:!this.useScreenCoordinates;
 this.affectedByDistance=b.affectedByDistance!==void 0?b.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=b.scaleByViewport!==void 0?b.scaleByViewport:!this.affectedByDistance;this.alignment=b.alignment instanceof THREE.Vector2?b.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;
 THREE.Sprite.prototype.supr=THREE.Object3D.prototype;THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);
 THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
 THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.overrideMaterial=this.fog=null;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};
-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 d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};
-THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else b instanceof THREE.Camera||(d=this.objects.indexOf(b),d!==-1&&(this.objects.splice(d,1),this.__objectsRemoved.push(b)));for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;
-THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,e){this.color=new THREE.Color(b);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==void 0?d:2.5E-4};
-THREE.Projector=function(){function b(){var b=k[j]=k[j]||new THREE.RenderableVertex;j++;return b}function d(b,d){return d.z-b.z}function e(b,d){var e=0,f=1,h=b.z+b.w,g=d.z+d.w,c=-b.z+b.w,i=-d.z+d.w;return h>=0&&g>=0&&c>=0&&i>=0?!0:h<0&&g<0||c<0&&i<0?!1:(h<0?e=Math.max(e,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),c<0?e=Math.max(e,c/(c-i)):i<0&&(f=Math.min(f,c/(c-i))),f<e?!1:(b.lerpSelf(d,e),d.lerpSelf(b,1-f),!0))}var f,h,i=[],g,j,k=[],q,n,r=[],t,o=[],F,x,G=[],E,U,ta=[],fa=new THREE.Vector4,I=new THREE.Vector4,
-w=new THREE.Matrix4,P=new THREE.Matrix4,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,Q=new THREE.Vector4;this.projectVector=function(b,d){w.multiply(d.projectionMatrix,d.matrixWorldInverse);w.multiplyVector3(b);return b};this.unprojectVector=function(b,d){w.multiply(d.matrixWorld,THREE.Matrix4.makeInvert(d.projectionMatrix));w.multiplyVector3(b);return b};this.projectObjects=function(b,e,g){var e=[],j,q,k;h=0;q=
-b.objects;b=0;for(j=q.length;b<j;b++){k=q[b];var c;if(!(c=!k.visible))if(c=k instanceof THREE.Mesh){a:{c=void 0;for(var n=k.matrixWorld,r=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),t=0;t<6;t++)if(c=J[t].x*n.n14+J[t].y*n.n24+J[t].z*n.n34+J[t].w,c<=r){c=!1;break a}c=!0}c=!c}if(!c)c=i[h]=i[h]||new THREE.RenderableObject,h++,f=c,fa.copy(k.position),w.multiplyVector3(fa),f.object=k,f.z=fa.z,e.push(f)}g&&e.sort(d);return e};this.projectScene=function(f,h,i){var fa=
-[],N=h.near,K=h.far,c,ha,R,pa,L,ca,O,da,T,S,ua,Ga,Ha,Ia,la,qa,ma;U=x=t=n=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);w.multiply(h.projectionMatrix,h.matrixWorldInverse);J[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);J[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);J[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);J[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);J[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-w.n33,w.n44-w.n34);J[5].set(w.n41+w.n31,w.n42+
-w.n32,w.n43+w.n33,w.n44+w.n34);for(c=0;c<6;c++)T=J[c],T.divideScalar(Math.sqrt(T.x*T.x+T.y*T.y+T.z*T.z));T=this.projectObjects(f,h,!0);f=0;for(c=T.length;f<c;f++)if(S=T[f].object,S.visible)if(ua=S.matrixWorld,Ga=S.matrixRotationWorld,Ha=S.materials,Ia=S.overdraw,j=0,S instanceof THREE.Mesh){la=S.geometry;pa=la.vertices;qa=la.faces;la=la.faceVertexUvs;ha=0;for(R=pa.length;ha<R;ha++)g=b(),g.positionWorld.copy(pa[ha].position),ua.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),
-w.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>N&&g.positionScreen.z<K;pa=0;for(ha=qa.length;pa<ha;pa++){R=qa[pa];if(R instanceof THREE.Face3)if(L=k[R.a],ca=k[R.b],O=k[R.c],L.visible&&ca.visible&&O.visible&&(S.doubleSided||S.flipSided!=(O.positionScreen.x-L.positionScreen.x)*(ca.positionScreen.y-L.positionScreen.y)-(O.positionScreen.y-L.positionScreen.y)*(ca.positionScreen.x-L.positionScreen.x)<0))da=r[n]=
-r[n]||new THREE.RenderableFace3,n++,q=da,q.v1.copy(L),q.v2.copy(ca),q.v3.copy(O);else continue;else if(R instanceof THREE.Face4)if(L=k[R.a],ca=k[R.b],O=k[R.c],da=k[R.d],L.visible&&ca.visible&&O.visible&&da.visible&&(S.doubleSided||S.flipSided!=((da.positionScreen.x-L.positionScreen.x)*(ca.positionScreen.y-L.positionScreen.y)-(da.positionScreen.y-L.positionScreen.y)*(ca.positionScreen.x-L.positionScreen.x)<0||(ca.positionScreen.x-O.positionScreen.x)*(da.positionScreen.y-O.positionScreen.y)-(ca.positionScreen.y-
-O.positionScreen.y)*(da.positionScreen.x-O.positionScreen.x)<0)))ma=o[t]=o[t]||new THREE.RenderableFace4,t++,q=ma,q.v1.copy(L),q.v2.copy(ca),q.v3.copy(O),q.v4.copy(da);else continue;q.normalWorld.copy(R.normal);Ga.multiplyVector3(q.normalWorld);q.centroidWorld.copy(R.centroid);ua.multiplyVector3(q.centroidWorld);q.centroidScreen.copy(q.centroidWorld);w.multiplyVector3(q.centroidScreen);O=R.vertexNormals;L=0;for(ca=O.length;L<ca;L++)da=q.vertexNormalsWorld[L],da.copy(O[L]),Ga.multiplyVector3(da);L=
-0;for(ca=la.length;L<ca;L++)if(ma=la[L][pa]){O=0;for(da=ma.length;O<da;O++)q.uvs[L][O]=ma[O]}q.meshMaterials=Ha;q.faceMaterials=R.materials;q.overdraw=Ia;q.z=q.centroidScreen.z;fa.push(q)}}else if(S instanceof THREE.Line){P.multiply(w,ua);pa=S.geometry.vertices;L=b();L.positionScreen.copy(pa[0].position);P.multiplyVector4(L.positionScreen);ha=1;for(R=pa.length;ha<R;ha++)if(L=b(),L.positionScreen.copy(pa[ha].position),P.multiplyVector4(L.positionScreen),ca=k[j-2],M.copy(L.positionScreen),Q.copy(ca.positionScreen),
-e(M,Q))M.multiplyScalar(1/M.w),Q.multiplyScalar(1/Q.w),ua=G[x]=G[x]||new THREE.RenderableLine,x++,F=ua,F.v1.positionScreen.copy(M),F.v2.positionScreen.copy(Q),F.z=Math.max(M.z,Q.z),F.materials=S.materials,fa.push(F)}else if(S instanceof THREE.Particle&&(I.set(S.matrixWorld.n14,S.matrixWorld.n24,S.matrixWorld.n34,1),w.multiplyVector4(I),I.z/=I.w,I.z>0&&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<b.children.length;c++)this.addChildRecurse(b.children[c])};THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};
+THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var c=this.lights.indexOf(b);c!==-1&&this.lights.splice(c,1)}else b instanceof THREE.Camera||(c=this.objects.indexOf(b),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(b)));for(c=0;c<b.children.length;c++)this.removeChildRecurse(b.children[c])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;
+THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,c,d){this.color=new THREE.Color(b);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
+THREE.Projector=function(){function b(){var b=q[k]=q[k]||new THREE.RenderableVertex;k++;return b}function c(b,c){return c.z-b.z}function d(b,c){var d=0,f=1,e=b.z+b.w,h=c.z+c.w,g=-b.z+b.w,j=-c.z+c.w;return e>=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))),f<d?!1:(b.lerpSelf(c,d),c.lerpSelf(b,1-f),!0))}var e,h,j=[],g,k,q=[],m,o,p=[],r,v=[],C,x,E=[],J,ya,za=[],sa=new THREE.Vector4,V=new THREE.Vector4,
+u=new THREE.Matrix4,Q=new THREE.Matrix4,O=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],T=new THREE.Vector4,U=new THREE.Vector4;this.projectVector=function(b,c){u.multiply(c.projectionMatrix,c.matrixWorldInverse);u.multiplyVector3(b);return b};this.unprojectVector=function(b,c){u.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));u.multiplyVector3(b);return b};this.projectObjects=function(b,d,g){var d=[],f,k,m;h=0;k=
+b.objects;b=0;for(f=k.length;b<f;b++){m=k[b];var q;if(!(q=!m.visible))if(q=m instanceof THREE.Mesh){a:{q=void 0;for(var o=m.matrixWorld,p=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),r=0;r<6;r++)if(q=O[r].x*o.n14+O[r].y*o.n24+O[r].z*o.n34+O[r].w,q<=p){q=!1;break a}q=!0}q=!q}if(!q)q=j[h]=j[h]||new THREE.RenderableObject,h++,e=q,sa.copy(m.position),u.multiplyVector3(sa),e.object=m,e.z=sa.z,d.push(e)}g&&d.sort(c);return d};this.projectScene=function(e,h,j){var f=
+[],sa=h.near,Aa=h.far,ta,va,Y,pa,D,W,P,S,fa,K,Ba,Ea,wa,ha,Z,Fa,Da;ya=x=r=o=0;h.matrixAutoUpdate&&h.update(void 0,!0);e.update(void 0,!1,h);u.multiply(h.projectionMatrix,h.matrixWorldInverse);O[0].set(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);O[1].set(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);O[2].set(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);O[3].set(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);O[4].set(u.n41-u.n31,u.n42-u.n32,u.n43-u.n33,u.n44-u.n34);O[5].set(u.n41+u.n31,
+u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);for(ta=0;ta<6;ta++)fa=O[ta],fa.divideScalar(Math.sqrt(fa.x*fa.x+fa.y*fa.y+fa.z*fa.z));fa=this.projectObjects(e,h,!0);e=0;for(ta=fa.length;e<ta;e++)if(K=fa[e].object,K.visible)if(Ba=K.matrixWorld,Ea=K.matrixRotationWorld,wa=K.materials,ha=K.overdraw,k=0,K instanceof THREE.Mesh){Z=K.geometry;pa=Z.vertices;Fa=Z.faces;Z=Z.faceVertexUvs;va=0;for(Y=pa.length;va<Y;va++)g=b(),g.positionWorld.copy(pa[va].position),Ba.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),
+u.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>sa&&g.positionScreen.z<Aa;pa=0;for(va=Fa.length;pa<va;pa++){Y=Fa[pa];if(Y instanceof THREE.Face3)if(D=q[Y.a],W=q[Y.b],P=q[Y.c],D.visible&&W.visible&&P.visible&&(K.doubleSided||K.flipSided!=(P.positionScreen.x-D.positionScreen.x)*(W.positionScreen.y-D.positionScreen.y)-(P.positionScreen.y-D.positionScreen.y)*(W.positionScreen.x-D.positionScreen.x)<0))S=p[o]=
+p[o]||new THREE.RenderableFace3,o++,m=S,m.v1.copy(D),m.v2.copy(W),m.v3.copy(P);else continue;else if(Y instanceof THREE.Face4)if(D=q[Y.a],W=q[Y.b],P=q[Y.c],S=q[Y.d],D.visible&&W.visible&&P.visible&&S.visible&&(K.doubleSided||K.flipSided!=((S.positionScreen.x-D.positionScreen.x)*(W.positionScreen.y-D.positionScreen.y)-(S.positionScreen.y-D.positionScreen.y)*(W.positionScreen.x-D.positionScreen.x)<0||(W.positionScreen.x-P.positionScreen.x)*(S.positionScreen.y-P.positionScreen.y)-(W.positionScreen.y-
+P.positionScreen.y)*(S.positionScreen.x-P.positionScreen.x)<0)))Da=v[r]=v[r]||new THREE.RenderableFace4,r++,m=Da,m.v1.copy(D),m.v2.copy(W),m.v3.copy(P),m.v4.copy(S);else continue;m.normalWorld.copy(Y.normal);Ea.multiplyVector3(m.normalWorld);m.centroidWorld.copy(Y.centroid);Ba.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);u.multiplyVector3(m.centroidScreen);P=Y.vertexNormals;D=0;for(W=P.length;D<W;D++)S=m.vertexNormalsWorld[D],S.copy(P[D]),Ea.multiplyVector3(S);D=0;for(W=
+Z.length;D<W;D++)if(Da=Z[D][pa]){P=0;for(S=Da.length;P<S;P++)m.uvs[D][P]=Da[P]}m.meshMaterials=wa;m.faceMaterials=Y.materials;m.overdraw=ha;m.z=m.centroidScreen.z;f.push(m)}}else if(K instanceof THREE.Line){Q.multiply(u,Ba);pa=K.geometry.vertices;D=b();D.positionScreen.copy(pa[0].position);Q.multiplyVector4(D.positionScreen);va=1;for(Y=pa.length;va<Y;va++)if(D=b(),D.positionScreen.copy(pa[va].position),Q.multiplyVector4(D.positionScreen),W=q[k-2],T.copy(D.positionScreen),U.copy(W.positionScreen),
+d(T,U))T.multiplyScalar(1/T.w),U.multiplyScalar(1/U.w),Ba=E[x]=E[x]||new THREE.RenderableLine,x++,C=Ba,C.v1.positionScreen.copy(T),C.v2.positionScreen.copy(U),C.z=Math.max(T.z,U.z),C.materials=K.materials,f.push(C)}else if(K instanceof THREE.Particle&&(V.set(K.matrixWorld.n14,K.matrixWorld.n24,K.matrixWorld.n34,1),u.multiplyVector4(V),V.z/=V.w,V.z>0&&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<b.length;d++)for(e in f=this.clone(b[d]),f)h[e]=f[e];return h},clone:function(b){var d,e,f,h={};for(d in b)for(e in h[d]={},b[d])f=b[d][e],h[d][e]=f instanceof THREE.Color||f instanceof THREE.Vector2||f instanceof THREE.Vector3||f instanceof THREE.Vector4||f instanceof THREE.Matrix4||f instanceof THREE.Texture?f.clone():f instanceof Array?f.slice():f;return h}};
+THREE.UniformsUtils={merge:function(b){var c,d,e,h={};for(c=0;c<b.length;c++)for(d in e=this.clone(b[c]),e)h[d]=e[d];return h},clone:function(b){var c,d,e,h={};for(c in b)for(d in h[c]={},b[c])e=b[c][d],h[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix4||e instanceof THREE.Texture?e.clone():e instanceof Array?e.slice():e;return h}};
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",
 value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",
 value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:3,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
@@ -185,130 +171,112 @@ THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderCh
 "void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},depthRGBA:{uniforms:{},fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}",vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,
 "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(b,d,e){var f,h,g,i=b.vertices,j=i.length,H=b.colors,D=H.length,p=b.__vertexArray,k=b.__colorArray,C=b.__sortArray,q=b.__dirtyVertices,n=b.__dirtyColors,r=b.__webglCustomAttributes,t,o;if(r)for(t in r)r[t].offset=0;if(e.sortParticles){wa.multiplySelf(e.matrixWorld);for(f=0;f<j;f++)h=i[f].position,Ja.copy(h),wa.multiplyVector3(Ja),C[f]=[Ja.z,f];C.sort(function(b,c){return c[0]-b[0]});for(f=0;f<j;f++)h=i[C[f][1]].position,g=f*3,p[g]=h.x,p[g+1]=h.y,p[g+2]=h.z;
-for(f=0;f<D;f++)g=f*3,color=H[C[f][1]],k[g]=color.r,k[g+1]=color.g,k[g+2]=color.b;if(r)for(t in r){f=r[t];H=f.value.length;for(g=0;g<H;g++){index=C[g][1];D=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[D]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")o=f.value[index];f.size===2?(f.array[D]=o.x,f.array[D+1]=o.y):f.size===3?f.type==="c"?(f.array[D]=o.r,f.array[D+1]=o.g,f.array[D+2]=o.b):(f.array[D]=o.x,f.array[D+1]=o.y,f.array[D+2]=o.z):(f.array[D]=
-o.x,f.array[D+1]=o.y,f.array[D+2]=o.z,f.array[D+3]=o.w)}f.offset+=f.size}}}else{if(q)for(f=0;f<j;f++)h=i[f].position,g=f*3,p[g]=h.x,p[g+1]=h.y,p[g+2]=h.z;if(n)for(f=0;f<D;f++)color=H[f],g=f*3,k[g]=color.r,k[g+1]=color.g,k[g+2]=color.b;if(r)for(t in r)if(f=r[t],f.__original.needsUpdate){H=f.value.length;for(g=0;g<H;g++){D=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[D]=f.value[g]}else{if(f.boundTo===void 0||f.boundTo==="vertices")o=f.value[g];f.size===2?(f.array[D]=
-o.x,f.array[D+1]=o.y):f.size===3?f.type==="c"?(f.array[D]=o.r,f.array[D+1]=o.g,f.array[D+2]=o.b):(f.array[D]=o.x,f.array[D+1]=o.y,f.array[D+2]=o.z):(f.array[D]=o.x,f.array[D+1]=o.y,f.array[D+2]=o.z,f.array[D+3]=o.w)}f.offset+=f.size}}}if(q||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,p,d);if(n||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,k,d);if(r)for(t in r)if(f=r[t],f.__original.needsUpdate||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,
-f.buffer),c.bufferData(c.ARRAY_BUFFER,f.array,d)}function e(b,d,e,f,h){f.program||K.initMaterial(f,d,e,h);if(f.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(K.maxMorphTargets);for(var g=0,i=K.maxMorphTargets;g<i;g++)h.__webglMorphTargetInfluences[g]=0}var g=f.program,i=g.uniforms,j=f.uniforms;g!=R&&(c.useProgram(g),R=g);c.uniformMatrix4fv(i.projectionMatrix,!1,Ka);if(e&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||
-f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(j.fogColor.value=e.color,e instanceof THREE.Fog)j.fogNear.value=e.near,j.fogFar.value=e.far;else if(e instanceof THREE.FogExp2)j.fogDensity.value=e.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var H,D,p,k=0,C=0,q=0,n,r,t,o=Ra,A=o.directional.colors,w=o.directional.positions,v=o.point.colors,E=o.point.positions,F=o.point.distances,
-x=0,s=0,e=D=t=0;for(H=d.length;e<H;e++)if(D=d[e],p=D.color,n=D.position,r=D.intensity,t=D.distance,D instanceof THREE.AmbientLight)k+=p.r,C+=p.g,q+=p.b;else if(D instanceof THREE.DirectionalLight)t=x*3,A[t]=p.r*r,A[t+1]=p.g*r,A[t+2]=p.b*r,w[t]=n.x,w[t+1]=n.y,w[t+2]=n.z,x+=1;else if(D instanceof THREE.SpotLight)t=x*3,A[t]=p.r*r,A[t+1]=p.g*r,A[t+2]=p.b*r,p=1/n.length(),w[t]=n.x*p,w[t+1]=n.y*p,w[t+2]=n.z*p,x+=1;else if(D instanceof THREE.PointLight)D=s*3,v[D]=p.r*r,v[D+1]=p.g*r,v[D+2]=p.b*r,E[D]=n.x,
-E[D+1]=n.y,E[D+2]=n.z,F[s]=t,s+=1;for(e=x*3;e<A.length;e++)A[e]=0;for(e=s*3;e<v.length;e++)v[e]=0;o.point.length=s;o.directional.length=x;o.ambient[0]=k;o.ambient[1]=C;o.ambient[2]=q;e=Ra;j.enableLighting.value=e.directional.length+e.point.length;j.ambientLightColor.value=e.ambient;j.directionalLightColor.value=e.directional.colors;j.directionalLightDirection.value=e.directional.positions;j.pointLightColor.value=e.point.colors;j.pointLightPosition.value=e.point.positions;j.pointLightDistance.value=
-e.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)j.diffuse.value=f.color,j.opacity.value=f.opacity,(j.map.texture=f.map)&&j.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),j.lightMap.texture=f.lightMap,j.envMap.texture=f.envMap,j.reflectivity.value=f.reflectivity,j.refractionRatio.value=f.refractionRatio,j.combine.value=f.combine,j.useRefract.value=f.envMap&&f.envMap.mapping instanceof
-THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)j.diffuse.value=f.color,j.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)j.psColor.value=f.color,j.opacity.value=f.opacity,j.size.value=f.size,j.scale.value=xa.height/2,j.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)j.ambient.value=f.ambient,j.specular.value=f.specular,j.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)j.mNear.value=b.near,j.mFar.value=b.far,j.opacity.value=
-f.opacity;else if(f instanceof THREE.MeshNormalMaterial)j.opacity.value=f.opacity;if(h.receiveShadow&&!f._shadowPass&&j.shadowMatrix){for(e=0;e<Na.length;e++)j.shadowMatrix.value[e]=Na[e],j.shadowMap.texture[e]=K.shadowMap[e];j.shadowDarkness.value=K.shadowMapDarkness;j.shadowBias.value=K.shadowMapBias}for(var m in j)if(k=g.uniforms[m])if(H=j[m],C=H.type,e=H.value,C=="i")c.uniform1i(k,e);else if(C=="f")c.uniform1f(k,e);else if(C=="fv1")c.uniform1fv(k,e);else if(C=="fv")c.uniform3fv(k,e);else if(C==
-"v2")c.uniform2f(k,e.x,e.y);else if(C=="v3")c.uniform3f(k,e.x,e.y,e.z);else if(C=="v4")c.uniform4f(k,e.x,e.y,e.z,e.w);else if(C=="m4"){if(!H._array)H._array=new Float32Array(16);e.flattenToArray(H._array);c.uniformMatrix4fv(k,!1,H._array)}else if(C=="m4v"){if(!H._array)H._array=new Float32Array(16*e.length);C=0;for(q=e.length;C<q;C++)e[C].flattenToArrayOffset(H._array,C*16);c.uniformMatrix4fv(k,!1,H._array)}else if(C=="c")c.uniform3f(k,e.r,e.g,e.b);else if(C=="t"){if(c.uniform1i(k,e),k=H.texture)if(k.image instanceof
-Array&&k.image.length==6){if(H=k,H.image.length==6){if(H.needsUpdate){if(H.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,H.image.__webglTextureCube);for(k=0;k<6;++k)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,c.RGBA,c.UNSIGNED_BYTE,H.image[k])}else{H.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,H.image.__webglTextureCube);for(k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,H.image[k]);H.__webglInit=!0}Q(c.TEXTURE_CUBE_MAP,
-H,H.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);H.needsUpdate=!1}c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_CUBE_MAP,H.image.__webglTextureCube)}}else ra(k,e)}else if(C=="tv"){if(!H._array){H._array=[];C=0;for(q=H.texture.length;C<q;C++)H._array[C]=e+C}c.uniform1iv(k,H._array);C=0;for(q=H.texture.length;C<q;C++)(k=H.texture[C])&&ra(k,H._array[C])}c.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray);c.uniformMatrix3fv(i.normalMatrix,!1,h._normalMatrixArray);(f instanceof
-THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&i.cameraPosition!==null&&c.uniform3f(i.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||h.receiveShadow)&&i.objectMatrix!==null&&c.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&i.viewMatrix!==null&&c.uniformMatrix4fv(i.viewMatrix,
-!1,La);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=j.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,c.uniform3fv(i.directionalLightDirection,b),c.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray),c.uniformMatrix4fv(i.viewMatrix,!1,La);f.skinning&&(c.uniformMatrix4fv(i.cameraInverseMatrix,!1,La),c.uniformMatrix4fv(i.boneGlobalMatrices,!1,h.boneMatrices));return g}function f(b,d,f,h,g,i){if(h.opacity!=0){var j,b=e(b,d,f,h,i).attributes;
-if(!h.morphTargets&&b.position>=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;f<h.numSupportedMorphTargets&&f<k.length;)c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[k[f]]),c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0),i.__webglMorphTargetInfluences[f]=q[k[f]],f++;else{var k=[],D=-1,p=0,q=i.morphTargetInfluences,n,C=q.length,f=0;for(i.morphTargetBase!==-1&&(k[i.morphTargetBase]=!0);f<h.numSupportedMorphTargets;){for(n=0;n<C;n++)!k[n]&&q[n]>D&&(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;C<r;C+=9)e=b.normalArray,f=e[C],g=e[C+1],h=e[C+2],i=e[C+3],k=e[C+4],p=e[C+5],j=e[C+6],q=e[C+7],n=e[C+8],f=(f+i+j)/
-3,g=(g+k+q)/3,h=(h+p+n)/3,e[C]=f,e[C+1]=g,e[C+2]=h,e[C+3]=f,e[C+4]=g,e[C+5]=h,e[C+6]=f,e[C+7]=g,e[C+8]=h}c.bufferData(c.ARRAY_BUFFER,b.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(d.attributes.normal);c.vertexAttribPointer(d.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,b.count);b.count=0}function i(b){if(ca!=b.doubleSided)b.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),ca=b.doubleSided;if(O!=b.flipSided)b.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW),O=b.flipSided}
-function g(b){T!=b&&(b?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST),T=b)}function j(b,e,d){S!=b&&(b?c.enable(c.POLYGON_OFFSET_FILL):c.disable(c.POLYGON_OFFSET_FILL),S=b);if(b&&(ua!=e||Ga!=d))c.polygonOffset(e,d),ua=e,Ga=d}function k(b){ma[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);ma[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);ma[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);ma[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);ma[4].set(b.n41-b.n31,b.n42-
-b.n32,b.n43-b.n33,b.n44-b.n34);ma[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=ma[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function q(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),d=0;d<6;d++)if(b=ma[d].x*c.n14+ma[d].y*c.n24+ma[d].z*c.n34+ma[d].w,b<=e)return!1;return!0}function n(b,c){b.list[b.count]=c;b.count+=1}function r(b){var c,d,e=b.object,f=b.opaque,g=b.transparent;g.count=0;b=
-f.count=0;for(c=e.materials.length;b<c;b++)d=e.materials[b],d.transparent?n(g,d):n(f,d)}function t(b){var c,d,e,f,g=b.object,h=b.buffer,i=b.opaque,j=b.transparent;j.count=0;b=i.count=0;for(e=g.materials.length;b<e;b++)if(c=g.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(d=h.materials.length;c<d;c++)(f=h.materials[c])&&(f.transparent?n(j,f):n(i,f))}else(f=c)&&(f.transparent?n(j,f):n(i,f))}function o(b,c){return c.z-b.z}function F(b,d){var j,Qa,Ba,n=0,r,Ca,H,D,p=b.lights;na||(na=new THREE.Camera(K.shadowCameraFov,
-d.aspect,K.shadowCameraNear,K.shadowCameraFar));j=0;for(Qa=p.length;j<Qa;j++)if(Ba=p[j],Ba instanceof THREE.SpotLight&&Ba.castShadow){K.shadowMap[n]||(K.shadowMap[n]=new THREE.WebGLRenderTarget(K.shadowMapWidth,K.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));Na[n]||(Na[n]=new THREE.Matrix4);r=K.shadowMap[n];Ca=Na[n];na.position.copy(Ba.position);na.target.position.copy(Ba.target.position);na.update(void 0,!0);b.update(void 0,!1,na);Ca.set(0.5,
-0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);Ca.multiplySelf(na.projectionMatrix);Ca.multiplySelf(na.matrixWorldInverse);na.matrixWorldInverse.flattenToArray(La);na.projectionMatrix.flattenToArray(Ka);wa.multiply(na.projectionMatrix,na.matrixWorldInverse);k(wa);K.initWebGLObjects(b);ka(r);c.clearColor(1,1,1,1);K.clear();c.clearColor(sa.r,sa.g,sa.b,Ma);Ca=b.__webglObjects.length;Ba=b.__webglObjectsImmediate.length;for(r=0;r<Ca;r++)H=b.__webglObjects[r],D=H.object,D.visible&&D.castShadow?!(D instanceof
-THREE.Mesh)||q(D)?(D.matrixWorld.flattenToArray(D._objectMatrixArray),U(D,na,!1),H.render=!0):H.render=!1:H.render=!1;g(!0);M(THREE.NormalBlending);for(r=0;r<Ca;r++)if(H=b.__webglObjects[r],H.render)D=H.object,buffer=H.buffer,i(D),H=D.customDepthMaterial?D.customDepthMaterial:D.geometry.morphTargets.length?Sa:Oa,f(na,p,null,H,buffer,D);for(r=0;r<Ba;r++)H=b.__webglObjectsImmediate[r],D=H.object,D.visible&&D.castShadow&&(D.matrixAutoUpdate&&D.matrixWorld.flattenToArray(D._objectMatrixArray),U(D,na,
-!1),i(D),program=e(na,p,null,Oa,D),D.render(function(b){h(b,program,Oa.shading)}));n++}}function x(b){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var d,e=b.lights.length,f,g=b.lights,h=[],i,j,k,q,p,n=b.__webglShadowVolumes.length;for(d=0;d<e;d++)if(f=b.lights[d],f instanceof
-THREE.DirectionalLight&&f.castShadow){h[0]=-f.position.x;h[1]=-f.position.y;h[2]=-f.position.z;for(p=0;p<n;p++)f=b.__webglShadowVolumes[p].object,i=b.__webglShadowVolumes[p].buffer,j=f.materials[0],j.program||K.initMaterial(j,g,void 0,f),j=j.program,k=j.uniforms,q=j.attributes,R!==j&&(c.useProgram(j),R=j,c.uniformMatrix4fv(k.projectionMatrix,!1,Ka),c.uniformMatrix4fv(k.viewMatrix,!1,La),c.uniform3fv(k.directionalLightDirection,h)),f.matrixWorld.flattenToArray(f._objectMatrixArray),c.uniformMatrix4fv(k.objectMatrix,
-!1,f._objectMatrixArray),c.bindBuffer(c.ARRAY_BUFFER,i.__webglVertexBuffer),c.vertexAttribPointer(q.position,3,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,i.__webglNormalBuffer),c.vertexAttribPointer(q.normal,3,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglFaceBuffer),c.cullFace(c.FRONT),c.drawElements(c.TRIANGLES,i.__webglFaceCount,c.UNSIGNED_SHORT,0),c.cullFace(c.BACK),c.drawElements(c.TRIANGLES,i.__webglFaceCount,c.UNSIGNED_SHORT,0)}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,
-!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);T=da=-1;R=u.program;c.useProgram(u.program);c.uniformMatrix4fv(u.projectionLocation,!1,Ka);c.uniform1f(u.darknessLocation,u.darkness);c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.vertexAttribPointer(u.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(u.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);
-c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(L)}function G(b,d){var e,f,g;e=v.attributes;var h=v.uniforms,i=qa/la,j,k=[],q=la*0.5,p=qa*0.5,n=!0;c.useProgram(v.program);R=v.program;T=da=-1;Ta||(c.enableVertexAttribArray(v.attributes.position),c.enableVertexAttribArray(v.attributes.uv),Ta=!0);c.disable(c.CULL_FACE);c.enable(c.BLEND);c.depthMask(!0);c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.vertexAttribPointer(e.position,2,c.FLOAT,
-!1,16,0);c.vertexAttribPointer(e.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.uniformMatrix4fv(h.projectionMatrix,!1,Ka);c.activeTexture(c.TEXTURE0);c.uniform1i(h.map,0);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.useScreenCoordinates?g.z=-g.position.z:(g._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,g.matrixWorld,g._modelViewMatrixArray),g.z=-g._modelViewMatrix.n34);b.__webglSprites.sort(o);e=0;for(f=b.__webglSprites.length;e<f;e++)g=
-b.__webglSprites[e],g.material===void 0&&g.map&&g.map.image&&g.map.image.width&&(g.useScreenCoordinates?(c.uniform1i(h.useScreenCoordinates,1),c.uniform3f(h.screenPosition,(g.position.x-q)/q,(p-g.position.y)/p,Math.max(0,Math.min(1,g.position.z)))):(c.uniform1i(h.useScreenCoordinates,0),c.uniform1i(h.affectedByDistance,g.affectedByDistance?1:0),c.uniformMatrix4fv(h.modelViewMatrix,!1,g._modelViewMatrixArray)),j=g.map.image.width/(g.scaleByViewport?qa:1),k[0]=j*i*g.scale.x,k[1]=j*g.scale.y,c.uniform2f(h.uvScale,
-g.uvScale.x,g.uvScale.y),c.uniform2f(h.uvOffset,g.uvOffset.x,g.uvOffset.y),c.uniform2f(h.alignment,g.alignment.x,g.alignment.y),c.uniform1f(h.opacity,g.opacity),c.uniform1f(h.rotation,g.rotation),c.uniform2fv(h.scale,k),g.mergeWith3D&&!n?(c.enable(c.DEPTH_TEST),n=!0):!g.mergeWith3D&&n&&(c.disable(c.DEPTH_TEST),n=!1),M(g.blending),ra(g.map,0),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0));c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(L)}function E(b,e){var d,f,g=b.__webglLensFlares.length,
-h,i,j,k=new THREE.Vector3,q=qa/la,p=la*0.5,n=qa*0.5,r=16/qa,t=[r*q,r],o=[1,1,0],w=[1,1],v=A.uniforms;d=A.attributes;c.useProgram(A.program);R=A.program;T=da=-1;Ua||(c.enableVertexAttribArray(A.attributes.vertex),c.enableVertexAttribArray(A.attributes.uv),Ua=!0);c.uniform1i(v.occlusionMap,0);c.uniform1i(v.map,1);c.bindBuffer(c.ARRAY_BUFFER,A.vertexBuffer);c.vertexAttribPointer(d.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(d.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.elementBuffer);
-c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.activeTexture(c.TEXTURE1);for(f=0;f<g;f++)if(d=b.__webglLensFlares[f].object,k.set(d.matrixWorld.n14,d.matrixWorld.n24,d.matrixWorld.n34),e.matrixWorldInverse.multiplyVector3(k),e.projectionMatrix.multiplyVector3(k),o[0]=k.x,o[1]=k.y,o[2]=k.z,w[0]=o[0]*p+p,w[1]=o[1]*n+n,A.hasVertexTexture||w[0]>0&&w[0]<la&&w[1]>0&&w[1]<qa){c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,
-0,c.RGB,w[0]-8,w[1]-8,16,16,0);c.uniform1i(v.renderType,0);c.uniform2fv(v.scale,t);c.uniform3fv(v.screenPosition,o);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,w[0]-8,w[1]-8,16,16,0);c.uniform1i(v.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);d.positionScreen.x=o[0];d.positionScreen.y=
-o[1];d.positionScreen.z=o[2];d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares();c.uniform1i(v.renderType,2);c.enable(c.BLEND);h=0;for(i=d.lensFlares.length;h<i;h++)if(j=d.lensFlares[h],j.opacity>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;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)if(e.attributes[c].needsUpdate)return!0;return!1}function fa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)e.attributes[c].needsUpdate=
-!1}function I(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups)if(g=f.geometryGroups[e],h=ta(g),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||h){h=g;var i=c.DYNAMIC_DRAW,j=!f.dynamic;if(h.__inittedArrays){var k=void 0,q=void 0,n=void 0,p=void 0,r=n=void 0,C=void 0,t=void 0,o=void 0,w=void 0,v=void 0,A=void 0,E=void 0,F=void 0,x=void 0,y=void 0,u=void 0,G=void 0,s=p=o=p=t=C=void 0,m=
-void 0,B=m=s=C=void 0,K=void 0,L=B=m=s=n=n=r=o=p=B=m=s=K=B=m=s=K=B=m=s=void 0,I=0,J=0,R=0,S=0,M=0,N=0,V=0,O=0,ea=0,z=0,ga=0,B=s=0,B=void 0,ia=h.__vertexArray,aa=h.__uvArray,ca=h.__uv2Array,Q=h.__normalArray,W=h.__tangentArray,ja=h.__colorArray,X=h.__skinVertexAArray,Y=h.__skinVertexBArray,Z=h.__skinIndexArray,$=h.__skinWeightArray,da=h.__morphTargetsArrays,U=h.__webglCustomAttributes,m=void 0,P=h.__faceArray,T=h.__lineArray,ma=h.__needsSmoothNormals,v=h.__vertexColorType,w=h.__uvType,A=h.__normalType,
-oa=b.geometry,la=oa.__dirtyVertices,na=oa.__dirtyElements,ha=oa.__dirtyUvs,pa=oa.__dirtyNormals,qa=oa.__dirtyTangents,ra=oa.__dirtyColors,sa=oa.__dirtyMorphTargets,ka=oa.vertices,ua=h.faces,va=oa.faces,wa=oa.faceVertexUvs[0],xa=oa.faceVertexUvs[1],Da=oa.skinVerticesA,Ea=oa.skinVerticesB,Fa=oa.skinIndices,za=oa.skinWeights,Aa=b instanceof THREE.ShadowVolume?oa.edgeFaces:void 0,ya=oa.morphTargets;if(U)for(L in U)U[L].offset=0,U[L].offsetSrc=0;k=0;for(q=ua.length;k<q;k++)if(n=ua[k],p=va[n],wa&&(E=wa[n]),
-xa&&(F=xa[n]),n=p.vertexNormals,r=p.normal,C=p.vertexColors,t=p.color,o=p.vertexTangents,p instanceof THREE.Face3){if(la)x=ka[p.a].position,y=ka[p.b].position,u=ka[p.c].position,ia[J]=x.x,ia[J+1]=x.y,ia[J+2]=x.z,ia[J+3]=y.x,ia[J+4]=y.y,ia[J+5]=y.z,ia[J+6]=u.x,ia[J+7]=u.y,ia[J+8]=u.z,J+=9;if(U)for(L in U)if(m=U[L],m.__original.needsUpdate)s=m.offset,B=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[p.a],m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c]):m.boundTo===
-"faces"?(B=m.value[B],m.array[s]=B,m.array[s+1]=B,m.array[s+2]=B,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[B],m.array[s+1]=m.value[B+1],m.array[s+2]=m.value[B+2],m.offsetSrc+=3),m.offset+=3):(m.boundTo===void 0||m.boundTo==="vertices"?(x=m.value[p.a],y=m.value[p.b],u=m.value[p.c]):m.boundTo==="faces"?(u=y=x=B=m.value[B],m.offsetSrc++):m.boundTo==="faceVertices"&&(x=m.value[B],y=m.value[B+1],u=m.value[B+2],m.offsetSrc+=3),m.size===2?(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=
-y.x,m.array[s+3]=y.y,m.array[s+4]=u.x,m.array[s+5]=u.y,m.offset+=6):m.size===3?(m.type==="c"?(m.array[s]=x.r,m.array[s+1]=x.g,m.array[s+2]=x.b,m.array[s+3]=y.r,m.array[s+4]=y.g,m.array[s+5]=y.b,m.array[s+6]=u.r,m.array[s+7]=u.g,m.array[s+8]=u.b):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=y.x,m.array[s+4]=y.y,m.array[s+5]=y.z,m.array[s+6]=u.x,m.array[s+7]=u.y,m.array[s+8]=u.z),m.offset+=9):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=x.w,m.array[s+4]=y.x,m.array[s+
-5]=y.y,m.array[s+6]=y.z,m.array[s+7]=y.w,m.array[s+8]=u.x,m.array[s+9]=u.y,m.array[s+10]=u.z,m.array[s+11]=u.w,m.offset+=12));if(sa){s=0;for(m=ya.length;s<m;s++)x=ya[s].vertices[p.a].position,y=ya[s].vertices[p.b].position,u=ya[s].vertices[p.c].position,B=da[s],B[ga]=x.x,B[ga+1]=x.y,B[ga+2]=x.z,B[ga+3]=y.x,B[ga+4]=y.y,B[ga+5]=y.z,B[ga+6]=u.x,B[ga+7]=u.y,B[ga+8]=u.z;ga+=9}if(za.length)s=za[p.a],m=za[p.b],B=za[p.c],$[z]=s.x,$[z+1]=s.y,$[z+2]=s.z,$[z+3]=s.w,$[z+4]=m.x,$[z+5]=m.y,$[z+6]=m.z,$[z+7]=m.w,
-$[z+8]=B.x,$[z+9]=B.y,$[z+10]=B.z,$[z+11]=B.w,s=Fa[p.a],m=Fa[p.b],B=Fa[p.c],Z[z]=s.x,Z[z+1]=s.y,Z[z+2]=s.z,Z[z+3]=s.w,Z[z+4]=m.x,Z[z+5]=m.y,Z[z+6]=m.z,Z[z+7]=m.w,Z[z+8]=B.x,Z[z+9]=B.y,Z[z+10]=B.z,Z[z+11]=B.w,s=Da[p.a],m=Da[p.b],B=Da[p.c],X[z]=s.x,X[z+1]=s.y,X[z+2]=s.z,X[z+3]=1,X[z+4]=m.x,X[z+5]=m.y,X[z+6]=m.z,X[z+7]=1,X[z+8]=B.x,X[z+9]=B.y,X[z+10]=B.z,X[z+11]=1,s=Ea[p.a],m=Ea[p.b],B=Ea[p.c],Y[z]=s.x,Y[z+1]=s.y,Y[z+2]=s.z,Y[z+3]=1,Y[z+4]=m.x,Y[z+5]=m.y,Y[z+6]=m.z,Y[z+7]=1,Y[z+8]=B.x,Y[z+9]=B.y,Y[z+
-10]=B.z,Y[z+11]=1,z+=12;if(ra&&v)C.length==3&&v==THREE.VertexColors?(p=C[0],s=C[1],m=C[2]):m=s=p=t,ja[ea]=p.r,ja[ea+1]=p.g,ja[ea+2]=p.b,ja[ea+3]=s.r,ja[ea+4]=s.g,ja[ea+5]=s.b,ja[ea+6]=m.r,ja[ea+7]=m.g,ja[ea+8]=m.b,ea+=9;if(qa&&oa.hasTangents)C=o[0],t=o[1],p=o[2],W[V]=C.x,W[V+1]=C.y,W[V+2]=C.z,W[V+3]=C.w,W[V+4]=t.x,W[V+5]=t.y,W[V+6]=t.z,W[V+7]=t.w,W[V+8]=p.x,W[V+9]=p.y,W[V+10]=p.z,W[V+11]=p.w,V+=12;if(pa&&A)if(n.length==3&&ma)for(o=0;o<3;o++)r=n[o],Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;else for(o=0;o<
-3;o++)Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;if(ha&&E!==void 0&&w)for(o=0;o<3;o++)n=E[o],aa[R]=n.u,aa[R+1]=n.v,R+=2;if(ha&&F!==void 0&&w)for(o=0;o<3;o++)n=F[o],ca[S]=n.u,ca[S+1]=n.v,S+=2;na&&(P[M]=I,P[M+1]=I+1,P[M+2]=I+2,M+=3,T[O]=I,T[O+1]=I+1,T[O+2]=I,T[O+3]=I+2,T[O+4]=I+1,T[O+5]=I+2,O+=6,I+=3)}else if(p instanceof THREE.Face4){if(la)x=ka[p.a].position,y=ka[p.b].position,u=ka[p.c].position,G=ka[p.d].position,ia[J]=x.x,ia[J+1]=x.y,ia[J+2]=x.z,ia[J+3]=y.x,ia[J+4]=y.y,ia[J+5]=y.z,ia[J+6]=u.x,ia[J+7]=u.y,
-ia[J+8]=u.z,ia[J+9]=G.x,ia[J+10]=G.y,ia[J+11]=G.z,J+=12;if(U)for(L in U)if(m=U[L],m.__original.needsUpdate)s=m.offset,B=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[p.a],m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c],m.array[s+3]=m.value[p.d]):m.boundTo==="faces"?(B=m.value[B],m.array[s]=B,m.array[s+1]=B,m.array[s+2]=B,m.array[s+3]=B,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[B],m.array[s+1]=m.value[B+1],m.array[s+2]=m.value[B+2],
-m.array[s+3]=m.value[B+3],m.offsetSrc+=4),m.offset+=4):(m.boundTo===void 0||m.boundTo==="vertices"?(x=m.value[p.a],y=m.value[p.b],u=m.value[p.c],G=m.value[p.d]):m.boundTo==="faces"?(G=u=y=x=B=m.value[B],m.offsetSrc++):m.boundTo==="faceVertices"&&(x=m.value[B],y=m.value[B+1],u=m.value[B+2],G=m.value[B+3],m.offsetSrc+=4),m.size===2?(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=y.x,m.array[s+3]=y.y,m.array[s+4]=u.x,m.array[s+5]=u.y,m.array[s+6]=G.x,m.array[s+7]=G.y,m.offset+=8):m.size===3?(m.type===
-"c"?(m.array[s]=x.r,m.array[s+1]=x.g,m.array[s+2]=x.b,m.array[s+3]=y.r,m.array[s+4]=y.g,m.array[s+5]=y.b,m.array[s+6]=u.r,m.array[s+7]=u.g,m.array[s+8]=u.b,m.array[s+9]=G.r,m.array[s+10]=G.g,m.array[s+11]=G.b):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=y.x,m.array[s+4]=y.y,m.array[s+5]=y.z,m.array[s+6]=u.x,m.array[s+7]=u.y,m.array[s+8]=u.z,m.array[s+9]=G.x,m.array[s+10]=G.y,m.array[s+11]=G.z),m.offset+=12):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=x.w,m.array[s+
-4]=y.x,m.array[s+5]=y.y,m.array[s+6]=y.z,m.array[s+7]=y.w,m.array[s+8]=u.x,m.array[s+9]=u.y,m.array[s+10]=u.z,m.array[s+11]=u.w,m.array[s+12]=G.x,m.array[s+13]=G.y,m.array[s+14]=G.z,m.array[s+15]=G.w,m.offset+=16));if(sa){s=0;for(m=ya.length;s<m;s++)x=ya[s].vertices[p.a].position,y=ya[s].vertices[p.b].position,u=ya[s].vertices[p.c].position,G=ya[s].vertices[p.d].position,B=da[s],B[ga]=x.x,B[ga+1]=x.y,B[ga+2]=x.z,B[ga+3]=y.x,B[ga+4]=y.y,B[ga+5]=y.z,B[ga+6]=u.x,B[ga+7]=u.y,B[ga+8]=u.z,B[ga+9]=G.x,B[ga+
-10]=G.y,B[ga+11]=G.z;ga+=12}if(za.length)s=za[p.a],m=za[p.b],B=za[p.c],K=za[p.d],$[z]=s.x,$[z+1]=s.y,$[z+2]=s.z,$[z+3]=s.w,$[z+4]=m.x,$[z+5]=m.y,$[z+6]=m.z,$[z+7]=m.w,$[z+8]=B.x,$[z+9]=B.y,$[z+10]=B.z,$[z+11]=B.w,$[z+12]=K.x,$[z+13]=K.y,$[z+14]=K.z,$[z+15]=K.w,s=Fa[p.a],m=Fa[p.b],B=Fa[p.c],K=Fa[p.d],Z[z]=s.x,Z[z+1]=s.y,Z[z+2]=s.z,Z[z+3]=s.w,Z[z+4]=m.x,Z[z+5]=m.y,Z[z+6]=m.z,Z[z+7]=m.w,Z[z+8]=B.x,Z[z+9]=B.y,Z[z+10]=B.z,Z[z+11]=B.w,Z[z+12]=K.x,Z[z+13]=K.y,Z[z+14]=K.z,Z[z+15]=K.w,s=Da[p.a],m=Da[p.b],
-B=Da[p.c],K=Da[p.d],X[z]=s.x,X[z+1]=s.y,X[z+2]=s.z,X[z+3]=1,X[z+4]=m.x,X[z+5]=m.y,X[z+6]=m.z,X[z+7]=1,X[z+8]=B.x,X[z+9]=B.y,X[z+10]=B.z,X[z+11]=1,X[z+12]=K.x,X[z+13]=K.y,X[z+14]=K.z,X[z+15]=1,s=Ea[p.a],m=Ea[p.b],B=Ea[p.c],p=Ea[p.d],Y[z]=s.x,Y[z+1]=s.y,Y[z+2]=s.z,Y[z+3]=1,Y[z+4]=m.x,Y[z+5]=m.y,Y[z+6]=m.z,Y[z+7]=1,Y[z+8]=B.x,Y[z+9]=B.y,Y[z+10]=B.z,Y[z+11]=1,Y[z+12]=p.x,Y[z+13]=p.y,Y[z+14]=p.z,Y[z+15]=1,z+=16;if(ra&&v)C.length==4&&v==THREE.VertexColors?(p=C[0],s=C[1],m=C[2],C=C[3]):C=m=s=p=t,ja[ea]=
-p.r,ja[ea+1]=p.g,ja[ea+2]=p.b,ja[ea+3]=s.r,ja[ea+4]=s.g,ja[ea+5]=s.b,ja[ea+6]=m.r,ja[ea+7]=m.g,ja[ea+8]=m.b,ja[ea+9]=C.r,ja[ea+10]=C.g,ja[ea+11]=C.b,ea+=12;if(qa&&oa.hasTangents)C=o[0],t=o[1],p=o[2],o=o[3],W[V]=C.x,W[V+1]=C.y,W[V+2]=C.z,W[V+3]=C.w,W[V+4]=t.x,W[V+5]=t.y,W[V+6]=t.z,W[V+7]=t.w,W[V+8]=p.x,W[V+9]=p.y,W[V+10]=p.z,W[V+11]=p.w,W[V+12]=o.x,W[V+13]=o.y,W[V+14]=o.z,W[V+15]=o.w,V+=16;if(pa&&A)if(n.length==4&&ma)for(o=0;o<4;o++)r=n[o],Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;else for(o=0;o<4;o++)Q[N]=
-r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;if(ha&&E!==void 0&&w)for(o=0;o<4;o++)n=E[o],aa[R]=n.u,aa[R+1]=n.v,R+=2;if(ha&&F!==void 0&&w)for(o=0;o<4;o++)n=F[o],ca[S]=n.u,ca[S+1]=n.v,S+=2;na&&(P[M]=I,P[M+1]=I+1,P[M+2]=I+3,P[M+3]=I+1,P[M+4]=I+2,P[M+5]=I+3,M+=6,T[O]=I,T[O+1]=I+1,T[O+2]=I,T[O+3]=I+3,T[O+4]=I+1,T[O+5]=I+2,T[O+6]=I+2,T[O+7]=I+3,O+=8,I+=4)}if(Aa){k=0;for(q=Aa.length;k<q;k++)P[M]=Aa[k].a,P[M+1]=Aa[k].b,P[M+2]=Aa[k].c,P[M+3]=Aa[k].a,P[M+4]=Aa[k].c,P[M+5]=Aa[k].d,M+=6}la&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),
-c.bufferData(c.ARRAY_BUFFER,ia,i));if(U)for(L in U)m=U[L],m.__original.needsUpdate&&(c.bindBuffer(c.ARRAY_BUFFER,m.buffer),c.bufferData(c.ARRAY_BUFFER,m.array,i));if(sa){s=0;for(m=ya.length;s<m;s++)c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[s]),c.bufferData(c.ARRAY_BUFFER,da[s],i)}ra&&ea>0&&(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<v;k++)q=w[k].position,g=k*3,A[g]=q.x,A[g+1]=q.y,A[g+2]=q.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,A,e)}if(E){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){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<v;k++)q=w[k].position,g=k*3,A[g]=q.x,A[g+1]=q.y,A[g+2]=q.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,A,e)}if(E){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=b.geometry,h=ta(f),(f.__dirtyVertices||
-f.__dirtyColors||b.sortParticles||h)&&d(f,c.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1,fa(f)}function w(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function P(b){function c(b){var f=[];d=0;for(e=b.length;d<e;d++)b[d]==void 0?f.push("undefined"):f.push(b[d].id);return f.join("_")}var d,e,f,h,g,i,j,k,p={},n=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)g=b.faces[f],i=g.materials,j=c(i),p[j]==void 0&&(p[j]={hash:j,
-counter:0}),k=p[j].hash+"_"+p[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n}),g=g instanceof THREE.Face3?3:4,b.geometryGroups[k].vertices+g>65535&&(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<n;k++)g=d[k],g instanceof THREE.SpotLight&&p++,g instanceof THREE.DirectionalLight&&p++,g instanceof THREE.PointLight&&j++;j+p<=4?k=p:(k=Math.ceil(4*p/(j+p)),j=4-k);g={directional:k,point:j};j=p=0;for(k=d.length;j<k;j++)n=d[j],n instanceof THREE.SpotLight&&n.castShadow&&p++;
-var q=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)q=f.bones.length;var o;a:{k=b.fragmentShader;n=b.vertexShader;var j=b.uniforms,d=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,
-shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:p,alphaTest:b.alphaTest},r,f=[];i?f.push(i):(f.push(k),f.push(n));for(r in e)f.push(r),f.push(e[r]);i=f.join();r=0;for(f=ha.length;r<f;r++)if(ha[r].code==i){o=ha[r].program;break a}r=c.createProgram();f=[Wa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?
-"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
-"",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");c.attachShader(r,aa("fragment",g+k));c.attachShader(r,aa("vertex",f+n));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms=
-{};r.attributes={};var t,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in j)f.push(t);t=f;f=0;for(j=t.length;f<j;f++)k=t[f],r.uniforms[k]=c.getUniformLocation(r,k);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(t=0;t<e.maxMorphTargets;t++)f.push("morphTarget"+t);for(o in d)f.push(o);o=f;t=0;for(d=o.length;t<d;t++)e=
-o[t],r.attributes[e]=c.getAttribLocation(r,e);ha.push({program:r,code:i});o=r}b.program=o;o=b.program.attributes;o.position>=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<this.maxMorphTargets;h++)t="morphTarget"+h,o[t]>=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<H;w++)if(v=b.__webglObjects[w],p=v.object,p.visible)if(!(p instanceof THREE.Mesh)||q(p)){if(p.matrixWorld.flattenToArray(p._objectMatrixArray),U(p,d,!0),t(v),v.render=!0,this.sortObjects)v.object.renderDepth?v.z=v.object.renderDepth:(Ja.copy(p.position),wa.multiplyVector3(Ja),
-v.z=Ja.z)}else v.render=!1;else v.render=!1;this.sortObjects&&b.__webglObjects.sort(o);D=b.__webglObjectsImmediate.length;for(w=0;w<D;w++)v=b.__webglObjectsImmediate[w],p=v.object,p.visible&&(p.matrixAutoUpdate&&p.matrixWorld.flattenToArray(p._objectMatrixArray),U(p,d,!0),r(v));if(b.overrideMaterial){g(b.overrideMaterial.depthTest);M(b.overrideMaterial.blending);for(w=0;w<H;w++)if(v=b.__webglObjects[w],v.render)p=v.object,I=v.buffer,i(p),f(d,C,J,b.overrideMaterial,I,p);for(w=0;w<D;w++)v=b.__webglObjectsImmediate[w],
-p=v.object,p.visible&&(i(p),A=e(d,C,J,b.overrideMaterial,p),p.render(function(c){h(c,A,b.overrideMaterial.shading)}))}else{M(THREE.NormalBlending);for(w=H-1;w>=0;w--)if(v=b.__webglObjects[w],v.render){p=v.object;I=v.buffer;y=v.opaque;i(p);for(v=0;v<y.count;v++)u=y.list[v],g(u.depthTest),j(u.polygonOffset,u.polygonOffsetFactor,u.polygonOffsetUnits),f(d,C,J,u,I,p)}for(w=0;w<D;w++)if(v=b.__webglObjectsImmediate[w],p=v.object,p.visible){y=v.opaque;i(p);for(v=0;v<y.count;v++)u=y.list[v],g(u.depthTest),
-j(u.polygonOffset,u.polygonOffsetFactor,u.polygonOffsetUnits),A=e(d,C,J,u,p),p.render(function(b){h(b,A,u.shading)})}for(w=0;w<H;w++)if(v=b.__webglObjects[w],v.render){p=v.object;I=v.buffer;y=v.transparent;i(p);for(v=0;v<y.count;v++)u=y.list[v],M(u.blending),g(u.depthTest),j(u.polygonOffset,u.polygonOffsetFactor,u.polygonOffsetUnits),f(d,C,J,u,I,p)}for(w=0;w<D;w++)if(v=b.__webglObjectsImmediate[w],p=v.object,p.visible){y=v.transparent;i(p);for(v=0;v<y.count;v++)u=y.list[v],M(u.blending),g(u.depthTest),
-j(u.polygonOffset,u.polygonOffsetFactor,u.polygonOffsetUnits),A=e(d,C,J,u,p),p.render(function(b){h(b,A,u.shading)})}}b.__webglSprites.length&&G(b,d);Pa&&b.__webglShadowVolumes.length&&b.lights.length&&x(b);b.__webglLensFlares.length&&E(b,d);n&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter&&(c.bindTexture(c.TEXTURE_2D,n.__webglTexture),c.generateMipmap(c.TEXTURE_2D),c.bindTexture(c.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],
-b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var d=b.__objectsAdded[0],e=b,f=void 0,g=void 0,h=void 0;if(d._modelViewMatrix==void 0)d._modelViewMatrix=new THREE.Matrix4,d._normalMatrixArray=new Float32Array(9),d._modelViewMatrixArray=new Float32Array(16),d._objectMatrixArray=new Float32Array(16),d.matrixWorld.flattenToArray(d._objectMatrixArray);if(d instanceof THREE.Mesh)for(f in g=d.geometry,g.geometryGroups==void 0&&
-P(g),g.geometryGroups){h=g.geometryGroups[f];if(!h.__webglVertexBuffer){var i=h;i.__webglVertexBuffer=c.createBuffer();i.__webglNormalBuffer=c.createBuffer();i.__webglTangentBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i.__webglUVBuffer=c.createBuffer();i.__webglUV2Buffer=c.createBuffer();i.__webglSkinVertexABuffer=c.createBuffer();i.__webglSkinVertexBBuffer=c.createBuffer();i.__webglSkinIndicesBuffer=c.createBuffer();i.__webglSkinWeightsBuffer=c.createBuffer();i.__webglFaceBuffer=
-c.createBuffer();i.__webglLineBuffer=c.createBuffer();if(i.numMorphTargets){var j=void 0,k=void 0;i.__webglMorphTargetsBuffers=[];j=0;for(k=i.numMorphTargets;j<k;j++)i.__webglMorphTargetsBuffers.push(c.createBuffer())}for(var i=h,j=d,o=void 0,p=void 0,n=void 0,r=n=void 0,q=void 0,t=void 0,v=t=k=0,u=n=p=void 0,x=u=p=o=void 0,n=void 0,r=j.geometry,q=r.faces,u=i.faces,o=0,p=u.length;o<p;o++)n=u[o],n=q[n],n instanceof THREE.Face3?(k+=3,t+=1,v+=3):n instanceof THREE.Face4&&(k+=4,t+=2,v+=4);for(var o=i,
-p=j,y=u=q=void 0,A=void 0,y=void 0,n=[],q=0,u=p.materials.length;q<u;q++)if(y=p.materials[q],y instanceof THREE.MeshFaceMaterial){y=0;for(l=o.materials.length;y<l;y++)(A=o.materials[y])&&n.push(A)}else(A=y)&&n.push(A);o=n;i.__materials=o;a:{q=p=void 0;u=o.length;for(p=0;p<u;p++)if(q=o[p],q.map||q.lightMap||q instanceof THREE.MeshShaderMaterial){p=!0;break a}p=!1}a:{u=q=void 0;n=o.length;for(q=0;q<n;q++)if(u=o[q],!(u instanceof THREE.MeshBasicMaterial&&!u.envMap||u instanceof THREE.MeshDepthMaterial)){u=
-u&&u.shading!=void 0&&u.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}u=!1}a:{n=q=void 0;y=o.length;for(q=0;q<y;q++)if(n=o[q],n.vertexColors){n=n.vertexColors;break a}n=!1}i.__vertexArray=new Float32Array(k*3);if(u)i.__normalArray=new Float32Array(k*3);if(r.hasTangents)i.__tangentArray=new Float32Array(k*4);if(n)i.__colorArray=new Float32Array(k*3);if(p){if(r.faceUvs.length>0||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<q;r++)i.__morphTargetsArrays.push(new Float32Array(k*
-3))}i.__needsSmoothNormals=u==THREE.SmoothShading;i.__uvType=p;i.__vertexColorType=n;i.__normalType=u;i.__webglFaceCount=t*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0);i.__webglLineCount=v*2;r=0;for(q=o.length;r<q;r++)if(p=o[r],p.attributes){if(i.__webglCustomAttributes===void 0)i.__webglCustomAttributes={};for(a in p.attributes){n=p.attributes[a];u={};for(x in n)u[x]=n[x];if(!u.__webglInitialized||u.createUniqueBuffers)u.__webglInitialized=!0,t=1,u.type==="v2"?t=2:u.type==="v3"?t=3:u.type===
-"v4"?t=4:u.type==="c"&&(t=3),u.size=t,u.array=new Float32Array(k*t),u.buffer=c.createBuffer(),u.buffer.belongsToAttribute=a,n.needsUpdate=!0,u.__original=n;i.__webglCustomAttributes[a]=u}}i.__inittedArrays=!0;g.__dirtyVertices=!0;g.__dirtyMorphTargets=!0;g.__dirtyElements=!0;g.__dirtyUvs=!0;g.__dirtyNormals=!0;g.__dirtyTangents=!0;g.__dirtyColors=!0}d instanceof THREE.ShadowVolume?J(e.__webglShadowVolumes,h,d):J(e.__webglObjects,h,d)}else if(d instanceof THREE.LensFlare)J(e.__webglLensFlares,void 0,
-d);else if(d instanceof THREE.Ribbon){g=d.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=c.createBuffer(),f.__webglColorBuffer=c.createBuffer(),f=g,h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__webglVertexCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;J(e.__webglObjects,g,d)}else if(d instanceof THREE.Line){g=d.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=c.createBuffer(),f.__webglColorBuffer=c.createBuffer(),f=g,
-h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__webglLineCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;J(e.__webglObjects,g,d)}else if(d instanceof THREE.ParticleSystem){g=d.geometry;if(!g.__webglVertexBuffer){f=g;f.__webglVertexBuffer=c.createBuffer();f.__webglColorBuffer=c.createBuffer();f=g;h=d;i=f.vertices.length;f.__vertexArray=new Float32Array(i*3);f.__colorArray=new Float32Array(i*3);f.__sortArray=[];f.__webglParticleCount=i;f.__materials=
-h.materials;x=k=j=void 0;j=0;for(k=h.materials.length;j<k;j++)if(x=h.materials[j],x.attributes){if(f.__webglCustomAttributes===void 0)f.__webglCustomAttributes={};for(a in x.attributes){originalAttribute=x.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=
-4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(i*size),attribute.buffer=c.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;f.__webglCustomAttributes[a]=attribute}}g.__dirtyVertices=!0;g.__dirtyColors=!0}J(e.__webglObjects,g,d)}else THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}}):
-d instanceof THREE.Sprite&&e.__webglSprites.push(d);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];d=b;if(e instanceof THREE.ShadowVolume)w(d.__webglShadowVolumes,e);else if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)w(d.__webglObjects,e);else if(e instanceof THREE.Sprite){d=d.__webglSprites;g=void 0;for(g=d.length-1;g>=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<e;d++)I(b.__webglObjects[d].object,b);d=0;for(e=b.__webglShadowVolumes.length;d<e;d++)I(b.__webglShadowVolumes[d].object,b);d=0;for(e=b.__webglLensFlares.length;d<e;d++)I(b.__webglLensFlares[d].object,b)};this.setFaceCulling=function(b,d){b?(!d||d=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW),b=="back"?c.cullFace(c.BACK):b=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK),
-c.enable(c.CULL_FACE)):c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return Wa}};
-THREE.WebGLRenderTarget=function(b,d,e){this.width=b;this.height=d;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
-THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};
+THREE.WebGLRenderer=function(b){function c(b,c,d){var e,h,g,j=b.vertices,A=j.length,k=b.colors,R=k.length,B=b.__vertexArray,F=b.__colorArray,m=b.__sortArray,q=b.__dirtyVertices,o=b.__dirtyColors,p=b.__webglCustomAttributes,r,u;if(p)for(r in p)p[r].offset=0;if(d.sortParticles){Z.multiplySelf(d.matrixWorld);for(e=0;e<A;e++)h=j[e].position,Ha.copy(h),Z.multiplyVector3(Ha),m[e]=[Ha.z,e];m.sort(function(b,c){return c[0]-b[0]});for(e=0;e<A;e++)h=j[m[e][1]].position,g=e*3,B[g]=h.x,B[g+1]=h.y,B[g+2]=h.z;
+for(e=0;e<R;e++)g=e*3,color=k[m[e][1]],F[g]=color.r,F[g+1]=color.g,F[g+2]=color.b;if(p)for(r in p){e=p[r];k=e.value.length;for(g=0;g<k;g++){index=m[g][1];R=e.offset;if(e.size===1){if(e.boundTo===void 0||e.boundTo==="vertices")e.array[R]=e.value[index]}else{if(e.boundTo===void 0||e.boundTo==="vertices")u=e.value[index];e.size===2?(e.array[R]=u.x,e.array[R+1]=u.y):e.size===3?e.type==="c"?(e.array[R]=u.r,e.array[R+1]=u.g,e.array[R+2]=u.b):(e.array[R]=u.x,e.array[R+1]=u.y,e.array[R+2]=u.z):(e.array[R]=
+u.x,e.array[R+1]=u.y,e.array[R+2]=u.z,e.array[R+3]=u.w)}e.offset+=e.size}}}else{if(q)for(e=0;e<A;e++)h=j[e].position,g=e*3,B[g]=h.x,B[g+1]=h.y,B[g+2]=h.z;if(o)for(e=0;e<R;e++)color=k[e],g=e*3,F[g]=color.r,F[g+1]=color.g,F[g+2]=color.b;if(p)for(r in p)if(e=p[r],e.__original.needsUpdate){k=e.value.length;for(g=0;g<k;g++){R=e.offset;if(e.size===1){if(e.boundTo===void 0||e.boundTo==="vertices")e.array[R]=e.value[g]}else{if(e.boundTo===void 0||e.boundTo==="vertices")u=e.value[g];e.size===2?(e.array[R]=
+u.x,e.array[R+1]=u.y):e.size===3?e.type==="c"?(e.array[R]=u.r,e.array[R+1]=u.g,e.array[R+2]=u.b):(e.array[R]=u.x,e.array[R+1]=u.y,e.array[R+2]=u.z):(e.array[R]=u.x,e.array[R+1]=u.y,e.array[R+2]=u.z,e.array[R+3]=u.w)}e.offset+=e.size}}}if(q||d.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,B,c);if(o||d.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,b.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,F,c);if(p)for(r in p)if(e=p[r],e.__original.needsUpdate||d.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,
+e.buffer),f.bufferData(f.ARRAY_BUFFER,e.array,c)}function d(b,c,d,e,h){e.program||L.initMaterial(e,c,d,h);if(e.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(L.maxMorphTargets);for(var g=0,j=L.maxMorphTargets;g<j;g++)h.__webglMorphTargetInfluences[g]=0}var g=e.program,j=g.uniforms,A=e.uniforms;g!=Aa&&(f.useProgram(g),Aa=g);f.uniformMatrix4fv(j.projectionMatrix,!1,Fa);if(d&&(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||
+e instanceof THREE.MeshPhongMaterial||e instanceof THREE.LineBasicMaterial||e instanceof THREE.ParticleBasicMaterial||e.fog))if(A.fogColor.value=d.color,d instanceof THREE.Fog)A.fogNear.value=d.near,A.fogFar.value=d.far;else if(d instanceof THREE.FogExp2)A.fogDensity.value=d.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){var k,m,B,F=0,q=0,o=0,p,u,r,t=Ta,v=t.directional.colors,H=t.directional.positions,C=t.point.colors,z=t.point.positions,x=t.point.distances,
+J=0,E=0,d=m=r=0;for(k=c.length;d<k;d++)if(m=c[d],B=m.color,p=m.position,u=m.intensity,r=m.distance,m instanceof THREE.AmbientLight)F+=B.r,q+=B.g,o+=B.b;else if(m instanceof THREE.DirectionalLight)r=J*3,v[r]=B.r*u,v[r+1]=B.g*u,v[r+2]=B.b*u,H[r]=p.x,H[r+1]=p.y,H[r+2]=p.z,J+=1;else if(m instanceof THREE.SpotLight)r=J*3,v[r]=B.r*u,v[r+1]=B.g*u,v[r+2]=B.b*u,B=1/p.length(),H[r]=p.x*B,H[r+1]=p.y*B,H[r+2]=p.z*B,J+=1;else if(m instanceof THREE.PointLight)m=E*3,C[m]=B.r*u,C[m+1]=B.g*u,C[m+2]=B.b*u,z[m]=p.x,
+z[m+1]=p.y,z[m+2]=p.z,x[E]=r,E+=1;for(d=J*3;d<v.length;d++)v[d]=0;for(d=E*3;d<C.length;d++)C[d]=0;t.point.length=E;t.directional.length=J;t.ambient[0]=F;t.ambient[1]=q;t.ambient[2]=o;c=Ta;A.enableLighting.value=c.directional.length+c.point.length;A.ambientLightColor.value=c.ambient;A.directionalLightColor.value=c.directional.colors;A.directionalLightDirection.value=c.directional.positions;A.pointLightColor.value=c.point.colors;A.pointLightPosition.value=c.point.positions;A.pointLightDistance.value=
+c.point.distances}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)A.diffuse.value=e.color,A.opacity.value=e.opacity,(A.map.texture=e.map)&&A.offsetRepeat.value.set(e.map.offset.x,e.map.offset.y,e.map.repeat.x,e.map.repeat.y),A.lightMap.texture=e.lightMap,A.envMap.texture=e.envMap,A.reflectivity.value=e.reflectivity,A.refractionRatio.value=e.refractionRatio,A.combine.value=e.combine,A.useRefract.value=e.envMap&&e.envMap.mapping instanceof
+THREE.CubeRefractionMapping;if(e instanceof THREE.LineBasicMaterial)A.diffuse.value=e.color,A.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)A.psColor.value=e.color,A.opacity.value=e.opacity,A.size.value=e.size,A.scale.value=Ia.height/2,A.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)A.ambient.value=e.ambient,A.specular.value=e.specular,A.shininess.value=e.shininess;else if(e instanceof THREE.MeshDepthMaterial)A.mNear.value=b.near,A.mFar.value=b.far,A.opacity.value=
+e.opacity;else if(e instanceof THREE.MeshNormalMaterial)A.opacity.value=e.opacity;if(h.receiveShadow&&!e._shadowPass&&A.shadowMatrix){for(c=0;c<Qa.length;c++)A.shadowMatrix.value[c]=Qa[c],A.shadowMap.texture[c]=L.shadowMap[c];A.shadowDarkness.value=L.shadowMapDarkness;A.shadowBias.value=L.shadowMapBias}for(var M in A)if(k=g.uniforms[M])if(d=A[M],F=d.type,c=d.value,F=="i")f.uniform1i(k,c);else if(F=="f")f.uniform1f(k,c);else if(F=="fv1")f.uniform1fv(k,c);else if(F=="fv")f.uniform3fv(k,c);else if(F==
+"v2")f.uniform2f(k,c.x,c.y);else if(F=="v3")f.uniform3f(k,c.x,c.y,c.z);else if(F=="v4")f.uniform4f(k,c.x,c.y,c.z,c.w);else if(F=="m4"){if(!d._array)d._array=new Float32Array(16);c.flattenToArray(d._array);f.uniformMatrix4fv(k,!1,d._array)}else if(F=="m4v"){if(!d._array)d._array=new Float32Array(16*c.length);F=0;for(q=c.length;F<q;F++)c[F].flattenToArrayOffset(d._array,F*16);f.uniformMatrix4fv(k,!1,d._array)}else if(F=="c")f.uniform3f(k,c.r,c.g,c.b);else if(F=="t"){if(f.uniform1i(k,c),k=d.texture)if(k.image instanceof
+Array&&k.image.length==6){if(d=k,d.image.length==6){if(d.needsUpdate){if(d.__webglInit){f.bindTexture(f.TEXTURE_CUBE_MAP,d.image.__webglTextureCube);for(k=0;k<6;++k)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,f.RGBA,f.UNSIGNED_BYTE,d.image[k])}else{d.image.__webglTextureCube=f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,d.image.__webglTextureCube);for(k=0;k<6;++k)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,d.image[k]);d.__webglInit=!0}Q(f.TEXTURE_CUBE_MAP,
+d,d.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);d.needsUpdate=!1}f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_CUBE_MAP,d.image.__webglTextureCube)}}else O(k,c)}else if(F=="tv"){if(!d._array){d._array=[];F=0;for(q=d.texture.length;F<q;F++)d._array[F]=c+F}f.uniform1iv(k,d._array);F=0;for(q=d.texture.length;F<q;F++)(k=d.texture[F])&&O(k,d._array[F])}f.uniformMatrix4fv(j.modelViewMatrix,!1,h._modelViewMatrixArray);f.uniformMatrix3fv(j.normalMatrix,!1,h._normalMatrixArray);(e instanceof THREE.MeshShaderMaterial||
+e instanceof THREE.MeshPhongMaterial||e.envMap)&&j.cameraPosition!==null&&f.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(e instanceof THREE.MeshShaderMaterial||e.envMap||e.skinning||h.receiveShadow)&&j.objectMatrix!==null&&f.uniformMatrix4fv(j.objectMatrix,!1,h._objectMatrixArray);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshShaderMaterial||e.skinning)&&j.viewMatrix!==null&&f.uniformMatrix4fv(j.viewMatrix,!1,Da);e.skinning&&
+(f.uniformMatrix4fv(j.cameraInverseMatrix,!1,Da),f.uniformMatrix4fv(j.boneGlobalMatrices,!1,h.boneMatrices));return g}function e(b,c,e,h,g,j){if(h.opacity!=0){var k,b=d(b,c,e,h,j).attributes;if(!h.morphTargets&&b.position>=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;e<h.numSupportedMorphTargets&&e<A.length;)f.bindBuffer(f.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[A[e]]),f.vertexAttribPointer(c["morphTarget"+e],3,f.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[e]=m[A[e]],e++;else{var A=[],q=-1,B=0,m=j.morphTargetInfluences,F,p=
+m.length,e=0;for(j.morphTargetBase!==-1&&(A[j.morphTargetBase]=!0);e<h.numSupportedMorphTargets;){for(F=0;F<p;F++)!A[F]&&m[F]>q&&(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<r;p+=9)d=b.normalArray,e=d[p],g=d[p+1],h=d[p+2],j=d[p+3],m=d[p+4],B=d[p+5],k=d[p+6],q=d[p+7],F=d[p+8],e=(e+j+k)/3,g=(g+m+q)/3,h=(h+B+F)/3,d[p]=e,d[p+1]=g,d[p+2]=h,d[p+3]=e,d[p+4]=g,d[p+5]=h,d[p+6]=e,d[p+7]=g,d[p+8]=h}f.bufferData(f.ARRAY_BUFFER,b.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(c.attributes.normal);f.vertexAttribPointer(c.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,
+0,b.count);b.count=0}function j(b){if(Y!=b.doubleSided)b.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),Y=b.doubleSided;if(pa!=b.flipSided)b.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),pa=b.flipSided}function g(b){W!=b&&(b?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),W=b)}function k(b,c,d){P!=b&&(b?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),P=b);if(b&&(S!=c||fa!=d))f.polygonOffset(c,d),S=c,fa=d}function q(b){ha[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-
+b.n14);ha[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);ha[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);ha[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);ha[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);ha[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=ha[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function m(b){for(var c=b.matrixWorld,f=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),
+d=0;d<6;d++)if(b=ha[d].x*c.n14+ha[d].y*c.n24+ha[d].z*c.n34+ha[d].w,b<=f)return!1;return!0}function o(b,c){b.list[b.count]=c;b.count+=1}function p(b){var c,d,f=b.object,e=b.opaque,g=b.transparent;g.count=0;b=e.count=0;for(c=f.materials.length;b<c;b++)d=f.materials[b],d.transparent?o(g,d):o(e,d)}function r(b){var c,d,f,e,g=b.object,h=b.buffer,j=b.opaque,k=b.transparent;k.count=0;b=j.count=0;for(f=g.materials.length;b<f;b++)if(c=g.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(d=h.materials.length;c<
+d;c++)(e=h.materials[c])&&(e.transparent?o(k,e):o(j,e))}else(e=c)&&(e.transparent?o(k,e):o(j,e))}function v(b,c){return c.z-b.z}function C(b,c){var k,Sa,G,p=0,ga,A,r,o,B=b.lights;ma||(ma=new THREE.Camera(L.shadowCameraFov,c.aspect,L.shadowCameraNear,L.shadowCameraFar));k=0;for(Sa=B.length;k<Sa;k++)if(G=B[k],G instanceof THREE.SpotLight&&G.castShadow){L.shadowMap[p]||(L.shadowMap[p]=new THREE.WebGLRenderTarget(L.shadowMapWidth,L.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
+format:THREE.RGBAFormat}));Qa[p]||(Qa[p]=new THREE.Matrix4);ga=L.shadowMap[p];A=Qa[p];ma.position.copy(G.position);ma.target.position.copy(G.target.position);ma.update(void 0,!0);b.update(void 0,!1,ma);A.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);A.multiplySelf(ma.projectionMatrix);A.multiplySelf(ma.matrixWorldInverse);ma.matrixWorldInverse.flattenToArray(Da);ma.projectionMatrix.flattenToArray(Fa);Z.multiply(ma.projectionMatrix,ma.matrixWorldInverse);q(Z);L.initWebGLObjects(b);T(ga);f.clearColor(1,
+1,1,1);L.clear();f.clearColor(xa.r,xa.g,xa.b,Ja);A=b.__webglObjects.length;G=b.__webglObjectsImmediate.length;for(ga=0;ga<A;ga++)r=b.__webglObjects[ga],o=r.object,o.visible&&o.castShadow?!(o instanceof THREE.Mesh)||m(o)?(o.matrixWorld.flattenToArray(o._objectMatrixArray),E(o,ma,!1),r.render=!0):r.render=!1:r.render=!1;g(!0);u(THREE.NormalBlending);for(ga=0;ga<A;ga++)if(r=b.__webglObjects[ga],r.render)o=r.object,buffer=r.buffer,j(o),r=o.customDepthMaterial?o.customDepthMaterial:o.geometry.morphTargets.length?
+Ua:Ra,e(ma,B,null,r,buffer,o);for(ga=0;ga<G;ga++)r=b.__webglObjectsImmediate[ga],o=r.object,o.visible&&o.castShadow&&(o.matrixAutoUpdate&&o.matrixWorld.flattenToArray(o._objectMatrixArray),E(o,ma,!1),j(o),program=d(ma,B,null,Ra,o),o.render(function(b){h(b,program,Ra.shading)}));p++}}function x(b,c){var d,e,g;d=t.attributes;var h=t.uniforms,j=wa/Ea,k,m=[],p=Ea*0.5,q=wa*0.5,F=!0;f.useProgram(t.program);Aa=t.program;W=D=-1;Va||(f.enableVertexAttribArray(t.attributes.position),f.enableVertexAttribArray(t.attributes.uv),
+Va=!0);f.disable(f.CULL_FACE);f.enable(f.BLEND);f.depthMask(!0);f.bindBuffer(f.ARRAY_BUFFER,t.vertexBuffer);f.vertexAttribPointer(d.position,2,f.FLOAT,!1,16,0);f.vertexAttribPointer(d.uv,2,f.FLOAT,!1,16,8);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,t.elementBuffer);f.uniformMatrix4fv(h.projectionMatrix,!1,Fa);f.activeTexture(f.TEXTURE0);f.uniform1i(h.map,0);d=0;for(e=b.__webglSprites.length;d<e;d++)g=b.__webglSprites[d],g.useScreenCoordinates?g.z=-g.position.z:(g._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
+g.matrixWorld,g._modelViewMatrixArray),g.z=-g._modelViewMatrix.n34);b.__webglSprites.sort(v);d=0;for(e=b.__webglSprites.length;d<e;d++)g=b.__webglSprites[d],g.material===void 0&&g.map&&g.map.image&&g.map.image.width&&(g.useScreenCoordinates?(f.uniform1i(h.useScreenCoordinates,1),f.uniform3f(h.screenPosition,(g.position.x-p)/p,(q-g.position.y)/q,Math.max(0,Math.min(1,g.position.z)))):(f.uniform1i(h.useScreenCoordinates,0),f.uniform1i(h.affectedByDistance,g.affectedByDistance?1:0),f.uniformMatrix4fv(h.modelViewMatrix,
+!1,g._modelViewMatrixArray)),k=g.map.image.width/(g.scaleByViewport?wa:1),m[0]=k*j*g.scale.x,m[1]=k*g.scale.y,f.uniform2f(h.uvScale,g.uvScale.x,g.uvScale.y),f.uniform2f(h.uvOffset,g.uvOffset.x,g.uvOffset.y),f.uniform2f(h.alignment,g.alignment.x,g.alignment.y),f.uniform1f(h.opacity,g.opacity),f.uniform1f(h.rotation,g.rotation),f.uniform2fv(h.scale,m),g.mergeWith3D&&!F?(f.enable(f.DEPTH_TEST),F=!0):!g.mergeWith3D&&F&&(f.disable(f.DEPTH_TEST),F=!1),u(g.blending),O(g.map,0),f.drawElements(f.TRIANGLES,
+6,f.UNSIGNED_SHORT,0));f.enable(f.CULL_FACE);f.enable(f.DEPTH_TEST);f.depthMask(va)}function E(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function J(b){var c,d,f,e;e=b.__materials;b=0;for(d=e.length;b<d;b++)if(f=e[b],f.attributes)for(c in f.attributes)if(f.attributes[c].needsUpdate)return!0;return!1}function ya(b){var c,d,f,e;e=b.__materials;b=0;for(d=
+e.length;b<d;b++)if(f=e[b],f.attributes)for(c in f.attributes)f.attributes[c].needsUpdate=!1}function za(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function sa(b){function c(b){var e=[];d=0;for(f=b.length;d<f;d++)b[d]==void 0?e.push("undefined"):e.push(b[d].id);return e.join("_")}var d,f,e,g,h,j,k,m,p={},q=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};e=0;for(g=b.faces.length;e<g;e++)h=b.faces[e],j=h.materials,k=c(j),p[k]==void 0&&(p[k]={hash:k,counter:0}),
+m=p[k].hash+"_"+p[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,vertices:0,numMorphTargets:q}),h=h instanceof THREE.Face3?3:4,b.geometryGroups[m].vertices+h>65535&&(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<p;m++)h=c[m],h instanceof THREE.SpotLight&&q++,h instanceof THREE.DirectionalLight&&q++,h instanceof THREE.PointLight&&
+k++;k+q<=4?m=q:(m=Math.ceil(4*q/(k+q)),k=4-m);h={directional:m,point:k};k=q=0;for(m=c.length;k<m;k++)p=c[k],p instanceof THREE.SpotLight&&p.castShadow&&q++;var o=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)o=e.bones.length;var r;a:{m=b.fragmentShader;p=b.vertexShader;var k=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,
+maxDirLights:h.directional,maxPointLights:h.point,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:q,alphaTest:b.alphaTest},u,e=[];j?e.push(j):(e.push(m),e.push(p));for(u in d)e.push(u),e.push(d[u]);j=e.join();u=0;for(e=ua.length;u<e;u++)if(ua[u].code==j){r=ua[u].program;break a}u=f.createProgram();e=[Xa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,
+"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+h=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,d.alphaTest?"#define ALPHATEST "+d.alphaTest:"",d.fog?"#define USE_FOG":"",d.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":
+"",d.shadowMapSoft?"#define SHADOWMAP_WIDTH "+d.shadowMapWidth.toFixed(1):"",d.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+d.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(u,U("fragment",h+m));f.attachShader(u,U("vertex",e+p));f.linkProgram(u);f.getProgramParameter(u,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(u,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");u.uniforms=
+{};u.attributes={};var t,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in k)e.push(t);t=e;e=0;for(k=t.length;e<k;e++)m=t[e],u.uniforms[m]=f.getUniformLocation(u,m);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(t=0;t<d.maxMorphTargets;t++)e.push("morphTarget"+t);for(r in c)e.push(r);r=e;t=0;for(c=r.length;t<c;t++)d=
+r[t],u.attributes[d]=f.getAttribLocation(u,d);ua.push({program:u,code:j});r=u}b.program=r;r=b.program.attributes;r.position>=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<this.maxMorphTargets;g++)t="morphTarget"+g,r[t]>=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<Pa;t++)if(G=b.__webglObjects[t],B=G.object,B.visible)if(!(B instanceof THREE.Mesh)||m(B)){if(B.matrixWorld.flattenToArray(B._objectMatrixArray),E(B,c,!0),r(G),G.render=!0,this.sortObjects)G.object.renderDepth?G.z=G.object.renderDepth:(Ha.copy(B.position),Z.multiplyVector3(Ha),
+G.z=Ha.z)}else G.render=!1;else G.render=!1;this.sortObjects&&b.__webglObjects.sort(v);R=b.__webglObjectsImmediate.length;for(t=0;t<R;t++)G=b.__webglObjectsImmediate[t],B=G.object,B.visible&&(B.matrixAutoUpdate&&B.matrixWorld.flattenToArray(B._objectMatrixArray),E(B,c,!0),p(G));if(b.overrideMaterial){g(b.overrideMaterial.depthTest);u(b.overrideMaterial.blending);for(t=0;t<Pa;t++)if(G=b.__webglObjects[t],G.render)B=G.object,F=G.buffer,j(B),e(c,D,Oa,b.overrideMaterial,F,B);for(t=0;t<R;t++)G=b.__webglObjectsImmediate[t],
+B=G.object,B.visible&&(j(B),J=d(c,D,Oa,b.overrideMaterial,B),B.render(function(c){h(c,J,b.overrideMaterial.shading)}))}else{u(THREE.NormalBlending);for(t=Pa-1;t>=0;t--)if(G=b.__webglObjects[t],G.render){B=G.object;F=G.buffer;ga=G.opaque;j(B);for(G=0;G<ga.count;G++)A=ga.list[G],g(A.depthTest),k(A.polygonOffset,A.polygonOffsetFactor,A.polygonOffsetUnits),e(c,D,Oa,A,F,B)}for(t=0;t<R;t++)if(G=b.__webglObjectsImmediate[t],B=G.object,B.visible){ga=G.opaque;j(B);for(G=0;G<ga.count;G++)A=ga.list[G],g(A.depthTest),
+k(A.polygonOffset,A.polygonOffsetFactor,A.polygonOffsetUnits),J=d(c,D,Oa,A,B),B.render(function(b){h(b,J,A.shading)})}for(t=0;t<Pa;t++)if(G=b.__webglObjects[t],G.render){B=G.object;F=G.buffer;ga=G.transparent;j(B);for(G=0;G<ga.count;G++)A=ga.list[G],u(A.blending),g(A.depthTest),k(A.polygonOffset,A.polygonOffsetFactor,A.polygonOffsetUnits),e(c,D,Oa,A,F,B)}for(t=0;t<R;t++)if(G=b.__webglObjectsImmediate[t],B=G.object,B.visible){ga=G.transparent;j(B);for(G=0;G<ga.count;G++)A=ga.list[G],u(A.blending),
+g(A.depthTest),k(A.polygonOffset,A.polygonOffsetFactor,A.polygonOffsetUnits),J=d(c,D,Oa,A,B),B.render(function(b){h(b,J,A.shading)})}}b.__webglSprites.length&&x(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&(f.bindTexture(f.TEXTURE_2D,o.__webglTexture),f.generateMipmap(f.TEXTURE_2D),f.bindTexture(f.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var d=
+b.__objectsAdded[0],e=b,g=void 0,h=void 0,j=void 0;if(d._modelViewMatrix==void 0)d._modelViewMatrix=new THREE.Matrix4,d._normalMatrixArray=new Float32Array(9),d._modelViewMatrixArray=new Float32Array(16),d._objectMatrixArray=new Float32Array(16),d.matrixWorld.flattenToArray(d._objectMatrixArray);if(d instanceof THREE.Mesh)for(g in h=d.geometry,h.geometryGroups==void 0&&sa(h),h.geometryGroups){j=h.geometryGroups[g];if(!j.__webglVertexBuffer){var k=j;k.__webglVertexBuffer=f.createBuffer();k.__webglNormalBuffer=
+f.createBuffer();k.__webglTangentBuffer=f.createBuffer();k.__webglColorBuffer=f.createBuffer();k.__webglUVBuffer=f.createBuffer();k.__webglUV2Buffer=f.createBuffer();k.__webglSkinVertexABuffer=f.createBuffer();k.__webglSkinVertexBBuffer=f.createBuffer();k.__webglSkinIndicesBuffer=f.createBuffer();k.__webglSkinWeightsBuffer=f.createBuffer();k.__webglFaceBuffer=f.createBuffer();k.__webglLineBuffer=f.createBuffer();if(k.numMorphTargets){var m=void 0,p=void 0;k.__webglMorphTargetsBuffers=[];m=0;for(p=
+k.numMorphTargets;m<p;m++)k.__webglMorphTargetsBuffers.push(f.createBuffer())}for(var k=j,m=d,r=void 0,q=void 0,o=void 0,u=o=void 0,t=void 0,v=void 0,C=v=p=0,x=o=q=void 0,E=x=q=r=void 0,o=void 0,u=m.geometry,t=u.faces,x=k.faces,r=0,q=x.length;r<q;r++)o=x[r],o=t[o],o instanceof THREE.Face3?(p+=3,v+=1,C+=3):o instanceof THREE.Face4&&(p+=4,v+=2,C+=4);for(var r=k,q=m,I=x=t=void 0,H=void 0,I=void 0,o=[],t=0,x=q.materials.length;t<x;t++)if(I=q.materials[t],I instanceof THREE.MeshFaceMaterial){I=0;for(l=
+r.materials.length;I<l;I++)(H=r.materials[I])&&o.push(H)}else(H=I)&&o.push(H);r=o;k.__materials=r;a:{t=q=void 0;x=r.length;for(q=0;q<x;q++)if(t=r[q],t.map||t.lightMap||t instanceof THREE.MeshShaderMaterial){q=!0;break a}q=!1}a:{x=t=void 0;o=r.length;for(t=0;t<o;t++)if(x=r[t],!(x instanceof THREE.MeshBasicMaterial&&!x.envMap||x instanceof THREE.MeshDepthMaterial)){x=x&&x.shading!=void 0&&x.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}x=!1}a:{o=t=void 0;I=r.length;for(t=
+0;t<I;t++)if(o=r[t],o.vertexColors){o=o.vertexColors;break a}o=!1}k.__vertexArray=new Float32Array(p*3);if(x)k.__normalArray=new Float32Array(p*3);if(u.hasTangents)k.__tangentArray=new Float32Array(p*4);if(o)k.__colorArray=new Float32Array(p*3);if(q){if(u.faceUvs.length>0||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<t;u++)k.__morphTargetsArrays.push(new Float32Array(p*3))}k.__needsSmoothNormals=x==THREE.SmoothShading;k.__uvType=q;k.__vertexColorType=o;k.__normalType=
+x;k.__webglFaceCount=v*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0);k.__webglLineCount=C*2;u=0;for(t=r.length;u<t;u++)if(q=r[u],q.attributes){if(k.__webglCustomAttributes===void 0)k.__webglCustomAttributes={};for(a in q.attributes){o=q.attributes[a];x={};for(E in o)x[E]=o[E];if(!x.__webglInitialized||x.createUniqueBuffers)x.__webglInitialized=!0,v=1,x.type==="v2"?v=2:x.type==="v3"?v=3:x.type==="v4"?v=4:x.type==="c"&&(v=3),x.size=v,x.array=new Float32Array(p*v),x.buffer=f.createBuffer(),
+x.buffer.belongsToAttribute=a,o.needsUpdate=!0,x.__original=o;k.__webglCustomAttributes[a]=x}}k.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}V(e.__webglObjects,j,d)}else if(d instanceof THREE.Ribbon){h=d.geometry;if(!h.__webglVertexBuffer)g=h,g.__webglVertexBuffer=f.createBuffer(),g.__webglColorBuffer=f.createBuffer(),g=h,j=g.vertices.length,g.__vertexArray=new Float32Array(j*3),g.__colorArray=
+new Float32Array(j*3),g.__webglVertexCount=j,h.__dirtyVertices=!0,h.__dirtyColors=!0;V(e.__webglObjects,h,d)}else if(d instanceof THREE.Line){h=d.geometry;if(!h.__webglVertexBuffer)g=h,g.__webglVertexBuffer=f.createBuffer(),g.__webglColorBuffer=f.createBuffer(),g=h,j=g.vertices.length,g.__vertexArray=new Float32Array(j*3),g.__colorArray=new Float32Array(j*3),g.__webglLineCount=j,h.__dirtyVertices=!0,h.__dirtyColors=!0;V(e.__webglObjects,h,d)}else if(d instanceof THREE.ParticleSystem){h=d.geometry;
+if(!h.__webglVertexBuffer){g=h;g.__webglVertexBuffer=f.createBuffer();g.__webglColorBuffer=f.createBuffer();g=h;j=d;k=g.vertices.length;g.__vertexArray=new Float32Array(k*3);g.__colorArray=new Float32Array(k*3);g.__sortArray=[];g.__webglParticleCount=k;g.__materials=j.materials;E=p=m=void 0;m=0;for(p=j.materials.length;m<p;m++)if(E=j.materials[m],E.attributes){if(g.__webglCustomAttributes===void 0)g.__webglCustomAttributes={};for(a in E.attributes){originalAttribute=E.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=
+originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(k*size),attribute.buffer=f.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;g.__webglCustomAttributes[a]=attribute}}h.__dirtyVertices=
+!0;h.__dirtyColors=!0}V(e.__webglObjects,h,d)}else THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}}):d instanceof THREE.Sprite&&e.__webglSprites.push(d);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];d=b;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)za(d.__webglObjects,e);else if(e instanceof
+THREE.Sprite){d=d.__webglSprites;h=void 0;for(h=d.length-1;h>=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;d<e;d++)if(g=b.__webglObjects[d].object,m=k=h=j=void 0,g instanceof THREE.Mesh){h=g.geometry;for(j in h.geometryGroups)if(k=h.geometryGroups[j],m=J(k),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||
+m)if(m=k,p=f.DYNAMIC_DRAW,E=!h.dynamic,m.__inittedArrays){var D=C=v=void 0,z=void 0,L=D=void 0,K=void 0,O=void 0,M=void 0,N=H=I=o=x=t=q=r=u=void 0,s=z=M=z=O=K=void 0,n=void 0,y=n=s=K=void 0,P=void 0,U=y=n=s=D=D=L=M=z=y=n=s=P=y=n=s=P=y=n=s=void 0,ia=0,ka=0,W=0,Y=0,T=0,Q=0,X=0,S=0,ja=0,w=0,la=0,y=s=0,y=void 0,na=m.__vertexArray,ma=m.__uvArray,pa=m.__uv2Array,Z=m.__normalArray,$=m.__tangentArray,oa=m.__colorArray,aa=m.__skinVertexAArray,ca=m.__skinVertexBArray,da=m.__skinIndexArray,ea=m.__skinWeightArray,
+ta=m.__morphTargetsArrays,fa=m.__webglCustomAttributes,n=void 0,ha=m.__faceArray,Ca=m.__lineArray,xa=m.__needsSmoothNormals,r=m.__vertexColorType,u=m.__uvType,q=m.__normalType,ra=g.geometry,ua=ra.__dirtyVertices,va=ra.__dirtyElements,qa=ra.__dirtyUvs,Aa=ra.__dirtyNormals,Ba=ra.__dirtyTangents,Da=ra.__dirtyColors,Ea=ra.__dirtyMorphTargets,wa=ra.vertices,Fa=m.faces,Ia=ra.faces,Ha=ra.faceVertexUvs[0],Ja=ra.faceVertexUvs[1],La=ra.skinVerticesA,Ma=ra.skinVerticesB,Na=ra.skinIndices,Ka=ra.skinWeights,Ga=
+ra.morphTargets;if(fa)for(U in fa)fa[U].offset=0,fa[U].offsetSrc=0;v=0;for(C=Fa.length;v<C;v++)if(D=Fa[v],z=Ia[D],Ha&&(t=Ha[D]),Ja&&(x=Ja[D]),D=z.vertexNormals,L=z.normal,K=z.vertexColors,O=z.color,M=z.vertexTangents,z instanceof THREE.Face3){if(ua)o=wa[z.a].position,I=wa[z.b].position,H=wa[z.c].position,na[ka]=o.x,na[ka+1]=o.y,na[ka+2]=o.z,na[ka+3]=I.x,na[ka+4]=I.y,na[ka+5]=I.z,na[ka+6]=H.x,na[ka+7]=H.y,na[ka+8]=H.z,ka+=9;if(fa)for(U in fa)if(n=fa[U],n.__original.needsUpdate)s=n.offset,y=n.offsetSrc,
+n.size===1?(n.boundTo===void 0||n.boundTo==="vertices"?(n.array[s]=n.value[z.a],n.array[s+1]=n.value[z.b],n.array[s+2]=n.value[z.c]):n.boundTo==="faces"?(y=n.value[y],n.array[s]=y,n.array[s+1]=y,n.array[s+2]=y,n.offsetSrc++):n.boundTo==="faceVertices"&&(n.array[s]=n.value[y],n.array[s+1]=n.value[y+1],n.array[s+2]=n.value[y+2],n.offsetSrc+=3),n.offset+=3):(n.boundTo===void 0||n.boundTo==="vertices"?(o=n.value[z.a],I=n.value[z.b],H=n.value[z.c]):n.boundTo==="faces"?(H=I=o=y=n.value[y],n.offsetSrc++):
+n.boundTo==="faceVertices"&&(o=n.value[y],I=n.value[y+1],H=n.value[y+2],n.offsetSrc+=3),n.size===2?(n.array[s]=o.x,n.array[s+1]=o.y,n.array[s+2]=I.x,n.array[s+3]=I.y,n.array[s+4]=H.x,n.array[s+5]=H.y,n.offset+=6):n.size===3?(n.type==="c"?(n.array[s]=o.r,n.array[s+1]=o.g,n.array[s+2]=o.b,n.array[s+3]=I.r,n.array[s+4]=I.g,n.array[s+5]=I.b,n.array[s+6]=H.r,n.array[s+7]=H.g,n.array[s+8]=H.b):(n.array[s]=o.x,n.array[s+1]=o.y,n.array[s+2]=o.z,n.array[s+3]=I.x,n.array[s+4]=I.y,n.array[s+5]=I.z,n.array[s+
+6]=H.x,n.array[s+7]=H.y,n.array[s+8]=H.z),n.offset+=9):(n.array[s]=o.x,n.array[s+1]=o.y,n.array[s+2]=o.z,n.array[s+3]=o.w,n.array[s+4]=I.x,n.array[s+5]=I.y,n.array[s+6]=I.z,n.array[s+7]=I.w,n.array[s+8]=H.x,n.array[s+9]=H.y,n.array[s+10]=H.z,n.array[s+11]=H.w,n.offset+=12));if(Ea){s=0;for(n=Ga.length;s<n;s++)o=Ga[s].vertices[z.a].position,I=Ga[s].vertices[z.b].position,H=Ga[s].vertices[z.c].position,y=ta[s],y[la]=o.x,y[la+1]=o.y,y[la+2]=o.z,y[la+3]=I.x,y[la+4]=I.y,y[la+5]=I.z,y[la+6]=H.x,y[la+7]=
+H.y,y[la+8]=H.z;la+=9}if(Ka.length)s=Ka[z.a],n=Ka[z.b],y=Ka[z.c],ea[w]=s.x,ea[w+1]=s.y,ea[w+2]=s.z,ea[w+3]=s.w,ea[w+4]=n.x,ea[w+5]=n.y,ea[w+6]=n.z,ea[w+7]=n.w,ea[w+8]=y.x,ea[w+9]=y.y,ea[w+10]=y.z,ea[w+11]=y.w,s=Na[z.a],n=Na[z.b],y=Na[z.c],da[w]=s.x,da[w+1]=s.y,da[w+2]=s.z,da[w+3]=s.w,da[w+4]=n.x,da[w+5]=n.y,da[w+6]=n.z,da[w+7]=n.w,da[w+8]=y.x,da[w+9]=y.y,da[w+10]=y.z,da[w+11]=y.w,s=La[z.a],n=La[z.b],y=La[z.c],aa[w]=s.x,aa[w+1]=s.y,aa[w+2]=s.z,aa[w+3]=1,aa[w+4]=n.x,aa[w+5]=n.y,aa[w+6]=n.z,aa[w+7]=
+1,aa[w+8]=y.x,aa[w+9]=y.y,aa[w+10]=y.z,aa[w+11]=1,s=Ma[z.a],n=Ma[z.b],y=Ma[z.c],ca[w]=s.x,ca[w+1]=s.y,ca[w+2]=s.z,ca[w+3]=1,ca[w+4]=n.x,ca[w+5]=n.y,ca[w+6]=n.z,ca[w+7]=1,ca[w+8]=y.x,ca[w+9]=y.y,ca[w+10]=y.z,ca[w+11]=1,w+=12;if(Da&&r)K.length==3&&r==THREE.VertexColors?(z=K[0],s=K[1],n=K[2]):n=s=z=O,oa[ja]=z.r,oa[ja+1]=z.g,oa[ja+2]=z.b,oa[ja+3]=s.r,oa[ja+4]=s.g,oa[ja+5]=s.b,oa[ja+6]=n.r,oa[ja+7]=n.g,oa[ja+8]=n.b,ja+=9;if(Ba&&ra.hasTangents)K=M[0],O=M[1],z=M[2],$[X]=K.x,$[X+1]=K.y,$[X+2]=K.z,$[X+3]=
+K.w,$[X+4]=O.x,$[X+5]=O.y,$[X+6]=O.z,$[X+7]=O.w,$[X+8]=z.x,$[X+9]=z.y,$[X+10]=z.z,$[X+11]=z.w,X+=12;if(Aa&&q)if(D.length==3&&xa)for(M=0;M<3;M++)L=D[M],Z[Q]=L.x,Z[Q+1]=L.y,Z[Q+2]=L.z,Q+=3;else for(M=0;M<3;M++)Z[Q]=L.x,Z[Q+1]=L.y,Z[Q+2]=L.z,Q+=3;if(qa&&t!==void 0&&u)for(M=0;M<3;M++)D=t[M],ma[W]=D.u,ma[W+1]=D.v,W+=2;if(qa&&x!==void 0&&u)for(M=0;M<3;M++)D=x[M],pa[Y]=D.u,pa[Y+1]=D.v,Y+=2;va&&(ha[T]=ia,ha[T+1]=ia+1,ha[T+2]=ia+2,T+=3,Ca[S]=ia,Ca[S+1]=ia+1,Ca[S+2]=ia,Ca[S+3]=ia+2,Ca[S+4]=ia+1,Ca[S+5]=ia+
+2,S+=6,ia+=3)}else if(z instanceof THREE.Face4){if(ua)o=wa[z.a].position,I=wa[z.b].position,H=wa[z.c].position,N=wa[z.d].position,na[ka]=o.x,na[ka+1]=o.y,na[ka+2]=o.z,na[ka+3]=I.x,na[ka+4]=I.y,na[ka+5]=I.z,na[ka+6]=H.x,na[ka+7]=H.y,na[ka+8]=H.z,na[ka+9]=N.x,na[ka+10]=N.y,na[ka+11]=N.z,ka+=12;if(fa)for(U in fa)if(n=fa[U],n.__original.needsUpdate)s=n.offset,y=n.offsetSrc,n.size===1?(n.boundTo===void 0||n.boundTo==="vertices"?(n.array[s]=n.value[z.a],n.array[s+1]=n.value[z.b],n.array[s+2]=n.value[z.c],
+n.array[s+3]=n.value[z.d]):n.boundTo==="faces"?(y=n.value[y],n.array[s]=y,n.array[s+1]=y,n.array[s+2]=y,n.array[s+3]=y,n.offsetSrc++):n.boundTo==="faceVertices"&&(n.array[s]=n.value[y],n.array[s+1]=n.value[y+1],n.array[s+2]=n.value[y+2],n.array[s+3]=n.value[y+3],n.offsetSrc+=4),n.offset+=4):(n.boundTo===void 0||n.boundTo==="vertices"?(o=n.value[z.a],I=n.value[z.b],H=n.value[z.c],N=n.value[z.d]):n.boundTo==="faces"?(N=H=I=o=y=n.value[y],n.offsetSrc++):n.boundTo==="faceVertices"&&(o=n.value[y],I=n.value[y+
+1],H=n.value[y+2],N=n.value[y+3],n.offsetSrc+=4),n.size===2?(n.array[s]=o.x,n.array[s+1]=o.y,n.array[s+2]=I.x,n.array[s+3]=I.y,n.array[s+4]=H.x,n.array[s+5]=H.y,n.array[s+6]=N.x,n.array[s+7]=N.y,n.offset+=8):n.size===3?(n.type==="c"?(n.array[s]=o.r,n.array[s+1]=o.g,n.array[s+2]=o.b,n.array[s+3]=I.r,n.array[s+4]=I.g,n.array[s+5]=I.b,n.array[s+6]=H.r,n.array[s+7]=H.g,n.array[s+8]=H.b,n.array[s+9]=N.r,n.array[s+10]=N.g,n.array[s+11]=N.b):(n.array[s]=o.x,n.array[s+1]=o.y,n.array[s+2]=o.z,n.array[s+3]=
+I.x,n.array[s+4]=I.y,n.array[s+5]=I.z,n.array[s+6]=H.x,n.array[s+7]=H.y,n.array[s+8]=H.z,n.array[s+9]=N.x,n.array[s+10]=N.y,n.array[s+11]=N.z),n.offset+=12):(n.array[s]=o.x,n.array[s+1]=o.y,n.array[s+2]=o.z,n.array[s+3]=o.w,n.array[s+4]=I.x,n.array[s+5]=I.y,n.array[s+6]=I.z,n.array[s+7]=I.w,n.array[s+8]=H.x,n.array[s+9]=H.y,n.array[s+10]=H.z,n.array[s+11]=H.w,n.array[s+12]=N.x,n.array[s+13]=N.y,n.array[s+14]=N.z,n.array[s+15]=N.w,n.offset+=16));if(Ea){s=0;for(n=Ga.length;s<n;s++)o=Ga[s].vertices[z.a].position,
+I=Ga[s].vertices[z.b].position,H=Ga[s].vertices[z.c].position,N=Ga[s].vertices[z.d].position,y=ta[s],y[la]=o.x,y[la+1]=o.y,y[la+2]=o.z,y[la+3]=I.x,y[la+4]=I.y,y[la+5]=I.z,y[la+6]=H.x,y[la+7]=H.y,y[la+8]=H.z,y[la+9]=N.x,y[la+10]=N.y,y[la+11]=N.z;la+=12}if(Ka.length)s=Ka[z.a],n=Ka[z.b],y=Ka[z.c],P=Ka[z.d],ea[w]=s.x,ea[w+1]=s.y,ea[w+2]=s.z,ea[w+3]=s.w,ea[w+4]=n.x,ea[w+5]=n.y,ea[w+6]=n.z,ea[w+7]=n.w,ea[w+8]=y.x,ea[w+9]=y.y,ea[w+10]=y.z,ea[w+11]=y.w,ea[w+12]=P.x,ea[w+13]=P.y,ea[w+14]=P.z,ea[w+15]=P.w,
+s=Na[z.a],n=Na[z.b],y=Na[z.c],P=Na[z.d],da[w]=s.x,da[w+1]=s.y,da[w+2]=s.z,da[w+3]=s.w,da[w+4]=n.x,da[w+5]=n.y,da[w+6]=n.z,da[w+7]=n.w,da[w+8]=y.x,da[w+9]=y.y,da[w+10]=y.z,da[w+11]=y.w,da[w+12]=P.x,da[w+13]=P.y,da[w+14]=P.z,da[w+15]=P.w,s=La[z.a],n=La[z.b],y=La[z.c],P=La[z.d],aa[w]=s.x,aa[w+1]=s.y,aa[w+2]=s.z,aa[w+3]=1,aa[w+4]=n.x,aa[w+5]=n.y,aa[w+6]=n.z,aa[w+7]=1,aa[w+8]=y.x,aa[w+9]=y.y,aa[w+10]=y.z,aa[w+11]=1,aa[w+12]=P.x,aa[w+13]=P.y,aa[w+14]=P.z,aa[w+15]=1,s=Ma[z.a],n=Ma[z.b],y=Ma[z.c],z=Ma[z.d],
+ca[w]=s.x,ca[w+1]=s.y,ca[w+2]=s.z,ca[w+3]=1,ca[w+4]=n.x,ca[w+5]=n.y,ca[w+6]=n.z,ca[w+7]=1,ca[w+8]=y.x,ca[w+9]=y.y,ca[w+10]=y.z,ca[w+11]=1,ca[w+12]=z.x,ca[w+13]=z.y,ca[w+14]=z.z,ca[w+15]=1,w+=16;if(Da&&r)K.length==4&&r==THREE.VertexColors?(z=K[0],s=K[1],n=K[2],K=K[3]):K=n=s=z=O,oa[ja]=z.r,oa[ja+1]=z.g,oa[ja+2]=z.b,oa[ja+3]=s.r,oa[ja+4]=s.g,oa[ja+5]=s.b,oa[ja+6]=n.r,oa[ja+7]=n.g,oa[ja+8]=n.b,oa[ja+9]=K.r,oa[ja+10]=K.g,oa[ja+11]=K.b,ja+=12;if(Ba&&ra.hasTangents)K=M[0],O=M[1],z=M[2],M=M[3],$[X]=K.x,$[X+
+1]=K.y,$[X+2]=K.z,$[X+3]=K.w,$[X+4]=O.x,$[X+5]=O.y,$[X+6]=O.z,$[X+7]=O.w,$[X+8]=z.x,$[X+9]=z.y,$[X+10]=z.z,$[X+11]=z.w,$[X+12]=M.x,$[X+13]=M.y,$[X+14]=M.z,$[X+15]=M.w,X+=16;if(Aa&&q)if(D.length==4&&xa)for(M=0;M<4;M++)L=D[M],Z[Q]=L.x,Z[Q+1]=L.y,Z[Q+2]=L.z,Q+=3;else for(M=0;M<4;M++)Z[Q]=L.x,Z[Q+1]=L.y,Z[Q+2]=L.z,Q+=3;if(qa&&t!==void 0&&u)for(M=0;M<4;M++)D=t[M],ma[W]=D.u,ma[W+1]=D.v,W+=2;if(qa&&x!==void 0&&u)for(M=0;M<4;M++)D=x[M],pa[Y]=D.u,pa[Y+1]=D.v,Y+=2;va&&(ha[T]=ia,ha[T+1]=ia+1,ha[T+2]=ia+3,ha[T+
+3]=ia+1,ha[T+4]=ia+2,ha[T+5]=ia+3,T+=6,Ca[S]=ia,Ca[S+1]=ia+1,Ca[S+2]=ia,Ca[S+3]=ia+3,Ca[S+4]=ia+1,Ca[S+5]=ia+2,Ca[S+6]=ia+2,Ca[S+7]=ia+3,S+=8,ia+=4)}ua&&(f.bindBuffer(f.ARRAY_BUFFER,m.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,na,p));if(fa)for(U in fa)n=fa[U],n.__original.needsUpdate&&(f.bindBuffer(f.ARRAY_BUFFER,n.buffer),f.bufferData(f.ARRAY_BUFFER,n.array,p));if(Ea){s=0;for(n=Ga.length;s<n;s++)f.bindBuffer(f.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[s]),f.bufferData(f.ARRAY_BUFFER,ta[s],
+p)}Da&&ja>0&&(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<r;v++)C=u[v].position,k=v*3,q[k]=C.x,q[k+1]=C.y,q[k+2]=C.z;f.bindBuffer(f.ARRAY_BUFFER,g.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,q,j)}if(t){for(v=0;v<p;v++)color=m[v],k=v*3,E[k]=color.r,E[k+1]=color.g,E[k+2]=color.b;f.bindBuffer(f.ARRAY_BUFFER,g.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,
+E,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(g instanceof THREE.Line){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<r;v++)C=u[v].position,k=v*3,q[k]=C.x,q[k+1]=C.y,q[k+2]=C.z;f.bindBuffer(f.ARRAY_BUFFER,g.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,q,j)}if(t){for(v=0;v<p;v++)color=m[v],k=v*3,E[k]=color.r,E[k+1]=color.g,
+E[k+2]=color.b;f.bindBuffer(f.ARRAY_BUFFER,g.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,E,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(g instanceof THREE.ParticleSystem)h=g.geometry,m=J(h),(h.__dirtyVertices||h.__dirtyColors||g.sortParticles||m)&&c(h,f.DYNAMIC_DRAW,g),h.__dirtyVertices=!1,h.__dirtyColors=!1,ya(h)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW),b=="back"?f.cullFace(f.BACK):b=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK),
+f.enable(f.CULL_FACE)):f.disable(f.CULL_FACE)};this.supportsVertexTextures=function(){return Xa}};
+THREE.WebGLRenderTarget=function(b,c,d){this.width=b;this.height=c;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:
+THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};

+ 0 - 1
examples/textures/metal.txt

@@ -1 +0,0 @@
-http://www.scene.org/file.php?file=/parties/2003/stream03/demo/kwl_itch.zip

+ 2 - 2
examples/webgl_custom_attributes.html

@@ -134,9 +134,9 @@
 
 			var radius = 50, segments = 128, rings = 64;
 			var geometry = new THREE.SphereGeometry( radius, segments, rings );
+			geometry.dynamic = true;
 
 			sphere = new THREE.Mesh( geometry, shaderMaterial );
-			sphere.dynamic = true;
 
 			var vertices = sphere.geometry.vertices;
 			var values = attributes.displacement.value;
@@ -210,4 +210,4 @@
 
 </body>
 
-</html>
+</html>

+ 0 - 178
examples/webgl_stencil.html

@@ -1,178 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
-	<head>
-		<title>three.js webgl - stencil shadow</title>
-		<meta charset="utf-8">
-		<style type="text/css">
-			body {
-				background:#fff;
-				padding:0;
-				margin:0;
-				font-weight: bold;
-				overflow:hidden;
-			}
-		</style>
-	</head>
-
-	<body>
-		<script type="text/javascript" src="../build/Three.js"></script>
-		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
-		<script type="text/javascript" src="js/Stats.js"></script>
-
-
-		<script type="text/javascript">
-
-			var container, stats;
-
-			var camera, scene, renderer;
-
-			var mesh, boxMesh, light, lightCube, light2, lightCube2, zmesh, lightMesh, geometry;
-
-			var mouseX = 0, mouseY = 0;
-
-			var windowHalfX = window.innerWidth / 2;
-			var windowHalfY = window.innerHeight / 2;
-
-			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
-
-			init();
-			animate();
-
-			function init() {
-
-				container = document.createElement( 'div' );
-				document.body.appendChild( container );
-
-				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
-				camera.position.z = 250;
-
-				scene = new THREE.Scene();
-
-
-				// world
-
-				var cube = new THREE.CubeGeometry( 300, 300, 10 );
-				var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
-				var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
-				var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
-
-				var mesh1 = new THREE.Mesh( cube, material0 );
-				mesh1.position.z = - 150;
-				scene.addChild( mesh1 );
-
-				var mesh2 = new THREE.Mesh( cube, material1 );
-				mesh2.position.x = - 150;
-				mesh2.rotation.y = 90 * Math.PI / 180;
-				scene.addChild( mesh2 );
-
-				var mesh3 = new THREE.Mesh( cube, material2 );
-				mesh3.position.y = - 150;
-				mesh3.rotation.x = 90 * Math.PI / 180;
-				scene.addChild( mesh3 );
-
-				new THREE.ShadowVolume( mesh1 )
-				new THREE.ShadowVolume( mesh2 )
-				new THREE.ShadowVolume( mesh3 )
-
-
-				// moving objects
-
-				var cube = new THREE.CubeGeometry( 40, 40, 40 );
-				var torus = new THREE.TorusGeometry( 40, 10 );
-				var sphere = new THREE.SphereGeometry( 40 );
-				var cylinder = new THREE.CylinderGeometry( 10, 10, 20, 40, 0, 0 );
-				mesh = new THREE.Mesh( torus, material1 );
-				scene.addChild( mesh );
-
-				boxMesh = new THREE.Mesh( cube, material2 );
-				scene.addChild( boxMesh );
-
-				new THREE.ShadowVolume( mesh );
-				new THREE.ShadowVolume( boxMesh );
-
-
-				// lights
-
-				light = new THREE.DirectionalLight( 0xffffff );
-				light.castShadow = true;
-				light.position.set( 0, 1, 0 );
-				scene.addChild( light );
-
-				var cube = new THREE.SphereGeometry( 5 );
-				lightCube = new THREE.Mesh( cube, material2 );
-				scene.addChild( lightCube );
-
-
-				// renderer
-
-				renderer = new THREE.WebGLRenderer();
-				renderer.setClearColorHex( 0xaaaaaa, 1 );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				container.appendChild( renderer.domElement );
-
-				stats = new Stats();
-				stats.domElement.style.position = 'absolute';
-				stats.domElement.style.top = '0px';
-				stats.domElement.style.zIndex = 100;
-				container.appendChild( stats.domElement );
-
-			}
-
-
-			function onDocumentMouseMove(event) {
-
-				mouseX = ( event.clientX - windowHalfX );
-				mouseY = ( event.clientY - windowHalfY );
-
-			}
-
-			function animate() {
-
-				requestAnimationFrame( animate );
-
-				render();
-				stats.update();
-
-			}
-
-			var t = 0;
-
-			function render() {
-
-				mesh.position.x = Math.sin( t ) * 100;
-				mesh.position.y = Math.cos( t ) * 100;
-
-				mesh.rotation.x += 0.5 * Math.PI / 180;
-				mesh.rotation.y += 1.0 * Math.PI / 180;
-				mesh.rotation.z += 1.5 * Math.PI / 180;
-
-				boxMesh.position.z = Math.sin( t ) * 100;
-				boxMesh.rotation.x = Math.sin( t ) * 180 * Math.PI / 180;
-
-				light.position.x = Math.sin( t );
-				light.position.y = 1.5;
-				light.position.z = Math.cos( t );
-
-				lightCube.position.copy( light.position );
-				lightCube.position.multiplyScalar( 200 );
-
-
-				t += 0.02;
-
-				camera.position.x += ( mouseX - camera.position.x ) * .05;
-				camera.position.y += ( - mouseY - camera.position.y ) * .05;
-
-				renderer.render( scene, camera );
-
-			}
-
-			function log( text ) {
-
-				var e = document.getElementById("log");
-				e.innerHTML = text + "<br/>" + e.innerHTML;
-
-			}
-		</script>
-
-	</body>
-</html>

+ 0 - 190
examples/webgl_stencilLensFlare.html

@@ -1,190 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en">
-	<head>
-		<title>three.js - webgl</title>
-		<meta charset="utf-8">
-		<style type="text/css">
-			body {
-				background:#fff;
-				padding:0;
-				margin:0;
-				font-weight: bold;
-				overflow:hidden;
-			}
-		</style>
-	</head>
-
-	<body>
-		<script type="text/javascript" src="../build/Three.js"></script>
-		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
-		<script type="text/javascript" src="js/Stats.js"></script>
-
-		<script type="text/javascript">
-
-			var container, stats;
-
-			var camera, scene, renderer;
-
-			var mesh, boxMesh, light, lightCube, light2, lightCube2, zmesh, lightMesh, geometry;
-
-			var mouseX = 0, mouseY = 0;
-
-			var windowHalfX = window.innerWidth / 2;
-			var windowHalfY = window.innerHeight / 2;
-
-			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
-
-			init();
-			animate();
-
-			function init() {
-
-				container = document.createElement( 'div' );
-				document.body.appendChild( container );
-
-				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
-				camera.position.z = 250;
-
-				scene = new THREE.Scene();
-
-
-				// world
-
-				var cube = new THREE.CubeGeometry( 300, 300, 10 );
-				var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
-				var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
-				var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
-
-				var mesh1 = new THREE.Mesh( cube, material0 );
-				mesh1.position.z = -150;
-				scene.addChild( mesh1 );
-
-				var mesh2 = new THREE.Mesh( cube, material1 );
-				mesh2.position.x = -150;
-				mesh2.rotation.y = 90 * Math.PI / 180;
-				scene.addChild( mesh2 );
-
-				var mesh3 = new THREE.Mesh( cube, material2 );
-				mesh3.position.y = -150;
-				mesh3.rotation.x = 90 * Math.PI / 180;
-				scene.addChild( mesh3 );
-
-				new THREE.ShadowVolume( mesh1 )
-				new THREE.ShadowVolume( mesh2 )
-				new THREE.ShadowVolume( mesh3 )
-
-
-				// moving objects
-
-				var cube = new THREE.CubeGeometry( 40, 40, 40 );
-				var torus = new THREE.TorusGeometry( 40, 10 );
-				var sphere = new THREE.SphereGeometry( 40 );
-				var cylinder = new THREE.CylinderGeometry( 10, 10, 20, 40, 0, 0 );
-				mesh = new THREE.Mesh( torus, material1 );
-				scene.addChild( mesh );
-
-				boxMesh = new THREE.Mesh( cube, material2 );
-				scene.addChild( boxMesh );
-
-				new THREE.ShadowVolume( mesh );
-				new THREE.ShadowVolume( boxMesh );
-
-
-				// lights
-
-				light = new THREE.PointLight( 0xffffff );
-				scene.addChild( light );
-
-
-				light = new THREE.DirectionalLight( 0xffffff );
-				light.castShadow = true;
-				light.position.set( 0, 1, 0 );
-				scene.addChild( light );
-
-
-				var cube = new THREE.SphereGeometry( 2 );
-				lightCube = new THREE.Mesh( cube, material2 );
-				lightCube.visible = false;
-				scene.addChild( lightCube );
-
-				var lensFlare = new THREE.LensFlare( THREE.ImageUtils.loadTexture( "textures/lensflare0.png" ), 128, 0.0, THREE.AdditiveBlending );
-				lensFlare.add( THREE.ImageUtils.loadTexture( "textures/lensflare1.png" ), 256, 0.33, THREE.AdditiveBlending );
-				lensFlare.add( lensFlare.lensFlares[ 1 ].texture, 300, 0.66, THREE.AdditiveBlending );
-				lensFlare.add( lensFlare.lensFlares[ 1 ].texture, 400, 1.0, THREE.AdditiveBlending );
-
-				lightCube.addChild( lensFlare );
-
-
-				// renderer
-
-				renderer = new THREE.WebGLRenderer( { antialias: false } );
-				renderer.setClearColorHex( 0x222222, 1 );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				container.appendChild( renderer.domElement );
-
-				stats = new Stats();
-				stats.domElement.style.position = 'absolute';
-				stats.domElement.style.top = '0px';
-				stats.domElement.style.zIndex = 100;
-				container.appendChild( stats.domElement );
-
-			}
-
-
-			function onDocumentMouseMove(event) {
-
-				mouseX = ( event.clientX - windowHalfX );
-				mouseY = ( event.clientY - windowHalfY );
-
-			}
-
-			function animate() {
-
-				requestAnimationFrame( animate );
-
-				render();
-				stats.update();
-
-			}
-
-			var t = 0;
-
-			function render() {
-
-				mesh.position.x = Math.sin( t ) * 100;
-				mesh.position.y = Math.cos( t ) * 100;
-
-				mesh.rotation.x += 0.5 * Math.PI / 180;
-				mesh.rotation.y += 1.0 * Math.PI / 180;
-				mesh.rotation.z += 1.5 * Math.PI / 180;
-
-				boxMesh.position.z = Math.sin( t ) * 100;
-				boxMesh.rotation.x = Math.sin( t ) * 180 * Math.PI / 180;
-
-				light.position.x = Math.sin( t );
-				light.position.y = 0.5;
-				light.position.normalize();
-
-				lightCube.position.copy( light.position );
-				lightCube.position.multiplyScalar( 200 );
-
-
-				t += 0.015;
-
-				camera.position.x += ( mouseX - camera.position.x ) * .05;
-				camera.position.y += ( - mouseY - camera.position.y ) * .05;
-
-				renderer.render( scene, camera );
-
-			}
-
-			function log( text ) {
-
-				var e = document.getElementById("log");
-				e.innerHTML = text + "<br/>" + e.innerHTML;
-
-			}
-		</script>
-
-	</body>
-</html>

+ 0 - 3
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();

+ 0 - 2
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();

+ 0 - 87
src/lights/LensFlare.js

@@ -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;
-
-	}
-
-};
-
-
-
-
-
-
-
-
-
-
-
-

+ 0 - 63
src/materials/ShadowVolumeDynamicMaterial.js

@@ -1,63 +0,0 @@
-/**
- * @author mr.doob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- *
- * parameters = {
- *  color: <hex>,
- *  opacity: <float>,
- *  map: new THREE.Texture( <Image> ),
- 
- *  lightMap: new THREE.Texture( <Image> ),
- 
- *  envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
- *  combine: THREE.Multiply,
- *  reflectivity: <float>,
- *  refractionRatio: <float>,
- 
- *  shading: THREE.SmoothShading,
- *  blending: THREE.NormalBlending,
- *  depthTest: <bool>,
- 
- *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
- 
- *  vertexColors: <bool>,
- *  skinning: <bool>
- * }
- */
-
-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;

+ 0 - 345
src/objects/ShadowVolume.js

@@ -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;
-
-};

+ 14 - 7
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 ) {

+ 9 - 592
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++ ) {
 

+ 0 - 6
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',

+ 0 - 359
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py

@@ -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()

+ 0 - 1623
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py

@@ -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'}

+ 0 - 635
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py

@@ -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()

+ 0 - 388
utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/__init__.py

@@ -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()

+ 0 - 1781
utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/export_threejs.py

@@ -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'}

+ 0 - 631
utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/import_threejs.py

@@ -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()

+ 0 - 0
utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/__init__.py → utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/__init__.py


+ 0 - 0
utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/export_threejs.py → utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/export_threejs.py


+ 0 - 0
utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/import_threejs.py → utils/exporters/blender/2.59/scripts/addons/io_mesh_threejs/import_threejs.py